Skip to content

Commit 2a7bbaf

Browse files
committed
update the test file in module_surchem
1 parent 2fb53b3 commit 2a7bbaf

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

source/module_hamilt_general/module_surchem/test/cal_pseudo_test.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class cal_pseudo_test : public testing::Test
2626
{
2727
protected:
2828
surchem solvent_model;
29+
UnitCell ucell;
2930
};
3031

3132
TEST_F(cal_pseudo_test, gauss_charge)
@@ -41,7 +42,7 @@ TEST_F(cal_pseudo_test, gauss_charge)
4142
double wfcecut;
4243
bool gamma_only;
4344

44-
Setcell::setupcell(GlobalC::ucell);
45+
Setcell::setupcell(ucell);
4546

4647
wfcecut = 80;
4748
gamma_only = false;
@@ -60,7 +61,7 @@ TEST_F(cal_pseudo_test, gauss_charge)
6061
#endif
6162
// pwtest.initgrids(lat0,latvec,wfcecut);
6263

63-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
64+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
6465

6566
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
6667
GlobalC::rhopw->setuptransform();
@@ -75,7 +76,7 @@ TEST_F(cal_pseudo_test, gauss_charge)
7576
Structure_Factor sf;
7677
sf.nbspline = -1;
7778

78-
solvent_model.gauss_charge(GlobalC::ucell, GlobalC::rhopw, N, &sf);
79+
solvent_model.gauss_charge(ucell, GlobalC::rhopw, N, &sf);
7980

8081
EXPECT_NEAR(N[14].real(), 0.002, 1e-9);
8182
EXPECT_NEAR(N[16].real(), -0.001573534, 1e-9);
@@ -115,7 +116,7 @@ TEST_F(cal_pseudo_test, cal_pseudo)
115116
#endif
116117
// pwtest.initgrids(lat0,latvec,wfcecut);
117118

118-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
119+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
119120
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
120121
GlobalC::rhopw->setuptransform();
121122
GlobalC::rhopw->collect_local_pw();
@@ -135,7 +136,7 @@ TEST_F(cal_pseudo_test, cal_pseudo)
135136
}
136137

137138
complex<double>* PS_TOTN = new complex<double>[npw];
138-
solvent_model.cal_pseudo(GlobalC::ucell, GlobalC::rhopw, Porter_g, PS_TOTN, &sf);
139+
solvent_model.cal_pseudo(ucell, GlobalC::rhopw, Porter_g, PS_TOTN, &sf);
139140

140141
EXPECT_NEAR(PS_TOTN[16].real(), 0.098426466, 1e-9);
141142
EXPECT_NEAR(PS_TOTN[14].real(), 0.102, 1e-9);

source/module_hamilt_general/module_surchem/test/cal_totn_test.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class cal_totn_test : public testing::Test
2525
{
2626
protected:
2727
surchem solvent_model;
28+
UnitCell ucell;
2829
};
2930

3031
TEST_F(cal_totn_test, cal_totn)
@@ -40,7 +41,7 @@ TEST_F(cal_totn_test, cal_totn)
4041
double wfcecut;
4142
bool gamma_only;
4243

43-
Setcell::setupcell(GlobalC::ucell);
44+
Setcell::setupcell(ucell);
4445

4546
wfcecut = 80;
4647
gamma_only = false;
@@ -59,7 +60,7 @@ TEST_F(cal_totn_test, cal_totn)
5960
#endif
6061
// pwtest.initgrids(lat0,latvec,wfcecut);
6162

62-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
63+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
6364

6465
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
6566
GlobalC::rhopw->setuptransform();
@@ -87,7 +88,7 @@ TEST_F(cal_totn_test, cal_totn)
8788
vloc[i] = 0.1;
8889
}
8990

90-
solvent_model.cal_totn(GlobalC::ucell, GlobalC::rhopw, Porter_g, N, TOTN, vloc);
91+
solvent_model.cal_totn(ucell, GlobalC::rhopw, Porter_g, N, TOTN, vloc);
9192

