ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModuleDFPT::DFPT_Rho Class Reference

First-order density response (C3). More...

#include <dfpt_rho.h>

Collaboration diagram for ModuleDFPT::DFPT_Rho:

Classes

struct  Config
 aggregate config for init (no defaults: every field must be set) More...

Public Member Functions

 DFPT_Rho ()
 ~DFPT_Rho ()
void init (const Config &cfg)
void compute_drho (const psi::Psi< std::complex< double > > &psi, const ModuleBase::matrix &wg, int q_idx, DFPT_PW_Data &data)
void compute_drhoc (const UnitCell &ucell, int iat, int dir, int q_idx, DFPT_PW_Data &data)
void compute_drhoc_g (const UnitCell &ucell, int iat, int dir, const ModuleBase::Vector3< double > &q_cart, std::vector< std::complex< double > > &drhoc_g) const
void cal_docc (const psi::Psi< std::complex< double > > &psi, const ModuleBase::matrix &wg, int q_idx, DFPT_PW_Data &data)
 first-order occupation matrix (docc) for DFT+U (U0 reservation).
void mix_drho (int q_idx, DFPT_PW_Data &data)
void reset_mixing (int q_idx)
void v_hartree_q (const ModuleBase::Vector3< double > &q_cart, const std::vector< std::complex< double > > &drho_g, std::vector< std::complex< double > > &dv_ha_g) const
double get_residual (int q_idx, DFPT_PW_Data &data) const

Private Member Functions

void add_band_ (int ik, int ib, double w, const std::complex< double > *c_ptr, const std::vector< std::complex< double > > &dpsi, const DFPT_KQ_Basis &kq, std::vector< std::complex< double > > &a_r)
 accumulate one (ik, ib) band contribution to the real-space amplitude
void make_drho_r_ (const std::vector< std::complex< double > > &drho_g, const ModuleBase::Vector3< double > &q_frac, std::vector< double > &drho_r) const
 rebuild the real-space manifest drho_r from G-space coefficients
void zero_neg_q_ (const ModuleBase::Vector3< double > &q_cart, std::vector< std::complex< double > > &drho_g) const
 charge conservation: zero the Delta = -q harmonic when -q is a G vector

Static Private Member Functions

static bool is_gamma_q_ (const ModuleBase::Vector3< double > &q)
 true if q is Gamma within 1e-10

Private Attributes

int nspin_ = 1
int nrxx_ = 0
ModulePW::PW_Basis * pw_rho_ = nullptr
ModulePW::PW_Basis_K * pw_wfc_ = nullptr
 reciprocal lattice matrix in 1/lat0 (UnitCell::G convention)
ModuleBase::Matrix3 recip_matrix_
double mix_beta_ = 0.7
 mixing algorithm: rho_plain | rho_kerker | rho_broyden (v_sc_* at solver)
std::string mix_type_
 Kerker screening parameter a^2 in 1/lat0^2 (same units as |G+q|^2).
double kerker_a2_ = 0.0
std::unique_ptr< Base_Mixing::Plain_Mixing > mixer_
std::unique_ptr< Base_Mixing::Broyden_Mixing > broyden_mixer_
 Broyden mixing data (per q, reset by reset_mixing).
std::vector< std::unique_ptr< Base_Mixing::Mixing_Data > > broyden_mdata_
std::vector< std::vector< std::vector< std::complex< double > > > > drho_in_
 mixing state, q-shifted coefficients on the rho grid, [q][spin]
std::vector< std::vector< std::vector< std::complex< double > > > > drho_out_
std::vector< double > residual_

Detailed Description

First-order density response (C3).

compute_drho builds the q-shifted response density drho(r) = 2 Re[ e^{i q r} A(r) ], A(r) = sum_{k,n occ} wg(k,n) u*_nk(r) du_nk(r), where u/du are the periodic parts of psi_nk (k basis) and dpsi_nk (k+q basis); PW_Basis_K / PW_Basis transforms are phase-free (they return the periodic part), so the Bloch phases combine into the single e^{i q r} factor. In reciprocal space drho_g holds the q-shifted coefficients drho_Delta (coefficient of e^{i (Delta+q) r}, indexed by the rho-grid ig), A_Delta = sum_{kn} wg sum_G c*_G(k,n) d_{G+Delta}(k,n); the Delta = -q harmonic is dropped when -q falls on a reciprocal-lattice vector (charge conservation, notably at q = Gamma).

