Skip to content

Commit 59b73f5

Browse files
committed
fix bug
1 parent a224da7 commit 59b73f5

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

source/module_basis/module_pw/test_serial/pw_basis_k_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ TEST_F(PWBasisKTEST,Constructor)
4949
EXPECT_EQ(basis_k2.fft_bundle.precision,"double");
5050
ModulePW::PW_Basis_K basis_k3(device_flag, precision_single);
5151
EXPECT_EQ(basis_k3.precision,"single");
52-
EXPECT_EQ(basis_k3.fft_bundle.precision,"mixing");
52+
EXPECT_EQ(basis_k3.fft_bundle.precision,"single");
5353
}
5454

5555
TEST_F(PWBasisKTEST,Initgrids1)

source/module_esolver/esolver_fp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ ESolver_FP::ESolver_FP()
2727

2828
ESolver_FP::~ESolver_FP()
2929
{
30-
delete pw_rho;
30+
if (pw_rho_flag == 1)
31+
{
32+
delete this->pw_rho;
33+
this->pw_rho_flag = 0;
34+
}
3135
if ( PARAM.globalv.double_grid)
3236
{
3337
delete pw_rhod;
@@ -60,6 +64,7 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp)
6064
}
6165
#endif
6266
pw_rho = new ModulePW::PW_Basis_Big(fft_device, fft_precison);
67+
pw_rho_flag = 1;
6368
if (PARAM.globalv.double_grid)
6469
{
6570
pw_rhod = new ModulePW::PW_Basis_Big(fft_device, fft_precison);

source/module_esolver/esolver_fp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ class ESolver_FP: public ESolver
9595

9696
//! solvent model
9797
surchem solvent;
98+
99+
int pw_rho_flag = 0; ///< flag for pw_rho, 0: not initialized, 1: initialized
100+
98101
};
99102
} // namespace ModuleESolver
100103

source/module_lr/esolver_lrtd_lcao.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,11 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
226226
this->gint_->reset_DMRGint(1);
227227

228228
// move pw basis
229-
delete this->pw_rho; // newed in ESolver_FP::ESolver_FP
229+
if (this->pw_rho_flag)
230+
{
231+
this->pw_rho_flag = 0;
232+
delete this->pw_rho; // newed in ESolver_FP::ESolver_FP
233+
}
230234
this->pw_rho = ks_sol.pw_rho;
231235
ks_sol.pw_rho = nullptr;
232236
//init potential and calculate kernels using ground state charge

0 commit comments

Comments
 (0)