Skip to content

Commit 367db31

Browse files
committed
delete grid integral in FORCE_STRESS
1 parent f39bc50 commit 367db31

File tree

13 files changed

+60
-97
lines changed

13 files changed

+60
-97
lines changed

source/source_esolver/esolver_double_xc.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,6 @@ void ESolver_DoubleXC<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& fo
399399
this->pv,
400400
this->pelec_base,
401401
this->psi,
402-
this->GG, // mohan add 2024-04-01
403-
this->GK, // mohan add 2024-04-01
404402
this->two_center_bundle_,
405403
this->orb_,
406404
force_base,

source/source_esolver/esolver_ks.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "source_io/output_log.h" // use write_head
1515
#include "source_estate/elecstate_print.h" // print_etot
1616
#include "source_io/print_info.h" // print_parameters
17+
#include "source_psi/setup_psi.h" // mohan add 20251009
1718

1819
namespace ModuleESolver
1920
{
@@ -28,7 +29,8 @@ ESolver_KS<T, Device>::~ESolver_KS()
2829
//****************************************************
2930
// do not add any codes in this deconstructor funcion
3031
//****************************************************
31-
delete this->psi;
32+
Setup_Psi<T>::deallocate_psi(this->psi);
33+
3234
delete this->p_hamilt;
3335
delete this->p_chgmix;
3436
this->ppcell.release_memory();

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -308,29 +308,13 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& for
308308

309309
deepks.dpks_out_type = "tot"; // for deepks method
310310

311-
fsl.getForceStress(ucell,
312-
PARAM.inp.cal_force,
313-
PARAM.inp.cal_stress,
314-
PARAM.inp.test_force,
315-
PARAM.inp.test_stress,
316-
this->gd,
317-
this->pv,
318-
this->pelec,
319-
this->psi,
320-
this->GG, // mohan add 2024-04-01
321-
this->GK, // mohan add 2024-04-01
322-
two_center_bundle_,
323-
orb_,
324-
force,
325-
this->scs,
326-
this->locpp,
327-
this->sf,
328-
this->kv,
329-
this->pw_rho,
330-
this->solvent,
331-
this->deepks,
332-
this->exx_nao,
333-
&ucell.symm);
311+
fsl.getForceStress(ucell, PARAM.inp.cal_force, PARAM.inp.cal_stress,
312+
PARAM.inp.test_force, PARAM.inp.test_stress,
313+
this->gd, this->pv, this->pelec, this->psi,
314+
two_center_bundle_, orb_, force, this->scs,
315+
this->locpp, this->sf, this->kv,
316+
this->pw_rho, this->solvent, this->deepks,
317+
this->exx_nao, &ucell.symm);
334318

335319
// delete RA after cal_force
336320
this->RA.delete_grid();

source/source_io/read_wfc_nao.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#include "source_base/tool_title.h" // use title
1111
#include "source_base/global_function.h" // use READ_VALUE
1212

13+
// mohan add 2025-10-19
14+
void ModuleIO::read_wfc_nao_one_data(std::ifstream& ifs, float& data)
15+
{
16+
ifs >> data;
17+
}
18+
1319
void ModuleIO::read_wfc_nao_one_data(std::ifstream& ifs, double& data)
1420
{
1521
ifs >> data;
@@ -23,6 +29,14 @@ void ModuleIO::read_wfc_nao_one_data(std::ifstream& ifs, std::complex<double>& d
2329
data = std::complex<double>(a, b);
2430
}
2531

32+
void ModuleIO::read_wfc_nao_one_data(std::ifstream& ifs, std::complex<float>& data)
33+
{
34+
float a = 0.0;
35+
float b = 0.0;
36+
ifs >> a >> b;
37+
data = std::complex<float>(a, b);
38+
}
39+
2640
template <typename T>
2741
bool ModuleIO::read_wfc_nao(
2842
const std::string& global_readin_dir,
@@ -218,6 +232,18 @@ template bool ModuleIO::read_wfc_nao<double>(const std::string& global_readin_di
218232
const int istep,
219233
const int skip_band);
220234

235+
// mohan add 2025-10-19
236+
template bool ModuleIO::read_wfc_nao<float>(const std::string& global_readin_dir,
237+
const Parallel_Orbitals& ParaV,
238+
psi::Psi<float>& psid,
239+
ModuleBase::matrix& ekb,
240+
ModuleBase::matrix& wg,
241+
const std::vector<int> &ik2iktot,
242+
const int nkstot,
243+
const int nspin,
244+
const int istep,
245+
const int skip_band);
246+
221247
template bool ModuleIO::read_wfc_nao<std::complex<double>>(const std::string& global_readin_dir,
222248
const Parallel_Orbitals& ParaV,
223249
psi::Psi<std::complex<double>>& psid,
@@ -228,3 +254,15 @@ template bool ModuleIO::read_wfc_nao<std::complex<double>>(const std::string& gl
228254
const int nspin,
229255
const int istep,
230256
const int skip_band);
257+
258+
// mohan add 2025-10-19
259+
template bool ModuleIO::read_wfc_nao<std::complex<float>>(const std::string& global_readin_dir,
260+
const Parallel_Orbitals& ParaV,
261+
psi::Psi<std::complex<float>>& psid,
262+
ModuleBase::matrix& ekb,
263+
ModuleBase::matrix& wg,
264+
const std::vector<int> &ik2iktot,
265+
const int nkstot,
266+
const int nspin,
267+
const int istep,
268+
const int skip_band);

source/source_lcao/FORCE.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,9 @@
1010
#include "source_estate/module_pot/potential_new.h"
1111
#include "source_lcao/force_stress_arrays.h"
1212
#include "source_lcao/module_deepks/LCAO_deepks.h"
13-
#include "source_lcao/module_gint/gint_gamma.h"
14-
#include "source_lcao/module_gint/gint_k.h"
1513
#include "source_psi/psi.h"
1614
#include "source_lcao/setup_deepks.h"
1715

18-
#ifndef TGINT_H
19-
#define TGINT_H
20-
template <typename T>
21-
struct TGint;
22-
template <>
23-
struct TGint<double>
24-
{
25-
using type = Gint_Gamma;
26-
};
27-
template <>
28-
struct TGint<std::complex<double>>
29-
{
30-
using type = Gint_k;
31-
};
32-
#endif
3316

3417
template <typename T>
3518
class Force_Stress_LCAO;
@@ -67,7 +50,6 @@ class Force_LCAO
6750
ModuleBase::matrix& fvnl_dalpha,
6851
ModuleBase::matrix& svnl_dalpha,
6952
Setup_DeePKS<T>& deepks,
70-
typename TGint<T>::type& gint,
7153
const TwoCenterBundle& two_center_bundle,
7254
const LCAO_Orbitals& orb,
7355
const Parallel_Orbitals& pv,
@@ -127,7 +109,6 @@ class Force_LCAO
127109
void cal_fvl_dphi(const bool isforce,
128110
const bool isstress,
129111
const elecstate::Potential* pot_in,
130-
typename TGint<T>::type& gint,
131112
ModuleBase::matrix& fvl_dphi,
132113
ModuleBase::matrix& svl_dphi);
133114

source/source_lcao/FORCE_STRESS.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ void Force_Stress_LCAO<T>::getForceStress(UnitCell& ucell,
4040
Parallel_Orbitals& pv,
4141
const elecstate::ElecState* pelec,
4242
const psi::Psi<T>* psi,
43-
Gint_Gamma& gint_gamma, // mohan add 2024-04-01
44-
Gint_k& gint_k, // mohan add 2024-04-01
4543
const TwoCenterBundle& two_center_bundle,
4644
const LCAO_Orbitals& orb,
4745
ModuleBase::matrix& fcs,
@@ -137,8 +135,8 @@ void Force_Stress_LCAO<T>::getForceStress(UnitCell& ucell,
137135
this->integral_part(PARAM.globalv.gamma_only_local, isforce, isstress,
138136
ucell, gd, fsr, pelec, psi, foverlap, ftvnl_dphi,
139137
fvnl_dbeta, fvl_dphi, soverlap, stvnl_dphi, svnl_dbeta,
140-
svl_dphi, fvnl_dalpha, svnl_dalpha, deepks, gint_gamma,
141-
gint_k, two_center_bundle, orb, pv, kv);
138+
svl_dphi, fvnl_dalpha, svnl_dalpha, deepks,
139+
two_center_bundle, orb, pv, kv);
142140

143141
// calculate force and stress for Nonlocal part
144142
if (PARAM.inp.nspin == 1 || PARAM.inp.nspin == 2)
@@ -732,8 +730,6 @@ void Force_Stress_LCAO<double>::integral_part(const bool isGammaOnly,
732730
ModuleBase::matrix& fvnl_dalpha,
733731
ModuleBase::matrix& svnl_dalpha,
734732
Setup_DeePKS<double>& deepks,
735-
Gint_Gamma& gint_gamma, // mohan add 2024-04-01
736-
Gint_k& gint_k, // mohan add 2024-04-01
737733
const TwoCenterBundle& two_center_bundle,
738734
const LCAO_Orbitals& orb,
739735
const Parallel_Orbitals& pv,
@@ -743,8 +739,7 @@ void Force_Stress_LCAO<double>::integral_part(const bool isGammaOnly,
743739
flk.ftable(isforce, isstress, fsr, ucell, gd, psi, pelec,
744740
foverlap, ftvnl_dphi, fvnl_dbeta, fvl_dphi,
745741
soverlap, stvnl_dphi, svnl_dbeta, svl_dphi,
746-
fvnl_dalpha, svnl_dalpha, deepks, gint_gamma,
747-
two_center_bundle, orb, pv);
742+
fvnl_dalpha, svnl_dalpha, deepks, two_center_bundle, orb, pv);
748743
return;
749744
}
750745

@@ -768,8 +763,6 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(const bool isGammaOn
768763
ModuleBase::matrix& fvnl_dalpha,
769764
ModuleBase::matrix& svnl_dalpha,
770765
Setup_DeePKS<std::complex<double>>& deepks,
771-
Gint_Gamma& gint_gamma,
772-
Gint_k& gint_k,
773766
const TwoCenterBundle& two_center_bundle,
774767
const LCAO_Orbitals& orb,
775768
const Parallel_Orbitals& pv,
@@ -778,7 +771,7 @@ void Force_Stress_LCAO<std::complex<double>>::integral_part(const bool isGammaOn
778771
flk.ftable(isforce, isstress, fsr, ucell, gd, psi, pelec,
779772
foverlap, ftvnl_dphi, fvnl_dbeta, fvl_dphi,
780773
soverlap, stvnl_dphi, svnl_dbeta, svl_dphi,
781-
fvnl_dalpha, svnl_dalpha, deepks, gint_k,
774+
fvnl_dalpha, svnl_dalpha, deepks,
782775
two_center_bundle, orb, pv, &kv, this->RA);
783776
return;
784777
}

source/source_lcao/FORCE_STRESS.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include "source_lcao/module_ri/Exx_LRI_interface.h"
1515
#endif
1616
#include "force_stress_arrays.h"
17-
#include "source_lcao/module_gint/gint_gamma.h"
18-
#include "source_lcao/module_gint/gint_k.h"
1917
#include "source_lcao/setup_exx.h" // for exx, mohan add 20251008
2018
#include "source_lcao/setup_deepks.h" // for deepks, mohan add 20251010
2119

@@ -41,8 +39,6 @@ class Force_Stress_LCAO
4139
Parallel_Orbitals& pv,
4240
const elecstate::ElecState* pelec,
4341
const psi::Psi<T>* psi,
44-
Gint_Gamma& gint_gamma, // mohan add 2024-04-01
45-
Gint_k& gint_k, // mohan add 2024-04-01
4642
const TwoCenterBundle& two_center_bundle,
4743
const LCAO_Orbitals& orb,
4844
ModuleBase::matrix& fcs,
@@ -96,8 +92,6 @@ class Force_Stress_LCAO
9692
ModuleBase::matrix& fvnl_dalpha,
9793
ModuleBase::matrix& svnl_dalpha,
9894
Setup_DeePKS<T>& deepks,
99-
Gint_Gamma& gint_gamma,
100-
Gint_k& gint_k,
10195
const TwoCenterBundle& two_center_bundle,
10296
const LCAO_Orbitals& orb,
10397
const Parallel_Orbitals& pv,

source/source_lcao/FORCE_gamma.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ void Force_LCAO<double>::ftable(const bool isforce,
170170
ModuleBase::matrix& fvnl_dalpha,
171171
ModuleBase::matrix& svnl_dalpha,
172172
Setup_DeePKS<double>& deepks,
173-
TGint<double>::type& gint,
174173
const TwoCenterBundle& two_center_bundle,
175174
const LCAO_Orbitals& orb,
176175
const Parallel_Orbitals& pv,
@@ -220,7 +219,6 @@ void Force_LCAO<double>::ftable(const bool isforce,
220219
*dm,
221220
ucell,
222221
pelec->pot,
223-
gint,
224222
isforce,
225223
isstress,
226224
false /*reset dm to gint*/);

source/source_lcao/FORCE_k.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ void Force_LCAO<std::complex<double>>::ftable(const bool isforce,
207207
ModuleBase::matrix& fvnl_dalpha,
208208
ModuleBase::matrix& svnl_dalpha,
209209
Setup_DeePKS<std::complex<double>>& deepks,
210-
TGint<std::complex<double>>::type& gint,
211210
const TwoCenterBundle& two_center_bundle,
212211
const LCAO_Orbitals& orb,
213212
const Parallel_Orbitals& pv,
@@ -247,7 +246,7 @@ void Force_LCAO<std::complex<double>>::ftable(const bool isforce,
247246
// doing on the real space grid.
248247
// vl_dphi
249248
PulayForceStress::cal_pulay_fs(fvl_dphi, svl_dphi, *dm, ucell,
250-
pelec->pot, gint, isforce, isstress,
249+
pelec->pot, isforce, isstress,
251250
false /*reset dm to gint*/);
252251

253252
#ifdef __MLALGO

source/source_lcao/pulay_fs.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
#pragma once
22
#include "source_basis/module_nao/two_center_bundle.h"
33
#include "source_estate/module_dm/density_matrix.h"
4-
#include "source_lcao/module_gint/gint_gamma.h"
5-
#include "source_lcao/module_gint/gint_k.h"
64
#include "source_estate/module_pot/potential_new.h"
75
#include "source_cell/unitcell.h"
86
#include "source_lcao/stress_tools.h"
9-
#ifndef TGINT_H
10-
#define TGINT_H
11-
template <typename T>
12-
struct TGint;
13-
template <> struct TGint<double> { using type = Gint_Gamma; };
14-
template <> struct TGint<std::complex<double>> { using type = Gint_k; };
15-
#endif
167

178
/// calculate the abstract formulas:
189
/// $Tr[D*dH/dx]$ (force) and $1/V Tr[D*(dH/dx_a*x_b)]$ (stress)
@@ -60,7 +51,6 @@ namespace PulayForceStress
6051
const elecstate::DensityMatrix<TK, TR>& dm, ///< [in] density matrix or energy density matrix
6152
const UnitCell& ucell, ///< [in] unit cell
6253
const elecstate::Potential* pot, ///< [in] potential on grid
63-
typename TGint<TK>::type& gint, ///< [in] Gint object
6454
const bool& isforce,
6555
const bool& isstress,
6656
const bool& set_dmr_gint = true);

0 commit comments

Comments
 (0)