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

Charge-density symmetrization free functions. More...

Namespaces

namespace  detail

Classes

struct  AtomicRhoCfg
 Configuration for atomic_rho, replacing GlobalV/PARAM reads. More...
class  Charge_Extra
 charge extrapolation method More...
struct  InitRhoCfg
struct  ScfMixingCtx
 Aggregated SCF convergence thresholds and status flags for chgmixing_ks. More...
struct  NlcCtx
 Radial grid and density data for non-linear core correction. More...

Functions

void atomic_rho (const int spin_number_need, const double &omega, double **rho_in, const ModuleBase::ComplexMatrix &strucFac, const UnitCell &ucell, const ModulePW::PW_Basis *rhopw, const AtomicRhoCfg &cfg)
void init_mixing_dmr (Base_Mixing::Mixing *mixing, Base_Mixing::Mixing_Data &mdata, const int nnr, const MixingConfig &cfg)
 Allocate the mixing buffer for the real-space density matrix and clear its history.
void mix_dmr (const std::vector< double * > &dmr_out, const std::vector< const double * > &dmr_in, const int nnr, Base_Mixing::Mixing *mixing, Base_Mixing::Mixing_Data &mdata, const MixingConfig &cfg)
 Mix the real-space density matrix (LCAO calculations only).
double cal_drho (Charge *chr, const double nelec, const ModulePW::PW_Basis &rhopw, const MixingConfig &cfg, const double omega, const double tpiba)
 Charge residual between chr->rho and chr->rho_save, normalized per electron.
double cal_dkin (Charge *chr, const double nelec, const ModulePW::PW_Basis &rhopw, const MixingConfig &cfg, const double omega)
 Kinetic-energy-density residual between chr->kin_r and chr->kin_r_save.
double inner_product_real (const double *rho1, const double *rho2, const ModulePW::PW_Basis &rhopw, const MixingConfig &cfg)
 Inner product of two real-space vectors used in real-space mixing.
double inner_product_recip_hartree (const std::complex< double > *rhog1, const std::complex< double > *rhog2, const ModulePW::PW_Basis &rhopw, const MixingConfig &cfg, const double omega, const double tpiba)
 Hartree-like reciprocal inner product used in charge mixing.
void init_rho (Charge &chr, const ModulePW::PW_Basis &rhopw, const UnitCell &ucell, const Parallel_Grid &pgrid, const ModuleBase::ComplexMatrix &strucFac, ModuleSymmetry::Symmetry &symm, const void *klist, const void *wfcpw, const InitRhoCfg &cfg)
 Initialize charge density from file, atomic superposition, restart cache, or wavefunctions, depending on cfg.init_chg.
void reduce_diff_pools (double *array_rho, const Charge &chr, const int kpar, const bool all_ks_run, const int bndpar)
 Reduce a real-space array across k-point pools and band groups.
void rho_mpi (Charge &chr, const int kpar, const bool all_ks_run, const int bndpar, const int nspin)
 Reduce rho across pools; also reduce kin_r when its buffer is allocated (meta-GGA functionals, or ELF output requested).
void kin_r_mpi (Charge &chr, const int kpar, const bool all_ks_run, const int bndpar, const int nspin)
 Reduce kin_r across pools when its buffer is allocated (meta-GGA functionals, or ELF output requested).
void kerker_screen_recip (const MixingConfig &cfg, ModulePW::PW_Basis *rhopw, double tpiba, std::complex< double > *drhog)
 Apply Kerker screening in reciprocal space.
void kerker_screen_real (const MixingConfig &cfg, ModulePW::PW_Basis *rhopw, double tpiba, double *drhor)
 Apply Kerker screening in real space via FFT.
void write_density_restart (Charge &charge, ModulePW::PW_Basis &pw_rhod, const ModuleBase::Matrix3 &reciprocal_lattice, const std::string &prefix, const int nspin, const bool enabled, const bool gamma_only, const bool write_tau, const bool writer_pool, const Parallel::ParaWorld &pw_world, std::ostream *warning)
 Write saved charge and optional kinetic-energy densities in reciprocal space.
