ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
spinconstrain::pw Namespace Reference

Classes

class  SubspaceCache
 Owning cache of PW subspace H/S/becp data plus the lambda snapshot. More...

Functions

void cal_mi_pw (ScState &state, void *psi, elecstate::ElecState *pelec)
 Calculate atomic magnetic moments using projector overlap (PW basis).
void 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 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.

Function Documentation

◆ cal_mi_pw()

void spinconstrain::pw::cal_mi_pw ( ScState & state,
void * psi,
elecstate::ElecState * pelec )

Calculate atomic magnetic moments using projector overlap (PW basis).

For each k-point: tabulate atomic projectors, compute becp = <alpha|psi> via OnsiteProjector::overlap_proj_psi, then decompose becp into magnetic moments. Finally Mi is summed across all MPI k-pool ranks.

Parameters
stateConstraint state; its magnetic moments are filled in place.
psiPW wavefunctions (psi::Psi<std::complex<double>>, passed as void to keep this header free of the Device template parameter).
pelecElectronic state (provides wg weights and k-list spin signs).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_delta_hcc()

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.

Adds H += becp^dagger * ps, where ps = delta_lambda * becp. For npol=2 uses the full 2x2 Pauli matrix; for npol=1 uses the z-component with spin_sign.

Parameters
stateConstraint state (npol, Mi size, lambda snapshot via cache).
cachePW subspace cache; supplies lambda_in_sub() for full_update.
pelecElectronic state (for collinear spin_sign lookup).
h_tmpSubspace Hamiltonian (nbands x nbands, modified in place).
becp_kProjector coefficients for k-point ik.
delta_lambdaLambda change per atom (or full lambda if full_update).
nbandsNumber of bands.
nkbTotal number of projectors.
nh_iatNumber of projectors per atom.
ikK-point index (for collinear spin_sign lookup).
full_updateIf true, compute delta = lambda_current - lambda_at_save.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_psi_charge_pw_cpu()

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.

Two-stage process
Stage 1 - Subspace diagonalization: apply DeltaSpin correction to the saved subspace H, then diagonalize to rotate wavefunctions (cheap, nbands x nbands). Stage 2 - Full-space update: if pw_solve, run HSolverPW for iterative refinement; else update weights from new eigenvalues and call psiToRho().

Frees the subspace cache after use (allocated in cal_mw_from_lambda).

Parameters
stateConstraint state.
cachePW subspace cache (released here).
psiPW wavefunctions (psi::Psi<std::complex<double>>, as void).
p_hamiltHamiltonian (hamilt::Hamilt<std::complex<double>>, as void).
pelecElectronic state.
pw_wfcPW basis for wavefunction storage.
delta_lambdaLambda change for incremental H correction.
pw_solveIf true, run full PW solver; if false, just update weights.
full_updateIf true, apply full lambda (not delta) to H correction.
Here is the call graph for this function:
Here is the caller graph for this function: