Skip to content

Commit 06cffb7

Browse files
authored
Rafactor:remove GlobalC::rhopw (#6093)
* remove the namespace * remove the rhopw * move back dftu * modify back paw
1 parent d1d14f2 commit 06cffb7

File tree

16 files changed

+103
-138
lines changed

16 files changed

+103
-138
lines changed

source/module_base/kernels/math_ylm_op.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct cal_ylm_real_op {
2020
/// @param PI_HALF - ModuleBase::PI_HALF
2121
/// @param FOUR_PI - ModuleBase::FOUR_PI,
2222
/// @param SQRT_INVERSE_FOUR_PI - ModuleBase::SQRT_INVERSE_FOUR_PI,
23-
/// @param g - input array with size npw * 3, GlobalC::wf.get_1qvec_cartesian
23+
/// @param g - input array with size npw * 3, wf.get_1qvec_cartesian
2424
/// @param p - intermediate array
2525
///
2626
/// Output Parameters

source/module_basis/module_nao/two_center_bundle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TwoCenterBundle
2828
void tabulate(const double lcao_ecut, const double lcao_dk, const double lcao_dr, const double lcao_rmax);
2929

3030
/**
31-
* @brief Overwrites the content of a LCAO_Orbitals object (e.g. GlobalC::ORB)
31+
* @brief Overwrites the content of a LCAO_Orbitals object (e.g. ORB)
3232
* with the current object.
3333
*
3434
* This function provides an interface to the corresponding object in the old module_ao.

source/module_cell/test/klist_test.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ Fcoef::~Fcoef()
8484
{
8585
}
8686

87-
namespace GlobalC
88-
{
89-
Parallel_Kpoints Pkpoints;
90-
} // namespace GlobalC
9187

9288
/************************************************
9389
* unit test of class K_Vectors

source/module_cell/test/klist_test_para.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ Fcoef::~Fcoef()
8787
{
8888
}
8989

90-
namespace GlobalC
91-
{
92-
Parallel_Kpoints Pkpoints;
93-
UnitCell ucell;
94-
} // namespace GlobalC
9590

9691
/************************************************
9792
* unit test of class K_Vectors

source/module_hamilt_general/module_surchem/test/cal_epsilon_test.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ TEST_F(cal_epsilon_test, cal_epsilon)
4545
device_flag = "cpu";
4646

4747
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
48-
GlobalC::rhopw = &pwtest;
49-
5048
ModuleBase::Matrix3 latvec;
5149
int nx, ny, nz; // f*G
5250
double wfcecut;
@@ -70,17 +68,17 @@ TEST_F(cal_epsilon_test, cal_epsilon)
7068
#endif
7169

7270
#ifdef __MPI
73-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
71+
pwtest.initmpi(1, 0, POOL_WORLD);
7472
#endif
7573
// pwtest.initgrids(lat0,latvec,wfcecut);
76-
GlobalC::rhopw->initgrids(lat0, latvec, wfcecut);
77-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
78-
GlobalC::rhopw->setuptransform();
79-
GlobalC::rhopw->collect_local_pw();
74+
pwtest.initgrids(lat0, latvec, wfcecut);
75+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
76+
pwtest.setuptransform();
77+
pwtest.collect_local_pw();
8078

81-
GlobalC::rhopw->nrxx = 125000;
82-
const int npw = GlobalC::rhopw->npw;
83-
const int nrxx = GlobalC::rhopw->nrxx;
79+
pwtest.nrxx = 125000;
80+
const int npw = pwtest.npw;
81+
const int nrxx = pwtest.nrxx;
8482

8583
std::ifstream fin;
8684
fin.open("./support/PS_TOTN_real.in");
@@ -99,8 +97,7 @@ TEST_F(cal_epsilon_test, cal_epsilon)
9997
double* epsilon = new double[nrxx];
10098
double* epsilon0 = new double[nrxx];
10199

102-
GlobalC::rhopw = &pwtest;
103-
solvent_model.cal_epsilon(GlobalC::rhopw, PS_TOTN_real, epsilon, epsilon0);
100+
solvent_model.cal_epsilon(&pwtest, PS_TOTN_real, epsilon, epsilon0);
104101

105102
EXPECT_EQ(PS_TOTN_real[0], 0.274231);
106103
EXPECT_EQ(epsilon[0], 1);

source/module_hamilt_general/module_surchem/test/cal_pseudo_test.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ TEST_F(cal_pseudo_test, gauss_charge)
3737
device_flag = "cpu";
3838

3939
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
40-
GlobalC::rhopw = &pwtest;
4140
ModuleBase::Matrix3 latvec;
4241
int nx, ny, nz; // f*G
4342
double wfcecut;
@@ -58,26 +57,26 @@ TEST_F(cal_pseudo_test, gauss_charge)
5857
#endif
5958

6059
#ifdef __MPI
61-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
60+
pwtest.initmpi(1, 0, POOL_WORLD);
6261
#endif
6362
// pwtest.initgrids(lat0,latvec,wfcecut);
6463

65-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
64+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
6665

67-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
68-
GlobalC::rhopw->setuptransform();
69-
GlobalC::rhopw->collect_local_pw();
70-
GlobalC::rhopw->collect_uniqgg();
66+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
67+
pwtest.setuptransform();
68+
pwtest.collect_local_pw();
69+
pwtest.collect_uniqgg();
7170

72-
const int npw = GlobalC::rhopw->npw;
73-
const int nrxx = GlobalC::rhopw->nrxx;
71+
const int npw = pwtest.npw;
72+
const int nrxx = pwtest.nrxx;
7473
complex<double>* N = new complex<double>[npw];
7574
ModuleBase::GlobalFunc::ZEROS(N, npw);
7675

7776
Structure_Factor sf;
7877
sf.nbspline = -1;
7978

80-
solvent_model.gauss_charge(ucell, pgrid, GlobalC::rhopw, N, &sf);
79+
solvent_model.gauss_charge(ucell, pgrid, &pwtest, N, &sf);
8180

8281
EXPECT_NEAR(N[14].real(), 0.002, 1e-9);
8382
EXPECT_NEAR(N[16].real(), -0.001573534, 1e-9);
@@ -92,7 +91,6 @@ TEST_F(cal_pseudo_test, cal_pseudo)
9291
device_flag = "cpu";
9392
Setcell::setupcell(ucell);
9493
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
95-
GlobalC::rhopw = &pwtest;
9694
ModuleBase::Matrix3 latvec;
9795
int nx, ny, nz; // f*G
9896
double wfcecut;
@@ -113,18 +111,18 @@ TEST_F(cal_pseudo_test, cal_pseudo)
113111
#endif
114112

115113
#ifdef __MPI
116-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
114+
pwtest.initmpi(1, 0, POOL_WORLD);
117115
#endif
118116
// pwtest.initgrids(lat0,latvec,wfcecut);
119117

120-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
121-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
122-
GlobalC::rhopw->setuptransform();
123-
GlobalC::rhopw->collect_local_pw();
124-
GlobalC::rhopw->collect_uniqgg();
118+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
119+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
120+
pwtest.setuptransform();
121+
pwtest.collect_local_pw();
122+
pwtest.collect_uniqgg();
125123

126-
const int npw = GlobalC::rhopw->npw;
127-
const int nrxx = GlobalC::rhopw->nrxx;
124+
const int npw = pwtest.npw;
125+
const int nrxx = pwtest.nrxx;
128126

129127
Structure_Factor sf;
130128
sf.nbspline = -1;
@@ -137,7 +135,7 @@ TEST_F(cal_pseudo_test, cal_pseudo)
137135
}
138136

139137
complex<double>* PS_TOTN = new complex<double>[npw];
140-
solvent_model.cal_pseudo(ucell, pgrid, GlobalC::rhopw, Porter_g, PS_TOTN, &sf);
138+
solvent_model.cal_pseudo(ucell, pgrid, &pwtest, Porter_g, PS_TOTN, &sf);
141139

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

source/module_hamilt_general/module_surchem/test/cal_totn_test.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ TEST_F(cal_totn_test, cal_totn)
3535
device_flag = "cpu";
3636

3737
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
38-
GlobalC::rhopw = &pwtest;
3938
ModuleBase::Matrix3 latvec;
4039
int nx, ny, nz; // f*G
4140
double wfcecut;
@@ -56,19 +55,19 @@ TEST_F(cal_totn_test, cal_totn)
5655
#endif
5756

5857
#ifdef __MPI
59-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
58+
pwtest.initmpi(1, 0, POOL_WORLD);
6059
#endif
6160
// pwtest.initgrids(lat0,latvec,wfcecut);
6261

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

65-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
66-
GlobalC::rhopw->setuptransform();
67-
GlobalC::rhopw->collect_local_pw();
68-
GlobalC::rhopw->collect_uniqgg();
64+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
65+
pwtest.setuptransform();
66+
pwtest.collect_local_pw();
67+
pwtest.collect_uniqgg();
6968

70-
const int npw = GlobalC::rhopw->npw;
71-
const int nrxx = GlobalC::rhopw->nrxx;
69+
const int npw = pwtest.npw;
70+
const int nrxx = pwtest.nrxx;
7271
complex<double>* N = new complex<double>[npw];
7372
ModuleBase::GlobalFunc::ZEROS(N, npw);
7473
complex<double>* TOTN = new complex<double>[npw];
@@ -88,7 +87,7 @@ TEST_F(cal_totn_test, cal_totn)
8887
vloc[i] = 0.1;
8988
}
9089

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

9392
EXPECT_NEAR(TOTN[0].real(), -0.0999496256, 1e-10);
9493
EXPECT_NEAR(TOTN[0].imag(), -1.299621928166352e-7, 1e-10);
@@ -107,7 +106,6 @@ TEST_F(cal_totn_test, induced_charge)
107106
Setcell::setupcell(ucell);
108107

109108
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
110-
GlobalC::rhopw = &pwtest;
111109
ModuleBase::Matrix3 latvec;
112110
int nx, ny, nz; // f*G
113111
double wfcecut;
@@ -126,19 +124,19 @@ TEST_F(cal_totn_test, induced_charge)
126124
#endif
127125

128126
#ifdef __MPI
129-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
127+
pwtest.initmpi(1, 0, POOL_WORLD);
130128
#endif
131129
// pwtest.initgrids(lat0,latvec,wfcecut);
132130

133-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
131+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
134132

135-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
136-
GlobalC::rhopw->setuptransform();
137-
GlobalC::rhopw->collect_local_pw();
138-
GlobalC::rhopw->collect_uniqgg();
133+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
134+
pwtest.setuptransform();
135+
pwtest.collect_local_pw();
136+
pwtest.collect_uniqgg();
139137

140138
double fac;
141-
fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (ucell.tpiba2 * GlobalC::rhopw->gg[0]);
139+
fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (ucell.tpiba2 * pwtest.gg[0]);
142140
complex<double> delta_phi{-2.0347933860e-05, 4.5900395826e-07};
143141
complex<double> induced_charge;
144142
induced_charge = -delta_phi / fac;

source/module_hamilt_general/module_surchem/test/cal_vcav_test.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TEST_F(cal_vcav_test, lapl_rho)
4141
device_flag = "cpu";
4242

4343
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
44-
GlobalC::rhopw = &pwtest;
44+
4545
ModuleBase::Matrix3 latvec;
4646
int nx, ny, nz; // f*G
4747
double wfcecut;
@@ -60,22 +60,22 @@ TEST_F(cal_vcav_test, lapl_rho)
6060
#endif
6161

6262
#ifdef __MPI
63-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
63+
pwtest.initmpi(1, 0, POOL_WORLD);
6464
#endif
65-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
65+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
6666

67-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
68-
GlobalC::rhopw->setuptransform();
69-
GlobalC::rhopw->collect_local_pw();
70-
GlobalC::rhopw->collect_uniqgg();
67+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
68+
pwtest.setuptransform();
69+
pwtest.collect_local_pw();
70+
pwtest.collect_uniqgg();
7171

72-
const int npw = GlobalC::rhopw->npw;
73-
const int nrxx = GlobalC::rhopw->nrxx;
72+
const int npw = pwtest.npw;
73+
const int nrxx = pwtest.nrxx;
7474
std::complex<double>* gdrtmpg = new std::complex<double>[npw];
7575
double* lapn = new double[nrxx];
7676
ModuleBase::GlobalFunc::ZEROS(lapn, nrxx);
7777

78-
std::complex<double>* aux = new std::complex<double>[GlobalC::rhopw->nmaxgr];
78+
std::complex<double>* aux = new std::complex<double>[pwtest.nmaxgr];
7979

8080
gdrtmpg[0] = {2.431e-07, 4.760e-08};
8181
gdrtmpg[1] = {-7.335e-08, 9.826e-07};
@@ -89,9 +89,9 @@ TEST_F(cal_vcav_test, lapl_rho)
8989
{
9090
for (int ig = 0; ig < npw; ig++)
9191
{
92-
aux[ig] = gdrtmpg[ig] * pow(GlobalC::rhopw->gcar[ig][i], 2);
92+
aux[ig] = gdrtmpg[ig] * pow(pwtest.gcar[ig][i], 2);
9393
}
94-
GlobalC::rhopw->recip2real(aux, aux);
94+
pwtest.recip2real(aux, aux);
9595
for (int ir = 0; ir < nrxx; ir++)
9696
{
9797
lapn[ir] -= aux[ir].real() * ucell.tpiba2;
@@ -148,7 +148,7 @@ TEST_F(cal_vcav_test, createcavity)
148148
device_flag = "cpu";
149149

150150
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
151-
GlobalC::rhopw = &pwtest;
151+
152152
ModuleBase::Matrix3 latvec;
153153
int nx, ny, nz; // f*G
154154
double wfcecut;
@@ -167,17 +167,17 @@ TEST_F(cal_vcav_test, createcavity)
167167
#endif
168168

169169
#ifdef __MPI
170-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
170+
pwtest.initmpi(1, 0, POOL_WORLD);
171171
#endif
172-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
172+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
173173

174-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
175-
GlobalC::rhopw->setuptransform();
176-
GlobalC::rhopw->collect_local_pw();
177-
GlobalC::rhopw->collect_uniqgg();
174+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
175+
pwtest.setuptransform();
176+
pwtest.collect_local_pw();
177+
pwtest.collect_uniqgg();
178178

179-
const int npw = GlobalC::rhopw->npw;
180-
const int nrxx = GlobalC::rhopw->nrxx;
179+
const int npw = pwtest.npw;
180+
const int nrxx = pwtest.nrxx;
181181
std::complex<double>* PS_TOTN = new std::complex<double>[npw];
182182
double* vwork = new double[nrxx];
183183
ModuleBase::GlobalFunc::ZEROS(vwork, nrxx);
@@ -191,7 +191,7 @@ TEST_F(cal_vcav_test, createcavity)
191191
PS_TOTN[ig] = 1e-7;
192192
}
193193

194-
solvent_model.createcavity(ucell, GlobalC::rhopw, PS_TOTN, vwork);
194+
solvent_model.createcavity(ucell, &pwtest, PS_TOTN, vwork);
195195

196196
EXPECT_NEAR(vwork[0], 4.8556305312, 1e-10);
197197
EXPECT_NEAR(vwork[1], -2.1006480538, 1e-10);
@@ -209,7 +209,7 @@ TEST_F(cal_vcav_test, cal_vcav)
209209
device_flag = "cpu";
210210

211211
ModulePW::PW_Basis pwtest(device_flag, precision_flag);
212-
GlobalC::rhopw = &pwtest;
212+
213213
ModuleBase::Matrix3 latvec;
214214
int nx, ny, nz;
215215
double wfcecut;
@@ -228,17 +228,17 @@ TEST_F(cal_vcav_test, cal_vcav)
228228
#endif
229229

230230
#ifdef __MPI
231-
GlobalC::rhopw->initmpi(1, 0, POOL_WORLD);
231+
pwtest.initmpi(1, 0, POOL_WORLD);
232232
#endif
233-
GlobalC::rhopw->initgrids(ucell.lat0, ucell.latvec, wfcecut);
233+
pwtest.initgrids(ucell.lat0, ucell.latvec, wfcecut);
234234

235-
GlobalC::rhopw->initparameters(gamma_only, wfcecut, distribution_type, xprime);
236-
GlobalC::rhopw->setuptransform();
237-
GlobalC::rhopw->collect_local_pw();
238-
GlobalC::rhopw->collect_uniqgg();
235+
pwtest.initparameters(gamma_only, wfcecut, distribution_type, xprime);
236+
pwtest.setuptransform();
237+
pwtest.collect_local_pw();
238+
pwtest.collect_uniqgg();
239239

240-
const int npw = GlobalC::rhopw->npw;
241-
const int nrxx = GlobalC::rhopw->nrxx;
240+
const int npw = pwtest.npw;
241+
const int nrxx = pwtest.nrxx;
242242
std::complex<double>* PS_TOTN = new std::complex<double>[npw];
243243

244244
PS_TOTN[0] = {2.432e-07, 4.862e-08};
@@ -253,7 +253,7 @@ TEST_F(cal_vcav_test, cal_vcav)
253253
int nspin = 2;
254254
solvent_model.Vcav.create(nspin, nrxx);
255255

256-
solvent_model.cal_vcav(ucell, GlobalC::rhopw, PS_TOTN, nspin);
256+
solvent_model.cal_vcav(ucell, &pwtest, PS_TOTN, nspin);
257257

258258
EXPECT_NEAR(solvent_model.Vcav(0, 0), 4.8556305312, 1e-10);
259259
EXPECT_NEAR(solvent_model.Vcav(0, 1), -2.1006480538, 1e-10);

0 commit comments

Comments
 (0)