bool read_rhog (const std::string &filename, const ModulePW::PW_Basis *pw_rhod, const int nspin, std::complex< double > **rhog, const Parallel::ParaWorld &pw_world, std::ostream *os_warning)
bool has_complete_charge_cubes (const std::string &directory, const int nspin, const Parallel::ParaWorld &world)
 Collectively select the complete cube set; partial sets fall back to restart.
bool read_rho_from_binary (const std::string &filename, const ModulePW::PW_Basis &rhopw, const int nspin, std::complex< double > **rhog, double **rho, const Parallel::ParaWorld &pw_world, std::ostream &log)
bool write_rhog (const std::string &fchg, const bool gamma_only, const ModulePW::PW_Basis *pw_rho, const int nspin, const ModuleBase::Matrix3 &GT, std::complex< double > **rhog, const Parallel::ParaWorld &pw_world, std::ostream *os_warning)
bool update_pot_model (const int iter, const double drho, const K_Vectors &kv, elecstate::Potential &pot, Charge_Mixing *p_chgmix)
void print_corr_iter (const K_Vectors &kv, const int sccs_debug, const double drho, const elecstate::Potential &pot)
void chgmixing_ks (const int iter, UnitCell &ucell, elecstate::ElecState *pelec, Charge &chr, const ModulePW::PW_Basis &rhopw, Charge_Mixing *p_chgmix, ScfMixingCtx &ctx, const Input_para &inp)
void chgmixing_ks_pw (const int iter, const int iter_limit, Charge_Mixing *p_chgmix, Plus_U_Base &dftu, const bool mag_converged, const Input_para &inp)
void chgmixing_ks_lcao (const int iter, const int iter_limit, Charge_Mixing *p_chgmix, Plus_U_Base &dftu, const int nnr, const Input_para &inp)
void symmetrize_rho (const int nspin, const Charge &chr, const ModulePW::PW_Basis *pw, ModuleSymmetry::Symmetry &symm)
 Symmetrize charge density for all spin channels.
void cal_rhog_symm (const int &spin_now, const Charge &CHR, const ModulePW::PW_Basis *pw, ModuleSymmetry::Symmetry &symm)
 Symmetrize one spin channel of the charge density.
void cal_rhog_symm (const int &spin_now, double **rho, std::complex< double > **rhog, int ngmc, double **kin_r, const ModulePW::PW_Basis *pw, ModuleSymmetry::Symmetry &symm)
 Symmetrize one spin channel of raw density arrays.
void cal_rhog_symm_soc (double **rho, std::complex< double > **rhog, const ModulePW::PW_Basis *pw, ModuleSymmetry::Symmetry &symm)
 Symmetrize raw nspin=4 spin-density arrays with coupled spin rotations.
double sum_rho (double *const *rho, const int nspin0, const int nrxx, const double omega, const int nxyz)
double cal_rho2ne (const double *rho_in, const int nrxx, const double omega, const int nxyz)
void check_rho (double *const *rho, const int nspin, const int nrxx, const double omega, const int nxyz, const double nelec)
void non_linear_core_correction (const NlcCtx &ctx, double *rhocg)
void set_rho_core (const UnitCell &ucell, const ModuleBase::ComplexMatrix &structure_factor, const bool *numeric, double *rho_core, std::complex< double > *rhog_core, const ModulePW::PW_Basis &rhopw)
double core_charge_form_factor (int mesh, const double *r, const double *rab, const double *rho_atc, double omega, double k, std::vector< double > &scratch)
void set_drho_core (const UnitCell &ucell, int iat, int dir, const ModuleBase::Vector3< double > &q_cart, const ModulePW::PW_Basis &rhopw, std::vector< std::complex< double > > &drhoc_g)
void split_dgrid (const std::complex< double > *data_d, std::vector< std::complex< double > > &data_s, std::vector< std::complex< double > > &data_hf, int nspin, int npw_smooth, int npw_dense)
 Split dense reciprocal-space data into smooth and high-frequency parts on the USPP double grid.
