@@ -17,7 +17,8 @@ pseudopot_cell_vl::~pseudopot_cell_vl()
1717 delete[] zp;
1818}
1919
20- void pseudopot_cell_vl::init_vloc (const ModulePW::PW_Basis* rho_basis)
20+ void pseudopot_cell_vl::init_vloc (const UnitCell& ucell,
21+ const ModulePW::PW_Basis* rho_basis)
2122{
2223 if (PARAM.inp .use_paw ) { return ;
2324}
@@ -30,19 +31,19 @@ void pseudopot_cell_vl::init_vloc(const ModulePW::PW_Basis* rho_basis)
3031 double *vloc1d = new double [rho_basis->ngg ];
3132 ModuleBase::GlobalFunc::ZEROS (vloc1d, rho_basis->ngg );
3233
33- this ->allocate (rho_basis->ngg );
34+ this ->allocate (ucell, rho_basis->ngg );
3435
35- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
36+ for (int it = 0 ; it < ucell.ntype ; it++)
3637 {
37- const Atom* atom = &GlobalC:: ucell.atoms [it];
38+ const Atom* atom = &ucell.atoms [it];
3839
3940 ModuleBase::GlobalFunc::ZEROS (vloc1d, rho_basis->ngg );
4041
4142 this ->zp [it] = atom->ncpp .zv ;
4243 // compute V_loc(G) for a given type of atom
4344 if (atom->coulomb_potential )
4445 {
45- this ->vloc_coulomb (this ->zp [it], vloc1d, rho_basis);
46+ this ->vloc_coulomb (ucell, this ->zp [it], vloc1d, rho_basis);
4647 }
4748 else if (numeric[it]==true )
4849 {
@@ -53,6 +54,7 @@ void pseudopot_cell_vl::init_vloc(const ModulePW::PW_Basis* rho_basis)
5354 atom->ncpp .vloc_at .data (), // local potential in real space radial form.
5455 this ->zp [it],
5556 vloc1d,
57+ ucell,
5658 rho_basis);
5759 }
5860 else
@@ -69,26 +71,27 @@ void pseudopot_cell_vl::init_vloc(const ModulePW::PW_Basis* rho_basis)
6971
7072 delete[] vloc1d;
7173
72- this ->print_vloc (rho_basis);
74+ this ->print_vloc (ucell, rho_basis);
7375
7476 ModuleBase::timer::tick (" ppcell_vl" ," init_vloc" );
7577 return ;
7678}
7779
7880
79- void pseudopot_cell_vl::allocate (const int ngg)
81+ void pseudopot_cell_vl::allocate (const UnitCell& ucell,
82+ const int ngg)
8083{
8184 if (PARAM.inp .test_pp >0 ) { ModuleBase::TITLE (" pseudopot_cell_vl" ," allocate" );
8285}
8386 if (PARAM.inp .use_paw ) { return ;
8487}
85- this ->vloc .create (GlobalC:: ucell.ntype , ngg);
88+ this ->vloc .create (ucell.ntype , ngg);
8689
8790 delete[] numeric;
88- this ->numeric = new bool [GlobalC:: ucell.ntype ];
89- ModuleBase::GlobalFunc::ZEROS (numeric, GlobalC:: ucell.ntype );
91+ this ->numeric = new bool [ucell.ntype ];
92+ ModuleBase::GlobalFunc::ZEROS (numeric, ucell.ntype );
9093
91- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
94+ for (int it = 0 ; it < ucell.ntype ; it++)
9295 {
9396 this ->numeric [it] = true ;
9497 }
@@ -104,7 +107,10 @@ void pseudopot_cell_vl::allocate(const int ngg)
104107 return ;
105108}
106109
107- void pseudopot_cell_vl::vloc_coulomb (const double & zp_in, double * vloc_1d, const ModulePW::PW_Basis* rho_basis) const
110+ void pseudopot_cell_vl::vloc_coulomb (const UnitCell& ucell,
111+ const double & zp_in,
112+ double * vloc_1d,
113+ const ModulePW::PW_Basis* rho_basis) const
108114{
109115 int igl0 = 0 ;
110116 // start from |G|=0 or not.
@@ -117,14 +123,14 @@ void pseudopot_cell_vl::vloc_coulomb(const double& zp_in, double* vloc_1d, const
117123 {
118124 igl0 = 0 ;
119125 }
120- const double d_fpi_omega = ModuleBase::FOUR_PI / GlobalC:: ucell.omega ; // mohan add 2008-06-04
126+ const double d_fpi_omega = ModuleBase::FOUR_PI / ucell.omega ; // mohan add 2008-06-04
121127 double fac = -zp_in * ModuleBase::e2 * d_fpi_omega;
122128#ifdef _OPENMP
123129#pragma omp for
124130#endif
125131 for (int ig = igl0; ig < rho_basis->ngg ; ig++)
126132 {
127- double gx2 = rho_basis->gg_uniq [ig] * GlobalC:: ucell.tpiba2 ;
133+ double gx2 = rho_basis->gg_uniq [ig] * ucell.tpiba2 ;
128134 vloc_1d[ig] = fac / gx2;
129135 }
130136 return ;
@@ -145,6 +151,7 @@ void pseudopot_cell_vl::vloc_of_g(const int& msh,
145151 const double * vloc_at,
146152 const double & zp_in,
147153 double * vloc_1d,
154+ const UnitCell& ucell,
148155 const ModulePW::PW_Basis* rho_basis) const
149156{
150157 // ----------------------------------------------------------------
@@ -173,7 +180,7 @@ void pseudopot_cell_vl::vloc_of_g(const int& msh,
173180 /*
174181 for(ir=0; ir<msh; ir++)
175182 {
176- aux[ir] = r[ir] * zp_in * e2 / GlobalC:: ucell.omega;
183+ aux[ir] = r[ir] * zp_in * e2 / ucell.omega;
177184 }
178185 ModuleBase::Integral::Simpson_Integral(msh, aux, rab, vloc_1d[0] );
179186 vloc_1d[0] *= 4*3.1415926;
@@ -224,7 +231,7 @@ void pseudopot_cell_vl::vloc_of_g(const int& msh,
224231#endif
225232 for (int ig = igl0;ig < rho_basis->ngg ;ig++)
226233 {
227- double gx2= rho_basis->gg_uniq [ig] * GlobalC:: ucell.tpiba2 ;
234+ double gx2= rho_basis->gg_uniq [ig] * ucell.tpiba2 ;
228235 double gx = std::sqrt (gx2);
229236 for (int ir = 0 ;ir < msh;ir++)
230237 {
@@ -235,7 +242,7 @@ void pseudopot_cell_vl::vloc_of_g(const int& msh,
235242 vloc_1d[ig] -= fac * ModuleBase::libm::exp (- gx2 * 0.25 )/ gx2;
236243 } // enddo
237244
238- const double d_fpi_omega = ModuleBase::FOUR_PI/GlobalC:: ucell.omega ;// mohan add 2008-06-04
245+ const double d_fpi_omega = ModuleBase::FOUR_PI/ucell.omega ;// mohan add 2008-06-04
239246#ifdef _OPENMP
240247#pragma omp for
241248#endif
@@ -253,21 +260,22 @@ void pseudopot_cell_vl::vloc_of_g(const int& msh,
253260 return ;
254261} // end subroutine vloc_of_g
255262
256- void pseudopot_cell_vl::print_vloc (const ModulePW::PW_Basis* rho_basis) const
263+ void pseudopot_cell_vl::print_vloc (const UnitCell& ucell,
264+ const ModulePW::PW_Basis* rho_basis) const
257265{
258266 if (GlobalV::MY_RANK!=0 ) { return ; // mohan fix bug 2011-10-13
259267}
260268 bool check_vl = PARAM.inp .out_element_info ;
261269 if (check_vl)
262270 {
263- for (int it=0 ; it<GlobalC:: ucell.ntype ; it++)
271+ for (int it=0 ; it<ucell.ntype ; it++)
264272 {
265273 std::stringstream ss ;
266- ss << PARAM.globalv .global_out_dir << GlobalC:: ucell.atoms [it].label << " /v_loc_g.dat" ;
274+ ss << PARAM.globalv .global_out_dir << ucell.atoms [it].label << " /v_loc_g.dat" ;
267275 std::ofstream ofs_vg ( ss.str ().c_str () );
268276 for (int ig=0 ;ig<rho_basis->ngg ;ig++)
269277 {
270- ofs_vg << std::setw (15 ) << rho_basis->gg_uniq [ig] * GlobalC:: ucell.tpiba2
278+ ofs_vg << std::setw (15 ) << rho_basis->gg_uniq [ig] * ucell.tpiba2
271279 << std::setw (15 ) << this ->vloc (it, ig) << std::endl;
272280 }
273281 ofs_vg.close ();
0 commit comments