Skip to content

Commit 1de65ad

Browse files
committed
update ucell in dftu_force
1 parent b1e4de5 commit 1de65ad

File tree

3 files changed

+45
-40
lines changed

3 files changed

+45
-40
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ void Force_Stress_LCAO<T>::getForceStress(const bool isforce,
300300
}
301301
if (PARAM.inp.dft_plus_u == 2)
302302
{
303-
GlobalC::dftu.force_stress(pelec,
303+
GlobalC::dftu.force_stress(ucell,
304+
pelec,
304305
pv,
305306
fsr, // mohan 2024-06-16
306307
force_dftu,

source/module_hamilt_lcao/module_dftu/dftu.h

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,23 @@ class DFTU
169169
//=============================================================
170170
public:
171171

172-
void force_stress(const elecstate::ElecState* pelec,
173-
const Parallel_Orbitals& pv,
174-
ForceStressArrays& fsr,
175-
ModuleBase::matrix& force_dftu,
176-
ModuleBase::matrix& stress_dftu,
177-
const K_Vectors& kv);
172+
void force_stress(const UnitCell& ucell,
173+
const elecstate::ElecState* pelec,
174+
const Parallel_Orbitals& pv,
175+
ForceStressArrays& fsr,
176+
ModuleBase::matrix& force_dftu,
177+
ModuleBase::matrix& stress_dftu,
178+
const K_Vectors& kv);
178179

179180
private:
180181

181-
void cal_force_k(
182-
ForceStressArrays &fsr,
183-
const Parallel_Orbitals &pv,
184-
const int ik,
185-
const std::complex<double>* rho_VU,
186-
ModuleBase::matrix& force_dftu,
187-
const std::vector<ModuleBase::Vector3<double>>& kvec_d);
182+
void cal_force_k(const UnitCell &ucell,
183+
ForceStressArrays &fsr,
184+
const Parallel_Orbitals &pv,
185+
const int ik,
186+
const std::complex<double>* rho_VU,
187+
ModuleBase::matrix& force_dftu,
188+
const std::vector<ModuleBase::Vector3<double>>& kvec_d);
188189

189190
void cal_stress_k(
190191
ForceStressArrays &fsr,
@@ -194,13 +195,13 @@ class DFTU
194195
ModuleBase::matrix& stress_dftu,
195196
const std::vector<ModuleBase::Vector3<double>>& kvec_d);
196197

197-
void cal_force_gamma(
198-
const double* rho_VU,
199-
const Parallel_Orbitals &pv,
200-
double* dsloc_x,
201-
double* dsloc_y,
202-
double* dsloc_z,
203-
ModuleBase::matrix& force_dftu);
198+
void cal_force_gamma(const UnitCell &ucell,
199+
const double* rho_VU,
200+
const Parallel_Orbitals &pv,
201+
double* dsloc_x,
202+
double* dsloc_y,
203+
double* dsloc_z,
204+
ModuleBase::matrix& force_dftu);
204205

205206
void cal_stress_gamma(
206207
const UnitCell &ucell,

source/module_hamilt_lcao/module_dftu/dftu_force.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ extern "C"
7171
namespace 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

Comments
 (0)