void merge_dgrid (std::complex< double > *data_d, const std::vector< std::complex< double > > &data_s, const std::vector< std::complex< double > > &data_hf, int nspin, int npw_smooth, int npw_dense)
 Merge smooth and high-frequency parts back into dense reciprocal- space data. Inverse of split_dgrid.

Detailed Description

Charge-density symmetrization free functions.

Internal reciprocal-space helpers for charge-density symmetrization.

I/O free function of rho(G) in binary format Author: YuLiu98, Kirk0830

The designed foramt of the binary file is kept similar to the one in QuantumESPRESSO Modules/io_base.f90, function write_rhog (non-HDF5):

/3/ /gammaonly/ /ngm_g/ /nspin/ /3/ ! bool, int, int. ngm_g is the global, total number of G-vectors /9/ /b11/ /b12/ /b13/ /b21/ /b22/ /b23/ /b31/ /b32/ /b33/ /9/ ! 9 real numbers, the three lattice vectors /ngm_g*3/ /miller(1,1)/ /miller(1,2)/ /miller(1,3)/ /miller(2,1)/ /miller(2,2)/ /miller(2,3)/ ... /miller(ngm_g,1)/ /miller(ngm_g,2)/ /miller(ngm_g,3)/ /ngm_g*3/ ! ngm_g*3 integers, the G-vectors in Miller indices /ngm_g/ /rhog(1)/ /rhog(2)/ /rhog(3)/ ... /ngm_g/ ! ngm_g complex numbers, the rho(G) values !/ngm_g/ ! ngm_g complex numbers, the rho(G) values for the second spin component !/rhog(1)/ /rhog(2)/ /rhog(3)/ ... !/ngm_g/ ! ngm_g complex numbers, the rho(G) values for the second spin component

There are some aspects needed to ensure:

  1. the correspondence between ABACUS PW and QuantumESPRESSO ABACUS PW QuantumESPRESSO bij UnitCell::GT b1, b2, b3 miller index ibox[*] mill rho Charge::rhog rho
  2. the unit of each quantity ABACUS PW QuantumESPRESSO bij a.u. miller index rho

The functions are stateless: every input is passed explicitly. The reciprocal-space helpers shared between translation units live in module_charge::detail (see chg_symm_detail.h).

Not part of the public module_charge API: only chg_symm.cpp and chg_symm_detail.cpp are expected to include this header.

Function Documentation

◆ atomic_rho()

void module_charge::atomic_rho ( const int spin_number_need,
const double & omega,
double ** rho_in,
const ModuleBase::ComplexMatrix & strucFac,
const UnitCell & ucell,
const ModulePW::PW_Basis * rhopw,
const AtomicRhoCfg & cfg )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_dkin()

double module_charge::cal_dkin ( Charge * chr,
const double nelec,
const ModulePW::PW_Basis & rhopw,
const MixingConfig & cfg,
const double omega )

Kinetic-energy-density residual between chr->kin_r and chr->kin_r_save.

Parameters
chrcharge object supplying kin_r/kin_r_save
nelecnumber of electrons, used to normalize the residual
rhopwplane-wave basis supplying the real-space grid size
cfgmixing config (nspin and magnetization flags select the loops)
omegacell volume, used to normalize the residual
Returns
pooled residual value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_drho()

double module_charge::cal_drho ( Charge * chr,
const double nelec,
const ModulePW::PW_Basis & rhopw,
const MixingConfig & cfg,
const double omega,
const double tpiba )

Charge residual between chr->rho and chr->rho_save, normalized per electron.

Parameters
chrcharge object supplying rho/rho_save (and rhog buffers for the reciprocal case)
nelecnumber of electrons, used to normalize the real-space residual
rhopwplane-wave basis supplying the real/reciprocal grid sizes
cfgmixing config (nspin, scf_thr_type and magnetization flags select the loops)
omegacell volume, used to normalize the real-space residual
tpiba2*pi/lattice constant, used by the reciprocal metric
Returns
pooled residual value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_rho2ne()