9293
EXPECT_NEAR(TOTN[0].real(), -0.0999496256, 1e-10);
9394
EXPECT_NEAR(TOTN[0].imag(), -1.299621928166352e-7, 1e-10);
@@ -128,15 +129,15 @@ TEST_F(cal_totn_test, induced_charge)
128129
#endif
129130
// pwtest.initgrids(lat0,latvec,wfcecut);
130131

131-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
132+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
132133

133134
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
134135
GlobalC::rhopw->setuptransform();
135136
GlobalC::rhopw->collect_local_pw();
136137
GlobalC::rhopw->collect_uniqgg();
137138

138139
double fac;
139-
fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (GlobalC::ucell.tpiba2 * GlobalC::rhopw->gg[0]);
140+
fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (ucell.tpiba2 * GlobalC::rhopw->gg[0]);
140141
complex<double> delta_phi{-2.0347933860e-05, 4.5900395826e-07};
141142
complex<double> induced_charge;
142143
induced_charge = -delta_phi / fac;

source/module_hamilt_general/module_surchem/test/cal_vcav_test.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ class cal_vcav_test : public testing::Test
3030
{
3131
protected:
3232
surchem solvent_model;
33+
UnitCell ucell;
3334
};
3435
TEST_F(cal_vcav_test, lapl_rho)
3536
{
36-
Setcell::setupcell(GlobalC::ucell);
37+
Setcell::setupcell(ucell);
3738

3839
std::string precision_flag, device_flag;
3940
precision_flag = "double";
@@ -61,7 +62,7 @@ TEST_F(cal_vcav_test, lapl_rho)
6162
#ifdef __MPI
6263
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
6364
#endif
64-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
65+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
6566

6667
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
6768
GlobalC::rhopw->setuptransform();
@@ -93,7 +94,7 @@ TEST_F(cal_vcav_test, lapl_rho)
9394
GlobalC::rhopw->recip2real(aux, aux);
9495
for (int ir = 0; ir < nrxx; ir++)
9596
{
96-
lapn[ir] -= aux[ir].real() * GlobalC::ucell.tpiba2;
97+
lapn[ir] -= aux[ir].real() * ucell.tpiba2;
9798
}
9899
}
99100

@@ -140,7 +141,7 @@ TEST_F(cal_vcav_test, shape_gradn)
140141

141142
TEST_F(cal_vcav_test, createcavity)
142143
{
143-
Setcell::setupcell(GlobalC::ucell);
144+
Setcell::setupcell(ucell);
144145

145146
std::string precision_flag, device_flag;
146147
precision_flag = "double";
@@ -168,7 +169,7 @@ TEST_F(cal_vcav_test, createcavity)
168169
#ifdef __MPI
169170
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
170171
#endif
171-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
172+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
172173

173174
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
174175
GlobalC::rhopw->setuptransform();
@@ -190,7 +191,7 @@ TEST_F(cal_vcav_test, createcavity)
190191
PS_TOTN[ig] = 1e-7;
191192
}
192193

193-
solvent_model.createcavity(GlobalC::ucell, GlobalC::rhopw, PS_TOTN, vwork);
194+
solvent_model.createcavity(ucell, GlobalC::rhopw, PS_TOTN, vwork);
194195

195196
EXPECT_NEAR(vwork[0], 4.8556305312, 1e-10);
196197
EXPECT_NEAR(vwork[1], -2.1006480538, 1e-10);
@@ -201,7 +202,7 @@ TEST_F(cal_vcav_test, createcavity)
201202

