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

Classes

struct  RhoG3dCtx
 Context bundling commonly-used data for rho_g3d fill helpers. More...

Functions

std::vector< double > compute_rhoatm (const Atom &atom, int mesh, std::ostream &ofs_warning)
 Compute the radial atomic charge density rhoatm from pseudopotential.
std::vector< double > compute_rho_lgl (const Atom &atom, const ModulePW::PW_Basis *rhopw, const UnitCell &ucell, const std::vector< double > &rhoatm, int test_charge, double omega, std::ostream &ofs_warning)
 Compute the 1D charge in G space from rhoatm.
void fill_rho_g3d_nspin1 (RhoG3dCtx &ctx)
 Fill rho_g3d for nspin==1 case.
void fill_rho_g3d_nspin2 (RhoG3dCtx &ctx, int startmag_type, double start_mag, const Atom &atom)
 Fill rho_g3d for nspin==2 case (both startmag_type 1 and 2).
void fill_rho_g3d_nspin4_type1 (RhoG3dCtx &ctx, double start_mag, const Atom &atom, bool domag, bool domag_z)
 Fill rho_g3d for nspin==4, startmag_type==1 case.
void fill_rho_g3d_nspin4_type2 (RhoG3dCtx &ctx, const Atom &atom, bool domag, bool domag_z)
 Fill rho_g3d for nspin==4, startmag_type==2 case.
void normalize_and_check (double **rho_in, const ModuleBase::ComplexMatrix &rho_g3d, const ModulePW::PW_Basis *rhopw, int spin_number_need, double omega, std::ostream &ofs_warning, double nelec)
double inner_product_recip_rho (const std::complex< double > *rho1, const std::complex< double > *rho2, const ModulePW::PW_Basis &rhopw, const MixingConfig &cfg, const double omega, const double tpiba)
 Coulomb-metric reciprocal inner product of the charge residual.
template<typename T>
std::function< void(T *, const T *, const T *)> make_twobeta_mix (const int total, const int nunit, const double mixing_beta, const double mixing_beta_mag)
 Create a two-beta mixing functor: mix the first nunit elements with mixing_beta and the rest (nunit..total) with mixing_beta_mag. Used for magnetic cases (nspin==2/4) where the charge channel and the magnetism channels use different betas.
template<typename T>
void pack_rho_mag (T *out, const T *d0, const T *d1, const int n)
 Pack charge and magnetism into interleaved layout: out[0..n] = d0 + d1 (charge channel) out[n..2n] = d0 - d1 (magnetism channel).
template<typename T>
void unpack_rho_mag (T *d0, T *d1, const T *in, const int n)
 Unpack interleaved layout back to charge and magnetism components: d0[i] = 0.5 * (in[i] + in[i+n]) d1[i] = 0.5 * (in[i] - in[i+n]).
void psymmg (std::complex< double > *rhog_part, const ModulePW::PW_Basis *rho_basis, ModuleSymmetry::Symmetry &symm)
 Symmetrize one reciprocal-space density component.
void psymmg_soc (std::complex< double > *rhog_x, std::complex< double > *rhog_y, std::complex< double > *rhog_z, const ModulePW::PW_Basis *rho_basis, ModuleSymmetry::Symmetry &symm)
 Symmetrize the three coupled reciprocal-space spin components for nspin=4.
void mix_tau_recip (Charge *chr, const int nspin, const bool double_grid, ModulePW::PW_Basis *rhopw, ModulePW::PW_Basis *rhodpw, Base_Mixing::Mixing *mixing, Base_Mixing::Mixing_Data &tau_mdata, Base_Mixing::Plain_Mixing *mixing_highf)
 Mix kinetic energy density in reciprocal space. Handles the double-grid split/merge for the smooth and high-frequency parts, DIIS mixing of the smooth part, and plain mixing of the high-frequency part.

Function Documentation

◆ compute_rho_lgl()

std::vector< double > module_charge::detail::compute_rho_lgl ( const Atom & atom,
const ModulePW::PW_Basis * rhopw,
const UnitCell & ucell,
const std::vector< double > & rhoatm,
int test_charge,
double omega,
std::ostream & ofs_warning )

Compute the 1D charge in G space from rhoatm.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_rhoatm()

std::vector< double > module_charge::detail::compute_rhoatm ( const Atom & atom,
int mesh,
std::ostream & ofs_warning )

Compute the radial atomic charge density rhoatm from pseudopotential.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_rho_g3d_nspin1()

void module_charge::detail::fill_rho_g3d_nspin1 ( RhoG3dCtx & ctx)

Fill rho_g3d for nspin==1 case.

Here is the caller graph for this function:

◆ fill_rho_g3d_nspin2()

void module_charge::detail::fill_rho_g3d_nspin2 ( RhoG3dCtx & ctx,
int startmag_type,
double start_mag,
const Atom & atom )

Fill rho_g3d for nspin==2 case (both startmag_type 1 and 2).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_rho_g3d_nspin4_type1()

