|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Classes | |
| struct | FoldingCtx |
| Shared context for the folding helpers. Bundles the read-only parameters that every folding variant needs (npol, ks_solver, orbital cutoffs, unit cell, parallel-orbitals descriptor, and the grid driver) so the per-call signatures stay small. More... | |
| class | DftuFsEnv |
| Immutable shared environment for the DFT+U force/stress kernels. More... | |
Typedefs | |
| using | NlmTot = std::vector<std::vector<std::unordered_map<int, std::vector<double>>>> |
Functions | |
| std::vector< AdjacentAtomInfo > | build_adjacent_atoms (const UnitCell *ucell, Plus_U_Base *dftu, const Grid_Driver *gridD, const std::vector< double > &orb_cutoff, const double onsite_radius) |
| build the adjacent-atom lists for all Hubbard atoms. | |
| NlmTot | cal_nlm_all (const UnitCell &ucell, const Plus_U_Base &dftu, const TwoCenterIntegrator &intor, const std::vector< AdjacentAtomInfo > &adjs_all, const Parallel_Orbitals &pv) |
| calculate the <phi|alpha^I> overlap values for all Hubbard atoms. | |
| double | calc_energy_u_collinear (const Plus_U_Base &dftu, int T, int iat, int l) |
| Accumulate the DFT+U energy term (0.5 * U * (n - n^2)) for one (T, iat, l) channel in the collinear case (nspin=1 or 2). Returns the per-atom contribution to energy_u. | |
| double | calc_energy_u_noncollinear (const Plus_U_Base &dftu, int T, int iat, int l) |
| Accumulate the DFT+U energy term for one (T, iat, l) channel in the noncollinear case (nspin=4). Returns the per-atom contribution to energy_u. | |
| double | calc_energy_dc_block (const Plus_U_Base &dftu, int T, int iat, int l, int nspin) |
| Accumulate the double-counting correction energy_dc for one (T, iat, l) channel by summing onsite_pot * occ over the (m1, ipol1, m2, ipol2) grid. Dispatches on nspin to choose the spin loop count. Returns the per-atom contribution to energy_dc. | |
| void | cal_energy_correction (Plus_U_Base &dftu, const UnitCell &ucell, int nspin) |
| DFT+U energy correction with the double-counting term subtracted. | |
| bool | is_adjacent_pair (const std::vector< double > &orb_cutoff, const UnitCell &ucell, const Grid_Driver &gd, int T1, int T2, const ModuleBase::Vector3< double > &tau1, const ModuleBase::Vector3< double > &tau2) |
| Judge whether atom pair (T1,I1) and (T2,I2,tau2) are adjacent by direct orbital cutoff overlap or three-body bridging via a common nonlocal projector center T0. | |
| int | get_linear_index (const std::string &ks_solver, int mu, int nu, const Parallel_Orbitals &pv) |
| Get the linear index of local matrix element (mu, nu) based on ks_solver (column-major or row-major). | |
| void | fold_dSR_gamma (const FoldingCtx &ctx, double *dsloc_x, double *dsloc_y, double *dsloc_z, double *dh_r, int dim1, int dim2, double *dSR_gamma) |
| Fold the dSR matrix for gamma-only calculations. npol is the spin-polarization factor; orb_cutoff and ks_solver are forwarded to is_adjacent_pair and get_linear_index. | |
| void | folding_matrix_k (const FoldingCtx &ctx, ForceStressArrays &fsr, int ik, int dim1, int dim2, std::complex< double > *mat_k, const ModuleBase::Vector3< double > &kvec_d) |
| void | folding_matrix_k_new (const std::string &ks_solver, bool gamma_only_local, int nspin, int ik, hamilt::Hamilt< std::complex< double > > *p_ham) |
| new function of folding_S_matrix only for Hamiltonian now, for force and stress will be developed later use HContainer as input and output in mat_k | |
| void | cal_for_IJR_nao_r (const int &iat1, const int &iat2, const Parallel_Orbitals *pv, const std::unordered_map< int, std::vector< double > > &nlm1_all, const std::unordered_map< int, std::vector< double > > &nlm2_all, const std::vector< double > &pot_onsite_in, const hamilt::BaseMatrix< double > **dmR_pointer, const int nspin, double *force1, double *force2) |
| Compute DFT+U force contribution from a single atom pair (I,J,R) in real space. | |
| template<typename T> | |
| void | accumulate_diag_force (const Parallel_Orbitals &pv, const UnitCell &ucell, const T *dm, const int dim, ModuleBase::matrix &force_dftu) |
| Add the real part of diagonal local-block entries to one force component. | |
| template<typename T> | |
| void | accumulate_diag_stress (const Parallel_Orbitals &pv, const T *dm, const int dim1, const int dim2, const double factor, ModuleBase::matrix &stress_dftu) |
| Add the real part of diagonal local-block entries to one stress pair. | |
| void | cal_force_k (const DftuFsEnv &env, const int ik, const ModuleBase::Vector3< double > &kvec_d, const std::complex< double > *rho_pot_onsite, ModuleBase::matrix &force_dftu) |
| void | cal_stress_k (const DftuFsEnv &env, const int ik, const ModuleBase::Vector3< double > &kvec_d, const std::complex< double > *rho_pot_onsite, ModuleBase::matrix &stress_dftu) |
| void | cal_force_gamma (const DftuFsEnv &env, const double *rho_pot_onsite, ModuleBase::matrix &force_dftu) |
| void | cal_stress_gamma (const DftuFsEnv &env, const double *rho_pot_onsite, ModuleBase::matrix &stress_dftu) |
| void | force_stress (const DftuFsEnv &env, const bool cal_force, const bool cal_stress, std::vector< std::vector< double > > *dmk_d, std::vector< std::vector< std::complex< double > > > *dmk_c, ModuleBase::matrix &force_dftu, ModuleBase::matrix &stress_dftu, const K_Vectors &kv, const bool gamma_only_local) |
| Top-level entry: drives force/stress from DFT+U. | |
| void | cal_fs_nao_r_impl (const UnitCell *ucell, Plus_U_Base *dftu, const TwoCenterIntegrator *intor, int nspin, const std::vector< AdjacentAtomInfo > &adjs_all, const std::vector< const hamilt::HContainer< double > * > &dmR, bool cal_force, bool cal_stress, ModuleBase::matrix &force, ModuleBase::matrix &stress) |
| Non-template core of DFT+U force/stress in real space. | |
| void | cal_fs_nao_r (const UnitCell *ucell, Plus_U_Base *dftu, const TwoCenterIntegrator *intor, int nspin, const std::vector< AdjacentAtomInfo > &adjs_all, const std::vector< const hamilt::HContainer< double > * > &dmR, bool cal_force, bool cal_stress, ModuleBase::matrix &force, ModuleBase::matrix &stress) |
| Calculate DFT+U force and stress in real space from explicit environment arguments (non-template overload). | |
| void | reduce_force_impl (ModuleBase::matrix &force, int nspin) |
| Post-process force: MPI Allreduce and spin-degeneracy scaling. | |
| void | reduce_stress_impl (const UnitCell *ucell, const std::vector< double > &stress_tmp, ModuleBase::matrix &stress) |
| Post-process stress: MPI Allreduce and renormalization to full 3x3 tensor from Voigt-like 6-component form. | |
| void | load_occ_from_file (const Plus_U_Base &dftu, const int iat0, const int target_L, const int nspin, const int current_spin, std::vector< double > &occ) |
| load the flattened occupation matrix of one Hubbard atom from pre-read occ_mat data. | |
| template<typename TR> | |
| void | cal_hr_ijr (const int iat1, const int iat2, const int npol, const Parallel_Orbitals &pv, const std::unordered_map< int, std::vector< double > > &nlm1_all, const std::unordered_map< int, std::vector< double > > &nlm2_all, const std::vector< TR > &pot_onsite, TR *data_pointer) |
| accumulate one real-space HR atom-pair block for DFT+U: HR += <psi_I|beta_m> * pot_onsite(m,m') * <beta_m'|psi_{J,R}> | |
| void | cal_occ_ijr (const int iat1, const int iat2, const int npol, const Parallel_Orbitals &pv, const std::unordered_map< int, std::vector< double > > &nlm1_all, const std::unordered_map< int, std::vector< double > > &nlm2_all, const double *dm_pointer, std::vector< double > &occ) |
| accumulate one atom-pair contribution to the DFT+U occupation matrix: occ_mm' += sum_R DMR(I,J,R) * <phi_0|alpha^I_m> * <alpha^J_m'|phi_R> | |
| template<typename Body> | |
| void | for_adj_pair (const UnitCell &ucell, const int iat0, const AdjacentAtomInfo &adjs, const NlmTot &nlm_tot, Body &&body) |
walk all (ad1, ad2) adjacent-atom pairs of one Hubbard atom iat0 and invoke body for each pair that has a matching matrix block. | |
| template<typename TR> | |
| void | accumulate_hr_for_iat0 (const UnitCell &ucell, hamilt::HContainer< TR > *hR, const NlmTot &nlm_tot, const int iat0, const AdjacentAtomInfo &adjs, const Parallel_Orbitals &pv, const std::vector< TR > &pot_onsite) |
| accumulate the real-space HR contributions of one Hubbard atom (iat0) from the precomputed pot_onsite: HR(I,J,R) += <phi_I|chi_m> pot_onsite(m,m') <chi_m'|phi_{J,R}> | |
| void | compute_occ_from_dmr (const UnitCell &ucell, Plus_U_Base &dftu, const int iat0, const int target_L, const int current_spin, const int nspin, const AdjacentAtomInfo &adjs, const Parallel_Orbitals &pv, const NlmTot &nlm_tot, const hamilt::HContainer< double > &dmR_current, std::vector< double > &occ) |
| compute the occupation matrix of one Hubbard atom (iat0) from the real-space density matrix: occ(m,m') = sum_R DMR(I,J,R) * <phi_0|chi_m(I)> * <chi_m'(J)|phi_R> then MPI-Allreduce it and store it into the Plus_U occupation matrix. | |
| void | cal_occ_mat_k (const Parallel_Orbitals *pv, const UnitCell &ucell, const std::vector< std::vector< std::complex< double > > > &dm_k, const K_Vectors &kv, const double &mixing_beta, hamilt::Hamilt< std::complex< double > > *p_ham, const bool gamma_only_local, Plus_U_Base &dftu, const std::string &ks_solver) |
| void | cal_occ_mat_gamma (const Parallel_Orbitals *pv, const UnitCell &ucell, const std::vector< std::vector< double > > &dm_gamma, const double &mixing_beta, hamilt::Hamilt< double > *p_ham, Plus_U_Base &dftu) |
| template<typename T> | |
| void | cal_occ_mat (const Parallel_Orbitals *pv, const UnitCell &ucell, const std::vector< std::vector< T > > &dm, const K_Vectors &kv, const double &mixing_beta, hamilt::Hamilt< T > *p_ham, Plus_U_Base &dftu, const bool gamma_only_local, const int nspin, const std::string &ks_solver) |
| Compute the occupation matrix occ(m,m') = sum_R DMR(I,J,R) * <phi_0|chi_m(I)> * <chi_m'(J)|phi_R> and delegate to the Plus_U member. | |
| void | cal_pot_onsite (const std::vector< double > &occ, const int m_size, const double u_value, double *pot_onsite, double &eu) |
| On-site potential and Hubbard energy for one correlated shell: pot_onsite(m,m') = U_eff * (0.5 * delta_{m,m'} - occ(m,m')) EU = (U_eff / 2) * sum_{m,m'} occ(m,m') * (delta_{m,m'} - occ(m',m)). | |
| template<typename TR> | |
| void | transfer_pot_onsite (const std::vector< double > &pot_onsite_tmp, std::vector< TR > &pot_onsite) |
| transfer pot_onsite format from Pauli matrix storage to the target matrix-element type used by the Hamiltonian. | |
| template<> | |
| void | transfer_pot_onsite< std::complex< double > > (const std::vector< double > &pot_onsite_tmp, std::vector< std::complex< double > > &pot_onsite) |
| double | get_onsite_pot (const Plus_U_Base &dftu, const int T, const int iat, const int L, const int spin, const int m0, const int m1, const bool new_occ_mat) |
| one-body effective onsite potential element for a given (m0,m1) pair. | |
| template<typename T> | |
| void | cal_pot_onsite (const Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, const bool new_occ_mat, T *pot_onsite) |
| Calculate onsite effective potential matrix in the local orbital basis. | |
| template void | cal_pot_onsite< double > (const Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, const bool new_occ_mat, double *pot_onsite) |
| template void | cal_pot_onsite< std::complex< double > > (const Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, const bool new_occ_mat, std::complex< double > *pot_onsite) |
| template<typename T> | |
| void | cal_pot_uterm (Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, T *pot_uterm, const T *sk) |
| Compute the LCAO-basis U-term effective potential matrix. | |
| template void | cal_pot_uterm< double > (Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, double *pot_uterm, const double *sk) |
| template void | cal_pot_uterm< std::complex< double > > (Plus_U_Base &dftu, const UnitCell &ucell, const Parallel_Orbitals *pv, const int spin, std::complex< double > *pot_uterm, const std::complex< double > *sk) |
| void | cal_str_IJR_nao_r (const int &iat1, const int &iat2, const Parallel_Orbitals *pv, const std::unordered_map< int, std::vector< double > > &nlm1_all, const std::unordered_map< int, std::vector< double > > &nlm2_all, const std::vector< double > &pot_onsite_in, const hamilt::BaseMatrix< double > **dmR_pointer, const int nspin, const ModuleBase::Vector3< double > &dis1, const ModuleBase::Vector3< double > &dis2, double *stress) |
| Compute DFT+U stress contribution from a single atom pair (I,J,R) in real space. | |
| TEST (GetLinearIndexTest, RowMajor) | |
| TEST (GetLinearIndexTest, ColumnMajor) | |
| using DFTU_LCAO::NlmTot = std::vector<std::vector<std::unordered_map<int, std::vector<double>>>> |
The <phi|alpha^I> overlap values for all [atoms][neighbors][orb_index(iw) in NAOs][m of target_l in Projectors]
| void DFTU_LCAO::accumulate_diag_force | ( | const Parallel_Orbitals & | pv, |
| const UnitCell & | ucell, | ||
| const T * | dm, | ||
| const int | dim, | ||
| ModuleBase::matrix & | force_dftu ) |
Add the real part of diagonal local-block entries to one force component.
Sums dm(ir, ic) over local block pairs whose global orbital indices coincide, attributing each entry to the atom owning the orbital along Cartesian component dim.
| void DFTU_LCAO::accumulate_diag_stress | ( | const Parallel_Orbitals & | pv, |
| const T * | dm, | ||
| const int | dim1, | ||
| const int | dim2, | ||
| const double | factor, | ||
| ModuleBase::matrix & | stress_dftu ) |
Add the real part of diagonal local-block entries to one stress pair.
| void DFTU_LCAO::accumulate_hr_for_iat0 | ( | const UnitCell & | ucell, |
| hamilt::HContainer< TR > * | hR, | ||
| const NlmTot & | nlm_tot, | ||
| const int | iat0, | ||
| const AdjacentAtomInfo & | adjs, | ||
| const Parallel_Orbitals & | pv, | ||
| const std::vector< TR > & | pot_onsite ) |
accumulate the real-space HR contributions of one Hubbard atom (iat0) from the precomputed pot_onsite: HR(I,J,R) += <phi_I|chi_m> pot_onsite(m,m') <chi_m'|phi_{J,R}>
| TR | real-space Hamiltonian scalar type: double for NSPIN=1,2 and std::complex<double> for NSPIN=4 |
| ucell | [in] unit cell (atom index maps, npol) |
| hR | [in,out] real-space Hamiltonian container; matching atom-pair blocks are updated in place |
| nlm_tot | [in] <phi|alpha^I> overlap table for all atoms |
| iat0 | [in] global atom index of the Hubbard atom |
| adjs | [in] adjacent atom info of the Hubbard atom |
| pv | [in] parallel-orbitals descriptor providing local index maps |
| pot_onsite | [in] onsite potential matrix packed in npol*npol spin blocks |
| std::vector< AdjacentAtomInfo > DFTU_LCAO::build_adjacent_atoms | ( | const UnitCell * | ucell, |
| Plus_U_Base * | dftu, | ||
| const Grid_Driver * | gridD, | ||
| const std::vector< double > & | orb_cutoff, | ||
| const double | onsite_radius ) |
build the adjacent-atom lists for all Hubbard atoms.
For every atom whose type carries a Hubbard-U channel, find its neighbor atoms within orb_cutoff + onsite_radius and filter the AdjacentAtomInfo accordingly.
| ucell | [in] unit cell |
| dftu | [in] DFT+U base object (per-type U channels) |
| gridD | [in] grid driver for neighbor search |
| orb_cutoff | [in] orbital cutoff radius per atom type |
| onsite_radius | [in] onsite projector cutoff radius |
| void DFTU_LCAO::cal_energy_correction | ( | Plus_U_Base & | dftu, |
| const UnitCell & | ucell, | ||
| int | nspin ) |
DFT+U energy correction with the double-counting term subtracted.
DFT+U energy correction with the double-counting term subtracted: E = E_U - E_dc, with E_U = (U_eff / 2) * sum_{m,m'} occ(m,m') * (delta_{m,m'} - occ(m',m)) E_dc = sum_{m,m'} onsite_pot(m,m') * occ(m',m).
Computes energy_u from occ_mat and the onsite potential, then writes the result back to dftu via set_energy. The spin channel count is sourced by the caller from the input parameter to avoid a PARAM read here.
| dftu | Plus_U_Base state (mutable: set_energy is called at the end) |
| ucell | unit cell |
| nspin | number of spin channels (1, 2, or 4); sourced by the caller from the input parameter to avoid a PARAM read here |
| void DFTU_LCAO::cal_for_IJR_nao_r | ( | const int & | iat1, |
| const int & | iat2, | ||
| const Parallel_Orbitals * | pv, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm1_all, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm2_all, | ||
| const std::vector< double > & | pot_onsite_in, | ||
| const hamilt::BaseMatrix< double > ** | dmR_pointer, | ||
| const int | nspin, | ||
| double * | force1, | ||
| double * | force2 ) |
Compute DFT+U force contribution from a single atom pair (I,J,R) in real space.
For a given on-site atom I with correlated orbital l, and a pair of basis atoms (J1, J2) separated by lattice vector R, the force contribution is:
F_{J1} += sum_{m,m'} V_U_{mm'}(I) * <phi_{mu,0}|chi_m(I)>
F_{J2} -= sum_{m,m'} V_U_{mm'}(I) * d<phi_{mu,0}|chi_m(I)>/d tau_{J2}
where mu runs over orbitals on J1, nu over orbitals on J2, and m,m' over the 2l+1 magnetic quantum numbers of the correlated orbital.
The two-center integrals <phi|chi> and their derivatives are pre-computed by TwoCenterIntegrator::snap() and stored in nlm_tot.
| iat1 | [in] global atom index of J1 |
| iat2 | [in] global atom index of J2 |
| pv | [in] Parallel_Orbitals for basis index mapping |
| nlm1_all | [in] pre-computed <phi|chi> and derivatives for atom J1 |
| nlm2_all | [in] pre-computed <phi|chi> and derivatives for atom J2 |
| pot_onsite | [in] flattened V_U matrix: [m1*m_size + m2 + is*m_size2] |
| dmR_pointer | [in] pointer to DMR matrix blocks for each spin |
| nspin | [in] number of spin channels (1, 2, or 4); the spinor polarization count is derived as npol = 2 for nspin=4 (non-collinear) and npol = 1 otherwise |
| force1 | [out] force accumulator for atom J1 (3 components) |
| force2 | [out] force accumulator for atom J2 (3 components) |
| void DFTU_LCAO::cal_force_gamma | ( | const DftuFsEnv & | env, |
| const double * | rho_pot_onsite, | ||
| ModuleBase::matrix & | force_dftu ) |
| void DFTU_LCAO::cal_force_k | ( | const DftuFsEnv & | env, |
| const int | ik, | ||
| const ModuleBase::Vector3< double > & | kvec_d, | ||
| const std::complex< double > * | rho_pot_onsite, | ||
| ModuleBase::matrix & | force_dftu ) |
| void DFTU_LCAO::cal_fs_nao_r | ( | const UnitCell * | ucell, |
| Plus_U_Base * | dftu, | ||
| const TwoCenterIntegrator * | intor, | ||
| int | nspin, | ||
| const std::vector< AdjacentAtomInfo > & | adjs_all, | ||
| const std::vector< const hamilt::HContainer< double > * > & | dmR, | ||
| bool | cal_force, | ||
| bool | cal_stress, | ||
| ModuleBase::matrix & | force, | ||
| ModuleBase::matrix & | stress ) |
Calculate DFT+U force and stress in real space from explicit environment arguments (non-template overload).
This overload does not require a DFTU operator object; it is intended for callers that only need force/stress and already hold the required data.
| ucell | [in] unit cell |
| dftu | [in] DFT+U base object (occupation matrix, U values) |
| intor | [in] two-center integrator for <phi|chi> and gradients |
| nspin | [in] number of spin channels (1, 2, or 4) |
| adjs_all | [in] adjacent atom info for all atoms with plus-U |
| dmR | [in] density matrices in real space, size nspin |
| cal_force | [in] whether to compute force |
| cal_stress | [in] whether to compute stress |
| force | [out] force matrix (nat, 3), accumulated |
| stress | [out] stress matrix (3, 3), accumulated |
| void DFTU_LCAO::cal_fs_nao_r_impl | ( | const UnitCell * | ucell, |
| Plus_U_Base * | dftu, | ||
| const TwoCenterIntegrator * | intor, | ||
| int | nspin, | ||
| const std::vector< AdjacentAtomInfo > & | adjs_all, | ||
| const std::vector< const hamilt::HContainer< double > * > & | dmR, | ||
| bool | cal_force, | ||
| bool | cal_stress, | ||
| ModuleBase::matrix & | force, | ||
| ModuleBase::matrix & | stress ) |
Non-template core of DFT+U force/stress in real space.
All types are concrete and independent of the operator's k-point type (TK) and real-space type (TR). The template wrapper cal_fs_nao_r only validates the density matrix and forwards arguments here.
| ucell | [in] unit cell |
| dftu | [in] DFT+U base object (occupation matrix, U values) |
| intor | [in] two-center integrator for <phi|chi> and gradients |
| nspin | [in] number of spin channels (1, 2, or 4) |
| adjs_all | [in] adjacent atom info for all atoms with plus-U |
| dmR | [in] density matrices in real space, size nspin |
| cal_force | [in] whether to compute force |
| cal_stress | [in] whether to compute stress |
| force | [out] force matrix (nat, 3), accumulated |
| stress | [out] stress matrix (3, 3), accumulated |
| void DFTU_LCAO::cal_hr_ijr | ( | const int | iat1, |
| const int | iat2, | ||
| const int | npol, | ||
| const Parallel_Orbitals & | pv, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm1_all, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm2_all, | ||
| const std::vector< TR > & | pot_onsite, | ||
| TR * | data_pointer ) |
accumulate one real-space HR atom-pair block for DFT+U: HR += <psi_I|beta_m> * pot_onsite(m,m') * <beta_m'|psi_{J,R}>
| TR | real-space Hamiltonian scalar type: double for NSPIN=1,2 and std::complex<double> for NSPIN=4 |
| iat1 | global atom index of the row atom I |
| iat2 | global atom index of the column atom J |
| npol | number of polarizations: 1 for NSPIN=1,2 and 2 for the non-collinear case (NSPIN=4) |
| pv | parallel-orbitals descriptor providing local index maps |
| nlm1_all | <psi_I|beta_m> overlap values keyed by local row index |
| nlm2_all | <beta_m'|psi_J> overlap values keyed by local column index |
| pot_onsite | onsite potential matrix packed in npol*npol spin blocks |
| data_pointer | pointer to the local HR matrix block; updated in place |
| NlmTot DFTU_LCAO::cal_nlm_all | ( | const UnitCell & | ucell, |
| const Plus_U_Base & | dftu, | ||
| const TwoCenterIntegrator & | intor, | ||
| const std::vector< AdjacentAtomInfo > & | adjs_all, | ||
| const Parallel_Orbitals & | pv ) |
calculate the <phi|alpha^I> overlap values for all Hubbard atoms.
The result is indexed by global atom index (empty entries for non-Hubbard atoms) and reused in the HR/occupation accumulation.
| ucell | [in] unit cell |
| dftu | [in] DFT+U base object (per-type U channels) |
| intor | [in] two-center integrator for <phi|chi_m> |
| adjs_all | [in] adjacent atom info for all Hubbard atoms |
| pv | [in] parallel-orbitals descriptor providing local index maps |
|
inline |
accumulate one atom-pair contribution to the DFT+U occupation matrix: occ_mm' += sum_R DMR(I,J,R) * <phi_0|alpha^I_m> * <alpha^J_m'|phi_R>
| iat1 | global atom index of the row atom I |
| iat2 | global atom index of the column atom J |
| npol | number of polarizations: 1 for NSPIN=1,2 and 2 for the non-collinear case (NSPIN=4) |
| pv | parallel-orbitals descriptor providing local index maps |
| nlm1_all | <phi_0|alpha^I_m> overlap values keyed by local row index |
| nlm2_all | <alpha^J_m'|phi_R> overlap values keyed by local column index |
| dm_pointer | pointer to the local real-space DMR block of (I,J,R) |
| occ | occupation matrix packed in npol*npol spin blocks; updated in place |
| void DFTU_LCAO::cal_occ_mat | ( | const Parallel_Orbitals * | pv, |
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< T > > & | dm, | ||
| const K_Vectors & | kv, | ||
| const double & | mixing_beta, | ||
| hamilt::Hamilt< T > * | p_ham, | ||
| Plus_U_Base & | dftu, | ||
| const bool | gamma_only_local, | ||
| const int | nspin, | ||
| const std::string & | ks_solver ) |
Compute the occupation matrix occ(m,m') = sum_R DMR(I,J,R) * <phi_0|chi_m(I)> * <chi_m'(J)|phi_R> and delegate to the Plus_U member.
| pv | parallel-orbitals descriptor that owns BLACS context and global<->local index maps; sourced by the caller from the same Parallel_Orbitals used to build the Hamiltonian and density matrix. |
| ks_solver | KS solver name (e.g. "scalapack"); forwarded to the multi-k path for folding-matrix selection. |
| void DFTU_LCAO::cal_occ_mat_gamma | ( | const Parallel_Orbitals * | pv, |
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< double > > & | dm_gamma, | ||
| const double & | mixing_beta, | ||
| hamilt::Hamilt< double > * | p_ham, | ||
| Plus_U_Base & | dftu ) |
| void DFTU_LCAO::cal_occ_mat_k | ( | const Parallel_Orbitals * | pv, |
| const UnitCell & | ucell, | ||
| const std::vector< std::vector< std::complex< double > > > & | dm_k, | ||
| const K_Vectors & | kv, | ||
| const double & | mixing_beta, | ||
| hamilt::Hamilt< std::complex< double > > * | p_ham, | ||
| const bool | gamma_only_local, | ||
| Plus_U_Base & | dftu, | ||
| const std::string & | ks_solver ) |
| void DFTU_LCAO::cal_pot_onsite | ( | const Plus_U_Base & | dftu, |
| const UnitCell & | ucell, | ||
| const Parallel_Orbitals * | pv, | ||
| const int | spin, | ||
| const bool | new_occ_mat, | ||
| T * | pot_onsite ) |
Calculate onsite effective potential matrix in the local orbital basis.
Fills pot_onsite (length pv->nloc) with the onsite potential elements projected onto the local orbital indices.
| dftu | Plus_U state |
| ucell | unit cell |
| pv | parallel orbitals descriptor |
| spin | spin channel |
| new_occ_mat | if true use occ_mat, otherwise use occ_mat_save |
| pot_onsite | output buffer (length pv->nloc) |
| void DFTU_LCAO::cal_pot_onsite | ( | const std::vector< double > & | occ, |
| const int | m_size, | ||
| const double | u_value, | ||
| double * | pot_onsite, | ||
| double & | eu ) |
On-site potential and Hubbard energy for one correlated shell: pot_onsite(m,m') = U_eff * (0.5 * delta_{m,m'} - occ(m,m')) EU = (U_eff / 2) * sum_{m,m'} occ(m,m') * (delta_{m,m'} - occ(m',m)).
Non-template core extracted from DFTU_onsite<OperatorLCAO<TK,TR>>::cal_pot_onsite.
| occ | flattened occupation matrix, size m_size*m_size*spin_fold |
| m_size | number of magnetic quantum states (2*l+1) |
| u_value | effective U parameter |
| pot_onsite | output potential, same size as occ |
| eu | output Hubbard energy contribution |
On-site potential and Hubbard energy for one correlated shell: pot_onsite(m,m') = U_eff * (0.5 * delta_{m,m'} - occ(m,m')) EU = (U_eff / 2) * sum_{m,m'} occ(m,m') * (delta_{m,m'} - occ(m',m))
|
extern |
|
extern |
| void DFTU_LCAO::cal_pot_uterm | ( | Plus_U_Base & | dftu, |
| const UnitCell & | ucell, | ||
| const Parallel_Orbitals * | pv, | ||
| const int | spin, | ||
| T * | pot_uterm, | ||
| const T * | sk ) |
Compute the LCAO-basis U-term effective potential matrix.
DFT+U effective potential in the LCAO basis, with V = pot_onsite (the on-site Hubbard correction potential in the full basis) and S the overlap matrix. Returns the symmetrized k-space U-term potential: pot_uterm = (V*S + (V*S)^T) / 2
| T | matrix element type (double or std::complex<double>) |
| dftu | Plus_U state |
| ucell | unit cell |
| pv | parallel orbitals descriptor |
| spin | spin channel (isk[ik] from caller) |
| pot_uterm | output buffer (length pv->nloc) |
| sk | overlap matrix in k-space (length pv->nloc) |
|
extern |
|
extern |
| void DFTU_LCAO::cal_str_IJR_nao_r | ( | const int & | iat1, |
| const int & | iat2, | ||
| const Parallel_Orbitals * | pv, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm1_all, | ||
| const std::unordered_map< int, std::vector< double > > & | nlm2_all, | ||
| const std::vector< double > & | pot_onsite_in, | ||
| const hamilt::BaseMatrix< double > ** | dmR_pointer, | ||
| const int | nspin, | ||
| const ModuleBase::Vector3< double > & | dis1, | ||
| const ModuleBase::Vector3< double > & | dis2, | ||
| double * | stress ) |
Compute DFT+U stress contribution from a single atom pair (I,J,R) in real space.
The stress tensor component (alpha,beta) receives contributions from both the derivative of <phi|chi> with respect to the strain and the explicit R_beta factor:
sigma_{alpha,beta} += -(1/Omega) * sum_{m,m'} V_U_{mm'}(I) * DMR_{mu,nu}(J1,J2,R) * [ d<phi_{mu,0}|chi_m(I)>/d tau_{J1,alpha} * <chi_m'(I)|phi_{nu,R}> * R_{J1,beta}
The strain derivative of the two-center integral is approximated by: d<phi|chi>/d epsilon_{alpha,beta} ~ d<phi|chi>/d tau_alpha * R_beta
| iat1 | [in] global atom index of J1 |
| iat2 | [in] global atom index of J2 |
| pv | [in] Parallel_Orbitals for basis index mapping |
| nlm1_all | [in] pre-computed <phi|chi> and derivatives for atom J1 |
| nlm2_all | [in] pre-computed <phi|chi> and derivatives for atom J2 |
| pot_onsite | [in] flattened V_U matrix |
| dmR_pointer | [in] pointer to DMR matrix blocks for each spin |
| nspin | [in] number of spin channels (1, 2, or 4); the spinor polarization count is derived as npol = 2 for nspin=4 (non-collinear) and npol = 1 otherwise |
| dis1 | [in] position vector of J1 relative to I |
| dis2 | [in] position vector of J2 relative to I |
| stress | [out] stress accumulator (6 components in Voigt notation) |
| void DFTU_LCAO::cal_stress_gamma | ( | const DftuFsEnv & | env, |
| const double * | rho_pot_onsite, | ||
| ModuleBase::matrix & | stress_dftu ) |
| void DFTU_LCAO::cal_stress_k | ( | const DftuFsEnv & | env, |
| const int | ik, | ||
| const ModuleBase::Vector3< double > & | kvec_d, | ||
| const std::complex< double > * | rho_pot_onsite, | ||
| ModuleBase::matrix & | stress_dftu ) |
| double DFTU_LCAO::calc_energy_dc_block | ( | const Plus_U_Base & | dftu, |
| int | T, | ||
| int | iat, | ||
| int | l, | ||
| int | nspin ) |
Accumulate the double-counting correction energy_dc for one (T, iat, l) channel by summing onsite_pot * occ over the (m1, ipol1, m2, ipol2) grid. Dispatches on nspin to choose the spin loop count. Returns the per-atom contribution to energy_dc.
Accumulate the double-counting correction energy_dc for one (T, iat, l) channel: E_dc = sum_{m1,ipol1,m2,ipol2} onsite_pot(m1,ipol1;m2,ipol2) * occ(m2,ipol2;m1,ipol1) Returns the per-atom contribution to energy_dc.
| double DFTU_LCAO::calc_energy_u_collinear | ( | const Plus_U_Base & | dftu, |
| int | T, | ||
| int | iat, | ||
| int | l ) |
Accumulate the DFT+U energy term (0.5 * U * (n - n^2)) for one (T, iat, l) channel in the collinear case (nspin=1 or 2). Returns the per-atom contribution to energy_u.
Accumulate the DFT+U energy term (U_eff / 2) * (n - n^2) for one (T, iat, l) channel in the collinear case (nspin=1 or 2). Returns the per-atom contribution to energy_u.
| double DFTU_LCAO::calc_energy_u_noncollinear | ( | const Plus_U_Base & | dftu, |
| int | T, | ||
| int | iat, | ||
| int | l ) |
Accumulate the DFT+U energy term for one (T, iat, l) channel in the noncollinear case (nspin=4). Returns the per-atom contribution to energy_u.
|
inline |
compute the occupation matrix of one Hubbard atom (iat0) from the real-space density matrix: occ(m,m') = sum_R DMR(I,J,R) * <phi_0|chi_m(I)> * <chi_m'(J)|phi_R> then MPI-Allreduce it and store it into the Plus_U occupation matrix.
| ucell | [in] unit cell (atom index maps, npol) |
| dftu | [in,out] Plus_U state receiving the occupation matrix |
| iat0 | [in] global atom index of the Hubbard atom |
| target_L | [in] angular momentum channel of the correlated shell |
| current_spin | [in] active spin channel (0 for nspin=1/4) |
| nspin | [in] number of spin components |
| adjs | [in] adjacent atom info of the Hubbard atom |
| pv | [in] parallel-orbitals descriptor providing local index maps |
| nlm_tot | [in] <phi|alpha^I> overlap table for all atoms |
| dmR_current | [in] real-space density matrix of the active spin |
| occ | [out] flattened occupation matrix; overwritten |
| void DFTU_LCAO::fold_dSR_gamma | ( | const FoldingCtx & | ctx, |
| double * | dsloc_x, | ||
| double * | dsloc_y, | ||
| double * | dsloc_z, | ||
| double * | dh_r, | ||
| int | dim1, | ||
| int | dim2, | ||
| double * | dSR_gamma ) |
Fold the dSR matrix for gamma-only calculations. npol is the spin-polarization factor; orb_cutoff and ks_solver are forwarded to is_adjacent_pair and get_linear_index.
| void DFTU_LCAO::folding_matrix_k | ( | const FoldingCtx & | ctx, |
| ForceStressArrays & | fsr, | ||
| int | ik, | ||
| int | dim1, | ||
| int | dim2, | ||
| std::complex< double > * | mat_k, | ||
| const ModuleBase::Vector3< double > & | kvec_d ) |
| void DFTU_LCAO::folding_matrix_k_new | ( | const std::string & | ks_solver, |
| bool | gamma_only_local, | ||
| int | nspin, | ||
| const int | ik, | ||
| hamilt::Hamilt< std::complex< double > > * | p_ham ) |
new function of folding_S_matrix only for Hamiltonian now, for force and stress will be developed later use HContainer as input and output in mat_k
|
inline |
walk all (ad1, ad2) adjacent-atom pairs of one Hubbard atom iat0 and invoke body for each pair that has a matching matrix block.
This is the common iteration skeleton shared by the HR accumulation (accumulate_hr_for_iat0), occupation-matrix computation (compute_occ_from_dmr), and the force/stress real-space implementation (cal_fs_nao_r_impl). The body receives (iat1, iat2, R_vector, nlm1, nlm2) and is responsible for the actual physics.
| ucell | [in] unit cell (atom index maps) |
| iat0 | [in] global atom index of the Hubbard atom |
| adjs | [in] adjacent atom info of the Hubbard atom |
| nlm_tot | [in] <phi|alpha^I> overlap table for all atoms |
| body | [in] callable with signature void(int iat1, int iat2, const ModuleBase::Vector3<int>& R_vector, const std::unordered_map<int, std::vector<double>>& nlm1, const std::unordered_map<int, std::vector<double>>& nlm2) |
| void DFTU_LCAO::force_stress | ( | const DftuFsEnv & | env, |
| const bool | cal_force, | ||
| const bool | cal_stress, | ||
| std::vector< std::vector< double > > * | dmk_d, | ||
| std::vector< std::vector< std::complex< double > > > * | dmk_c, | ||
| ModuleBase::matrix & | force_dftu, | ||
| ModuleBase::matrix & | stress_dftu, | ||
| const K_Vectors & | kv, | ||
| const bool | gamma_only_local ) |
Top-level entry: drives force/stress from DFT+U.
| int DFTU_LCAO::get_linear_index | ( | const std::string & | ks_solver, |
| const int | mu, | ||
| const int | nu, | ||
| const Parallel_Orbitals & | pv ) |
Get the linear index of local matrix element (mu, nu) based on ks_solver (column-major or row-major).
| double DFTU_LCAO::get_onsite_pot | ( | const Plus_U_Base & | dftu, |
| const int | T, | ||
| const int | iat, | ||
| const int | L, | ||
| const int | spin, | ||
| const int | m0, | ||
| const int | m1, | ||
| const bool | new_occ_mat ) |
one-body effective onsite potential element for a given (m0,m1) pair.
Dispatches on UForm; only dud_fll (Dudarev simplified formalism with FLL double counting) is currently implemented, the other forms return 0.
| dftu | Plus_U state providing U/J values and occupation matrices |
| T | atom type |
| iat | global atom index |
| L | angular momentum |
| spin | spin channel |
| m0 | first magnetic quantum index (packed with polarization) |
| m1 | second magnetic quantum index (packed with polarization) |
| new_occ_mat | if true use occ_mat, otherwise use occ_mat_save |
| bool DFTU_LCAO::is_adjacent_pair | ( | const std::vector< double > & | orb_cutoff, |
| const UnitCell & | ucell, | ||
| const Grid_Driver & | gd, | ||
| int | T1, | ||
| int | T2, | ||
| const ModuleBase::Vector3< double > & | tau1, | ||
| const ModuleBase::Vector3< double > & | tau2 ) |
Judge whether atom pair (T1,I1) and (T2,I2,tau2) are adjacent by direct orbital cutoff overlap or three-body bridging via a common nonlocal projector center T0.
| orb_cutoff | orbital cutoff radii per atom type |
|
inline |
load the flattened occupation matrix of one Hubbard atom from pre-read occ_mat data.
| dftu | Plus_U state providing the stored occupation matrix |
| iat0 | global atom index of the Hubbard atom |
| target_L | angular momentum channel of the correlated shell |
| nspin | number of spin components |
| current_spin | active spin channel for nspin=2 |
| occ | output flattened occupation matrix |
| void DFTU_LCAO::reduce_force_impl | ( | ModuleBase::matrix & | force, |
| int | nspin ) |
Post-process force: MPI Allreduce and spin-degeneracy scaling.
| force | [in,out] force matrix (nat, 3), reduced and scaled |
| nspin | [in] number of spin channels (1, 2, or 4) |
| void DFTU_LCAO::reduce_stress_impl | ( | const UnitCell * | ucell, |
| const std::vector< double > & | stress_tmp, | ||
| ModuleBase::matrix & | stress ) |
Post-process stress: MPI Allreduce and renormalization to full 3x3 tensor from Voigt-like 6-component form.
| ucell | [in] unit cell (for lat0/omega) |
| stress_tmp | [in] Voigt-like 6-component stress, reduced in-place |
| stress | [out] full 3x3 stress tensor |
| DFTU_LCAO::TEST | ( | GetLinearIndexTest | , |
| ColumnMajor | ) |
| DFTU_LCAO::TEST | ( | GetLinearIndexTest | , |
| RowMajor | ) |
| void DFTU_LCAO::transfer_pot_onsite | ( | const std::vector< double > & | pot_onsite_tmp, |
| std::vector< TR > & | pot_onsite ) |
transfer pot_onsite format from Pauli matrix storage to the target matrix-element type used by the Hamiltonian.
Generic overload performs an identity copy. The complex specialization converts Pauli blocks to spinor blocks for the non-collinear case.
| pot_onsite_tmp | input onsite potential in Pauli-block storage |
| pot_onsite | output onsite potential in target storage |
|
inline |