Skip to content

Commit b3ffb5a

Browse files
author
dyzheng
committed
refactor: FORCE_STRESS.cpp file
1 parent a5623a5 commit b3ffb5a

8 files changed

Lines changed: 1185 additions & 774 deletions

source/source_lcao/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ if(ENABLE_LCAO)
2525
module_operator_lcao/operator_force_stress_utils.cpp
2626
pulay_fs_center2.cpp
2727
FORCE_STRESS.cpp
28+
force_stress_pw.cpp
29+
force_stress_symmetry.cpp
30+
force_stress_lcao_contributions.cpp
31+
force_stress_lcao_operator.cpp
32+
force_stress_lcao_output.cpp
2833
FORCE_gamma.cpp
2934
FORCE_k.cpp
3035
stress_tools.cpp

source/source_lcao/FORCE_STRESS.cpp

Lines changed: 80 additions & 773 deletions
Large diffs are not rendered by default.

source/source_lcao/FORCE_STRESS.h

Lines changed: 211 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "source_lcao/setup_deepks.h" // for deepks, mohan add 20251010
1919
#include "source_lcao/setup_dm.h" // mohan add 2025-11-03
2020
#include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-07
21+
#include "source_hamilt/module_vdw/vdw.h" // mohan add 2026-01-22
2122

2223

2324
template <typename T>
@@ -114,13 +115,222 @@ class Force_Stress_LCAO
114115
const pseudopot_cell_vl& locpp,
115116
const Structure_Factor& sf);
116117