mix_drho mixes the q-shifted coefficients: drho_in <- drho_in + beta_g (drho_out - drho_in) through Base_Mixing::Plain_Mixing (no Charge_Mixing / Charge dependency). With mix_type = "rho_plain" beta_g = beta on every shell; with mix_type = "rho_kerker" beta_g = beta * f_g, the Kerker screen f_g = |G+q|^2 / (|G+q|^2 + a^2), evaluated with the same q_shifted |G+q| = |gcar + q_cart * recip| (in 1/lat0^2 units) convention as v_hartree_q, so the Coulomb-stiffness eigenvalues concentrated on the smallest shells (lambda ~ -2.2 on {111}/{200} for the diamond smoke case, where plain mixing needs beta < 2 / (1 + |lambda|)) become stabilizable at beta up to 1. The screen is applied to both drho_in and drho_out before the plain mix and the screened-out part is added back, i.e. the stored mixed density is rin + beta_g (out - in) (physical, not screen-scaled); the |G+q| = 0 harmonic (f = 0) is frozen, consistent with its drop in compute_drho.

Constructor & Destructor Documentation

◆ DFPT_Rho()

ModuleDFPT::DFPT_Rho::DFPT_Rho ( )

◆ ~DFPT_Rho()

ModuleDFPT::DFPT_Rho::~DFPT_Rho ( )
default

Member Function Documentation

◆ add_band_()

void ModuleDFPT::DFPT_Rho::add_band_ ( int ik,
int ib,
double w,
const std::complex< double > * c_ptr,
const std::vector< std::complex< double > > & dpsi,
const DFPT_KQ_Basis & kq,
std::vector< std::complex< double > > & a_r )
private

accumulate one (ik, ib) band contribution to the real-space amplitude

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

◆ cal_docc()

void ModuleDFPT::DFPT_Rho::cal_docc ( const psi::Psi< std::complex< double > > & psi,
const ModuleBase::matrix & wg,
int q_idx,
DFPT_PW_Data & data )

first-order occupation matrix (docc) for DFT+U (U0 reservation).

Here is the call graph for this function:

◆ compute_drho()

void ModuleDFPT::DFPT_Rho::compute_drho ( const psi::Psi< std::complex< double > > & psi,
const ModuleBase::matrix & wg,
int q_idx,
DFPT_PW_Data & data )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_drhoc()

void ModuleDFPT::DFPT_Rho::compute_drhoc ( const UnitCell & ucell,
int iat,
int dir,
int q_idx,
DFPT_PW_Data & data )

q-shifted first-order core-density amplitude for an nlcc pseudopotential atom displaced along (iat, dir), in G space: d rho_core/d tau_dir (G+q) = -i tpiba (G+q)_dir

  • rho_core~(|G+q|) * exp(i (G+q) tau_iat) where rho_core~ is the radial spherical-Bessel FT of the core charge (the same non_linear_core_correction used by the ground state). Non-nlcc atoms / types give zero. The result enters the XC channel of assemble_v_sc only (the core Coulomb is already in the ionic pseudopotential, so no Hartree contribution). ucell is passed explicitly (DFPT_Rho does not own it).
Here is the call graph for this function:

◆ compute_drhoc_g()

void ModuleDFPT::DFPT_Rho::compute_drhoc_g ( const UnitCell & ucell,
int iat,
int dir,
const ModuleBase::Vector3< double > & q_cart,
std::vector< std::complex< double > > & drhoc_g ) const

same first-order core-density amplitude as compute_drhoc, but pure: takes the cartesian q explicitly and writes into a caller-owned vector instead of the DFPT_PW_Data slot. Used by the 2n+1 nlcc direct terms, which need the core response of EVERY displacement while the data slot holds only the current one.

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

◆ get_residual()

