Skip to content

Commit 0797d01

Browse files
dyzhengdyzheng
andauthored
Feat/issue 7726 dftu pw nspin fixes (#7744)
* Fix(dftu-pw): correct Pauli-to-spin conversion signs and weight_eu for nspin=1 In cal_occ_pw(): - Swap the imaginary signs in the Pauli-to-spin conversion for nspin=4: index[1] (spin down-up): -i*vu_tmp[2] -> +i*vu_tmp[2] index[2] (spin up-down): +i*vu_tmp[2] -> -i*vu_tmp[2] The DFT+U vu array convention requires opposite sign from deeq_nc. - Fix weight_eu for nspin=1: 0.25 -> 1.0 nspin=1 has single occupancy, not the Pauli double-counting factor. Verified with tests/17_DS_DFTU/08 and 09: 08: -6792.33351671617 (ref -6792.33351670950, diff 6.7e-9 eV) 09: -6364.26587638707 (ref -6364.26587639017, diff 3.1e-9 eV) * Test: migrate PW DFT+U tests (08/09) from 17_DS_DFTU to 01_PW 815_PW_DFTU_S2_Z — nspin=2 DFT+U, matches ref -6792.33351671614 816_PW_DFTU_S4_XY — nspin=4 DFT+U, matches ref -6364.26587638708 * Test: disable migrated 08/09 in 17_DS_DFTU CASES_CPU, enabled in 01_PW * Test: regenerate 099_PW_DJ_SO reference for nspin=4 DFT+U sign fix The nspin=4 Pauli-to-spin sign swap in cal_occ_pw changes the output of all nspin=4 DFT+U PW tests, including the pre-existing 099_PW_DJ_SO whose result.ref was not updated. Regenerate its etot/force/stress references: etot -5662.3881388456420609 -> -5662.3908859903258417 force 15.774740 -> 17.965510 stress 100840.559090 -> 100582.607209 Without this, the 01_PW integrate suite fails on 099_PW_DJ_SO (etot dev 2.7e-3 eV, force dev -2.19, stress dev 258). * fix: add explicit nspin=4 to 816_PW_DFTU_S4_XY test INPUT Commit b95f433 on develop removed the automatic nspin=4 reset when noncolin/lspinorb is enabled, instead requiring explicit nspin=4. Since the PR does not touch read_input_item_elec_stru.cpp, the CI merge uses develop's validation code, causing ABACUS to quit with: nspin must be 4 when noncolin or lspinorb is enabled. --------- Co-authored-by: dyzheng <zhengdy@bjaisi.com>
1 parent d8ff3fb commit 0797d01

14 files changed

Lines changed: 128 additions & 9 deletions

File tree

source/source_lcao/module_dftu/dftu_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void Plus_U::cal_occ_pw(const int iter,
247247
}
248248

249249
Plus_U::energy_u = 0.0;
250-
const double weight_eu = (Plus_U::nspin == 1) ? 0.25 : (Plus_U::nspin == 2) ? 0.5 : 0.25;
250+
const double weight_eu = (Plus_U::nspin == 1) ? 1.0 : (Plus_U::nspin == 2) ? 0.5 : 0.25;
251251
const double diag_coeff = (Plus_U::nspin == 4) ? 1.0 : 0.5;
252252
// calculate VU and energy (locale already reduced above)
253253
for(int iat = 0; iat < cell.nat; iat++)
@@ -309,8 +309,8 @@ void Plus_U::cal_occ_pw(const int iter,
309309
}
310310
vu_iat[index[0]] = 0.5 * (vu_tmp[0] + vu_tmp[3]);
311311
vu_iat[index[3]] = 0.5 * (vu_tmp[0] - vu_tmp[3]);
312-
vu_iat[index[1]] = 0.5 * (vu_tmp[1] - std::complex<double>(0.0, 1.0) * vu_tmp[2]);
313-
vu_iat[index[2]] = 0.5 * (vu_tmp[1] + std::complex<double>(0.0, 1.0) * vu_tmp[2]);
312+
vu_iat[index[1]] = 0.5 * (vu_tmp[1] + std::complex<double>(0.0, 1.0) * vu_tmp[2]);
313+
vu_iat[index[2]] = 0.5 * (vu_tmp[1] - std::complex<double>(0.0, 1.0) * vu_tmp[2]);
314314
}
315315
}
316316
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -5662.3881388456420609
2-
etotperatomref -2831.1940694228
3-
totalforceref 15.774740
4-
totalstressref 100840.559090
1+
etotref -5662.3908859903258417
2+
etotperatomref -2831.1954429952
3+
totalforceref 17.965510
4+
totalstressref 100582.607209
55
totaltimeref 1.26

tests/01_PW/815_PW_DFTU_S2_Z/INPUT

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
calculation scf
4+
basis_type pw
5+
ecutwfc 50
6+
gamma_only 0
7+
device cpu
8+
9+
nspin 2
10+
nbands 28
11+
scf_thr 1.0e-6
12+
scf_nmax 100
13+
out_chg 0
14+
smearing_method gaussian
15+
smearing_sigma 0.01
16+
mixing_type broyden
17+
mixing_beta 0.4
18+
ks_solver dav_subspace
19+
symmetry 0
20+
21+
# DFT+U parameters
22+
dft_plus_u 1
23+
orbital_corr 2
24+
hubbard_u 5.0
25+
onsite_radius 3.0
26+
27+
pseudo_dir ../../PP_ORB
28+
orbital_dir ../../PP_ORB
29+
pw_seed 1

tests/01_PW/815_PW_DFTU_S2_Z/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+
Monkhorst-Pack
4+
2 2 2 0 0 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test PW DFT+U (U=5.0eV, l=2) with collinear spin (nspin=2), Z magnetization

tests/01_PW/815_PW_DFTU_S2_Z/STRU

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ATOMIC_SPECIES
2+
Fe 1.000 Fe.upf
3+
4+
NUMERICAL_ORBITAL
5+
Fe_gga_6au_100Ry_4s2p2d1f.orb
6+
7+
LATTICE_CONSTANT
8+
8.190
9+
10+
LATTICE_VECTORS
11+
1.00 0.50 0.50
12+
0.50 1.00 0.50
13+
0.50 0.50 1.00
14+
ATOMIC_POSITIONS
15+
Direct
16+
17+
Fe
18+
0.0
19+
2
20+
0.00 0.00 0.00 mag 2.0
21+
0.51 0.51 0.51 mag -2.0
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
etotref -6792.3335167095001452
2+
etotperatomref -3396.1667583548
3+
totaltimeref 21.07
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
calculation scf
4+
basis_type pw
5+
ecutwfc 20
6+
gamma_only 0
7+
device cpu
8+
9+
noncolin 1
10+
nspin 4
11+
scf_thr 1.0e-6
12+
scf_nmax 50
13+
out_chg 0
14+
smearing_method gaussian
15+
smearing_sigma 0.01
16+
mixing_type broyden
17+
mixing_beta 0.4
18+
ks_solver dav_subspace
19+
symmetry 0
20+
21+
# DFT+U parameters
22+
dft_plus_u 1
23+
orbital_corr 2
24+
hubbard_u 5.0
25+
onsite_radius 3.0
26+
27+
kpar 1
28+
pseudo_dir ../../PP_ORB
29+
orbital_dir ../../PP_ORB
30+
pw_seed 1

tests/01_PW/816_PW_DFTU_S4_XY/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+
Monkhorst-Pack
4+
2 2 2 0 0 0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test PW DFT+U with noncollinear spin (nspin=4), XY magnetization constraint

0 commit comments

Comments
 (0)