88
99// calculate local pseudopotential stress in PW or VL_dVL stress in LCAO
1010template <typename FPTYPE, typename Device>
11- void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
11+ void Stress_Func<FPTYPE, Device>::stress_loc(const UnitCell& ucell,
12+ ModuleBase::matrix& sigma,
1213 ModulePW::PW_Basis* rho_basis,
1314 const ModuleBase::matrix& vloc,
1415 const Structure_Factor* p_sf,
@@ -69,7 +70,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
6970 if (is_pw)
7071 {
7172#pragma omp parallel for collapse(2) reduction(+:evloc)
72- for (int it=0 ; it<GlobalC:: ucell.ntype ; it++)
73+ for (int it=0 ; it<ucell.ntype ; it++)
7374 {
7475 for (int ig=0 ; ig<rho_basis->npw ; ig++)
7576 {
@@ -83,15 +84,15 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
8384 }
8485 }
8586 }
86- for (int it = 0 ; it < GlobalC:: ucell.ntype ; ++it)
87+ for (int it = 0 ; it < ucell.ntype ; ++it)
8788 {
88- const Atom* atom = &GlobalC:: ucell.atoms [it];
89+ const Atom* atom = &ucell.atoms [it];
8990 if (atom->coulomb_potential )
9091 {
9192 //
9293 // special case: pseudopotential is coulomb 1/r potential
9394 //
94- this ->dvloc_coulomb (atom->ncpp .zv , dvloc.data (), rho_basis);
95+ this ->dvloc_coulomb (ucell, atom->ncpp .zv , dvloc.data (), rho_basis);
9596 //
9697 }
9798 else
@@ -100,7 +101,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
100101 // normal case: dvloc contains dV_loc(G)/dG
101102 //
102103 this ->dvloc_of_g ( atom->ncpp .msh , atom->ncpp .rab .data (), atom->ncpp .r .data (),
103- atom->ncpp .vloc_at .data (), atom->ncpp .zv , dvloc.data (), rho_basis, GlobalC:: ucell);
104+ atom->ncpp .vloc_at .data (), atom->ncpp .zv , dvloc.data (), rho_basis, ucell);
104105 //
105106 }
106107#ifndef _OPENMP
@@ -119,7 +120,7 @@ void Stress_Func<FPTYPE, Device>::stress_loc(ModuleBase::matrix& sigma,
119120 {
120121 local_sigma (l, m) = local_sigma (l, m)
121122 + (conj (aux[ig]) * p_sf->strucFac (it, ig)).real () * 2.0
122- * dvloc[rho_basis->ig2igg [ig]] * GlobalC:: ucell.tpiba2
123+ * dvloc[rho_basis->ig2igg [ig]] * ucell.tpiba2
123124 * rho_basis->gcar [ig][l] * rho_basis->gcar [ig][m] * fact;
124125 }
125126 }
@@ -277,7 +278,10 @@ const UnitCell& ucell_in
277278}
278279
279280template <typename FPTYPE, typename Device>
280- void Stress_Func<FPTYPE, Device>::dvloc_coulomb (const FPTYPE& zp, FPTYPE* dvloc, ModulePW::PW_Basis* rho_basis)
281+ void Stress_Func<FPTYPE, Device>::dvloc_coulomb (const UnitCell& ucell,
282+ const FPTYPE& zp,
283+ FPTYPE* dvloc,
284+ ModulePW::PW_Basis* rho_basis)
281285{
282286 int igl0;
283287 // start from |G|=0 or not.
@@ -295,8 +299,8 @@ void Stress_Func<FPTYPE, Device>::dvloc_coulomb(const FPTYPE& zp, FPTYPE* dvloc,
295299#endif
296300 for (int i = igl0; i < rho_basis->ngg ; i++)
297301 {
298- dvloc[i] = ModuleBase::FOUR_PI * zp * ModuleBase::e2 / GlobalC:: ucell.omega
299- / pow ((GlobalC:: ucell.tpiba2 * rho_basis->gg_uniq [i]), 2 );
302+ dvloc[i] = ModuleBase::FOUR_PI * zp * ModuleBase::e2 / ucell.omega
303+ / pow ((ucell.tpiba2 * rho_basis->gg_uniq [i]), 2 );
300304 }
301305
302306 return ;
0 commit comments