void module_charge::detail::fill_rho_g3d_nspin4_type1 ( RhoG3dCtx & ctx,
double start_mag,
const Atom & atom,
bool domag,
bool domag_z )

Fill rho_g3d for nspin==4, startmag_type==1 case.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_rho_g3d_nspin4_type2()

void module_charge::detail::fill_rho_g3d_nspin4_type2 ( RhoG3dCtx & ctx,
const Atom & atom,
bool domag,
bool domag_z )

Fill rho_g3d for nspin==4, startmag_type==2 case.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_recip_rho()

double module_charge::detail::inner_product_recip_rho ( const std::complex< double > * rho1,
const std::complex< double > * rho2,
const ModulePW::PW_Basis & rhopw,
const MixingConfig & cfg,
const double omega,
const double tpiba )

Coulomb-metric reciprocal inner product of the charge residual.

Parameters
rho1first reciprocal-space vector
rho2second reciprocal-space vector
rhopwplane-wave basis supplying npw/gg and the G=0 index
cfgmixing config (spin channels, gamma-only and magnetism flags)
omegacell volume
tpiba2*pi/lattice constant
Returns
pooled Coulomb-metric inner product
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_twobeta_mix()

template<typename T>
std::function< void(T *, const T *, const T *)> module_charge::detail::make_twobeta_mix ( const int total,
const int nunit,
const double mixing_beta,
const double mixing_beta_mag )

Create a two-beta mixing functor: mix the first nunit elements with mixing_beta and the rest (nunit..total) with mixing_beta_mag. Used for magnetic cases (nspin==2/4) where the charge channel and the magnetism channels use different betas.

Template Parameters
Telement type, double (real space) or std::complex<double> (reciprocal)
Parameters
totaltotal number of elements
nunitnumber of elements in the charge channel
mixing_betabeta for the charge channel
mixing_beta_magbeta for the magnetism channel
Returns
mixing functor
Here is the caller graph for this function:

◆ mix_tau_recip()

void module_charge::detail::mix_tau_recip ( Charge * chr,
const int nspin,
const bool double_grid,
ModulePW::PW_Basis * rhopw,
ModulePW::PW_Basis * rhodpw,
Base_Mixing::Mixing * mixing,
Base_Mixing::Mixing_Data & tau_mdata,
Base_Mixing::Plain_Mixing * mixing_highf )

Mix kinetic energy density in reciprocal space. Handles the double-grid split/merge for the smooth and high-frequency parts, DIIS mixing of the smooth part, and plain mixing of the high-frequency part.

Parameters
chrpointer to Charge object (must have kin_r/kin_r_save)
nspinnumber of spins
double_gridwhether double grid is used
rhopwsmooth grid
rhodpwdense grid (same as rhopw when double_grid is off)
mixingDIIS mixing object
tau_mdatamixing data for tau
mixing_highfplain mixing for high-frequency part (may be null when double_grid is off)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize_and_check()

void module_charge::detail::normalize_and_check ( double ** rho_in,
const ModuleBase::ComplexMatrix & rho_g3d,
const ModulePW::PW_Basis * rhopw,
int spin_number_need,
double omega,
std::ostream & ofs_warning,
double nelec )

FFT rho_g3d to real space, check for negative/imaginary charge, and normalize to target electron number.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pack_rho_mag()

template<typename T>
void module_charge::detail::pack_rho_mag ( T * out,
const T * d0,
const T * d1,
const int n )

Pack charge and magnetism into interleaved layout: out[0..n] = d0 + d1 (charge channel) out[n..2n] = d0 - d1 (magnetism channel).

Template Parameters
Tdouble (real space) or std::complex<double> (reciprocal)
Parameters
outoutput buffer, size >= 2*n
d0first component (e.g. chr->rho[0] or chr->rhog[0])
d1second component
nnumber of elements per component
Here is the call graph for this function:
Here is the caller graph for this function:

◆ psymmg()

void module_charge::detail::psymmg ( std::complex< double > * rhog_part,
const ModulePW::PW_Basis * rho_basis,
ModuleSymmetry::Symmetry & symm )

Symmetrize one reciprocal-space density component.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ psymmg_soc()

void module_charge::detail::psymmg_soc ( std::complex< double > * rhog_x,
std::complex< double > * rhog_y,
std::complex< double > * rhog_z,
const ModulePW::PW_Basis * rho_basis,
ModuleSymmetry::Symmetry & symm )

Symmetrize the three coupled reciprocal-space spin components for nspin=4.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack_rho_mag()

template<typename T>
void module_charge::detail::unpack_rho_mag ( T * d0,
T * d1,
const T * in,
const int n )

Unpack interleaved layout back to charge and magnetism components: d0[i] = 0.5 * (in[i] + in[i+n]) d1[i] = 0.5 * (in[i] - in[i+n]).

Template Parameters
Tdouble (real space) or std::complex<double> (reciprocal)
Parameters
d0output first component (e.g. chr->rho[0] or chr->rhog[0])
d1output second component
ininput buffer, size >= 2*n
nnumber of elements per component
Here is the call graph for this function:
Here is the caller graph for this function: