Skip to content

Commit db142bf

Browse files
Merge branch 'develop' into toolchain-202501
2 parents 2ac981d + 33d0b4f commit db142bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2177
-308
lines changed

examples/hse/pw_Si2/INPUT

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
INPUT_PARAMETERS
2+
pseudo_dir ../../../tests/PP_ORB
3+
orbital_dir ../../../tests/PP_ORB
4+
nbands 4
5+
nspin 1
6+
calculation scf
7+
basis_type pw
8+
ks_solver dav
9+
ecutwfc 50
10+
scf_thr 1e-9
11+
scf_nmax 100
12+
gamma_only 0
13+
symmetry -1
14+
smearing_method fixed
15+
mixing_type broyden
16+
mixing_beta 0.7
17+
18+
dft_functional hse
19+
20+
# init_wfc file
21+
# init_chg file
22+
23+
pseudo_mesh 1
24+
pseudo_rcut 10
25+
26+
# out_wfc_pw 1
27+
# out_chg 1
28+
29+
exx_hybrid_alpha 0.25
30+
31+
cal_stress 1
32+
# cal_force 1

examples/hse/pw_Si2/KPT

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
K_POINTS
2+
0
3+
Gamma
4+
3 3 3 0 0 0

examples/hse/pw_Si2/STRU

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
ATOMIC_SPECIES
2+
Si 1 Si_ONCV_PBE_FR-1.1.upf #Pseudopotentials are downloaded from http://www.quantum-simulation.org/potentials/sg15_oncv/upf/
3+
4+
NUMERICAL_ORBITAL
5+
orb_Si.dat
6+
7+
LATTICE_CONSTANT
8+
1.889766
9+
10+
LATTICE_VECTORS
11+
0.0 2.708337 2.708337
12+
2.708337 0.0 2.708337
13+
2.708337 2.708337 0.0
14+
15+
16+
17+
ATOMIC_POSITIONS
18+
Direct
19+
20+
Si
21+
0
22+
2
23+
0.125 0.125 0.125 0 0 0
24+
0.875 0.875 0.875 0 0 0

source/Makefile.Objects

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ VPATH=./src_global:\
5050
./module_hamilt_pw/hamilt_stodft:\
5151
./module_hamilt_pw/hamilt_pwdft/operator_pw:\
5252
./module_hamilt_pw/hamilt_pwdft/kernels:\
53+
./module_hamilt_pw/hamilt_pwdft/module_exx_helper:\
5354
./module_hamilt_pw/hamilt_stodft/kernels:\
5455
./module_hamilt_lcao/module_hcontainer:\
5556
./module_hamilt_lcao/hamilt_lcaodft:\
@@ -222,6 +223,7 @@ OBJS_ELECSTAT=elecstate.o\
222223
elecstate_pw_sdft.o\
223224
elecstate_pw_cal_tau.o\
224225
elecstate_op.o\
226+
elecstate_tools.o\
225227
efield.o\
226228
gatefield.o\
227229
potential_new.o\
@@ -294,6 +296,7 @@ OBJS_HAMILT=hamilt_pw.o\
294296
hamilt_sdft_pw.o\
295297
operator.o\
296298
operator_pw.o\
299+
op_exx_pw.o\
297300
ekinetic_pw.o\
298301
ekinetic_op.o\
299302
hpsi_norm_op.o\
@@ -305,6 +308,7 @@ OBJS_HAMILT=hamilt_pw.o\
305308
meta_op.o\
306309
velocity_pw.o\
307310
radial_proj.o\
311+
exx_helper.o\
308312

309313
OBJS_HAMILT_OF=kedf_tf.o\
310314
kedf_vw.o\
@@ -670,6 +674,7 @@ OBJS_SRCPW=H_Ewald_pw.o\
670674
sto_stress_pw.o\
671675
stress_func_cc.o\
672676
stress_func_ewa.o\
677+
stress_func_exx.o\
673678
stress_func_gga.o\
674679
stress_func_mgga.o\
675680
stress_func_har.o\

