Background
Background
DeltaSpin (constrained magnetic moment DFT) previously had limited basis/nspin coverage. This issue ports DeltaSpin to the PW basis for nspin=1/2/4, introduces configurable lambda update strategies, and adds a direction_only constraint mode for noncollinear calculations. Several correctness bugs in the existing implementation are fixed along the way.
Bugs to fix
- Wrong
E_lambda formula: change from -sum(lambda*Mi) to -sum(lambda*(Mi - Mtarget)), and remove the is_Mi_converged gate.
- Inconsistent lambda sign convention between PW and LCAO paths: unify to
E' = E + lambda*(M - Mtarget).
reduce_double_allpool uses wrong communicator size: use GlobalV::NPROC_IN_POOL (fixes nspin=4 reference mismatches under kpar>1).
run_lambda_loop iteration indexing error in the PW path.
- SCF crash and charge-density sync issues in LCAO DeltaSpin.
- Segfault in
cal_escon(): add empty-check guard.
- Memory leak in
cal_pre_HR() when reinitialized.
current_spin not propagated through the operator chain in init().
Feature work
- PW nspin=1/2/4 support:
npol_ member, get_spin_sign(ik), accumulate_Mi_from_becp(), pauli_to_moment(); PW-specific update_psi_charge_pw_cpu/gpu() using subspace diagonalization.
- Lambda update strategies selectable via new input
sc_lambda_strategy: BFGS (default), linear_response, augmented_lagrangian, hybrid_delayed.
direction_only mode (sc_direction_only, default false): project lambda perpendicular to the target magnetization; two-phase BFGS with sc_dir_phase1_steps (default 10) phase-1 steps; useful for noncollinear constraints.
- SCF threshold mode
sc_scf_thr_mode (off/immediate, default off).
- Execution strategy
sc_strategy (normal/fast/off, default normal).
- Full/incremental lambda update strategies for both PW and LCAO paths.
- Remove the deprecated
sc_scf_nmin parameter and dead parameters (sc_mu_init, sc_mu_max, sc_mu_growth, sc_mix_beta).
- Refactor: cache frequently-used
PARAM.inp values as SpinConstrain members; add getters for basis_type/ks_solver/nbands; add #ifdef __LCAO guards for LCAO-only code.
New INPUT parameters
| Parameter |
Description |
Default |
sc_lambda_strategy |
Lambda update strategy |
BFGS |
sc_direction_only |
Project lambda perpendicular to target moment |
false |
sc_scf_thr_mode |
SCF threshold mode (off/immediate) |
off |
sc_dir_phase1_steps |
Phase-1 BFGS steps for direction_only mode |
10 |
sc_strategy |
Execution strategy (normal/fast/off) |
normal |
Scope
source/source_lcao/module_deltaspin/ (spin_constrain., lambda_loop.cpp, cal_mw, init_sc.cpp, deltaspin_lcao.*)
source/source_pw/module_pwdft/deltaspin_pw.cpp, setup_pot.cpp, op_pw_nl.*
source/source_esolver/esolver_ks_lcao.cpp, lcao_others.cpp
source/source_estate/elecstate_pw.*, elecstate_lcao.h, module_dm/
- Input registration:
read_input_item_*.cpp, parameters.yaml, input-main.md
- Unit tests:
module_deltaspin/test/deltaspin_pw_test.cpp, strategy tests
- Integration tests: DeltaSpin-only and DFTU+DeltaSpin cases under
tests/17_DS_DFTU/
- Docs: comprehensive DeltaSpin guide in
docs/advanced/scf/spin.md
Testing
- PW and LCAO DeltaSpin cases for nspin=1/2/4, including ReadLam, threshold variants, BFGS strategy, and direction_only cases.
- Verify PW/LCAO lambda sign consistency on the same system.
Dependencies
- Depends on Issue 1 (onsite projector npol interfaces,
setup_pot plumbing).
Related
Split out from PR #7693.
Describe the solution you'd like
Above.
Task list only for developers
Notice Possible Changes of Behavior (Reminder only for developers)
No response
Notice any changes of core modules (Reminder only for developers)
No response
Notice Possible Changes of Core Modules (Reminder only for developers)
No response
Additional Context
No response
Task list for Issue attackers (only for developers)
Background
Background
DeltaSpin (constrained magnetic moment DFT) previously had limited basis/nspin coverage. This issue ports DeltaSpin to the PW basis for nspin=1/2/4, introduces configurable lambda update strategies, and adds a
direction_onlyconstraint mode for noncollinear calculations. Several correctness bugs in the existing implementation are fixed along the way.Bugs to fix
E_lambdaformula: change from-sum(lambda*Mi)to-sum(lambda*(Mi - Mtarget)), and remove theis_Mi_convergedgate.E' = E + lambda*(M - Mtarget).reduce_double_allpooluses wrong communicator size: useGlobalV::NPROC_IN_POOL(fixes nspin=4 reference mismatches under kpar>1).run_lambda_loopiteration indexing error in the PW path.cal_escon(): add empty-check guard.cal_pre_HR()when reinitialized.current_spinnot propagated through the operator chain ininit().Feature work
npol_member,get_spin_sign(ik),accumulate_Mi_from_becp(),pauli_to_moment(); PW-specificupdate_psi_charge_pw_cpu/gpu()using subspace diagonalization.sc_lambda_strategy:BFGS(default),linear_response,augmented_lagrangian,hybrid_delayed.direction_onlymode (sc_direction_only, default false): project lambda perpendicular to the target magnetization; two-phase BFGS withsc_dir_phase1_steps(default 10) phase-1 steps; useful for noncollinear constraints.sc_scf_thr_mode(off/immediate, defaultoff).sc_strategy(normal/fast/off, defaultnormal).sc_scf_nminparameter and dead parameters (sc_mu_init,sc_mu_max,sc_mu_growth,sc_mix_beta).PARAM.inpvalues as SpinConstrain members; add getters forbasis_type/ks_solver/nbands; add#ifdef __LCAOguards for LCAO-only code.New INPUT parameters
sc_lambda_strategyBFGSsc_direction_onlyfalsesc_scf_thr_modeoff/immediate)offsc_dir_phase1_steps10sc_strategynormal/fast/off)normalScope
source/source_lcao/module_deltaspin/(spin_constrain., lambda_loop.cpp, cal_mw, init_sc.cpp, deltaspin_lcao.*)source/source_pw/module_pwdft/deltaspin_pw.cpp,setup_pot.cpp,op_pw_nl.*source/source_esolver/esolver_ks_lcao.cpp,lcao_others.cppsource/source_estate/elecstate_pw.*,elecstate_lcao.h,module_dm/read_input_item_*.cpp,parameters.yaml,input-main.mdmodule_deltaspin/test/deltaspin_pw_test.cpp, strategy teststests/17_DS_DFTU/docs/advanced/scf/spin.mdTesting
Dependencies
setup_potplumbing).Related
Split out from PR #7693.
Describe the solution you'd like
Above.
Task list only for developers
Notice Possible Changes of Behavior (Reminder only for developers)
No response
Notice any changes of core modules (Reminder only for developers)
No response
Notice Possible Changes of Core Modules (Reminder only for developers)
No response
Additional Context
No response
Task list for Issue attackers (only for developers)