Skip to content

Commit 440b690

Browse files
committed
update esolver
1 parent 38093a1 commit 440b690

File tree

10 files changed

+38
-8
lines changed

10 files changed

+38
-8
lines changed

source/source_esolver/esolver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class ESolver
1717

1818
virtual ~ESolver()
1919
{
20+
//****************************************************
21+
// do not add any codes in this deconstructor funcion
22+
//****************************************************
2023
}
2124

2225
//! initialize the energy solver by using input parameters and cell modules

source/source_esolver/esolver_fp.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ ESolver_FP::ESolver_FP()
2727

2828
ESolver_FP::~ESolver_FP()
2929
{
30-
delete this->pelec;
30+
//****************************************************
31+
// do not add any codes in this deconstructor funcion
32+
//****************************************************
33+
// mohan add 20251005
34+
pw::teardown_pwrho(this->pw_rho_flag, PARAM.globalv.double_grid, this->pw_rho, this->pw_rhod);
35+
36+
delete this->pelec;
3137
}
3238

3339
void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
@@ -257,8 +263,6 @@ void ESolver_FP::after_all_runners(UnitCell& ucell)
257263
GlobalV::ofs_running << " !FINAL_ETOT_IS " << this->pelec->f_en.etot * ModuleBase::Ry_to_eV << " eV" << std::endl;
258264
GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl;
259265

260-
// mohan add 20251005
261-
pw::teardown_pwrho(this->pw_rho_flag, PARAM.globalv.double_grid, this->pw_rho, this->pw_rhod);
262266
}
263267

264268
} // namespace ModuleESolver

source/source_esolver/esolver_ks.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ ESolver_KS<T, Device>::ESolver_KS()
3838
template <typename T, typename Device>
3939
ESolver_KS<T, Device>::~ESolver_KS()
4040
{
41-
delete this->psi;
41+
//****************************************************
42+
// do not add any codes in this deconstructor funcion
43+
//****************************************************
44+
delete this->psi;
4245
delete this->pw_wfc;
4346
delete this->p_hamilt;
4447
delete this->p_chgmix;

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ ESolver_KS_LCAO<TK, TR>::ESolver_KS_LCAO()
9797
template <typename TK, typename TR>
9898
ESolver_KS_LCAO<TK, TR>::~ESolver_KS_LCAO()
9999
{
100+
//****************************************************
101+
// do not add any codes in this deconstructor funcion
102+
//****************************************************
100103
}
101104

102105
template <typename TK, typename TR>

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ ESolver_KS_LCAO_TDDFT<TR, Device>::ESolver_KS_LCAO_TDDFT()
5757
template <typename TR, typename Device>
5858
ESolver_KS_LCAO_TDDFT<TR, Device>::~ESolver_KS_LCAO_TDDFT()
5959
{
60-
delete psi_laststep;
60+
//****************************************************
61+
// do not add any codes in this deconstructor funcion
62+
//****************************************************
63+
delete psi_laststep;
6164
if (Hk_laststep != nullptr)
6265
{
6366
for (int ik = 0; ik < this->kv.get_nks(); ++ik)

source/source_esolver/esolver_ks_lcaopw.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ namespace ModuleESolver
5151
template <typename T>
5252
ESolver_KS_LIP<T>::~ESolver_KS_LIP()
5353
{
54+
//****************************************************
55+
// do not add any codes in this deconstructor funcion
56+
//****************************************************
5457
delete this->psi_local;
5558
// delete Hamilt
5659
this->deallocate_hamilt();

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ ESolver_KS_PW<T, Device>::ESolver_KS_PW()
4242
template <typename T, typename Device>
4343
ESolver_KS_PW<T, Device>::~ESolver_KS_PW()
4444
{
45-
// delete Hamilt
45+
//****************************************************
46+
// do not add any codes in this deconstructor funcion
47+
//****************************************************
48+
// delete Hamilt
4649
this->deallocate_hamilt();
4750

4851
if (PARAM.inp.device == "gpu" || PARAM.inp.precision == "single")

source/source_esolver/esolver_of.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ ESolver_OF::ESolver_OF()
2525

2626
ESolver_OF::~ESolver_OF()
2727
{
28-
delete psi_;
28+
//****************************************************
29+
// do not add any codes in this deconstructor funcion
30+
//****************************************************
31+
delete psi_;
2932
delete[] this->pphi_;
3033

3134
for (int i = 0; i < PARAM.inp.nspin; ++i)

source/source_esolver/esolver_sdft_pw.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ ESolver_SDFT_PW<T, Device>::ESolver_SDFT_PW()
2727
template <typename T, typename Device>
2828
ESolver_SDFT_PW<T, Device>::~ESolver_SDFT_PW()
2929
{
30+
//****************************************************
31+
// do not add any codes in this deconstructor funcion
32+
//****************************************************
3033
}
3134

3235
template <typename T, typename Device>

source/source_pw/module_pwdft/setup_pwrho.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ void pw::teardown_pwrho(bool &pw_rho_flag,
126126
if (pw_rho_flag == true)
127127
{
128128
delete pw_rho;
129+
pw_rho = nullptr;
129130
pw_rho_flag = false;
130131
}
131132

132-
if (double_grid)
133+
if (double_grid == true)
133134
{
134135
delete pw_rhod;
136+
pw_rhod = nullptr;
135137
}
136138

137139
return;

0 commit comments

Comments
 (0)