Skip to content

Commit 480a7ef

Browse files
zgn-26714dyzheng
authored andcommitted
Apply the changes related to force calculation from the develop branch, fixing the memory error bug that occurs during direct cherry-pick.
1 parent 0e0201e commit 480a7ef

File tree

8 files changed

+534
-857
lines changed

8 files changed

+534
-857
lines changed

source/module_hamilt_pw/hamilt_pwdft/forces.cpp

Lines changed: 214 additions & 475 deletions
Large diffs are not rendered by default.

source/module_hamilt_pw/hamilt_pwdft/forces.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Forces
3737
void cal_force(UnitCell& ucell,
3838
ModuleBase::matrix& force,
3939
const elecstate::ElecState& elec,
40-
ModulePW::PW_Basis* rho_basis,
40+
const ModulePW::PW_Basis* rho_basis,
4141
ModuleSymmetry::Symmetry* p_symm,
4242
Structure_Factor* p_sf,
4343
surchem& solvent,
@@ -53,15 +53,15 @@ class Forces
5353

5454
void cal_force_loc(const UnitCell& ucell,
5555
ModuleBase::matrix& forcelc,
56-
ModulePW::PW_Basis* rho_basis,
56+
const ModulePW::PW_Basis* rho_basis,
5757
const ModuleBase::matrix& vloc,
5858
const Charge* const chr);
5959
void cal_force_ew(const UnitCell& ucell,
6060
ModuleBase::matrix& forceion,
61-
ModulePW::PW_Basis* rho_basis,
61+
const ModulePW::PW_Basis* rho_basis,
6262
const Structure_Factor* p_sf);
6363
void cal_force_cc(ModuleBase::matrix& forcecc,
64-
ModulePW::PW_Basis* rho_basis,
64+
const ModulePW::PW_Basis* rho_basis,
6565
const Charge* const chr,
6666
const bool* numeric,
6767
UnitCell& ucell_in);
@@ -96,13 +96,13 @@ class Forces
9696
const UnitCell& ucell_in,
9797
const psi::Psi<complex<FPTYPE>, Device>* psi_in = nullptr);
9898
void cal_force_scc(ModuleBase::matrix& forcescc,
99-
ModulePW::PW_Basis* rho_basis,
99+
const ModulePW::PW_Basis* rho_basis,
100100
const ModuleBase::matrix& v_current,
101101
const bool vnew_exist,
102102
const bool* numeric,
103103
const UnitCell& ucell_in);
104104
void cal_force_us(ModuleBase::matrix& forcenl,
105-
ModulePW::PW_Basis* rho_basis,
105+
const ModulePW::PW_Basis* rho_basis,
106106
const pseudopot_cell_vnl& ppcell_in,
107107
const elecstate::ElecState& elec,
108108
const UnitCell& ucell);
@@ -113,7 +113,7 @@ class Forces
113113
const FPTYPE* rab,
114114
const FPTYPE* rhoc,
115115
FPTYPE* drhocg,
116-
ModulePW::PW_Basis* rho_basis,
116+
const ModulePW::PW_Basis* rho_basis,
117117
int type,
118118
const UnitCell& ucell_in); // used in nonlinear core correction stress
119119
void deriv_drhoc_scc(const bool& numeric,
@@ -122,7 +122,7 @@ class Forces
122122
const FPTYPE* rab,
123123
const FPTYPE* rhoc,
124124
FPTYPE* drhocg,
125-
ModulePW::PW_Basis* rho_basis,
125+
const ModulePW::PW_Basis* rho_basis,
126126
const UnitCell& ucell_in); // used in nonlinear core correction stress
127127
protected:
128128
Device* ctx = {};

source/module_hamilt_pw/hamilt_pwdft/forces_cc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
template <typename FPTYPE, typename Device>
3333
void Forces<FPTYPE, Device>::cal_force_cc(ModuleBase::matrix& forcecc,
34-
ModulePW::PW_Basis* rho_basis,
34+
const ModulePW::PW_Basis* rho_basis,
3535
const Charge* const chr,
3636
const bool* numeric,
3737
UnitCell& ucell_in)
@@ -239,7 +239,7 @@ void Forces<FPTYPE, Device>::deriv_drhoc
239239
const FPTYPE *rab,
240240
const FPTYPE *rhoc,
241241
FPTYPE *drhocg,
242-
ModulePW::PW_Basis* rho_basis,
242+
const ModulePW::PW_Basis* rho_basis,
243243
int type,
244244
const UnitCell& ucell_in
245245
)

source/module_hamilt_pw/hamilt_pwdft/forces_scc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
template <typename FPTYPE, typename Device>
2626
void Forces<FPTYPE, Device>::cal_force_scc(ModuleBase::matrix& forcescc,
27-
ModulePW::PW_Basis* rho_basis,
27+
const ModulePW::PW_Basis* rho_basis,
2828
const ModuleBase::matrix& vnew,
2929
const bool vnew_exist,
3030
const bool* numeric,
@@ -147,7 +147,7 @@ void Forces<FPTYPE, Device>::deriv_drhoc_scc(const bool& numeric,
147147
const FPTYPE* rab,
148148
const FPTYPE* rhoc,
149149
FPTYPE* drhocg,
150-
ModulePW::PW_Basis* rho_basis,
150+
const ModulePW::PW_Basis* rho_basis,
151151
const UnitCell& ucell_in) {
152152
int igl0 = 0;
153153
double gx = 0;

source/module_hamilt_pw/hamilt_pwdft/forces_us.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// On output: the contribution is added to \(\text{forcenl}\).
1616
template <typename FPTYPE, typename Device>
1717
void Forces<FPTYPE, Device>::cal_force_us(ModuleBase::matrix& forcenl,
18-
ModulePW::PW_Basis* rho_basis,
18+
const ModulePW::PW_Basis* rho_basis,
1919
const pseudopot_cell_vnl& nlpp,
2020
const elecstate::ElecState& elec,
2121
const UnitCell& ucell)

0 commit comments

Comments
 (0)