202203
TEST_F(cal_vcav_test, cal_vcav)
203204
{
204-
Setcell::setupcell(GlobalC::ucell);
205+
Setcell::setupcell(ucell);
205206

206207
std::string precision_flag, device_flag;
207208
precision_flag = "double";
@@ -229,7 +230,7 @@ TEST_F(cal_vcav_test, cal_vcav)
229230
#ifdef __MPI
230231
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
231232
#endif
232-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
233+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
233234

234235
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
235236
GlobalC::rhopw->setuptransform();
@@ -252,7 +253,7 @@ TEST_F(cal_vcav_test, cal_vcav)
252253
int nspin = 2;
253254
solvent_model.Vcav.create(nspin, nrxx);
254255

255-
solvent_model.cal_vcav(GlobalC::ucell, GlobalC::rhopw, PS_TOTN, nspin);
256+
solvent_model.cal_vcav(ucell, GlobalC::rhopw, PS_TOTN, nspin);
256257

257258
EXPECT_NEAR(solvent_model.Vcav(0, 0), 4.8556305312, 1e-10);
258259
EXPECT_NEAR(solvent_model.Vcav(0, 1), -2.1006480538, 1e-10);

source/module_hamilt_general/module_surchem/test/cal_vel_test.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class cal_vel_test : public testing::Test
3131
{
3232
protected:
3333
surchem solvent_model;
34+
UnitCell ucell;
3435
};
3536

3637
TEST_F(cal_vel_test, shape_gradn)
@@ -69,7 +70,7 @@ TEST_F(cal_vel_test, shape_gradn)
6970

7071
TEST_F(cal_vel_test, eps_pot)
7172
{
72-
Setcell::setupcell(GlobalC::ucell);
73+
Setcell::setupcell(ucell);
7374

7475
std::string precision_flag, device_flag;
7576
precision_flag = "double";
@@ -97,7 +98,7 @@ TEST_F(cal_vel_test, eps_pot)
9798
#ifdef __MPI
9899
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
99100
#endif
100-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
101+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
101102

102103
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
103104
GlobalC::rhopw->setuptransform();
@@ -142,7 +143,7 @@ TEST_F(cal_vel_test, eps_pot)
142143
ModuleBase::Vector3<double>* nabla_phi = new ModuleBase::Vector3<double>[nrxx];
143144
double* phisq = new double[nrxx];
144145

145-
XC_Functional::grad_rho(phi, nabla_phi, GlobalC::rhopw, GlobalC::ucell.tpiba);
146+
XC_Functional::grad_rho(phi, nabla_phi, GlobalC::rhopw, ucell.tpiba);
146147

147148
for (int ir = 0; ir < nrxx; ir++)
148149
{
@@ -167,7 +168,7 @@ TEST_F(cal_vel_test, eps_pot)
167168

168169
TEST_F(cal_vel_test, cal_vel)
169170
{
170-
Setcell::setupcell(GlobalC::ucell);
171+
Setcell::setupcell(ucell);
171172

172173
std::string precision_flag, device_flag;
173174
precision_flag = "double";
@@ -195,7 +196,7 @@ TEST_F(cal_vel_test, cal_vel)
195196
#ifdef __MPI
196197
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
197198
#endif
198-
GlobalC::rhopw->initgrids(GlobalC::ucell.lat0, GlobalC::ucell.latvec, wfcecut);
199+
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
199200

200201
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
201202
GlobalC::rhopw->setuptransform();
@@ -220,7 +221,7 @@ TEST_F(cal_vel_test, cal_vel)
220221
solvent_model.TOTN_real = new double[nrxx];
221222
solvent_model.delta_phi = new double[nrxx];
222223

223-
solvent_model.cal_vel(GlobalC::ucell, GlobalC::rhopw, TOTN, PS_TOTN, nspin);
224+
solvent_model.cal_vel(ucell, GlobalC::rhopw, TOTN, PS_TOTN, nspin);
224225

225226
EXPECT_NEAR(solvent_model.Vel(0, 0), 0.0532168705, 1e-10);
226227
EXPECT_NEAR(solvent_model.Vel(0, 1), 0.0447818244, 1e-10);

0 commit comments

Comments
 (0)