double ModuleDFPT::DFPT_Rho::get_residual ( int q_idx,
DFPT_PW_Data & data ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void ModuleDFPT::DFPT_Rho::init ( const Config & cfg)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_gamma_q_()

bool ModuleDFPT::DFPT_Rho::is_gamma_q_ ( const ModuleBase::Vector3< double > & q)
staticprivate

true if q is Gamma within 1e-10

< empirical parameter: fractional-q tolerance for the Gamma test

Here is the caller graph for this function:

◆ make_drho_r_()

void ModuleDFPT::DFPT_Rho::make_drho_r_ ( const std::vector< std::complex< double > > & drho_g,
const ModuleBase::Vector3< double > & q_frac,
std::vector< double > & drho_r ) const
private

rebuild the real-space manifest drho_r from G-space coefficients

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

◆ mix_drho()

void ModuleDFPT::DFPT_Rho::mix_drho ( int q_idx,
DFPT_PW_Data & data )

< empirical parameter: |G+q|^2 zero-shell guard (1/lat0^2, Kerker freeze)

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

◆ reset_mixing()

void ModuleDFPT::DFPT_Rho::reset_mixing ( int q_idx)

C7: drop the mixing state of q_idx so the next perturbation at the same q restarts from a zero input density (the drho_in slot is indexed by q only, while every (atom, direction) needs its own self-consistent cycle).

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

◆ v_hartree_q()

void ModuleDFPT::DFPT_Rho::v_hartree_q ( const ModuleBase::Vector3< double > & q_cart,
const std::vector< std::complex< double > > & drho_g,
std::vector< std::complex< double > > & dv_ha_g ) const

C6: q-shifted first-order Hartree potential in reciprocal space, dV_H(G) = 4 pi e^2 / |G+q|^2 * drho_g, with the convention aligned with elecstate::H_Hartree_pw::v_hartree (fac = e2 * FOUR_PI / (tpiba2 * |G+q|^2)); the |G+q| = 0 component (ig = -q) is skipped. Serves both the C6 q->0 response and the C7 screened potential at every q point.

< empirical parameter: |G+q|^2 zero-shell guard (1/lat0^2, Coulomb skip)

Here is the call graph for this function:

◆ zero_neg_q_()

void ModuleDFPT::DFPT_Rho::zero_neg_q_ ( const ModuleBase::Vector3< double > & q_cart,
std::vector< std::complex< double > > & drho_g ) const
private

charge conservation: zero the Delta = -q harmonic when -q is a G vector

< empirical parameter: folded -q reciprocal-vector match tolerance

Here is the caller graph for this function:

Member Data Documentation

◆ broyden_mdata_

std::vector<std::unique_ptr<Base_Mixing::Mixing_Data> > ModuleDFPT::DFPT_Rho::broyden_mdata_
private

◆ broyden_mixer_

std::unique_ptr<Base_Mixing::Broyden_Mixing> ModuleDFPT::DFPT_Rho::broyden_mixer_
private

Broyden mixing data (per q, reset by reset_mixing).

◆ drho_in_

std::vector<std::vector<std::vector<std::complex<double> > > > ModuleDFPT::DFPT_Rho::drho_in_
private

mixing state, q-shifted coefficients on the rho grid, [q][spin]

◆ drho_out_

std::vector<std::vector<std::vector<std::complex<double> > > > ModuleDFPT::DFPT_Rho::drho_out_
private

◆ kerker_a2_

double ModuleDFPT::DFPT_Rho::kerker_a2_ = 0.0
private

◆ mix_beta_

double ModuleDFPT::DFPT_Rho::mix_beta_ = 0.7
private

mixing algorithm: rho_plain | rho_kerker | rho_broyden (v_sc_* at solver)

◆ mix_type_

std::string ModuleDFPT::DFPT_Rho::mix_type_
private

Kerker screening parameter a^2 in 1/lat0^2 (same units as |G+q|^2).

◆ mixer_

std::unique_ptr<Base_Mixing::Plain_Mixing> ModuleDFPT::DFPT_Rho::mixer_
private

Broyden mixer for the broyden mix_type (separate from the plain mixer because their interfaces differ: Broyden needs push_data + cal_coef before each mix, with internal history state)

◆ nrxx_

int ModuleDFPT::DFPT_Rho::nrxx_ = 0
private

◆ nspin_

int ModuleDFPT::DFPT_Rho::nspin_ = 1
private

◆ pw_rho_

ModulePW::PW_Basis* ModuleDFPT::DFPT_Rho::pw_rho_ = nullptr
private

◆ pw_wfc_

ModulePW::PW_Basis_K* ModuleDFPT::DFPT_Rho::pw_wfc_ = nullptr
private

reciprocal lattice matrix in 1/lat0 (UnitCell::G convention)

◆ recip_matrix_

ModuleBase::Matrix3 ModuleDFPT::DFPT_Rho::recip_matrix_
private

◆ residual_

std::vector<double> ModuleDFPT::DFPT_Rho::residual_
private

The documentation for this class was generated from the following files: