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

Core header for the DeltaSpin (spin-constrained DFT) module. More...

#include <complex>
#include <fstream>
#include <map>
#include <vector>
#include "source_base/constants.h"
#include "source_base/complexmatrix.h"
#include "source_base/matrix.h"
#include "source_base/tool_quit.h"
#include "source_base/tool_title.h"
#include "source_base/vector3.h"
#include "source_basis/module_ao/parallel_orbitals.h"
#include "source_cell/klist.h"
#include "source_cell/unitcell.h"
#include "source_hamilt/operator.h"
#include "source_estate/elecstate.h"
#include "deltaspin_state.h"
#include "deltaspin_pw_cache.h"
Include dependency graph for spin_constrain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  spinconstrain::SpinConstrain< TK >
 Singleton class implementing spin-constrained DFT (DeltaSpin). More...

Namespaces

namespace  spinconstrain

Detailed Description

Core header for the DeltaSpin (spin-constrained DFT) module.

Purpose
Implements constrained local spin density (CLSD) functional calculations, where atomic magnetic moments are constrained to target values via Lagrange multipliers (lambda). The constrained energy functional is: E'[rho] = E[rho] - sum_i lambda_i . (M_i - M_target_i) where lambda_i is the Lagrange multiplier (magnetic force) on atom i, M_i is the computed magnetic moment, and M_target_i is the target moment.
Algorithm
The lambda optimization uses a conjugate-gradient-like scheme (run_lambda_loop):
  1. Compute magnetic moments Mi from current wavefunction
  2. Calculate residual: delta_spin = Mi - M_target
  3. Build search direction (steepest descent or Polak-Ribiere CG)
  4. Apply lambda update: lambda += alpha * search_direction
  5. Re-diagonalize Hamiltonian with DeltaSpin correction
  6. Compute new Mi, find optimal alpha via linear interpolation
  7. Repeat until RMS(delta_spin) < sc_thr
Basis Set Support
  • LCAO: Uses real-space projection via DeltaSpin operator on density matrix
  • PW (Plane Wave): Uses subspace diagonalization with OnsiteProjector becp coefficients
Spin Types
  • nspin=2 (collinear): Only z-component constrained, npol=1, uses spin_sign (+1/-1)
  • nspin=4 (non-collinear): Full xyz components constrained, npol=2, full Pauli matrices
Convergence Criteria
  • RMS error: sqrt(mean(delta_spin^2)) < sc_thr (adaptive threshold)
  • Gradient decay: max(dM/dlambda) per atom type < decay_grad[itype]
  • Maximum steps: nsc (default 50), minimum steps: nsc_min
Internal layout
All basis-set-independent constraint data (lambda, target_mag, Mi, constrain, indexing maps, loop parameters) is owned by the ScState member state_ (see deltaspin_state.h). The public setters/getters below are thin forwarding shells kept for backward compatibility with existing call sites.