|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
First-order density response (C3). More...
#include <dfpt_rho.h>
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_ |
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.
| ModuleDFPT::DFPT_Rho::DFPT_Rho | ( | ) |
|
default |
|
private |
accumulate one (ik, ib) band contribution to the real-space amplitude
| 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).
| void ModuleDFPT::DFPT_Rho::compute_drho | ( | const psi::Psi< std::complex< double > > & | psi, |
| const ModuleBase::matrix & | wg, | ||
| int | q_idx, | ||
| DFPT_PW_Data & | data ) |
| 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
| 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.
| double ModuleDFPT::DFPT_Rho::get_residual | ( | int | q_idx, |
| DFPT_PW_Data & | data ) const |
| void ModuleDFPT::DFPT_Rho::init | ( | const Config & | cfg | ) |
|
staticprivate |
true if q is Gamma within 1e-10
< empirical parameter: fractional-q tolerance for the Gamma test
|
private |
rebuild the real-space manifest drho_r from G-space coefficients
| 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)
| 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).
| 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)
|
private |
charge conservation: zero the Delta = -q harmonic when -q is a G vector
< empirical parameter: folded -q reciprocal-vector match tolerance
|
private |
|
private |
Broyden mixing data (per q, reset by reset_mixing).
|
private |
mixing state, q-shifted coefficients on the rho grid, [q][spin]
|
private |
|
private |
|
private |
mixing algorithm: rho_plain | rho_kerker | rho_broyden (v_sc_* at solver)
|
private |
Kerker screening parameter a^2 in 1/lat0^2 (same units as |G+q|^2).
|
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)
|
private |
|
private |
|
private |
|
private |
reciprocal lattice matrix in 1/lat0 (UnitCell::G convention)
|
private |
|
private |