Skip to content

Commit c614a9a

Browse files
dyzhengdyzheng
andauthored
Fix: OperatorDFTU for multi-k and NSPIN=2 (#1570)
* Fix: OperatorDFTU for multi-k case * Test: add 360* case for DFTU in Gamma_only * Fix: solve conflicts Co-authored-by: dyzheng <[email protected]>
1 parent ac9a2b1 commit c614a9a

File tree

13 files changed

+120
-39
lines changed

13 files changed

+120
-39
lines changed

source/module_hamilt/hamilt_lcao.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -144,28 +144,29 @@ HamiltLCAO<T>::HamiltLCAO(
144144
this->opsd->add(exx);
145145
}
146146

147-
if (GlobalV::dft_plus_u)
147+
#ifdef __DEEPKS
148+
if (GlobalV::deepks_scf)
148149
{
149-
Operator<double>* dftu = new OperatorDFTU<OperatorLCAO<double>>(
150+
Operator<double>* deepks = new DeePKS<OperatorLCAO<double>>(
151+
loc_in,
150152
LM_in,
151153
nullptr,// no explicit call yet
152154
&(LM_in->Hloc)
153155
);
154-
this->opsd->add(dftu);
156+
this->opsd->add(deepks);
155157
}
158+
#endif
156159

157-
#ifdef __DEEPKS
158-
if (GlobalV::deepks_scf)
160+
//end node should be OperatorDFTU
161+
if (GlobalV::dft_plus_u)
159162
{
160-
Operator<double>* deepks = new DeePKS<OperatorLCAO<double>>(
161-
loc_in,
163+
Operator<double>* dftu = new OperatorDFTU<OperatorLCAO<double>>(
162164
LM_in,
163165
nullptr,// no explicit call yet
164166
&(LM_in->Hloc)
165167
);
166-
this->opsd->add(deepks);
168+
this->opsd->add(dftu);
167169
}
168-
#endif
169170
return;
170171
}
171172

@@ -288,16 +289,6 @@ HamiltLCAO<T>::HamiltLCAO(
288289
this->ops->add(nonlocal);
289290
}
290291

291-
if (GlobalV::dft_plus_u)
292-
{
293-
Operator<std::complex<double>>* dftu = new OperatorDFTU<OperatorLCAO<std::complex<double>>>(
294-
LM_in,
295-
nullptr,// no explicit call yet
296-
&(LM_in->Hloc2)
297-
);
298-
this->ops->add(dftu);
299-
}
300-
301292
#ifdef __DEEPKS
302293
if (GlobalV::deepks_scf)
303294
{
@@ -310,6 +301,16 @@ HamiltLCAO<T>::HamiltLCAO(
310301
this->ops->add(deepks);
311302
}
312303
#endif
304+
//end node should be OperatorDFTU
305+
if (GlobalV::dft_plus_u)
306+
{
307+
Operator<std::complex<double>>* dftu = new OperatorDFTU<OperatorLCAO<std::complex<double>>>(
308+
LM_in,
309+
nullptr,// no explicit call yet
310+
&(LM_in->Hloc2)
311+
);
312+
this->ops->add(dftu);
313+
}
313314

314315
}
315316

source/module_hamilt/ks_lcao/operator_lcao.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ void OperatorLCAO<T>::init(const int ik_in)
155155
{
156156
//only HK should be updated when cal_type=lcao_dftu
157157
//in cal_type=lcao_dftu, HK only need to update from one node
158+
//dftu is a special operator, it should be the last node of chain
159+
//Overlap matrix for ik is used by it, do folding first and then return
160+
this->folding_fixed(ik_in);
158161
this->contributeHk(ik_in);
162+
return;
159163

160164
break;
161165
}

tests/integrate/260_NO_15_PK_PU_AF/INPUT

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
INPUT_PARAMETERS
22
suffix autotest
3-
ntype 3
3+
ntype 2
44
nbands 40
55

66
calculation scf
7-
ecutwfc 20
7+
ecutwfc 50
88
scf_thr 1.0e-4
9-
scf_nmax 2
9+
scf_nmax 3
1010
out_chg 0
1111

1212
#init_chg file
@@ -18,6 +18,7 @@ smearing_method gaussian
1818
smearing_sigma 0.07
1919

2020
#cal_force 1
21+
#cal_stress 1
2122
#force_thr_ev 0.01
2223
#relax_method cg
2324
#relax_bfgs_init 0.5
@@ -28,7 +29,7 @@ mixing_beta 0.4
2829

2930
ks_solver scalapack_gvx
3031
basis_type lcao
31-
gamma_only 1
32+
gamma_only 0
3233
symmetry 0
3334
nspin 2
3435

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
K_POINTS
22
0
33
Gamma
4-
1 1 1 0 0 0
4+
2 2 2 0 0 0

tests/integrate/260_NO_15_PK_PU_AF/STRU

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
ATOMIC_SPECIES
2-
Fe1 1.000 Fe_ONCV_PBE-1.0.upf
3-
Fe2 1.000 Fe_ONCV_PBE-1.0.upf
2+
Fe 1.000 Fe_ONCV_PBE-1.0.upf
43
O 1.000 O_ONCV_PBE-1.0.upf
54

65
NUMERICAL_ORBITAL
76
Fe_gga_9au_100Ry_4s2p2d1f.orb
8-
Fe_gga_9au_100Ry_4s2p2d1f.orb
97
O_gga_7au_100Ry_2s2p1d.orb
108

119
LATTICE_CONSTANT
@@ -18,15 +16,11 @@ LATTICE_VECTORS
1816
ATOMIC_POSITIONS
1917
Direct
2018

21-
Fe1
22-
1.0
23-
1
24-
0.00 0.00 0.00 1 1 1
25-
26-
Fe2
27-
-1.0
28-
1
29-
0.50 0.50 0.50 1 1 1
19+
Fe
20+
0.0
21+
2
22+
0.00 0.00 0.00 mag 1.0
23+
0.50 0.50 0.50 mag -1.0
3024

3125
O
3226
0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DFTU + NSPIN2, Fe2O2, multi-k case
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
etotref -7250.8489104634409159
2-
etotperatomref -1812.7122276159
3-
totaltimeref 7.86288
1+
etotref -7301.6331988753327096
2+
etotperatomref -1825.4082997188
3+
totaltimeref 18.05934
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
ntype 2
4+
nbands 40
5+
6+
calculation scf
7+
ecutwfc 50
8+
scf_thr 1.0e-4
9+
scf_nmax 3
10+
out_chg 0
11+
12+
#init_chg file
13+
#out_dos 1
14+
#dos_sigma 0.05
15+
#out_band 1
16+
17+
smearing_method gaussian
18+
smearing_sigma 0.07
19+
20+
cal_force 0
21+
cal_stress 0
22+
#force_thr_ev 0.01
23+
#relax_method cg
24+
#relax_bfgs_init 0.5
25+
26+
mixing_type pulay
27+
mixing_beta 0.4
28+
#mixing_gg0 1.5
29+
30+
ks_solver scalapack_gvx
31+
basis_type lcao
32+
gamma_only 1
33+
symmetry 0
34+
nspin 2
35+
36+
#Parameter DFT+U
37+
dft_plus_u 1
38+
orbital_corr 2 2 -1
39+
hubbard_u 5.0 5.0 0.0
40+
hund_j 0.0 0.0 0.0
41+
pseudo_dir ../../PP_ORB
42+
orbital_dir ../../PP_ORB
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+
1 1 1 0 0 0
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
ATOMIC_SPECIES
2+
Fe 1.000 Fe_ONCV_PBE-1.0.upf
3+
O 1.000 O_ONCV_PBE-1.0.upf
4+
5+
NUMERICAL_ORBITAL
6+
Fe_gga_9au_100Ry_4s2p2d1f.orb
7+
O_gga_7au_100Ry_2s2p1d.orb
8+
9+
LATTICE_CONSTANT
10+
8.190
11+
12+
LATTICE_VECTORS
13+
1.00 0.50 0.50
14+
0.50 1.00 0.50
15+
0.50 0.50 1.00
16+
ATOMIC_POSITIONS
17+
Direct
18+
19+
Fe
20+
0.0
21+
2
22+
0.00 0.00 0.00 mag 1.0
23+
0.50 0.50 0.50 mag -1.0
24+
25+
O
26+
0.0
27+
2
28+
0.25 0.25 0.25 1 1 1
29+
0.75 0.75 0.75 1 1 1

0 commit comments

Comments
 (0)