1313
1414// NLCC term, need to be tested
1515template <typename FPTYPE, typename Device>
16- void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
16+ void Stress_Func<FPTYPE, Device>::stress_cc(UnitCell& ucell,
17+ ModuleBase::matrix& sigma,
1718 ModulePW::PW_Basis* rho_basis,
1819 const Structure_Factor* p_sf,
1920 const bool is_pw,
@@ -34,9 +35,9 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
3435 FPTYPE* rhocg;
3536
3637 int judge=0 ;
37- for (int nt=0 ;nt<GlobalC:: ucell.ntype ;nt++)
38+ for (int nt=0 ;nt<ucell.ntype ;nt++)
3839 {
39- if (GlobalC:: ucell.atoms [nt].ncpp .nlcc )
40+ if (ucell.atoms [nt].ncpp .nlcc )
4041 {
4142 judge++;
4243 }
@@ -54,7 +55,7 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
5455 {
5556#ifdef USE_LIBXC
5657 const auto etxc_vtxc_v
57- = XC_Functional_Libxc::v_xc_meta (XC_Functional::get_func_id (), rho_basis->nrxx , GlobalC:: ucell.omega , GlobalC:: ucell.tpiba , chr);
58+ = XC_Functional_Libxc::v_xc_meta (XC_Functional::get_func_id (), rho_basis->nrxx , ucell.omega , ucell.tpiba , chr);
5859
5960 // etxc = std::get<0>(etxc_vtxc_v);
6061 // vtxc = std::get<1>(etxc_vtxc_v);
@@ -65,8 +66,8 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
6566 }
6667 else
6768 {
68- elecstate::cal_ux (GlobalC:: ucell);
69- const auto etxc_vtxc_v = XC_Functional::v_xc (rho_basis->nrxx , chr, &GlobalC:: ucell);
69+ elecstate::cal_ux (ucell);
70+ const auto etxc_vtxc_v = XC_Functional::v_xc (rho_basis->nrxx , chr, &ucell);
7071 // etxc = std::get<0>(etxc_vtxc_v); // may delete?
7172 // vtxc = std::get<1>(etxc_vtxc_v); // may delete?
7273 vxc = std::get<2 >(etxc_vtxc_v);
@@ -103,17 +104,17 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
103104 rhocg= new FPTYPE [rho_basis->ngg ];
104105
105106 sigmadiag=0.0 ;
106- for (int nt=0 ;nt<GlobalC:: ucell.ntype ;nt++)
107+ for (int nt=0 ;nt<ucell.ntype ;nt++)
107108 {
108- if (GlobalC:: ucell.atoms [nt].ncpp .nlcc )
109+ if (ucell.atoms [nt].ncpp .nlcc )
109110 {
110111 // drhoc();
111112 this ->deriv_drhoc (
112113 numeric,
113- GlobalC:: ucell.atoms [nt].ncpp .msh ,
114- GlobalC:: ucell.atoms [nt].ncpp .r .data (),
115- GlobalC:: ucell.atoms [nt].ncpp .rab .data (),
116- GlobalC:: ucell.atoms [nt].ncpp .rho_atc .data (),
114+ ucell.atoms [nt].ncpp .msh ,
115+ ucell.atoms [nt].ncpp .r .data (),
116+ ucell.atoms [nt].ncpp .rab .data (),
117+ ucell.atoms [nt].ncpp .rho_atc .data (),
117118 rhocg,
118119 rho_basis,
119120 1 );
@@ -130,15 +131,15 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
130131 local_sigmadiag = conj (psic[ig]) * p_sf->strucFac (nt, ig) * rhocg[rho_basis->ig2igg [ig]];
131132 } else {
132133 local_sigmadiag = conj (psic[ig]) * p_sf->strucFac (nt, ig) * rhocg[rho_basis->ig2igg [ig]] * fact;
133- }
134+ }
134135 sigmadiag += local_sigmadiag.real ();
135136 }
136137 this ->deriv_drhoc (
137138 numeric,
138- GlobalC:: ucell.atoms [nt].ncpp .msh ,
139- GlobalC:: ucell.atoms [nt].ncpp .r .data (),
140- GlobalC:: ucell.atoms [nt].ncpp .rab .data (),
141- GlobalC:: ucell.atoms [nt].ncpp .rho_atc .data (),
139+ ucell.atoms [nt].ncpp .msh ,
140+ ucell.atoms [nt].ncpp .r .data (),
141+ ucell.atoms [nt].ncpp .rab .data (),
142+ ucell.atoms [nt].ncpp .rho_atc .data (),
142143 rhocg,
143144 rho_basis,
144145 0 );
@@ -154,15 +155,15 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
154155 for (int ig = 0 ;ig< rho_basis->npw ;ig++)
155156 {
156157 const FPTYPE norm_g = sqrt (rho_basis->gg [ig]);
157- if (norm_g < 1e-4 ) { continue ;
158- }
158+ if (norm_g < 1e-4 ) {continue ;
159+ }
159160 for (int l = 0 ; l < 3 ; l++)
160161 {
161162 for (int m = 0 ;m< 3 ;m++)
162163 {
163164 const std::complex <FPTYPE> t
164165 = conj (psic[ig]) * p_sf->strucFac (nt, ig) * rhocg[rho_basis->ig2igg [ig]]
165- * GlobalC:: ucell.tpiba * rho_basis->gcar [ig][l] * rho_basis->gcar [ig][m] / norm_g * fact;
166+ * ucell.tpiba * rho_basis->gcar [ig][l] * rho_basis->gcar [ig][m] / norm_g * fact;
166167 // sigmacc [l][ m] += t.real();
167168 local_sigma (l,m) += t.real ();
168169 }// end m
@@ -254,7 +255,7 @@ void Stress_Func<FPTYPE, Device>::deriv_drhoc
254255 aux [ir] = r [ir] * r [ir] * rhoc [ir];
255256 }
256257 ModuleBase::Integral::Simpson_Integral (mesh, aux.data (), rab, rhocg1);
257- drhocg [0 ] = ModuleBase::FOUR_PI * rhocg1 / GlobalC:: ucell. omega ;
258+ drhocg [0 ] = ModuleBase::FOUR_PI * rhocg1 / ucell-> omega ;
258259 igl0 = 1 ;
259260 }
260261 else
@@ -273,7 +274,7 @@ void Stress_Func<FPTYPE, Device>::deriv_drhoc
273274#endif
274275 for (int igl = igl0;igl< rho_basis->ngg ;igl++)
275276 {
276- gx_arr[igl] = sqrt (rho_basis->gg_uniq [igl] * GlobalC:: ucell. tpiba2 );
277+ gx_arr[igl] = sqrt (rho_basis->gg_uniq [igl] * ucell-> tpiba2 );
277278 }
278279
279280 double *r_d = nullptr ;
@@ -298,12 +299,12 @@ void Stress_Func<FPTYPE, Device>::deriv_drhoc
298299
299300 if (this ->device == base_device::GpuDevice) {
300301 hamilt::cal_stress_drhoc_aux_op<FPTYPE, Device>()(
301- r_d,rhoc_d,gx_arr_d+igl0,rab_d,drhocg_d+igl0,mesh,igl0,rho_basis->ngg -igl0,GlobalC:: ucell. omega ,type);
302+ r_d,rhoc_d,gx_arr_d+igl0,rab_d,drhocg_d+igl0,mesh,igl0,rho_basis->ngg -igl0,ucell-> omega ,type);
302303 syncmem_var_d2h_op ()(this ->cpu_ctx , this ->ctx , drhocg+igl0, drhocg_d+igl0, rho_basis->ngg -igl0);
303304
304305 } else {
305306 hamilt::cal_stress_drhoc_aux_op<FPTYPE, Device>()(
306- r,rhoc,gx_arr.data ()+igl0,rab,drhocg+igl0,mesh,igl0,rho_basis->ngg -igl0,GlobalC:: ucell. omega ,type);
307+ r,rhoc,gx_arr.data ()+igl0,rab,drhocg+igl0,mesh,igl0,rho_basis->ngg -igl0,ucell-> omega ,type);
307308
308309 }
309310 delmem_var_op ()(this ->ctx , r_d);
0 commit comments