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

PW-basis DeltaSpin computation path as free functions, decoupled from SpinConstrain. More...

#include <complex>
#include "source_base/vector3.h"
#include "deltaspin_state.h"
Include dependency graph for deltaspin_pw_mi.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  psi
namespace  hamilt
namespace  elecstate
namespace  ModulePW
namespace  spinconstrain
namespace  spinconstrain::pw

Functions

void spinconstrain::pw::cal_mi_pw (ScState &state, void *psi, elecstate::ElecState *pelec)
 Calculate atomic magnetic moments using projector overlap (PW basis).
void spinconstrain::pw::calculate_delta_hcc (ScState &state, const SubspaceCache &cache, elecstate::ElecState *pelec, std::complex< double > *h_tmp, const std::complex< double > *becp_k, const ModuleBase::Vector3< double > *delta_lambda, const int nbands, const int nkb, const int *nh_iat, const int ik, const bool full_update)
 Compute DeltaSpin correction to a subspace Hamiltonian.
void spinconstrain::pw::update_psi_charge_pw_cpu (ScState &state, SubspaceCache &cache, void *psi, void *p_hamilt, elecstate::ElecState *pelec, ModulePW::PW_Basis_K *pw_wfc, const ModuleBase::Vector3< double > *delta_lambda, bool pw_solve, bool full_update)
 CPU implementation of PW wavefunction and charge density update.

Detailed Description

PW-basis DeltaSpin computation path as free functions, decoupled from SpinConstrain.

Purpose
These functions implement the PW-basis branch of DeltaSpin that used to be member functions of SpinConstrain<std::complex<double>>, defined out-of-line in source/source_pw/module_pwdft/deltaspin_pw_impl.cpp. They are now free functions in spinconstrain::pw so the PW implementation lives in module_deltaspin instead of source_pw (removing the reverse source_pw -> module_deltaspin implementation dependency), and so dependencies are passed explicitly per the AGENTS.md rule.

The PW path is always instantiated on complex wavefunctions (psi::Psi<std::complex<double>>), so these functions are not templated on TK.

Workflow
  • cal_mi_pw(): compute atomic magnetic moments Mi from becp = <alpha|psi>.
  • calculate_delta_hcc(): add the DeltaSpin correction H += becp^dagger * lambda * becp to a subspace Hamiltonian.
  • update_psi_charge_pw_cpu()/update_psi_charge_pw_gpu(): subspace diagonalization + optional full-space refinement to update psi and charge density after the lambda loop.