ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
deltaspin_init.cpp File Reference

Solver-independent initialization of the spin-constrained state, plus the thin SpinConstrain::init_sc() shell. More...

Include dependency graph for deltaspin_init.cpp:

Namespaces

namespace  spinconstrain

Functions

void spinconstrain::init_sc_state (const ScInitParams &params, const UnitCell &ucell, ScState &state)
 Populate ScState from UnitCell and input parameters.

Detailed Description

Solver-independent initialization of the spin-constrained state, plus the thin SpinConstrain::init_sc() shell.

Called once at the start of a DeltaSpin calculation
init_sc_state() fills ScState from UnitCell/INPUT data. The SpinConstrain::init_sc() member then only stores solver-side pointers (Hamiltonian, psi, electronic state, density matrix, PW basis).
Initialization order (critical):
  1. Input parameters (convergence thresholds, step sizes)
  2. Atom/orbital/lnchi counts (needed for array sizing)
  3. nspin and npol (determines which code paths are used)
  4. target_mag, lambda, constrain (from STRU parsing)
  5. For nspin=2: force x,y constraint flags to 0 (collinear: only z constrained)
  6. Parallel orbitals info (LCAO-specific)
  7. Solver parameters (Hamiltonian, psi, electronic state pointers)
Error conditions
  • If UnitCell.get_atom_Counts() returns empty map, subsequent operations will fail with "atomCounts is not set" in check_atomCounts()
  • If nspin is not 2 or 4, set_nspin() will call WARNING_QUIT