ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
force_stress_lcao.h
Go to the documentation of this file.
1#ifndef FORCE_STRESS_LCAO_H
2#define FORCE_STRESS_LCAO_H
3
5
6#include <string>
7
8#include "edm.h"
10#include "source_base/matrix.h"
15#include "source_psi/psi.h"
16#ifdef __EXX
18#endif
19#include "force_stress_arrays.h"
20#include "source_lcao/setup_exx.h" // for exx, mohan add 20251008
21#include "source_lcao/setup_deepks.h" // for deepks, mohan add 20251010
22#include "source_lcao/allocate_dm.h" // mohan add 2025-11-03
23#include "source_pw/module_pwdft/dftu_base.h" // mohan add 2025-11-07
26
27namespace vdw
28{
29struct VdwResult;
30}
31
32class TwoCenterBundle;
33class BasisFlattenedIndexing; // Defined in source/source_base/basis_flattened_indexing.h
34
35// INPUT scalars that steer the force/stress kernels. Bundling them into one
36// aggregate keeps getForceStress and its helpers from each re-reading the
37// global PARAM object, and collapses five arguments into a single reference.
39{
40 int nspin;
41 int nbands;
42 bool t_in_h;
44 std::string device;
45 bool domag;
46 bool domag_z;
49 int imp_sol; // 2 adds the SCCS component force
50};
51
52// Force/stress component matrices assembled by getForceStress. Grouping them
53// into a struct lets the assembly/print helpers take one reference instead of
54// ~19 individual matrix arguments. Members are default-constructed and only
55// created (allocated) when the corresponding term is active.
78
96
97
98template <typename T>
100{
101 // mohan add 2021-02-09
102 friend class md;
103 friend void Input_Conv::Convert();
104 friend class ions;
105
106 public:
107 Force_Stress_LCAO(Record_adj& ra, const int nat_in);
109
110 void getForceStress(UnitCell& ucell,
111 const vdw::VdwResult* vdw_result,
112 const bool isforce,
113 const bool isstress,
114 const bool istestf,
115 const bool istests,
116 const Grid_Driver& gd,
118 const BasisFlattenedIndexing& basis,
119 const elecstate::ElecState* pelec,
120 module_dm::Setup_DM<T> &dmat, // mohan add 2025-11-03
121 const psi::Psi<T>* psi,
122 const TwoCenterBundle& two_center_bundle,
123 const LCAO_Orbitals& orb,
126 const pseudopot_cell_vl& locpp,
127 const Structure_Factor& sf,
128 const K_Vectors& kv,
129 ModulePW::PW_Basis* rhopw,
130 surchem& solvent,
131 Plus_U_Base &dftu, // mohan add 2025-11-07
132 Setup_DeePKS<T> &deepks,
133 Exx_NAO<T> &exx_nao,
135 const Exx_Info& exx_info,
136 const FSCalcConfig& cfg,
137 TD_info* td_info,
138 hamilt::Hamilt<T>* p_hamilt);
139
140 private:
141 int nat;
142 Record_adj* RA = nullptr;
145
146 // Operator-based force/stress terms: kinetic, overlap, nonlocal,
147 // rt-TDDFT hybrid gauge, local-potential Pulay term, and DeltaSpin.
148 void cal_operator_fs(UnitCell& ucell,
149 const Grid_Driver& gd,
151 const BasisFlattenedIndexing& basis,
152 const elecstate::ElecState* pelec,
154 const psi::Psi<T>* psi,
155 const TwoCenterBundle& two_center_bundle,
156 const LCAO_Orbitals& orb,
157 const K_Vectors& kv,
158 const bool isforce,
159 const bool isstress,
160 const FSCalcConfig& cfg,
161 TD_info* td_info,
162 hamilt::Hamilt<T>* p_hamilt,
163 LCAOForceParts& parts,
164 LCAOStressParts& sparts);
165
166
167 // Local pseudopotential, Ewald, core-correction and self-consistent-field
168 // force contributions, computed with the plane-wave Forces driver. Kept as
169 // a member because it needs friend access to Forces::cal_force_*.
170 void calForcePwPart(UnitCell& ucell,
171 ModuleBase::matrix& fvl_dvl,
172 ModuleBase::matrix& fewalds,
174 ModuleBase::matrix& fscc,
175 const double& etxc,
176 const ModuleBase::matrix& vnew,
177 const bool vnew_exist,
178 const Charge* const chr,
179 ModulePW::PW_Basis* rhopw,
180 const pseudopot_cell_vl& locpp,
181 const Structure_Factor& sf,
182 const FSCalcConfig& cfg);
183
185};
186
187template <typename T>
189
190// only for DFT+U, mohan add 2025-11-04
191template <typename T>
194 std::vector<std::vector<double>>*& dmk_d,
195 std::vector<std::vector<std::complex<double>>>*& dmk_c
196);
197
198#endif
Canonical atom-major flattening of the LCAO basis hierarchy.
Definition basis_flattened_indexing.h:40
Definition edm.h:15
Definition charge.h:24
Definition setup_exx.h:21
Record_adj * RA
Definition force_stress_lcao.h:142
void getForceStress(UnitCell &ucell, const vdw::VdwResult *vdw_result, const bool isforce, const bool isstress, const bool istestf, const bool istests, const Grid_Driver &gd, Parallel_Orbitals &pv, const BasisFlattenedIndexing &basis, const elecstate::ElecState *pelec, module_dm::Setup_DM< T > &dmat, const psi::Psi< T > *psi, const TwoCenterBundle &two_center_bundle, const LCAO_Orbitals &orb, ModuleBase::matrix &fcs, ModuleBase::matrix &scs, const pseudopot_cell_vl &locpp, const Structure_Factor &sf, const K_Vectors &kv, ModulePW::PW_Basis *rhopw, surchem &solvent, Plus_U_Base &dftu, Setup_DeePKS< T > &deepks, Exx_NAO< T > &exx_nao, ModuleSymmetry::Symmetry *symm, const Exx_Info &exx_info, const FSCalcConfig &cfg, TD_info *td_info, hamilt::Hamilt< T > *p_hamilt)
Definition force_stress_lcao.cpp:72
int nat
Definition force_stress_lcao.h:141
void calForcePwPart(UnitCell &ucell, ModuleBase::matrix &fvl_dvl, ModuleBase::matrix &fewalds, ModuleBase::matrix &fcc, ModuleBase::matrix &fscc, const double &etxc, const ModuleBase::matrix &vnew, const bool vnew_exist, const Charge *const chr, ModulePW::PW_Basis *rhopw, const pseudopot_cell_vl &locpp, const Structure_Factor &sf, const FSCalcConfig &cfg)
Definition force_stress_lcao.cpp:400
~Force_Stress_LCAO()
Definition force_stress_lcao.cpp:68
Stress_Func< double > sc_pw
Definition force_stress_lcao.h:144
Force_Stress_LCAO(Record_adj &ra, const int nat_in)
Definition force_stress_lcao.cpp:64
friend class ions
Definition force_stress_lcao.h:104
CalEDM< T > edm_cal
Definition force_stress_lcao.h:143
static double force_invalid_threshold_ev
Definition force_stress_lcao.h:184
friend class md
Definition force_stress_lcao.h:102
void cal_operator_fs(UnitCell &ucell, const Grid_Driver &gd, Parallel_Orbitals &pv, const BasisFlattenedIndexing &basis, const elecstate::ElecState *pelec, module_dm::Setup_DM< T > &dmat, const psi::Psi< T > *psi, const TwoCenterBundle &two_center_bundle, const LCAO_Orbitals &orb, const K_Vectors &kv, const bool isforce, const bool isstress, const FSCalcConfig &cfg, TD_info *td_info, hamilt::Hamilt< T > *p_hamilt, LCAOForceParts &parts, LCAOStressParts &sparts)
Definition force_stress_lcao.cpp:238
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
Class for k-points management.
Definition klist.h:20
Definition orb_read.h:18
Definition matrix.h:15
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Symmetry analysis class.
Definition symmetry.h:24
Definition parallel_orbitals.h:16
Definition dftu_base.h:21
Definition record_adj.h:15
Definition setup_deepks.h:23
Definition stress_func.h:58
Definition stru_fac.h:10
Definition td_info.h:18
Definition two_center_bundle.h:11
Provide the basic information about unitcell.
Definition unitcell.h:16
Definition elecstate.h:20
Definition hamilt.h:17
DensityMatrix Class <TK,TR> = <double,double> for Gamma-only calculation <TK,TR> = <std::complex<doub...
Definition density_matrix.h:172
Definition dm_holder.h:10
Definition vl_pw.h:13
Definition psi.h:37
Definition surchem.h:34
void assign_dmk_ptr(module_dm::DensityMatrix< T, double > *dm, std::vector< std::vector< double > > *&dmk_d, std::vector< std::vector< std::complex< double > > > *&dmk_c)
void Convert()
Pass the data members from the INPUT instance(defined in source_io/input.cpp) to GlobalV and GlobalC.
Definition input_conv.cpp:46
Definition diag_lcao.h:14
Definition esolver_fp.h:18
Definition exx_info.h:10
Definition force_stress_lcao.h:39
int imp_sol
Definition force_stress_lcao.h:49
int nspin
Definition force_stress_lcao.h:40
int gga_grad
Definition force_stress_lcao.h:47
bool t_in_h
Definition force_stress_lcao.h:42
bool domag
Definition force_stress_lcao.h:45
bool gamma_only_pw
Definition force_stress_lcao.h:48
bool domag_z
Definition force_stress_lcao.h:46
int nbands
Definition force_stress_lcao.h:41
bool sc_mag_switch
Definition force_stress_lcao.h:43
std::string device
Definition force_stress_lcao.h:44
Definition force_stress_lcao.h:57
ModuleBase::matrix fscc
Definition force_stress_lcao.h:65
ModuleBase::matrix fgate
Definition force_stress_lcao.h:74
ModuleBase::matrix force_dspin
Definition force_stress_lcao.h:69
ModuleBase::matrix fefield_tddft
Definition force_stress_lcao.h:73
ModuleBase::matrix force_u
Definition force_stress_lcao.h:68
ModuleBase::matrix fvl_dvl
Definition force_stress_lcao.h:62
ModuleBase::matrix fvl_dphi
Definition force_stress_lcao.h:61
ModuleBase::matrix force_exx
Definition force_stress_lcao.h:70
ModuleBase::matrix fefield
Definition force_stress_lcao.h:72
ModuleBase::matrix force_vdw
Definition force_stress_lcao.h:71
ModuleBase::matrix fvnl_dbeta
Definition force_stress_lcao.h:60
ModuleBase::matrix fcc
Definition force_stress_lcao.h:64
ModuleBase::matrix fpothybrid
Definition force_stress_lcao.h:67
ModuleBase::matrix fsol
Definition force_stress_lcao.h:75
ModuleBase::matrix fewalds
Definition force_stress_lcao.h:63
ModuleBase::matrix foverlap
Definition force_stress_lcao.h:58
ModuleBase::matrix fpcc
Definition force_stress_lcao.h:76
ModuleBase::matrix fvnl_dalpha
Definition force_stress_lcao.h:66
ModuleBase::matrix ftvnl_dphi
Definition force_stress_lcao.h:59
Definition force_stress_lcao.h:80
ModuleBase::matrix stvnl_dphi
Definition force_stress_lcao.h:82
ModuleBase::matrix sigmaxc
Definition force_stress_lcao.h:89
ModuleBase::matrix stress_u
Definition force_stress_lcao.h:91
ModuleBase::matrix sigmahar
Definition force_stress_lcao.h:86
ModuleBase::matrix stress_dspin
Definition force_stress_lcao.h:92
ModuleBase::matrix sigmacc
Definition force_stress_lcao.h:88
ModuleBase::matrix svl_dphi
Definition force_stress_lcao.h:84
ModuleBase::matrix sigmaewa
Definition force_stress_lcao.h:87
ModuleBase::matrix svnl_dalpha
Definition force_stress_lcao.h:90
ModuleBase::matrix soverlap
Definition force_stress_lcao.h:81
ModuleBase::matrix sigmadvl
Definition force_stress_lcao.h:85
ModuleBase::matrix stress_vdw
Definition force_stress_lcao.h:94
ModuleBase::matrix svnl_dbeta
Definition force_stress_lcao.h:83
ModuleBase::matrix stress_exx
Definition force_stress_lcao.h:93
Definition vdw.h:30
Plus_U_Base dftu
Definition test_dftu_nao_op.cpp:11