Skip to content

Test: add PW/LCAO DeltaSpin+DFT+U NSCF integration tests, remove legacy DS_DFTU cases - #8525

Open
mohanchen wants to merge 23 commits into
deepmodeling:developfrom
mohanchen:mc2-2026-12-05-a
Open

mohanchen wants to merge 23 commits into
deepmodeling:developfrom
mohanchen:mc2-2026-12-05-a

Conversation

@mohanchen

@mohanchen mohanchen commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Fix #8529

Summary

Add two new integration test cases for DeltaSpin + DFT+U NSCF band structure calculations, and remove four legacy test cases from 17_DS_DFTU.

New test cases

  • tests/01_PW/nscf_deltaspin4_dftu — PW basis, noncollinear nscf with DFT+U and DeltaSpin (XY constraint), reading charge density and occupation matrix from prior scf step
  • tests/03_NAO_multik/nscf_deltaspin4_u — LCAO basis, same setup

Both cases use init_occ_mat 1 to explicitly read the occupation matrix, out_band 1 for band structure output, and are registered in CASES_CPU.txt and CASES_GPU.txt.

DFT+U code change

  • Decoupled occupation-matrix initialization from init_chg: previously init_chg=file implicitly read occ_mat.txt; now only init_occ_mat controls whether the occupation matrix is loaded

Removed legacy cases (superseded by new ones)

  • tests/17_DS_DFTU/55_PW_DS_NSCF_S4_XY
  • tests/17_DS_DFTU/60_PW_DFTU_DS_NSCF_Band_XY
  • tests/17_DS_DFTU/61_LCAO_DS_NSCF_S4_XY + 62_LCAO_DFTU_NSCF_Band_XY
  • tests/17_DS_DFTU/63_LCAO_DFTU_DS_NSCF_Band_XY

abacus_fixer added 8 commits December 5, 2026 17:28
Test PW DFT+U + DeltaSpin in NSCF band structure calculation,
XY magnetization constraint, SCF+NSCF workflow.
Add to both CASES_CPU.txt and CASES_GPU.txt.
Superseded by tests/01_PW/nscf_deltaspin4_dftu.
Test LCAO DFT+U + DeltaSpin in NSCF band structure calculation,
XY magnetization constraint, SCF+NSCF workflow.
Add to both CASES_CPU.txt and CASES_GPU.txt.
Superseded by tests/03_NAO_multik/nscf_deltaspin4_u.
Previously, when init_chg=file, the occupation matrix was implicitly
read from occ_mat.txt even without init_occ_mat. This made the two
code paths (init_occ_mat vs init_chg=file) overlapping and confusing.

Now only init_occ_mat controls occupation-matrix initialization:
- init_occ_mat != 0: read from dm_onsite_ini.txt / occ_mat.txt
- init_occ_mat == 0: zero the matrix regardless of init_chg
@mohanchen mohanchen added Refactor Refactor ABACUS codes Collinear/non-collinear/SOC/delta-spin Issues related to SOC Tests/Examples Issues/PR related to unit tests and integrate tests Solve before 3.11 labels Dec 5, 2026
abacus_fixer added 14 commits December 5, 2026 18:18
These cases duplicate coverage already provided by 01_PW/02_NAO_Gamma/
03_NAO_multik:
- plain spin (nspin=2/4) SCF: 01, 02, 06, 07
- DFT+U SCF: 03, 04, 05, 08, 09, 11
- DeltaSpin SCF (nspin=2/4): 12, 14, 15, 16, 24, 26, 27, 28
- DFT+U + DeltaSpin combos: 18, 19, 21, 30, 31, 32, 33
- sc_scf_thr parameter variants: 38-45

Remaining 8 cases (ReadLam, FeO atom-order, DirectionOnly) cover
unique code paths and will be migrated to 01_PW/03_NAO_multik.
…n_state.h

- test_read_atoms.cpp: add 3 tests covering lambda vector parsing,
  lambda scalar (z-only), and default zero when lambda is absent