double module_charge::cal_rho2ne ( const double * rho_in,
const int nrxx,
const double omega,
const int nxyz )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cal_rhog_symm() [1/2]

void module_charge::cal_rhog_symm ( const int & spin_now,
const Charge & CHR,
const ModulePW::PW_Basis * pw,
ModuleSymmetry::Symmetry & symm )

Symmetrize one spin channel of the charge density.

The kinetic-energy density kin_r is symmetrized as well whenever its buffer is allocated (meta-GGA functionals, or ELF output requested).

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

◆ cal_rhog_symm() [2/2]

void module_charge::cal_rhog_symm ( const int & spin_now,
double ** rho,
std::complex< double > ** rhog,
int ngmc,
double ** kin_r,
const ModulePW::PW_Basis * rho_basis,
ModuleSymmetry::Symmetry & symm )

Symmetrize one spin channel of raw density arrays.

Here is the call graph for this function:

◆ cal_rhog_symm_soc()

void module_charge::cal_rhog_symm_soc ( double ** rho,
std::complex< double > ** rhog,
const ModulePW::PW_Basis * pw,
ModuleSymmetry::Symmetry & symm )

Symmetrize raw nspin=4 spin-density arrays with coupled spin rotations.

Parameters
rhoReal-space density components ordered as rho0, mx, my, mz.
rhogReciprocal-space work arrays with the same component ordering.
pwPlane-wave basis used for the Fourier transforms.
symmSymmetry operations and spin rotations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_rho()

void module_charge::check_rho ( double *const * rho,
const int nspin,
const int nrxx,
const double omega,
const int nxyz,
const double nelec )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ chgmixing_ks()

void module_charge::chgmixing_ks ( const int iter,
UnitCell & ucell,
elecstate::ElecState * pelec,
Charge & chr,
const ModulePW::PW_Basis & rhopw,
Charge_Mixing * p_chgmix,
ScfMixingCtx & ctx,
const Input_para & inp )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ chgmixing_ks_lcao()

void module_charge::chgmixing_ks_lcao ( const int iter,
const int iter_limit,
Charge_Mixing * p_chgmix,
Plus_U_Base & dftu,
const int nnr,
const Input_para & inp )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ chgmixing_ks_pw()

void module_charge::chgmixing_ks_pw ( const int iter,
const int iter_limit,
Charge_Mixing * p_chgmix,
Plus_U_Base & dftu,
const bool mag_converged,
const Input_para & inp )
Parameters
mag_convergedwhether DeltaSpin magnetization converged; pass true when sc_mag_switch is off
Here is the call graph for this function:
Here is the caller graph for this function:

◆ core_charge_form_factor()

double module_charge::core_charge_form_factor ( int mesh,
const double * r,
const double * rab,
const double * rho_atc,
double omega,
double k,
std::vector< double > & scratch )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ has_complete_charge_cubes()

bool module_charge::has_complete_charge_cubes ( const std::string & directory,
const int nspin,
const Parallel::ParaWorld & world )

Collectively select the complete cube set; partial sets fall back to restart.

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

◆ init_mixing_dmr()

void module_charge::init_mixing_dmr ( Base_Mixing::Mixing * mixing,
Base_Mixing::Mixing_Data & mdata,
const int nnr,
const MixingConfig & cfg )

Allocate the mixing buffer for the real-space density matrix and clear its history.

The buffer cannot be allocated in Charge_Mixing::set_mixing(): its length nnr (number of non-zero R-matrix elements) is only known after DensityMatrix::init_dmr(), which runs later in beforescf().

Parameters
mixingmixing strategy object, non-null
mdatamixing history buffer for DMR, resized and reset in place
nnrnumber of real-space density-matrix elements per spin, > 0
cfgmixing config (nspin and scf_thr_type select the path)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_rho()

