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

PW-basis subspace data cache for DeltaSpin, decoupled from SpinConstrain. More...

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

Go to the source code of this file.

Classes

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

Namespaces

namespace  spinconstrain
namespace  spinconstrain::pw

Detailed Description

PW-basis subspace data cache for DeltaSpin, decoupled from SpinConstrain.

Purpose
In the PW basis, the subspace Hamiltonian H_sub = <psi|H|psi>, overlap S_sub and becp coefficients are expensive to compute. They are cached on the first cal_mw_from_lambda() call and reused across multiple lambda steps within the same SCF iteration, then freed after the final subspace diagonalization in update_psi_charge_pw_{cpu,gpu}().

This class owns the three raw device/host pointers plus the lambda snapshot taken when the cache was filled, replacing the ad-hoc new[]/delete[] that used to live as public SpinConstrain members. It encapsulates the CPU vs GPU allocation/free difference behind allocate()/release(), while still exposing raw per-k pointers (h_k/s_k/becp_k) because the hsolver subspace routines and GPU memcpy ops require raw pointers.

Layout (same as before, unchanged)
  • h(ik)[i * nbands + j]: H_sub for k-point ik
  • s(ik): same layout for overlap S_sub
  • becp(ik)[ib * nkb * npol + ip]: becp coefficients