- deltaspin_state.h: fix stale comment - lambda unit in STRU is eV/uB,
  matching parser and print conventions (was meV/uB)
- read_atoms_helper.cpp: add input_lambda flag to detect repeated lambda
  keyword; emit WARNING when lambda is repeated for the same atom
- read_atoms.cpp: pass input_lambda flag through to parse_atom_properties
- read_atoms_helper.h: add input_lambda parameter to parse_atom_properties
- deltaspin_state.cpp/h: remove dead ScData/ScAtomData code (never populated)
- spin_constrain.h: remove dead wrapper functions set_sc_lambda(),
  set_target_mag(), set_constrain() (never called)
- read_atoms_helper.h/cpp: add input_sc flag to parse_atom_properties;
  WARNING_QUIT when sc is repeated for the same atom
- read_atoms_helper.cpp: explicitly zero x/y components when single-value
  sc is parsed (consistent with lambda behavior)
- read_atoms.cpp: pass input_sc flag to parse_atom_properties
- read_atoms_helper.h/cpp: add input_mag, input_angle1, input_angle2 flags;
  WARNING_QUIT when mag/angle1/angle2 is repeated for the same atom
- read_atoms.cpp: pass new flags to parse_atom_properties
- test_read_atoms.cpp: add 3 death tests for repeated mag/angle1/angle2
- read_atoms_helper.h/cpp: add input_m and input_v flags;
  WARNING_QUIT when m or v/vel/velocity is repeated for the same atom
- read_atoms.cpp: pass new flags to parse_atom_properties
- test_read_atoms.cpp: add ScVectorParsed and ScScalarParsedAsZ tests
These cases use nsc=1 (read lambda from file) but the required lambda
files are absent, so they cannot run. Remove them along with the other
duplicate cases in 17_DS_DFTU.
- Swap O/Fe species order in 03_NAO_multik/scf_u_spin2 so O is atom
  type 0 and Fe is type 1; apply U only to Fe (orbital_corr -1 2,
  hubbard_u 0.0 5.0)
- Regenerate result.ref; energy/force/stress are numerically identical
  to the previous Fe-first order, confirming order independence
- Remove duplicate PW atom-order cases 50/51 from 17_DS_DFTU
Keep only the plain DeltaSpin direction-only coverage in PW (56) and
LCAO (58). Update CASES_CPU.txt to list the remaining cases; the old
list still referenced deleted cases 01 and 03.
- Move 56_PW_DS_S4_DirectionOnly_XY from 17_DS_DFTU to
  01_PW/scf_deltaspin4_dir and switch the element from Fe to Ni
  (Ni_ONCV_PBE-1.0.upf, Ni_gga_9au_100Ry_4s2p2d1f.orb)
- Align INPUT formatting with other 01_PW cases
- Disable the case in CASES_CPU.txt as a known bug: direction_only
  projects lambda parallel component to zero, triggering repeated
  [GRAD-DECAY] nu_change warnings and stalling convergence
- Remove 56 from 17_DS_DFTU/CASES_CPU.txt
The remaining direction-only case (58) is no longer needed. DeltaSpin
direction-only coverage is now the Ni case in 01_PW, currently disabled
as a known bug. Drop the add_subdirectory entry as well.
@mohanchen
mohanchen requested a review from hujieting December 5, 2026 14:21
CI rejects modifications to unit test sources under the legacy test/
directory. Migrate read_atoms_hlp_test.cpp to
source_cell/unittests/test_read_atoms_hlp.cpp, drop the hand-written
mocks and main() (the cell library and gtest_main now provide them), and
register the target in unittests/CMakeLists.txt.

Verified: target builds and all 33 tests pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Collinear/non-collinear/SOC/delta-spin Issues related to SOC Refactor Refactor ABACUS codes Solve before 3.11 Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate DeltaSpin/DFT+U integration tests and remove tests/17_DS_DFTU

1 participant