Skip to content

Commit e208fe0

Browse files
committed
add GlobalC::solvent_model, add delta_phi, TOTN_real.
1 parent 6b2afdc commit e208fe0

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

source/module_surchem/cal_vel.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
5757
ModuleBase::TITLE("surchem", "cal_vel");
5858
ModuleBase::timer::tick("surchem", "cal_vel");
5959

60-
double *TOTN_real = new double[pwb.nrxx];
60+
// double *TOTN_real = new double[pwb.nrxx];
6161
GlobalC::UFFT.ToRealSpace(TOTN, TOTN_real);
6262

6363
// -4pi * TOTN(G)
@@ -93,20 +93,20 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
9393

9494
double *phi_tilda_R = new double[pwb.nrxx];
9595
double *phi_tilda_R0 = new double[pwb.nrxx];
96-
double *delta_phi_R = new double[pwb.nrxx];
96+
// double *delta_phi_R = new double[pwb.nrxx];
9797

9898
GlobalC::UFFT.ToRealSpace(Sol_phi, phi_tilda_R);
9999
GlobalC::UFFT.ToRealSpace(Sol_phi0, phi_tilda_R0);
100100

101101
// the 1st item of Vel
102102
for (int i = 0; i < pwb.nrxx; i++)
103103
{
104-
delta_phi_R[i] = phi_tilda_R[i] - phi_tilda_R0[i];
105-
Vel[i] += delta_phi_R[i];
104+
delta_phi[i] = phi_tilda_R[i] - phi_tilda_R0[i];
105+
Vel[i] += delta_phi[i];
106106
}
107107

108108
// calculate Ael
109-
double Ael = cal_Ael(cell, pwb, TOTN_real, delta_phi_R);
109+
double Ael = cal_Ael(cell, pwb, TOTN_real, delta_phi);
110110

111111
// the 2nd item of Vel
112112
double *Vel2 = new double[pwb.nrxx];
@@ -147,10 +147,10 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
147147
delete[] epsilon0;
148148
delete[] Vel;
149149
delete[] Vel2;
150-
delete[] TOTN_real;
150+
// delete[] TOTN_real;
151151
delete[] phi_tilda_R;
152152
delete[] phi_tilda_R0;
153-
delete[] delta_phi_R;
153+
// delete[] delta_phi_R;
154154

155155
ModuleBase::timer::tick("surchem", "cal_vel");
156156
return v;

source/module_surchem/surchem.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
#include "surchem.h"
22

3+
namespace GlobalC
4+
{
5+
surchem solvent_model;
6+
}
7+
38
surchem::surchem()
49
{
5-
10+
TOTN_real = new double[1];
11+
delta_phi = new double[1];
612
}
713

8-
surchem::~surchem()
14+
void surchem::allocate(const int &nrxx)
915
{
16+
delete[] TOTN_real;
17+
delete[] delta_phi;
18+
TOTN_real = new double[nrxx];
19+
delta_phi = new double[nrxx];
20+
}
1021

22+
surchem::~surchem()
23+
{
24+
delete[] TOTN_real;
25+
delete[] delta_phi;
1126
}

source/module_surchem/surchem.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ class surchem
1717
surchem();
1818
~surchem();
1919

20+
double *TOTN_real;
21+
double *delta_phi;
22+
2023
atom_in GetAtom;
2124

25+
void allocate(const int &nrxx);
26+
2227
void cal_epsilon(PW_Basis &pwb, const double *PS_TOTN_real, double *epsilon, double *epsilon0);
2328

2429
void cal_pseudo(const UnitCell &cell,
@@ -73,4 +78,9 @@ class surchem
7378
private:
7479
};
7580

81+
namespace GlobalC
82+
{
83+
extern surchem solvent_model;
84+
}
85+
7686
#endif

source/src_pw/potential.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ void Potential::allocate(const int nrxx)
6161
this->vnew.create(GlobalV::NSPIN, nrxx);
6262
ModuleBase::Memory::record("Potential", "vnew", GlobalV::NSPIN * nrxx, "double");
6363

64+
if (GlobalV::imp_sol)
65+
{
66+
GlobalC::solvent_model.allocate(nrxx);
67+
}
68+
6469
return;
6570
}
6671

@@ -358,8 +363,9 @@ ModuleBase::matrix Potential::v_of_rho(const double *const *const rho_in, const
358363
v += H_Hartree_pw::v_hartree(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
359364
if (GlobalV::imp_sol)
360365
{
361-
surchem tmp;
362-
v += tmp.v_correction(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
366+
// surchem tmp;
367+
// v += tmp.v_correction(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
368+
v += GlobalC::solvent_model.v_correction(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
363369
}
364370
}
365371

0 commit comments

Comments
 (0)