Skip to content

Commit a9626e7

Browse files
committed
change ucell in pwdft/stress_func_mgga.cpp
1 parent 25f9cfb commit a9626e7

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

source/module_hamilt_lcao/hamilt_lcaodft/FORCE_STRESS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ void Force_Stress_LCAO<T>::calStressPwPart(const UnitCell& ucell,
10081008
// local pseudopotential stress:
10091009
// use charge density; plane wave; local pseudopotential;
10101010
//--------------------------------------------------------
1011-
sc_pw.stress_loc(sigmadvl, rhopw, nlpp.vloc, &sf, 0, chr);
1011+
sc_pw.stress_loc(ucell,sigmadvl, rhopw, nlpp.vloc, &sf, 0, chr);
10121012

10131013
//--------------------------------------------------------
10141014
// hartree term

source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void OF_Stress_PW::cal_stress(ModuleBase::matrix& sigmatot,
7676
stress_gga(ucell,sigmaxc, this->rhopw, pelec->charge);
7777

7878
// local contribution
79-
stress_loc(sigmaloc, this->rhopw, locpp.vloc, p_sf, true, pelec->charge);
79+
stress_loc(ucell,sigmaloc, this->rhopw, locpp.vloc, p_sf, true, pelec->charge);
8080

8181
// nlcc
8282
stress_cc(sigmaxcc, this->rhopw, p_sf, true, locpp.numeric, pelec->charge);

source/module_hamilt_pw/hamilt_pwdft/stress_func.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ class Stress_Func
8484
const bool is_pw); // ewald part in PW or LCAO basis
8585

8686
// 4) the stress from the local pseudopotentials
87-
void stress_loc(ModuleBase::matrix& sigma,
87+
void stress_loc(const UnitCell& ucell,
88+
ModuleBase::matrix& sigma,
8889
ModulePW::PW_Basis* rho_basis,
8990
const ModuleBase::matrix& vloc,
9091
const Structure_Factor* p_sf,
@@ -105,7 +106,8 @@ class Stress_Func
105106
* D V(g^2) / D g^2 = 4pi e^2/omegai /G^4
106107
*
107108
*/
108-
void dvloc_coulomb(const FPTYPE& zp,
109+
void dvloc_coulomb(const UnitCell& ucell,
110+
const FPTYPE& zp,
109111
FPTYPE* dvloc,
110112
ModulePW::PW_Basis* rho_basis); // used in local pseudopotential stress
111113

source/module_hamilt_pw/hamilt_pwdft/stress_func_loc.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
//calculate local pseudopotential stress in PW or VL_dVL stress in LCAO
1010
template <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

279280
template <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;

source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void Stress_PW<FPTYPE, Device>::cal_stress(ModuleBase::matrix& sigmatot,
8989
}
9090

9191
// local contribution
92-
this->stress_loc(sigmaloc, rho_basis, nlpp.vloc, p_sf, 1, pelec->charge);
92+
this->stress_loc(ucell,sigmaloc, rho_basis, nlpp.vloc, p_sf, 1, pelec->charge);
9393

9494
// nlcc
9595
this->stress_cc(sigmaxcc, rho_basis, p_sf, 1, nlpp.numeric, pelec->charge);

source/module_hamilt_pw/hamilt_stodft/sto_stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void Sto_Stress_PW<FPTYPE, Device>::cal_stress(ModuleBase::matrix& sigmatot,
5252
this->stress_gga(ucell_in,sigmaxc, rho_basis, chr);
5353

5454
// local contribution
55-
this->stress_loc(sigmaloc, rho_basis, nlpp->vloc, p_sf, true, chr);
55+
this->stress_loc(ucell_in,sigmaloc, rho_basis, nlpp->vloc, p_sf, true, chr);
5656

5757
// nlcc
5858
this->stress_cc(sigmaxcc, rho_basis, p_sf, true, nlpp->numeric, chr);

0 commit comments

Comments
 (0)