void module_charge::init_rho ( Charge & chr,
const ModulePW::PW_Basis & rhopw,
const UnitCell & ucell,
const Parallel_Grid & pgrid,
const ModuleBase::ComplexMatrix & strucFac,
ModuleSymmetry::Symmetry & symm,
const void * klist,
const void * wfcpw,
const InitRhoCfg & cfg )

Initialize charge density from file, atomic superposition, restart cache, or wavefunctions, depending on cfg.init_chg.

Parameters
chr[inout] Charge object whose rho/rhog/kin_r buffers are filled.
rhopw[in] plane-wave basis bound to chr (grid sizes and FFT backend)
ucell[in] unit cell
pgrid[in] parallel grid descriptor
strucFac[in] structure factor for atomic-charge superposition
symm[in] symmetry operations (used by wfc-based init)
klist[in] k-point list pointer (K_Vectors*), needed only for wfc init
wfcpw[in] PW_Basis_K pointer, needed only for wfc init
cfg[in] INPUT values for charge initialization
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_real()

double module_charge::inner_product_real ( const double * rho1,
const double * rho2,
const ModulePW::PW_Basis & rhopw,
const MixingConfig & cfg )

Inner product of two real-space vectors used in real-space mixing.

Parameters
rho1first real-space vector
rho2second real-space vector
rhopwplane-wave basis supplying the real-space grid size
cfgmixing config (nspin and mixing_angle select the loop bound)
Returns
pooled inner product
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inner_product_recip_hartree()

double module_charge::inner_product_recip_hartree ( const std::complex< double > * rhog1,
const std::complex< double > * rhog2,
const ModulePW::PW_Basis & rhopw,
const MixingConfig & cfg,
const double omega,
const double tpiba )

Hartree-like reciprocal inner product used in charge mixing.

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

◆ kerker_screen_real()

void module_charge::kerker_screen_real ( const MixingConfig & cfg,
ModulePW::PW_Basis * rhopw,
double tpiba,
double * drhor )

Apply Kerker screening in real space via FFT.

Forward-transforms drhor to drhog, applies (1 - filter_g) in reciprocal space, backward-transforms the filtered residual, and subtracts it from drhor in place. Early return if Kerker is disabled.

Parameters
cfgmixing config (spin count, betas, gg0s, angle, gg0_min)
rhopwplane-wave basis supplying npw, nrxx, gg[], real2recip/recip2real
tpiba2*pi/lattice constant used to convert gg0 to atomic units
drhor[in,out]real-space density residual, length nspin*nrxx

consider a resize for mixing_angle

inverse FT

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

◆ kerker_screen_recip()

void module_charge::kerker_screen_recip ( const MixingConfig & cfg,
ModulePW::PW_Basis * rhopw,
double tpiba,
std::complex< double > * drhog )

Apply Kerker screening in reciprocal space.

Multiplies drhog[is*npw + ig] by max(gg/(gg+gg0), gg0_min/amin) per spin channel, where gg0 is derived from cfg.mixing_gg0 (density) or cfg.mixing_gg0_mag (magnetization). Early return if Kerker is disabled.

Parameters
cfgmixing config (spin count, betas, gg0s, angle, gg0_min)
rhopwplane-wave basis supplying npw and gg[]
tpiba2*pi/lattice constant used to convert gg0 to atomic units
drhog[in,out]reciprocal-space density residual, length nspin*npw

consider a resize for mixing_angle

implement Kerker for density and magnetization separately

new mixing method only support nspin=2 not nspin=4

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

◆ kin_r_mpi()

void module_charge::kin_r_mpi ( Charge & chr,
const int kpar,
const bool all_ks_run,
const int bndpar,
const int nspin )

Reduce kin_r across pools when its buffer is allocated (meta-GGA functionals, or ELF output requested).

Parameters
chrcharge object supplying kin_r buffers
kparnumber of k-point pools (GlobalV::KPAR)
all_ks_runwhether all processes run KS calculations (PARAM.globalv.all_ks_run)
bndparnumber of band groups (PARAM.inp.bndpar)
nspinnumber of spin channels (PARAM.inp.nspin)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ merge_dgrid()