source/module_elecstate/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ list(APPEND objects
44
elecstate_energy.cpp
55
elecstate_exx.cpp
66
elecstate_print.cpp
7+
elecstate_tools.cpp
78
elecstate_pw.cpp
89
elecstate_pw_sdft.cpp
910
elecstate_pw_cal_tau.cpp

source/module_elecstate/elecstate.cpp

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,6 @@ const double* ElecState::getRho(int spin) const
1515
return &(this->charge->rho[spin][0]);
1616
}
1717

18-
void ElecState::fixed_weights(const std::vector<double>& ocp_kb, const int& nbands, const double& nelec)
19-
{
20-
assert(nbands > 0);
21-
assert(nelec > 0.0);
22-
23-
const double ne_thr = 1.0e-5;
24-
25-
const int num = this->klist->get_nks() * nbands;
26-
if (num != ocp_kb.size())
27-
{
28-
ModuleBase::WARNING_QUIT("ElecState::fixed_weights",
29-
"size of occupation array is wrong , please check ocp_set");
30-
}
31-
32-
double num_elec = 0.0;
33-
for (int i = 0; i < ocp_kb.size(); ++i)
34-
{
35-
num_elec += ocp_kb[i];
36-
}
37-
38-
if (std::abs(num_elec - nelec) > ne_thr)
39-
{
40-
ModuleBase::WARNING_QUIT("ElecState::fixed_weights",
41-
"total number of occupations is wrong , please check ocp_set");
42-
}
43-
44-
for (int ik = 0; ik < this->wg.nr; ++ik)
45-
{
46-
for (int ib = 0; ib < this->wg.nc; ++ib)
47-
{
48-
this->wg(ik, ib) = ocp_kb[ik * this->wg.nc + ib];
49-
}
50-
}
51-
this->skip_weights = true;
52-
53-
return;
54-
}
5518

5619

5720
void ElecState::init_nelec_spin()
@@ -64,143 +27,6 @@ void ElecState::init_nelec_spin()
6427
}
6528
}
6629

