@@ -71,7 +71,8 @@ extern "C"
7171namespace ModuleDFTU
7272{
7373
74- void DFTU::force_stress (const elecstate::ElecState* pelec,
74+ void DFTU::force_stress (const UnitCell& ucell,
75+ const elecstate::ElecState* pelec,
7576 const Parallel_Orbitals& pv,
7677 ForceStressArrays& fsr, // mohan add 2024-06-16
7778 ModuleBase::matrix& force_dftu,
@@ -140,12 +141,12 @@ void DFTU::force_stress(const elecstate::ElecState* pelec,
140141
141142 if (PARAM.inp .cal_force )
142143 {
143- this ->cal_force_gamma (&rho_VU[0 ], pv, fsr.DSloc_x , fsr.DSloc_y , fsr.DSloc_z , force_dftu);
144+ this ->cal_force_gamma (ucell, &rho_VU[0 ], pv, fsr.DSloc_x , fsr.DSloc_y , fsr.DSloc_z , force_dftu);
144145 }
145146
146147 if (PARAM.inp .cal_stress )
147148 {
148- this ->cal_stress_gamma (GlobalC:: ucell,
149+ this ->cal_stress_gamma (ucell,
149150 pv,
150151 &GlobalC::GridD,
151152 fsr.DSloc_x ,
@@ -206,7 +207,7 @@ void DFTU::force_stress(const elecstate::ElecState* pelec,
206207
207208 if (PARAM.inp .cal_force )
208209 {
209- cal_force_k (fsr, pv, ik, &rho_VU[0 ], force_dftu, kv.kvec_d );
210+ cal_force_k (ucell, fsr, pv, ik, &rho_VU[0 ], force_dftu, kv.kvec_d );
210211 }
211212 if (PARAM.inp .cal_stress )
212213 {
@@ -237,7 +238,7 @@ void DFTU::force_stress(const elecstate::ElecState* pelec,
237238 {
238239 for (int j = 0 ; j < 3 ; j++)
239240 {
240- stress_dftu (i, j) *= GlobalC:: ucell.lat0 / GlobalC:: ucell.omega ;
241+ stress_dftu (i, j) *= ucell.lat0 / ucell.omega ;
241242 }
242243 }
243244 }
@@ -246,7 +247,8 @@ void DFTU::force_stress(const elecstate::ElecState* pelec,
246247 return ;
247248}
248249
249- void DFTU::cal_force_k (ForceStressArrays& fsr,
250+ void DFTU::cal_force_k (const UnitCell& ucell,
251+ ForceStressArrays& fsr,
250252 const Parallel_Orbitals& pv,
251253 const int ik,
252254 const std::complex <double >* rho_VU,
@@ -294,7 +296,7 @@ void DFTU::cal_force_k(ForceStressArrays& fsr,
294296 for (int ir = 0 ; ir < pv.nrow ; ir++)
295297 {
296298 const int iwt1 = pv.local2global_row (ir);
297- const int iat1 = GlobalC:: ucell.iwt2iat [iwt1];
299+ const int iat1 = ucell.iwt2iat [iwt1];
298300
299301 for (int ic = 0 ; ic < pv.ncol ; ic++)
300302 {
@@ -329,22 +331,22 @@ void DFTU::cal_force_k(ForceStressArrays& fsr,
329331 pv.desc );
330332#endif
331333
332- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
334+ for (int it = 0 ; it < ucell.ntype ; it++)
333335 {
334- const int NL = GlobalC:: ucell.atoms [it].nwl + 1 ;
336+ const int NL = ucell.atoms [it].nwl + 1 ;
335337 const int LC = orbital_corr[it];
336338
337339 if (LC == -1 )
338340 continue ;
339- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
341+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
340342 {
341- const int iat = GlobalC:: ucell.itia2iat (it, ia);
343+ const int iat = ucell.itia2iat (it, ia);
342344
343345 for (int l = 0 ; l < NL; l++)
344346 {
345347 if (l != orbital_corr[it])
346348 continue ;
347- const int N = GlobalC:: ucell.atoms [it].l_nchi [l];
349+ const int N = ucell.atoms [it].l_nchi [l];
348350
349351 for (int n = 0 ; n < N; n++)
350352 {
@@ -449,7 +451,8 @@ void DFTU::cal_stress_k(ForceStressArrays& fsr,
449451 return ;
450452}
451453
452- void DFTU::cal_force_gamma (const double * rho_VU,
454+ void DFTU::cal_force_gamma (const UnitCell& ucell,
455+ const double * rho_VU,
453456 const Parallel_Orbitals& pv,
454457 double * dsloc_x,
455458 double * dsloc_y,
@@ -505,7 +508,7 @@ void DFTU::cal_force_gamma(const double* rho_VU,
505508 for (int ir = 0 ; ir < pv.nrow ; ir++)
506509 {
507510 const int iwt1 = pv.local2global_row (ir);
508- const int iat1 = GlobalC:: ucell.iwt2iat [iwt1];
511+ const int iat1 = ucell.iwt2iat [iwt1];
509512
510513 for (int ic = 0 ; ic < pv.ncol ; ic++)
511514 {
@@ -540,23 +543,23 @@ void DFTU::cal_force_gamma(const double* rho_VU,
540543 pv.desc );
541544#endif
542545
543- for (int it = 0 ; it < GlobalC:: ucell.ntype ; it++)
546+ for (int it = 0 ; it < ucell.ntype ; it++)
544547 {
545- const int NL = GlobalC:: ucell.atoms [it].nwl + 1 ;
548+ const int NL = ucell.atoms [it].nwl + 1 ;
546549 const int LC = orbital_corr[it];
547550
548551 if (LC == -1 )
549552 continue ;
550- for (int ia = 0 ; ia < GlobalC:: ucell.atoms [it].na ; ia++)
553+ for (int ia = 0 ; ia < ucell.atoms [it].na ; ia++)
551554 {
552- const int iat = GlobalC:: ucell.itia2iat (it, ia);
555+ const int iat = ucell.itia2iat (it, ia);
553556
554557 for (int l = 0 ; l < NL; l++)
555558 {
556559 if (l != orbital_corr[it])
557560 continue ;
558561
559- const int N = GlobalC:: ucell.atoms [it].l_nchi [l];
562+ const int N = ucell.atoms [it].l_nchi [l];
560563
561564 for (int n = 0 ; n < N; n++)
562565 {
0 commit comments