void module_charge::merge_dgrid ( std::complex< double > * data_d,
const std::vector< std::complex< double > > & data_s,
const std::vector< std::complex< double > > & data_hf,
int nspin,
int npw_smooth,
int npw_dense )

Merge smooth and high-frequency parts back into dense reciprocal- space data. Inverse of split_dgrid.

Vectors are not cleared; the caller may reuse them or let them go out of scope. The output data_d must be pre-allocated by the caller with size nspin * npw_dense.

Parameters
data_ddense output, shape [nspin * npw_dense], non-null
data_ssmooth input, sized to nspin * npw_smooth
data_hfhigh-frequency input, sized to nspin * (npw_dense - npw_smooth)
nspinnumber of spin channels, >= 1
npw_smoothsmooth grid npw, >= 0
npw_densedense grid npw, >= npw_smooth
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mix_dmr()

void module_charge::mix_dmr ( const std::vector< double * > & dmr_out,
const std::vector< const double * > & dmr_in,
const int nnr,
Base_Mixing::Mixing * mixing,
Base_Mixing::Mixing_Data & mdata,
const MixingConfig & cfg )

Mix the real-space density matrix (LCAO calculations only).

For nspin == 1/4 the single spin channel is mixed directly; for nspin == 2 the up/down channels are transformed into charge/magnetization channels, mixed with independent betas, and transformed back.

Parameters
dmr_outwritable DMR buffers, one per spin channel, each of length nnr; mixed results are written back through these pointers
dmr_inDMR buffers saved at the previous mixing step, one per spin channel, each of length nnr (read-only)
nnrnumber of DMR elements per spin channel, > 0
mixingmixing strategy object, non-null
mdataDMR mixing history buffer
cfgmixing config (nspin and the two mixing betas)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ non_linear_core_correction()

void module_charge::non_linear_core_correction ( const NlcCtx & ctx,
double * rhocg )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_corr_iter()

void module_charge::print_corr_iter ( const K_Vectors & kv,
const int sccs_debug,
const double drho,
const elecstate::Potential & pot )

sccs_debug report of the SCCS correction in this SCF iteration, in the running log of the first rank of the first pool.

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

◆ read_rho_from_binary()

bool module_charge::read_rho_from_binary ( const std::string & filename,
const ModulePW::PW_Basis & rhopw,
const int nspin,
std::complex< double > ** rhog,
double ** rho,
const Parallel::ParaWorld & pw_world,
std::ostream & log )

Read binary reciprocal-space density and perform inverse FFT for every spin. Requires the stored spin count to match nspin exactly (no implicit conversion). Reads density only; does not restore calculation or solver state. Returns false for recoverable open/configuration failures, leaving rho unchanged. Malformed or truncated binary input can terminate via Binstream/ WARNING_QUIT.

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

◆ read_rhog()

bool module_charge::read_rhog ( const std::string & filename,
const ModulePW::PW_Basis * pw_rhod,
const int nspin,
std::complex< double > ** rhog,
const Parallel::ParaWorld & pw_world,
std::ostream * os_warning )
Here is the caller graph for this function:

◆ reduce_diff_pools()

void module_charge::reduce_diff_pools ( double * array_rho,
const Charge & chr,
const int kpar,
const bool all_ks_run,
const int bndpar )

Reduce a real-space array across k-point pools and band groups.

Parameters
array_rhoreal-space array [chr.nrxx], reduced in place
chrcharge object supplying the parallel grid and the local grid size
kparnumber of k-point pools (GlobalV::KPAR)
all_ks_runwhether all processes run KS calculations (PARAM.globalv.all_ks_run)
bndparnumber of band groups (PARAM.inp.bndpar)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rho_mpi()

void module_charge::rho_mpi ( Charge & chr,
const int kpar,
const bool all_ks_run,
const int bndpar,
const int nspin )

