Skip to content

Commit 25f9cfb

Browse files
committed
change ucell in pwdft/stress_func_har.cpp
1 parent 6b9a63e commit 25f9cfb

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
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
@@ -1013,7 +1013,7 @@ void Force_Stress_LCAO<T>::calStressPwPart(const UnitCell& ucell,
10131013
//--------------------------------------------------------
10141014
// hartree term
10151015
//--------------------------------------------------------
1016-
sc_pw.stress_har(sigmahar, rhopw, 0, chr);
1016+
sc_pw.stress_har(ucell,sigmahar, rhopw, 0, chr);
10171017

10181018
//--------------------------------------------------------
10191019
// ewald stress: use plane wave only.

source/module_hamilt_pw/hamilt_ofdft/of_stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void OF_Stress_PW::cal_stress(ModuleBase::matrix& sigmatot,
6363
}
6464

6565
// hartree contribution
66-
stress_har(sigmahar, this->rhopw, true, pelec->charge);
66+
stress_har(ucell,sigmahar, this->rhopw, true, pelec->charge);
6767

6868
// ewald contribution
6969
stress_ewa(ucell,sigmaewa, this->rhopw, true);

source/module_hamilt_pw/hamilt_pwdft/stress_func.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class Stress_Func
7070
const psi::Psi<complex<FPTYPE>, Device>* psi_in = nullptr); // electron kinetic part in PW basis
7171

7272
// 2) the stress from the Hartree term
73-
void stress_har(ModuleBase::matrix& sigma,
73+
void stress_har(const UnitCell& ucell,
74+
ModuleBase::matrix& sigma,
7475
ModulePW::PW_Basis* rho_basis,
7576
const bool is_pw,
7677
const Charge* const chr); // hartree part in PW or LCAO basis

source/module_hamilt_pw/hamilt_pwdft/stress_func_har.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
//calculate the Hartree part in PW or LCAO base
88
template<typename FPTYPE, typename Device>
9-
void Stress_Func<FPTYPE, Device>::stress_har(ModuleBase::matrix& sigma, ModulePW::PW_Basis* rho_basis, const bool is_pw, const Charge* const chr)
9+
void Stress_Func<FPTYPE, Device>::stress_har(const UnitCell& ucell,
10+
ModuleBase::matrix& sigma,
11+
ModulePW::PW_Basis* rho_basis,
12+
const bool is_pw,
13+
const Charge* const chr)
1014
{
1115
ModuleBase::TITLE("Stress_Func","stress_har");
1216
ModuleBase::timer::tick("Stress_Func","stress_har");
@@ -65,10 +69,10 @@ void Stress_Func<FPTYPE, Device>::stress_har(ModuleBase::matrix& sigma, ModulePW
6569
const FPTYPE g2 = rho_basis->gg[ig];
6670
if(g2 < 1e-8) { continue;
6771
}
68-
//const FPTYPE fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (GlobalC::ucell.tpiba2 * GlobalC::sf.gg [ig]);
72+
//const FPTYPE fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (ucell.tpiba2 * GlobalC::sf.gg [ig]);
6973
//ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac;
7074
//vh_g[ig] = fac * Porter[j];
71-
FPTYPE shart= ( conj( aux[ig] ) * aux[ig] ).real()/(GlobalC::ucell.tpiba2 * g2);
75+
FPTYPE shart= ( conj( aux[ig] ) * aux[ig] ).real()/(ucell.tpiba2 * g2);
7276
for(int l=0;l<3;l++)
7377
{
7478
for(int m=0;m<l+1;m++)
@@ -100,7 +104,7 @@ void Stress_Func<FPTYPE, Device>::stress_har(ModuleBase::matrix& sigma, ModulePW
100104
}
101105

102106
// Parallel_Reduce::reduce_pool( ehart );
103-
// ehart *= 0.5 * GlobalC::ucell.omega;
107+
// ehart *= 0.5 * ucell.omega;
104108
//psic(:)=(0.0,0.0)
105109
if(is_pw&&PARAM.globalv.gamma_only_pw)
106110
{
@@ -125,8 +129,8 @@ void Stress_Func<FPTYPE, Device>::stress_har(ModuleBase::matrix& sigma, ModulePW
125129

126130
for(int l=0;l<3;l++)
127131
{
128-
if(is_pw) { sigma(l,l) -= elecstate::H_Hartree_pw::hartree_energy /GlobalC::ucell.omega;
129-
} else { sigma(l,l) += elecstate::H_Hartree_pw::hartree_energy /GlobalC::ucell.omega;
132+
if(is_pw) { sigma(l,l) -= elecstate::H_Hartree_pw::hartree_energy /ucell.omega;
133+
} else { sigma(l,l) += elecstate::H_Hartree_pw::hartree_energy /ucell.omega;
130134
}
131135
for(int m=0;m<l;m++)
132136
{

source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void Stress_PW<FPTYPE, Device>::cal_stress(ModuleBase::matrix& sigmatot,
6666
this->stress_kin(sigmakin, this->pelec->wg, p_symm, p_kv, wfc_basis, ucell, d_psi_in);
6767

6868
// hartree contribution
69-
this->stress_har(sigmahar, rho_basis, 1, pelec->charge);
69+
this->stress_har(ucell,sigmahar, rho_basis, 1, pelec->charge);
7070

7171
// ewald contribution
7272
this->stress_ewa(ucell,sigmaewa, rho_basis, 1);

source/module_hamilt_pw/hamilt_stodft/sto_stress_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void Sto_Stress_PW<FPTYPE, Device>::cal_stress(ModuleBase::matrix& sigmatot,
3939
this->sto_stress_kin(sigmakin, wg, p_symm, p_kv, wfc_basis, psi_in, stowf);
4040

4141
// hartree contribution
42-
this->stress_har(sigmahar, rho_basis, true, chr);
42+
this->stress_har(ucell_in,sigmahar, rho_basis, true, chr);
4343

4444
// ewald contribution
4545
this->stress_ewa(ucell_in,sigmaewa, rho_basis, true);

0 commit comments

Comments
 (0)