Skip to content

Commit 475bddd

Browse files
committed
update ucell in dftu_force
1 parent 1de65ad commit 475bddd

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

source/module_hamilt_lcao/module_dftu/dftu.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,14 @@ class DFTU
147147
// dim = 4-6 : dS * dR, for stress
148148

149149
void folding_matrix_k(
150+
const UnitCell &ucell,
150151
ForceStressArrays &fsr,
151152
const Parallel_Orbitals &pv,
152-
const int ik,
153-
const int dim1,
154-
const int dim2,
155-
std::complex<double>* mat_k,
156-
const std::vector<ModuleBase::Vector3<double>> &kvec_d);
153+
const int ik,
154+
const int dim1,
155+
const int dim2,
156+
std::complex<double>* mat_k,
157+
const std::vector<ModuleBase::Vector3<double>> &kvec_d);
157158

158159

159160
/**
@@ -188,6 +189,7 @@ class DFTU
188189
const std::vector<ModuleBase::Vector3<double>>& kvec_d);
189190

190191
void cal_stress_k(
192+
const UnitCell &ucell,
191193
ForceStressArrays &fsr,
192194
const Parallel_Orbitals &pv,
193195
const int ik,

source/module_hamilt_lcao/module_dftu/dftu_folding.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ void DFTU::fold_dSR_gamma(
126126
}
127127

128128
void DFTU::folding_matrix_k(
129+
const UnitCell &ucell,
129130
ForceStressArrays &fsr,
130131
const Parallel_Orbitals &pv,
131132
const int ik,
@@ -153,26 +154,26 @@ void DFTU::folding_matrix_k(
153154
ModuleBase::Vector3<double> dtau2;
154155
ModuleBase::Vector3<double> tau0;
155156

156-
for (int T1 = 0; T1 < GlobalC::ucell.ntype; ++T1)
157+
for (int T1 = 0; T1 < ucell.ntype; ++T1)
157158
{
158-
Atom* atom1 = &GlobalC::ucell.atoms[T1];
159+
Atom* atom1 = &ucell.atoms[T1];
159160
for (int I1 = 0; I1 < atom1->na; ++I1)
160161
{
161162
tau1 = atom1->tau[I1];
162-
GlobalC::GridD.Find_atom(GlobalC::ucell, tau1, T1, I1);
163-
Atom* atom1 = &GlobalC::ucell.atoms[T1];
164-
const int start1 = GlobalC::ucell.itiaiw2iwt(T1, I1, 0);
163+
GlobalC::GridD.Find_atom(ucell, tau1, T1, I1);
164+
Atom* atom1 = &ucell.atoms[T1];
165+
const int start1 = ucell.itiaiw2iwt(T1, I1, 0);
165166

166167
// (2) search among all adjacent atoms.
167168
for (int ad = 0; ad < GlobalC::GridD.getAdjacentNum() + 1; ++ad)
168169
{
169170
const int T2 = GlobalC::GridD.getType(ad);
170171
const int I2 = GlobalC::GridD.getNatom(ad);
171-
Atom* atom2 = &GlobalC::ucell.atoms[T2];
172+
Atom* atom2 = &ucell.atoms[T2];
172173

173174
tau2 = GlobalC::GridD.getAdjacentTau(ad);
174175
dtau = tau2 - tau1;
175-
double distance = dtau.norm() * GlobalC::ucell.lat0;
176+
double distance = dtau.norm() * ucell.lat0;
176177
double rcut = orb_cutoff_[T1] + orb_cutoff_[T2];
177178

178179
bool adj = false;
@@ -192,11 +193,11 @@ void DFTU::folding_matrix_k(
192193
dtau1 = tau0 - tau1;
193194
dtau2 = tau0 - tau2;
194195

195-
double distance1 = dtau1.norm() * GlobalC::ucell.lat0;
196-
double distance2 = dtau2.norm() * GlobalC::ucell.lat0;
196+
double distance1 = dtau1.norm() * ucell.lat0;
197+
double distance2 = dtau2.norm() * ucell.lat0;
197198

198-
double rcut1 = orb_cutoff_[T1] + GlobalC::ucell.infoNL.Beta[T0].get_rcut_max();
199-
double rcut2 = orb_cutoff_[T2] + GlobalC::ucell.infoNL.Beta[T0].get_rcut_max();
199+
double rcut1 = orb_cutoff_[T1] + ucell.infoNL.Beta[T0].get_rcut_max();
200+
double rcut2 = orb_cutoff_[T2] + ucell.infoNL.Beta[T0].get_rcut_max();
200201

201202
if (distance1 < rcut1 && distance2 < rcut2)
202203
{
@@ -209,7 +210,7 @@ void DFTU::folding_matrix_k(
209210
if (adj)
210211
{
211212
// (3) calculate the nu of atom (T2, I2)
212-
const int start2 = GlobalC::ucell.itiaiw2iwt(T2, I2, 0);
213+
const int start2 = ucell.itiaiw2iwt(T2, I2, 0);
213214
//------------------------------------------------
214215
// exp(k dot dR)
215216
// dR is the index of box in Crystal coordinates

source/module_hamilt_lcao/module_dftu/dftu_force.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void DFTU::force_stress(const UnitCell& ucell,
211211
}
212212
if (PARAM.inp.cal_stress)
213213
{
214-
cal_stress_k(fsr, pv, ik, &rho_VU[0], stress_dftu, kv.kvec_d);
214+
cal_stress_k(ucell,fsr, pv, ik, &rho_VU[0], stress_dftu, kv.kvec_d);
215215
}
216216
} // ik
217217
}
@@ -269,7 +269,7 @@ void DFTU::cal_force_k(const UnitCell& ucell,
269269

270270
for (int dim = 0; dim < 3; dim++)
271271
{
272-
this->folding_matrix_k(fsr, pv, ik, dim + 1, 0, &dSm_k[0], kvec_d);
272+
this->folding_matrix_k(ucell,fsr, pv, ik, dim + 1, 0, &dSm_k[0], kvec_d);
273273

274274
#ifdef __MPI
275275
pzgemm_(&transN,
@@ -376,7 +376,8 @@ void DFTU::cal_force_k(const UnitCell& ucell,
376376
return;
377377
}
378378

379-
void DFTU::cal_stress_k(ForceStressArrays& fsr,
379+
void DFTU::cal_stress_k(const UnitCell& ucell,
380+
ForceStressArrays& fsr,
380381
const Parallel_Orbitals& pv,
381382
const int ik,
382383
const std::complex<double>* rho_VU,
@@ -401,7 +402,8 @@ void DFTU::cal_stress_k(ForceStressArrays& fsr,
401402
{
402403
for (int dim2 = dim1; dim2 < 3; dim2++)
403404
{
404-
this->folding_matrix_k(fsr, // mohan add 2024-06-16
405+
this->folding_matrix_k(ucell,
406+
fsr, // mohan add 2024-06-16
405407
pv,
406408
ik,
407409
dim1 + 4,

0 commit comments

Comments
 (0)