Skip to content

Commit 0370fb9

Browse files
committed
add vcav, vcel.
1 parent e208fe0 commit 0370fb9

File tree

5 files changed

+39
-22
lines changed

5 files changed

+39
-22
lines changed

source/module_surchem/cal_vcav.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,17 @@ ModuleBase::matrix surchem::cal_vcav(const UnitCell &ucell, PW_Basis &pwb, const
176176
ModuleBase::TITLE("surchem", "cal_vcav");
177177
ModuleBase::timer::tick("surchem", "cal_vcav");
178178

179-
double *Vcav = new double[pwb.nrxx];
180-
ModuleBase::GlobalFunc::ZEROS(Vcav, pwb.nrxx);
179+
double *tmp_Vcav = new double[pwb.nrxx];
180+
ModuleBase::GlobalFunc::ZEROS(tmp_Vcav, pwb.nrxx);
181181

182-
createcavity(ucell, pwb, PS_TOTN, Vcav);
182+
createcavity(ucell, pwb, PS_TOTN, tmp_Vcav);
183183

184-
ModuleBase::matrix v(nspin, pwb.nrxx);
184+
ModuleBase::GlobalFunc::ZEROS(Vcav.c, nspin * pwb.nrxx);
185185
if (nspin == 4)
186186
{
187187
for (int ir = 0; ir < pwb.nrxx; ir++)
188188
{
189-
v(0, ir) += Vcav[ir];
189+
Vcav(0, ir) += tmp_Vcav[ir];
190190
}
191191
}
192192
else
@@ -195,11 +195,11 @@ ModuleBase::matrix surchem::cal_vcav(const UnitCell &ucell, PW_Basis &pwb, const
195195
{
196196
for (int ir = 0; ir < pwb.nrxx; ir++)
197197
{
198-
v(is, ir) += Vcav[ir];
198+
Vcav(is, ir) += tmp_Vcav[ir];
199199
}
200200
}
201201
}
202-
delete[] Vcav;
202+
delete[] tmp_Vcav;
203203
ModuleBase::timer::tick("surchem", "cal_vcav");
204-
return v;
204+
return Vcav;
205205
}

source/module_surchem/cal_vel.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
8080
complex<double> *Sol_phi0 = new complex<double>[pwb.ngmc];
8181
int ncgsol = 0;
8282

83-
double *Vel = new double[pwb.nrxx];
84-
ModuleBase::GlobalFunc::ZEROS(Vel, pwb.nrxx);
83+
double *tmp_Vel = new double[pwb.nrxx];
84+
ModuleBase::GlobalFunc::ZEROS(tmp_Vel, pwb.nrxx);
8585

8686
// Calculate Sol_phi with epsilon.
8787
ncgsol = 0;
@@ -98,34 +98,35 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
9898
GlobalC::UFFT.ToRealSpace(Sol_phi, phi_tilda_R);
9999
GlobalC::UFFT.ToRealSpace(Sol_phi0, phi_tilda_R0);
100100

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

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

111-
// the 2nd item of Vel
111+
// the 2nd item of tmp_Vel
112112
double *Vel2 = new double[pwb.nrxx];
113113
ModuleBase::GlobalFunc::ZEROS(Vel2, pwb.nrxx);
114114

115115
eps_pot(PS_TOTN_real, Sol_phi, pwb, epsilon, Vel2);
116116

117117
for (int i = 0; i < pwb.nrxx; i++)
118118
{
119-
Vel[i] += Vel2[i];
119+
tmp_Vel[i] += Vel2[i];
120120
}
121121

122-
ModuleBase::matrix v(nspin, pwb.nrxx);
122+
// ModuleBase::matrix v(nspin, pwb.nrxx);
123+
ModuleBase::GlobalFunc::ZEROS(Vel.c, nspin * pwb.nrxx);
123124

124125
if (nspin == 4)
125126
{
126127
for (int ir = 0; ir < pwb.nrxx; ir++)
127128
{
128-
v(0, ir) += Vel[ir];
129+
Vel(0, ir) += tmp_Vel[ir];
129130
}
130131
}
131132
else
@@ -134,7 +135,7 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
134135
{
135136
for (int ir = 0; ir < pwb.nrxx; ir++)
136137
{
137-
v(is, ir) += Vel[ir];
138+
Vel(is, ir) += tmp_Vel[ir];
138139
}
139140
}
140141
}
@@ -145,13 +146,13 @@ ModuleBase::matrix surchem::cal_vel(const UnitCell &cell,
145146
delete[] B;
146147
delete[] epsilon;
147148
delete[] epsilon0;
148-
delete[] Vel;
149+
delete[] tmp_Vel;
149150
delete[] Vel2;
150151
// delete[] TOTN_real;
151152
delete[] phi_tilda_R;
152153
delete[] phi_tilda_R0;
153154
// delete[] delta_phi_R;
154155

155156
ModuleBase::timer::tick("surchem", "cal_vel");
156-
return v;
157+
return Vel;
157158
}

source/module_surchem/surchem.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@ surchem::surchem()
99
{
1010
TOTN_real = new double[1];
1111
delta_phi = new double[1];
12+
Vcav = ModuleBase::matrix();
13+
Vel = ModuleBase::matrix();
14+
qs = 0;
1215
}
1316

14-
void surchem::allocate(const int &nrxx)
17+
void surchem::allocate(const int &nrxx, const int &nspin)
1518
{
19+
assert(nrxx > 0);
20+
assert(nspin > 0);
21+
1622
delete[] TOTN_real;
1723
delete[] delta_phi;
24+
1825
TOTN_real = new double[nrxx];
1926
delta_phi = new double[nrxx];
27+
Vcav.create(nspin, nrxx);
28+
Vel.create(nspin, nrxx);
29+
30+
ModuleBase::GlobalFunc::ZEROS(delta_phi, nrxx);
31+
ModuleBase::GlobalFunc::ZEROS(TOTN_real, nrxx);
32+
return;
2033
}
2134

2235
surchem::~surchem()

source/module_surchem/surchem.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ class surchem
1919

2020
double *TOTN_real;
2121
double *delta_phi;
22+
ModuleBase::matrix Vcav;
23+
ModuleBase::matrix Vel;
24+
double qs;
2225

2326
atom_in GetAtom;
2427

25-
void allocate(const int &nrxx);
28+
void allocate(const int &nrxx, const int &nspin);
2629

2730
void cal_epsilon(PW_Basis &pwb, const double *PS_TOTN_real, double *epsilon, double *epsilon0);
2831

source/src_pw/potential.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void Potential::allocate(const int nrxx)
6363

6464
if (GlobalV::imp_sol)
6565
{
66-
GlobalC::solvent_model.allocate(nrxx);
66+
GlobalC::solvent_model.allocate(nrxx, GlobalV::NSPIN);
6767
}
6868

6969
return;

0 commit comments

Comments
 (0)