Reduce rho across pools; also reduce kin_r when its buffer is allocated (meta-GGA functionals, or ELF output requested).

Parameters
chrcharge object supplying rho/kin_r buffers
kparnumber of k-point pools (GlobalV::KPAR)
all_ks_runwhether all processes run KS calculations (PARAM.globalv.all_ks_run)
bndparnumber of band groups (PARAM.inp.bndpar)
nspinnumber of spin channels (PARAM.inp.nspin)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_drho_core()

void module_charge::set_drho_core ( const UnitCell & ucell,
int iat,
int dir,
const ModuleBase::Vector3< double > & q_cart,
const ModulePW::PW_Basis & rhopw,
std::vector< std::complex< double > > & drhoc_g )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_rho_core()

void module_charge::set_rho_core ( const UnitCell & ucell,
const ModuleBase::ComplexMatrix & structure_factor,
const bool * numeric,
double * rho_core,
std::complex< double > * rhog_core,
const ModulePW::PW_Basis & rhopw )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ split_dgrid()

void module_charge::split_dgrid ( const std::complex< double > * data_d,
std::vector< std::complex< double > > & data_s,
std::vector< std::complex< double > > & data_hf,
int nspin,
int npw_smooth,
int npw_dense )

Split dense reciprocal-space data into smooth and high-frequency parts on the USPP double grid.

For each spin channel, the first npw_smooth entries of data_d are copied into data_s and the remaining (npw_dense - npw_smooth) entries are copied into data_hf. No aliasing is performed: both output vectors own their storage and must be pre-sized by the caller.

Parameters
data_ddense input, shape [nspin * npw_dense], non-null
data_ssmooth output, pre-sized to nspin * npw_smooth
data_hfhigh-frequency output, pre-sized to nspin * (npw_dense - npw_smooth); zero-size is allowed when npw_dense == npw_smooth
nspinnumber of spin channels, >= 1
npw_smoothsmooth grid npw, >= 0
npw_densedense grid npw, >= npw_smooth
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sum_rho()

double module_charge::sum_rho ( double *const * rho,
const int nspin0,
const int nrxx,
const double omega,
const int nxyz )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ symmetrize_rho()

void module_charge::symmetrize_rho ( const int nspin,
const Charge & chr,
const ModulePW::PW_Basis * pw,
ModuleSymmetry::Symmetry & symm )

Symmetrize charge density for all spin channels.

This is a helper function that symmetrizes the charge density for all spin channels by calling cal_rhog_symm() for each spin.

Parameters
nspinNumber of spin channels
chrCharge object containing the density
pwPlane wave basis
symmSymmetry object
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_pot_model()

bool module_charge::update_pot_model ( const int iter,
const double drho,
const K_Vectors & kv,
elecstate::Potential & pot,
Charge_Mixing * p_chgmix )

Lets a potential component change its model before mixing (SCCS delayed start); true only in the iteration in which it does, which then restarts the mixing. The first rank of the first pool announces the change on the screen.

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

◆ write_density_restart()

void module_charge::write_density_restart ( Charge & charge,
ModulePW::PW_Basis & pw_rhod,
const ModuleBase::Matrix3 & reciprocal_lattice,
const std::string & prefix,
const int nspin,
const bool enabled,
const bool gamma_only,
const bool write_tau,
const bool writer_pool,
const Parallel::ParaWorld & pw_world,
std::ostream * warning )

Write saved charge and optional kinetic-energy densities in reciprocal space.

All pools participate in their density transforms; only the designated writer pool writes files. The caller selects the output time and supplies saved densities in rho_save and kin_r_save. rhog_save is updated by the transform.

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

◆ write_rhog()

bool module_charge::write_rhog ( const std::string & fchg,
const bool gamma_only,
const ModulePW::PW_Basis * pw_rho,
const int nspin,
const ModuleBase::Matrix3 & GT,
std::complex< double > ** rhog,
const Parallel::ParaWorld & pw_world,
std::ostream * os_warning )
Here is the call graph for this function:
Here is the caller graph for this function: