Skip to content

Commit 3a96cd7

Browse files
author
abacus_fixer
committed
Test: add DeltaSpin integration tests with force/stress (PW + LCAO, nspin=2/4)
Add four fast, reproducible DeltaSpin integration cases to cover the spin-constrained (deltaspin) code paths ahead of the planned SpinConstrain refactor. All cases compute force and stress in addition to total energy. New cases: - tests/01_PW/scf_deltaspin2: PW basis, collinear (nspin=2), Z magnetization constraint, iterative lambda optimization to target. kpar=2, pw_seed=1. - tests/01_PW/scf_deltaspin4: PW basis, noncollinear (nspin=4), Z-only constraint (verifies no unphysical XY components). kpar=2, pw_seed=1. - tests/03_NAO_multik/scf_deltaspin2: LCAO basis, collinear (nspin=2), Z constraint, Gamma k-point. Single MPI process. - tests/03_NAO_multik/scf_deltaspin4: LCAO basis, noncollinear (nspin=4), Z-only constraint, 2x2x2 Monkhorst-Pack. Exercises the LCAO lambda loop. Each case carries INPUT/KPT/STRU/result.ref/README. result.ref records etotref/etotperatomref plus totalforceref/totalstressref (sum-of-absolutes, matching tests/integrate/tools/catch_properties.sh). Cases were each run three times (OMP_NUM_THREADS=1) to confirm bit-identical etot before the reference was written. Registration: - tests/01_PW/CASES_CPU.txt and CASES_GPU.txt: scf_deltaspin2/4 (PW runs on GPU) - tests/03_NAO_multik/CASES_CPU.txt: scf_deltaspin2/4 Note: an LCAO gamma_only=1 DeltaSpin variant was evaluated for tests/02_NAO_Gamma but is excluded because it hits a pre-existing latent bug (SpinConstrain<double>::cal_mi_lcao is an empty stub, so print_Mi reads an empty Mi_ vector and segfaults); that bug is out of scope for this change and should be fixed separately. The LCAO coverage here uses multik instead. Verification: abacus_max_para v3.11.0-beta8 (build_max_para_test, make -j 30); each of the four cases run 3x with bit-identical FINAL_ETOT; force/stress references extracted from the same runs.
1 parent 370e024 commit 3a96cd7

23 files changed

Lines changed: 260 additions & 0 deletions

File tree

tests/01_PW/CASES_CPU.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,5 @@ scf_out_chg_tau
132132
814_PW_LT_triclinic
133133
815_PW_DFTU_S2_Z
134134
816_PW_DFTU_S4_XY
135+
scf_deltaspin2
136+
scf_deltaspin4

tests/01_PW/CASES_GPU.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ scf_out_elf
130130
814_PW_LT_triclinic
131131
815_PW_DFTU_S2_Z
132132
816_PW_DFTU_S4_XY
133+
scf_deltaspin2
134+
scf_deltaspin4

tests/01_PW/scf_deltaspin2/INPUT

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
calculation scf
4+
basis_type pw
5+
ecutwfc 20
6+
gamma_only 0
7+
nspin 2
8+
#nbands 28
9+
scf_thr 1.0e-6
10+
scf_nmax 50
11+
out_chg 0
12+
smearing_method gaussian
13+
smearing_sigma 0.01
14+
mixing_type broyden
15+
mixing_beta 0.4
16+
ks_solver dav_subspace
17+
symmetry 0
18+
cal_force 1
19+
cal_stress 1
20+
21+
# DeltaSpin parameters
22+
sc_mag_switch 1
23+
sc_thr 1e-4
24+
nsc 100
25+
nsc_min 2
26+
alpha_trial 0.01
27+
sccut 3.0
28+
sc_scf_thr 10
29+
30+
kpar 2
31+
pseudo_dir ../../PP_ORB
32+
orbital_dir ../../PP_ORB
33+
pw_seed 1

tests/01_PW/scf_deltaspin2/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

tests/01_PW/scf_deltaspin2/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test PW DeltaSpin with collinear spin (nspin=2), Z magnetization constraint, iterative optimization to target. Force and stress computed.

tests/01_PW/scf_deltaspin2/STRU

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
15+
ATOMIC_POSITIONS
16+
Direct
17+
18+
Fe
19+
0.0
20+
2
21+
0.00 0.00 0.00 mag 2.0 sc 1 1 1
22+
0.51 0.51 0.51 mag -2.0 sc 1 1 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
etotref -6369.198268154196
2+
etotperatomref -3184.599134077098
3+
totalforceref 23.414157
4+
totalstressref 63452.888627

tests/01_PW/scf_deltaspin4/INPUT

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
INPUT_PARAMETERS
2+
suffix autotest
3+
calculation scf
4+
basis_type pw
5+
ecutwfc 20
6+
gamma_only 0
7+
noncolin 1
8+
nspin 4
9+
#nbands 40
10+
scf_thr 1.0e-6
11+
scf_nmax 50
12+
out_chg 0
13+
smearing_method gaussian
14+
smearing_sigma 0.01
15+
mixing_type broyden
16+
mixing_beta 0.4
17+
ks_solver dav_subspace
18+
symmetry 0
19+
cal_force 1
20+
cal_stress 1
21+
22+
# DeltaSpin parameters
23+
sc_mag_switch 1
24+
sc_thr 1e-4
25+
nsc 100
26+
nsc_min 2
27+
alpha_trial 0.01
28+
sccut 3.0
29+
sc_scf_thr 10
30+
31+
kpar 2
32+
pseudo_dir ../../PP_ORB
33+
orbital_dir ../../PP_ORB
34+
pw_seed 1

tests/01_PW/scf_deltaspin4/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

tests/01_PW/scf_deltaspin4/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test PW DeltaSpin with noncollinear spin (nspin=4), Z-only constraint to verify no unphysical XY components. Force and stress computed.

0 commit comments

Comments
 (0)