67-
68-
void ElecState::calculate_weights()
69-
{
70-
ModuleBase::TITLE("ElecState", "calculate_weights");
71-
if (this->skip_weights)
72-
{
73-
return;
74-
}
75-
76-
const int nbands = this->ekb.nc;
77-
const int nks = this->ekb.nr;
78-
79-
if (!Occupy::use_gaussian_broadening && !Occupy::fixed_occupations)
80-
{
81-
if (PARAM.globalv.two_fermi)
82-
{
83-
Occupy::iweights(nks,
84-
this->klist->wk,
85-
nbands,
86-
this->nelec_spin[0],
87-
this->ekb,
88-
this->eferm.ef_up,
89-
this->wg,
90-
0,
91-
this->klist->isk);
92-
Occupy::iweights(nks,
93-
this->klist->wk,
94-
nbands,
95-
this->nelec_spin[1],
96-
this->ekb,
97-
this->eferm.ef_dw,
98-
this->wg,
99-
1,
100-
this->klist->isk);
101-
// ef = ( ef_up + ef_dw ) / 2.0_dp need??? mohan add 2012-04-16
102-
}
103-
else
104-
{
105-
// -1 means don't need to consider spin.
106-
Occupy::iweights(nks,
107-
this->klist->wk,
108-
nbands,
109-
PARAM.inp.nelec,
110-
this->ekb,
111-
this->eferm.ef,
112-
this->wg,
113-
-1,
114-
this->klist->isk);
115-
}
116-
}
117-
else if (Occupy::use_gaussian_broadening)
118-
{
119-
if (PARAM.globalv.two_fermi)
120-
{
121-
double demet_up = 0.0;
122-
double demet_dw = 0.0;
123-
Occupy::gweights(nks,
124-
this->klist->wk,
125-
nbands,
126-
this->nelec_spin[0],
127-
Occupy::gaussian_parameter,
128-
Occupy::gaussian_type,
129-
this->ekb,
130-
this->eferm.ef_up,
131-
demet_up,
132-
this->wg,
133-
0,
134-
this->klist->isk);
135-
Occupy::gweights(nks,
136-
this->klist->wk,
137-
nbands,
138-
this->nelec_spin[1],
139-
Occupy::gaussian_parameter,
140-
Occupy::gaussian_type,
141-
this->ekb,
142-
this->eferm.ef_dw,
143-
demet_dw,
144-
this->wg,
145-
1,
146-
this->klist->isk);
147-
this->f_en.demet = demet_up + demet_dw;
148-
}
149-
else
150-
{
151-
// -1 means is no related to spin.
152-
Occupy::gweights(nks,
153-
this->klist->wk,
154-
nbands,
155-
PARAM.inp.nelec,
156-
Occupy::gaussian_parameter,
157-
Occupy::gaussian_type,
158-
this->ekb,
159-
this->eferm.ef,
160-
this->f_en.demet,
161-
this->wg,
162-
-1,
163-
this->klist->isk);
164-
}
165-
#ifdef __MPI
166-
const int npool = GlobalV::KPAR * PARAM.inp.bndpar;
167-
Parallel_Reduce::reduce_double_allpool(npool, GlobalV::NPROC_IN_POOL, this->f_en.demet);
168-
#endif
169-
}
170-
else if (Occupy::fixed_occupations)
171-
{
172-
ModuleBase::WARNING_QUIT("calculate_weights", "other occupations, not implemented");
173-
}
174-
175-
return;
176-
}
177-
178-
179-
void ElecState::calEBand()
180-
{
181-
ModuleBase::TITLE("ElecState", "calEBand");
182-
// calculate ebands using wg and ekb
183-
double eband = 0.0;
184-
#ifdef _OPENMP
185-
#pragma omp parallel for collapse(2) reduction(+ : eband)
186-
#endif
187-
for (int ik = 0; ik < this->ekb.nr; ++ik)
188-
{
189-
for (int ibnd = 0; ibnd < this->ekb.nc; ibnd++)
190-
{
191-
eband += this->ekb(ik, ibnd) * this->wg(ik, ibnd);
192-
}
193-
}
194-
this->f_en.eband = eband;
195-
196-
#ifdef __MPI
197-
const int npool = GlobalV::KPAR * PARAM.inp.bndpar;
198-
Parallel_Reduce::reduce_double_allpool(npool, GlobalV::NPROC_IN_POOL, this->f_en.eband);
199-
#endif
200-
return;
201-
}
202-
203-
20430
void ElecState::init_scf(const int istep,
20531
const UnitCell& ucell,
20632
const Parallel_Grid& pgrid,

source/module_elecstate/elecstate.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ class ElecState
7272
return;
7373
}
7474

75-
// calculate wg from ekb
76-
virtual void calculate_weights();
75+
7776

7877
// use occupied weights from INPUT and skip calculate_weights
7978
// mohan updated on 2024-06-08
80-
void fixed_weights(const std::vector<double>& ocp_kb, const int& nbands, const double& nelec);
79+
8180

8281
// if nupdown is not 0(TWO_EFERMI case),
8382
// nelec_spin will be fixed and weights will be constrained
@@ -132,12 +131,8 @@ class ElecState
132131
bool vnew_exist = false;
133132
void cal_converged();
134133
void cal_energies(const int type);
135-
#ifdef __EXX
136-
#ifdef __LCAO
137134
void set_exx(const double& Eexx);
138135
void set_exx(const std::complex<double>& Eexx);
139-
#endif //__LCAO
140-
#endif //__EXX
141136

142137
double get_hartree_energy();
143138
double get_etot_efield();
@@ -167,11 +162,11 @@ class ElecState
167162
ModuleBase::matrix wg; ///< occupation weight for each k-point and band
168163

169164
public:
170-
// calculate ebands for all k points and all occupied bands
171-
void calEBand();
172165

173166
bool skip_weights = false;
174167
};
168+
169+
175170

176171
} // namespace elecstate
177172
#endif

source/module_elecstate/elecstate_exx.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace elecstate
44
{
55

6-
#ifdef __EXX
7-
#ifdef __LCAO
86
/// @brief calculation if converged
97
/// @date Peize Lin add 2016-12-03
108
void ElecState::set_exx(const double& Eexx)
@@ -17,7 +15,5 @@ void ElecState::set_exx(const double& Eexx)
1715
}
1816
return;
1917
}
20-
#endif //__LCAO
21-
#endif //__EXX
2218

2319
}

0 commit comments

Comments
 (0)