118+
void calculate_operator_force_stress(
119+
const bool isforce,
120+
const bool isstress,
121+
const UnitCell& ucell,
122+
const Grid_Driver& gd,
123+
const K_Vectors& kv,
124+
const TwoCenterBundle& two_center_bundle,
125+
const LCAO_Orbitals& orb,
126+
LCAO_domain::Setup_DM<T>& dmat,
127+
const elecstate::DensityMatrix<T, double>& edm,
128+
ModuleBase::matrix& foverlap,
129+
ModuleBase::matrix& ftvnl_dphi,
130+
ModuleBase::matrix& fvnl_dbeta,
131+
ModuleBase::matrix& fvl_dphi,
132+
ModuleBase::matrix& soverlap,
133+
ModuleBase::matrix& stvnl_dphi,
134+
ModuleBase::matrix& svnl_dbeta,
135+
ModuleBase::matrix& svl_dphi);
136+
137+
void calculate_operator_force_stress_spin12(
138+
const bool isforce,
139+
const bool isstress,
140+
const UnitCell& ucell,
141+
const Grid_Driver& gd,
142+
const K_Vectors& kv,
143+
const TwoCenterBundle& two_center_bundle,
144+
const LCAO_Orbitals& orb,
145+
LCAO_domain::Setup_DM<T>& dmat,
146+
const elecstate::DensityMatrix<T, double>& edm,
147+
ModuleBase::matrix& foverlap,
148+
ModuleBase::matrix& ftvnl_dphi,
149+
ModuleBase::matrix& fvnl_dbeta,
150+
ModuleBase::matrix& fvl_dphi,
151+
ModuleBase::matrix& soverlap,
152+
ModuleBase::matrix& stvnl_dphi,
153+
ModuleBase::matrix& svnl_dbeta,
154+
ModuleBase::matrix& svl_dphi);
155+
156+
void calculate_operator_force_stress_spin4(
157+
const bool isforce,
158+
const bool isstress,
159+
const UnitCell& ucell,
160+
const Grid_Driver& gd,
161+
const K_Vectors& kv,
162+
const TwoCenterBundle& two_center_bundle,
163+
const LCAO_Orbitals& orb,
164+
LCAO_domain::Setup_DM<T>& dmat,
165+
const elecstate::DensityMatrix<T, double>& edm,
166+
ModuleBase::matrix& foverlap,
167+
ModuleBase::matrix& ftvnl_dphi,
168+
ModuleBase::matrix& fvnl_dbeta,
169+
ModuleBase::matrix& fvl_dphi,
170+
ModuleBase::matrix& soverlap,
171+
ModuleBase::matrix& stvnl_dphi,
172+
ModuleBase::matrix& svnl_dbeta,
173+
ModuleBase::matrix& svl_dphi);
174+
175+
void calculate_deepks_force_stress(
176+
const UnitCell& ucell,
177+
const bool isforce,
178+
const bool isstress,
179+
const Grid_Driver& gd,
180+
const K_Vectors& kv,
181+
const LCAO_Orbitals& orb,
182+
Setup_DeePKS<T>& deepks,
183+
ModuleBase::matrix& fvnl_dalpha,
184+
ModuleBase::matrix& svnl_dalpha);
185+
186+
void calculate_vdw_force_stress(
187+
const UnitCell& ucell,
188+
const bool isforce,
189+
const bool isstress,
190+
ModuleBase::matrix& force_vdw,
191+
ModuleBase::matrix& stress_vdw);
192+
193+
void calculate_efield_force(
194+
const UnitCell& ucell,
195+
const bool isforce,
196+
ModuleBase::matrix& fefield);
197+
198+
void calculate_tddft_efield_force(
199+
const UnitCell& ucell,
200+
const bool isforce,
201+
ModuleBase::matrix& fefield_tddft);
202+
203+
void calculate_gatefield_force(
204+
const UnitCell& ucell,
205+
const bool isforce,
206+
ModuleBase::matrix& fgate);
207+
208+
void calculate_solvent_force(
209+
UnitCell& ucell,
210+
const bool isforce,
211+
ModulePW::PW_Basis* rhopw,
212+
const pseudopot_cell_vl& locpp,
213+
surchem& solvent,
214+
ModuleBase::matrix& fsol);
215+
216+
void calculate_dftu_force_stress(
217+
const UnitCell& ucell,
218+
const Grid_Driver& gd,
219+
LCAO_domain::Setup_DM<T>& dmat,
220+
Parallel_Orbitals& pv,
221+
const K_Vectors& kv,
222+
const bool isforce,
223+
const bool isstress,
224+
const TwoCenterBundle& two_center_bundle,
225+
const LCAO_Orbitals& orb,
226+
Plus_U& dftu,
227+
ModuleBase::matrix& force_u,
228+
ModuleBase::matrix& stress_u);
229+
230+
void calculate_deltaspin_force_stress(
231+
const UnitCell& ucell,
232+
const Grid_Driver& gd,
233+
LCAO_domain::Setup_DM<T>& dmat,
234+
const K_Vectors& kv,
235+
const bool isforce,
236+
const bool isstress,
237+
const TwoCenterBundle& two_center_bundle,
238+
const LCAO_Orbitals& orb,
239+
ModuleBase::matrix& force_dspin,
240+
ModuleBase::matrix& stress_dspin);
241+
242+
void calculate_exx_force_stress(
243+
const UnitCell& ucell,
244+
const bool isforce,
245+
const bool isstress,
246+
Exx_NAO<T>& exx_nao,
247+
ModuleBase::matrix& force_exx,
248+
ModuleBase::matrix& stress_exx);
249+
250+
void aggregate_forces(
251+
const UnitCell& ucell,
252+
const int nat,
253+
ModuleBase::matrix& fcs,
254+
const ModuleBase::matrix& foverlap,
255+
const ModuleBase::matrix& ftvnl_dphi,
256+
const ModuleBase::matrix& fvnl_dbeta,
257+
const ModuleBase::matrix& fvl_dphi,
258+
const ModuleBase::matrix& fvl_dvl,
259+
const ModuleBase::matrix& fewalds,
260+
const ModuleBase::matrix& fcc,
261+
const ModuleBase::matrix& fscc,
262+
const ModuleBase::matrix& force_vdw,
263+
const ModuleBase::matrix& fefield,
264+
const ModuleBase::matrix& fefield_tddft,
265+
const ModuleBase::matrix& fgate,
266+
const ModuleBase::matrix& fsol,
267+
const ModuleBase::matrix& force_u,
268+
const ModuleBase::matrix& force_dspin,
269+
const ModuleBase::matrix& force_exx,
270+
const ModuleBase::matrix& fvnl_dalpha);
271+
272+
void aggregate_stresses(
273+
ModuleBase::matrix& scs,
274+
const ModuleBase::matrix& soverlap,
275+
const ModuleBase::matrix& stvnl_dphi,
276+
const ModuleBase::matrix& svnl_dbeta,
277+
const ModuleBase::matrix& svl_dphi,
278+
const ModuleBase::matrix& sigmadvl,
279+
const ModuleBase::matrix& sigmaewa,
280+
const ModuleBase::matrix& sigmacc,
281+
const ModuleBase::matrix& sigmaxc,
282+
const ModuleBase::matrix& sigmahar,
283+
const ModuleBase::matrix& stress_vdw,
284+
const ModuleBase::matrix& stress_u,
285+
const ModuleBase::matrix& stress_dspin,
286+
const ModuleBase::matrix& stress_exx,
287+
const ModuleBase::matrix& svnl_dalpha);
288+
289+
void print_force_test_output(
290+
const UnitCell& ucell,
291+
const int nat,
292+
const bool istestf,
293+
const ModuleBase::matrix& foverlap,
294+
const ModuleBase::matrix& ftvnl_dphi,
295+
const ModuleBase::matrix& fvnl_dbeta,
296+
const ModuleBase::matrix& fvl_dphi,
297+
const ModuleBase::matrix& fvl_dvl,
298+
const ModuleBase::matrix& fewalds,
299+
const ModuleBase::matrix& fcc,
300+
const ModuleBase::matrix& fscc,
301+
const ModuleBase::matrix& fefield,
302+
const ModuleBase::matrix& fefield_tddft,
303+
const ModuleBase::matrix& fgate,
304+
const ModuleBase::matrix& fsol,
305+
const ModuleBase::matrix& force_vdw,
306+
const ModuleBase::matrix& force_u,
307+
const ModuleBase::matrix& force_dspin,
308+
const ModuleBase::matrix& fvnl_dalpha,
309+
const std::unique_ptr<vdw::Vdw>& vdw_solver);
310+
311+
void print_stress_test_output(
312+
const int istests,
313+
const ModuleBase::matrix& soverlap,
314+
const ModuleBase::matrix& stvnl_dphi,
315+
const ModuleBase::matrix& svnl_dbeta,
316+
const ModuleBase::matrix& svl_dphi,
317+
const ModuleBase::matrix& sigmadvl,
318+
const ModuleBase::matrix& sigmahar,
319+
const ModuleBase::matrix& sigmaewa,
320+
const ModuleBase::matrix& sigmacc,
321+
const ModuleBase::matrix& sigmaxc,
322+
const ModuleBase::matrix& stress_vdw,
323+
const ModuleBase::matrix& stress_u,
324+
const ModuleBase::matrix& stress_dspin,
325+
const ModuleBase::matrix& scs,
326+
const std::unique_ptr<vdw::Vdw>& vdw_solver);
327+
117328
static double force_invalid_threshold_ev;
118329
};
119330

120331
template <typename T>
121332
double Force_Stress_LCAO<T>::force_invalid_threshold_ev = 0.00;
122333

123-
// only for DFT+U, mohan add 2025-11-04
124334
template <typename T>
125335
void assign_dmk_ptr(
126336
elecstate::DensityMatrix<T,double>* dm,

0 commit comments

Comments
 (0)