Skip to content

Commit fe794c4

Browse files
committed
add calculation of Ael and Acav.
1 parent 0370fb9 commit fe794c4

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

source/module_surchem/cal_vcav.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void surchem::createcavity(const UnitCell &ucell, PW_Basis &pwb, const complex<d
122122
// quantum surface area, integral of (gamma*A / n) * |\nabla n|
123123
//=term1 * sqrt_nablan_2
124124
//-------------------------------------------------------------
125-
double qs = 0;
125+
qs = 0;
126126

127127
for (int ir = 0; ir < pwb.nrxx; ir++)
128128
{
@@ -136,7 +136,7 @@ void surchem::createcavity(const UnitCell &ucell, PW_Basis &pwb, const complex<d
136136
// cavitation energy
137137
//-------------------------------------------------------------
138138

139-
double Ael = surchem::cal_Acav(ucell, pwb, qs);
139+
double Ael = cal_Acav(ucell, pwb);
140140

141141
// packs the real array into a complex one
142142
// to G space
@@ -199,6 +199,7 @@ ModuleBase::matrix surchem::cal_vcav(const UnitCell &ucell, PW_Basis &pwb, const
199199
}
200200
}
201201
}
202+
202203
delete[] tmp_Vcav;
203204
ModuleBase::timer::tick("surchem", "cal_vcav");
204205
return Vcav;

source/module_surchem/cal_vel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
106106
}
107107

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

111111
// the 2nd item of tmp_Vel
112112
double *Vel2 = new double[pwb.nrxx];

source/module_surchem/corrected_energy.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "surchem.h"
22

3+
/*
34
double surchem::cal_Ael(const UnitCell &cell, PW_Basis &pwb, const double *TOTN_real, const double *delta_phi_R)
45
{
56
double Ael = 0.0;
@@ -14,6 +15,30 @@ double surchem::cal_Ael(const UnitCell &cell, PW_Basis &pwb, const double *TOTN_
1415
}
1516
1617
double surchem::cal_Acav(const UnitCell &cell, PW_Basis &pwb, double qs)
18+
{
19+
double Acav = 0.0;
20+
Acav = GlobalV::tau * qs;
21+
Acav = Acav * cell.omega * 0.5 / pwb.nxyz;
22+
Parallel_Reduce::reduce_double_pool(Acav);
23+
cout << "Acav: " << Acav << endl;
24+
return Acav;
25+
}
26+
*/
27+
28+
double surchem::cal_Ael(const UnitCell &cell, PW_Basis &pwb)
29+
{
30+
double Ael = 0.0;
31+
for (int ir = 0; ir < pwb.nrxx; ir++)
32+
{
33+
Ael -= TOTN_real[ir] * delta_phi[ir];
34+
}
35+
Parallel_Reduce::reduce_double_pool(Ael);
36+
Ael = Ael * cell.omega * 0.5 / pwb.nxyz;
37+
cout << "Ael: " << Ael << endl;
38+
return Ael;
39+
}
40+
41+
double surchem::cal_Acav(const UnitCell &cell, PW_Basis &pwb)
1742
{
1843
double Acav = 0.0;
1944
Acav = GlobalV::tau * qs;

source/module_surchem/surchem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class surchem
5252
const complex<double> *PS_TOTN,
5353
int nspin);
5454

55-
double cal_Ael(const UnitCell &cell, PW_Basis &pwb, const double *TOTN_real, const double *delta_phi_R);
55+
double cal_Ael(const UnitCell &cell, PW_Basis &pwb);
5656

57-
double cal_Acav(const UnitCell &cell, PW_Basis &pwb, double qs);
57+
double cal_Acav(const UnitCell &cell, PW_Basis &pwb);
5858

5959
void minimize_cg(const UnitCell &ucell,
6060
PW_Basis &pwb,

source/src_pw/potential.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,12 @@ ModuleBase::matrix Potential::v_of_rho(const double *const *const rho_in, const
363363
v += H_Hartree_pw::v_hartree(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
364364
if (GlobalV::imp_sol)
365365
{
366-
// surchem tmp;
367-
// v += tmp.v_correction(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
368366
v += GlobalC::solvent_model.v_correction(GlobalC::ucell, GlobalC::pw, GlobalV::NSPIN, rho_in);
367+
368+
// test energy outside
369+
cout << endl << "energy Outside: " << endl;
370+
GlobalC::solvent_model.cal_Ael(GlobalC::ucell, GlobalC::pw);
371+
GlobalC::solvent_model.cal_Acav(GlobalC::ucell, GlobalC::pw);
369372
}
370373
}
371374

0 commit comments

Comments
 (0)