Skip to content

Commit 1f7e8fb

Browse files
authored
Fixed DFT-1/2 memory bug and added integration testing for DFT-1/2. (#6573)
* (Fix) Fixed the uninitialized error during DFT-1/2 calculations. * During DFT-1/2 calculations, the self-energy potential vsep_cell required for DFT-1/2 was not initialized before computing potential_new. * The generation of the self-energy potential vsep_cell has been moved forward to before the computation of potential_new. * (Test) Add integration testing for DFT-1/2 * Add integration testing 01_PW/209_PW_DFTHALF for DFT-1/2
1 parent d9ac0c6 commit 1f7e8fb

File tree

10 files changed

+3592
-15
lines changed

10 files changed

+3592
-15
lines changed

source/source_pw/module_pwdft/setup_pot.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "source_pw/module_pwdft/VSep_in_pw.h"
88

99
template <typename T, typename Device>
10-
void pw::setup_pot(const int istep,
11-
UnitCell& ucell, // unitcell
10+
void pw::setup_pot(const int istep,
11+
UnitCell& ucell, // unitcell
1212
const K_Vectors &kv, // kpoints
1313
Structure_Factor &sf, // structure factors
1414
elecstate::ElecState *pelec, // pointer of electrons
@@ -24,6 +24,16 @@ void pw::setup_pot(const int istep,
2424
const Input_para& inp) // input parameters
2525
{
2626
ModuleBase::TITLE("pw", "setup_pot");
27+
28+
//----------------------------------------------------------
29+
//! 0) DFT-1/2 calculations, sep potential need to generate
30+
// before effective potential calculation
31+
//----------------------------------------------------------
32+
if (PARAM.inp.dfthalf_type > 0)
33+
{
34+
vsep_cell->generate_vsep_r(pw_rhod[0], sf.strucFac, ucell.sep_cell);
35+
}
36+
2737
//----------------------------------------------------------
2838
//! 1) Renew local pseudopotential
2939
//----------------------------------------------------------
@@ -110,21 +120,12 @@ void pw::setup_pot(const int istep,
110120
dftu->init(ucell, nullptr, kv.get_nks());
111121
}
112122

113-
//----------------------------------------------------------
114-
//! 7) DFT-1/2 calculations, sep potential need to generate
115-
// before effective potential calculation
116-
//----------------------------------------------------------
117-
if (PARAM.inp.dfthalf_type > 0)
118-
{
119-
vsep_cell->generate_vsep_r(pw_rhod[0], sf.strucFac, ucell.sep_cell);
120-
}
121-
122123
return;
123124
}
124125

125126
template void pw::setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
126127
const int istep, // ionic step
127-
UnitCell& ucell, // unitcell
128+
UnitCell& ucell, // unitcell
128129
const K_Vectors &kv, // kpoints
129130
Structure_Factor &sf, // structure factors
130131
elecstate::ElecState *pelec, // pointer of electrons
@@ -142,7 +143,7 @@ template void pw::setup_pot<std::complex<float>, base_device::DEVICE_CPU>(
142143

143144
template void pw::setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
144145
const int istep, // ionic step
145-
UnitCell& ucell, // unitcell
146+
UnitCell& ucell, // unitcell
146147
const K_Vectors &kv, // kpoints
147148
Structure_Factor &sf, // structure factors
148149
elecstate::ElecState *pelec, // pointer of electrons
@@ -161,7 +162,7 @@ template void pw::setup_pot<std::complex<double>, base_device::DEVICE_CPU>(
161162

162163
template void pw::setup_pot<std::complex<float>, base_device::DEVICE_GPU>(
163164
const int istep, // ionic step
164-
UnitCell& ucell, // unitcell
165+
UnitCell& ucell, // unitcell
165166
const K_Vectors &kv, // kpoints
166167
Structure_Factor &sf, // structure factors
167168
elecstate::ElecState *pelec, // pointer of electrons
@@ -178,7 +179,7 @@ template void pw::setup_pot<std::complex<float>, base_device::DEVICE_GPU>(
178179

179180
template void pw::setup_pot<std::complex<double>, base_device::DEVICE_GPU>(
180181
const int istep, // ionic step
181-
UnitCell& ucell, // unitcell
182+
UnitCell& ucell, // unitcell
182183
const K_Vectors &kv, // kpoints
183184
Structure_Factor &sf, // structure factors
184185
elecstate::ElecState *pelec, // pointer of electrons

tests/01_PW/209_PW_DFTHALF/INPUT

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
INPUT_PARAMETERS
2+
#Parameters (1.General)
3+
suffix autotest
4+
calculation scf
5+
ks_solver dav
6+
dfthalf_type 1
7+
8+
symmetry 1
9+
pseudo_dir ../../PP_ORB
10+
11+
#Parameters (2.Iteration)
12+
ecutwfc 50
13+
scf_thr 1e-9
14+
scf_nmax 100
15+
16+
17+
#Parameters (3.Basis)
18+
basis_type pw
19+
20+
#Parameters (4.Smearing)
21+
smearing_method gauss
22+
smearing_sigma 0.002
23+
24+
#Parameters (5.Mixing)
25+
mixing_type broyden
26+
mixing_beta 0.7
27+
28+
dft_functional PBE
29+
30+
#OUT
31+
out_bandgap true
32+
33+
pw_seed 1

tests/01_PW/209_PW_DFTHALF/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+
2 2 2 0 0 0

tests/01_PW/209_PW_DFTHALF/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DFT-1/2 method in PW basis, soc off

tests/01_PW/209_PW_DFTHALF/STRU

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ATOMIC_SPECIES
2+
Li 0.0 Li_ONCV_PBE-1.2.upf upf201
3+
F 0.0 F_ONCV_PBE-1.2.upf upf201
4+
5+
LATTICE_CONSTANT
6+
1.0000000000
7+
8+
LATTICE_VECTORS
9+
0.0000000000 3.8379626543 3.8379626543
10+
3.8379626543 0.0000000000 3.8379626543
11+
3.8379626543 3.8379626543 0.0000000000
12+
13+
SEP_FILES
14+
Li 0
15+
F 1 F_pbe_50.sep 0.0 2.2 20.0 1.0
16+
17+
ATOMIC_POSITIONS
18+
Direct
19+
20+
Li #label
21+
0.0000 #magnetism
22+
1 #number of atoms
23+
0.0000000000 0.0000000000 0.0000000000 m 1 1 1
24+
25+
F #label
26+
0.0000 #magnetism
27+
1 #number of atoms
28+
0.5000000000 0.5000000000 0.5000000000 m 1 1 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
etotref -906.0447337890729
2+
etotperatomref -453.0223668945
3+
pointgroupref O_h
4+
spacegroupref O_h
5+
nksibzref 3
6+
totaltimeref 0.39

tests/01_PW/CASES_CPU.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
206_PW_SCAN_S2
109109
207_PW_skip
110110
208_PW_CG_float
111+
209_PW_DFTHALF
111112
801_PW_LT_sc
112113
802_PW_LT_fcc
113114
803_PW_LT_bcc

0 commit comments

Comments
 (0)