Skip to content

Commit 5823c99

Browse files
authored
Fix: wrong rho in charge_extra.cpp (#2242)
1 parent 4a7c116 commit 5823c99

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

source/module_elecstate/module_charge/charge.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void Charge::init_rho()
158158
std::cout << " START CHARGE : " << GlobalV::init_chg << std::endl;
159159
if (GlobalV::init_chg == "atomic") // mohan add 2007-10-17
160160
{
161-
this->atomic_rho(GlobalV::NSPIN, rho, GlobalC::rhopw);
161+
this->atomic_rho(GlobalV::NSPIN, GlobalC::ucell.omega, rho, GlobalC::rhopw);
162162
}
163163
else if (GlobalV::init_chg == "file")
164164
{
@@ -338,7 +338,7 @@ void Charge::renormalize_rho(void)
338338
// rho_at (read from pseudopotential files)
339339
// allocate work space (psic must already be allocated)
340340
//-------------------------------------------------------
341-
void Charge::atomic_rho(const int spin_number_need, double** rho_in, ModulePW::PW_Basis* rho_basis)const // Peize Lin refactor 2021.04.08
341+
void Charge::atomic_rho(const int spin_number_need, const double& omega, double** rho_in, ModulePW::PW_Basis* rho_basis)const // Peize Lin refactor 2021.04.08
342342
{
343343
ModuleBase::TITLE("Charge","atomic_rho");
344344
ModuleBase::timer::tick("Charge","atomic_rho");
@@ -467,7 +467,7 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in, ModulePW::P
467467
#pragma omp for
468468
#endif
469469
for (int igg=0; igg< rho_basis->ngg ; igg++)
470-
rho_lgl[igg] /= GlobalC::ucell.omega;
470+
rho_lgl[igg] /= omega;
471471
#ifdef _OPENMP
472472
}
473473
#endif
@@ -635,7 +635,7 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in, ModulePW::P
635635

636636
for(int ir=0; ir<rho_basis->nrxx; ++ir)
637637
ne[is] += rho_in[is][ir];
638-
ne[is] *= GlobalC::ucell.omega/(double)rho_basis->nxyz;
638+
ne[is] *= omega/(double)rho_basis->nxyz;
639639
Parallel_Reduce::reduce_double_pool( ne[is] );
640640

641641
// we check that everything is correct
@@ -656,9 +656,9 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in, ModulePW::P
656656
Parallel_Reduce::reduce_double_pool( sumrea );
657657

658658
// mohan fix bug 2011-04-03
659-
neg = neg / (double)rho_basis->nxyz * GlobalC::ucell.omega;
660-
ima = ima / (double)rho_basis->nxyz * GlobalC::ucell.omega;
661-
sumrea = sumrea / (double)rho_basis->nxyz * GlobalC::ucell.omega;
659+
neg = neg / (double)rho_basis->nxyz * omega;
660+
ima = ima / (double)rho_basis->nxyz * omega;
661+
sumrea = sumrea / (double)rho_basis->nxyz * omega;
662662

663663
if( ((neg<-1.0e-4) && (is==0||GlobalV::NSPIN==2)) || ima>1.0e-4)
664664
{

source/module_elecstate/module_charge/charge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Charge
4848
// mohan update 2021-02-20
4949
void allocate(const int &nspin_in, const int &nrxx_in, const int &ngmc_in);
5050

51-
void atomic_rho(const int spin_number_need, double **rho_in, ModulePW::PW_Basis *rho_basis) const;
51+
void atomic_rho(const int spin_number_need, const double& omega, double **rho_in, ModulePW::PW_Basis *rho_basis) const;
5252

5353
void set_rho_core(const ModuleBase::ComplexMatrix &structure_factor);
5454

source/module_elecstate/module_charge/charge_extra.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void Charge_Extra::extrapolate_charge(Charge* chr)
120120

121121
ModuleBase::GlobalFunc::ZEROS(rho_atom[is], GlobalC::rhopw->nrxx);
122122
}
123-
chr->atomic_rho(GlobalV::NSPIN, rho_atom, GlobalC::rhopw);
123+
chr->atomic_rho(GlobalV::NSPIN, omega_old, rho_atom, GlobalC::rhopw);
124124
#ifdef _OPENMP
125125
#pragma omp parallel for collapse(2) schedule(static, 512)
126126
#endif
@@ -215,7 +215,7 @@ void Charge_Extra::extrapolate_charge(Charge* chr)
215215
ModuleBase::GlobalFunc::ZEROS(rho_atom[is] + irbeg, irlen);
216216
}
217217
});
218-
chr->atomic_rho(GlobalV::NSPIN, rho_atom, GlobalC::rhopw);
218+
chr->atomic_rho(GlobalV::NSPIN, GlobalC::ucell.omega, rho_atom, GlobalC::rhopw);
219219
#ifdef _OPENMP
220220
#pragma omp parallel for collapse(2) schedule(static, 512)
221221
#endif

0 commit comments

Comments
 (0)