Skip to content

Commit 3c248e0

Browse files
committed
change file in elestate_getters
1 parent a4baf84 commit 3c248e0

File tree

11 files changed

+22
-21
lines changed

11 files changed

+22
-21
lines changed

source/module_elecstate/elecstate_getters.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88
namespace elecstate
99
{
1010

11-
double get_ucell_omega()
12-
{
13-
return GlobalC::ucell.omega;
14-
}
15-
1611
double get_ucell_tpiba()
1712
{
1813
return GlobalC::ucell.tpiba;

source/module_elecstate/elecstate_getters.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
namespace elecstate
88
{
99

10-
/// @brief get the value of .omega
11-
double get_ucell_omega();
1210
/// @brief get the value of .tpiba
1311
double get_ucell_tpiba();
1412
/// @brief get the value of XC_Functional::func_type

source/module_elecstate/elecstate_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
176176

177177
this->basis->recip_to_real(this->ctx, &psi(ibnd,npwx), this->wfcr_another_spin, ik);
178178

179-
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / get_ucell_omega());
179+
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / ucell->omega);
180180

181181
if (w1 != 0.0)
182182
{
@@ -202,7 +202,7 @@ void ElecStatePW<T, Device>::rhoBandK(const psi::Psi<T, Device>& psi)
202202

203203
this->basis->recip_to_real(this->ctx, &psi(ibnd,0), this->wfcr, ik);
204204

205-
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / get_ucell_omega());
205+
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / ucell->omega);
206206

207207
if (w1 != 0.0)
208208
{

source/module_elecstate/elecstate_pw_cal_tau.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void ElecStatePW<T, Device>::cal_tau(const psi::Psi<T, Device>& psi)
2626
{
2727
this->basis->recip_to_real(this->ctx, &psi(ibnd,0), this->wfcr, ik);
2828

29-
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / get_ucell_omega());
29+
const auto w1 = static_cast<Real>(this->wg(ik, ibnd) / ucell->omega);
3030

3131
// kinetic energy density
3232
for (int j = 0; j < 3; j++)

source/module_elecstate/magnetism.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ Magnetism::~Magnetism()
1515
delete[] this->start_magnetization;
1616
}
1717

18-
void Magnetism::compute_magnetization(const int& nrxx, const int& nxyz, const double* const * rho, double* nelec_spin)
18+
void Magnetism::compute_magnetization(const double omega,
19+
const int& nrxx,
20+
const int& nxyz,
21+
const double* const * rho,
22+
double* nelec_spin)
1923
{
2024
if (PARAM.inp.nspin==2)
2125
{
@@ -32,8 +36,8 @@ void Magnetism::compute_magnetization(const int& nrxx, const int& nxyz, const do
3236
Parallel_Reduce::reduce_pool(this->tot_magnetization);
3337
Parallel_Reduce::reduce_pool(this->abs_magnetization);
3438
#endif
35-
this->tot_magnetization *= elecstate::get_ucell_omega() / nxyz;
36-
this->abs_magnetization *= elecstate::get_ucell_omega() / nxyz;
39+
this->tot_magnetization *= omega / nxyz;
40+
this->abs_magnetization *= omega / nxyz;
3741

3842
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"total magnetism (Bohr mag/cell)",this->tot_magnetization);
3943
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"absolute magnetism (Bohr mag/cell)",this->abs_magnetization);
@@ -65,8 +69,8 @@ void Magnetism::compute_magnetization(const int& nrxx, const int& nxyz, const do
6569
Parallel_Reduce::reduce_pool(this->tot_magnetization_nc, 3);
6670
Parallel_Reduce::reduce_pool(this->abs_magnetization);
6771
#endif
68-
for(int i=0;i<3;i++)this->tot_magnetization_nc[i] *= elecstate::get_ucell_omega() / nxyz;
69-
this->abs_magnetization *= elecstate::get_ucell_omega() / nxyz;
72+
for(int i=0;i<3;i++)this->tot_magnetization_nc[i] *= omega / nxyz;
73+
this->abs_magnetization *= omega / nxyz;
7074
GlobalV::ofs_running<<"total magnetism (Bohr mag/cell)"<<'\t'<<this->tot_magnetization_nc[0]<<'\t'<<this->tot_magnetization_nc[1]<<'\t'<<this->tot_magnetization_nc[2]<<'\n';
7175
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"absolute magnetism (Bohr mag/cell)",this->abs_magnetization);
7276
}

source/module_elecstate/magnetism.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Magnetism
2121
double tot_magnetization_nc[3];
2222
double abs_magnetization;
2323

24-
void compute_magnetization(const int& nrxx, const int& nxyz, const double* const * rho, double* nelec_spin = nullptr);
24+
void compute_magnetization(const double omega, const int& nrxx, const int& nxyz, const double* const * rho, double* nelec_spin = nullptr);
2525

2626
ModuleBase::Vector3<double> *m_loc_; //magnetization for each element along c-axis
2727
double *angle1_; //angle between c-axis and real spin std::vector

source/module_elecstate/module_charge/charge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ double Charge::sum_rho() const
218218
}
219219

220220
// multiply the sum of charge density by a factor
221-
sum_rho *= elecstate::get_ucell_omega() / static_cast<double>(this->rhopw->nxyz);
221+
sum_rho *= this->omega / static_cast<double>(this->rhopw->nxyz);
222222

223223
#ifdef __MPI
224224
Parallel_Reduce::reduce_pool(sum_rho);
@@ -722,7 +722,7 @@ double Charge::cal_rho2ne(const double* rho_in) const
722722
#ifdef __MPI
723723
Parallel_Reduce::reduce_pool(ne);
724724
#endif
725-
ne = ne * elecstate::get_ucell_omega() / (double)this->rhopw->nxyz;
725+
ne = ne * this->omega / (double)this->rhopw->nxyz;
726726

727727
return ne;
728728
}

source/module_elecstate/module_charge/charge.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ class Charge
149149
void destroy(); // free arrays liuyu 2023-03-12
150150

151151
bool allocate_rho;
152-
152+
double omega; // volume of the unit cell
153+
double tpiba2; // 2*pi/lat0
153154
bool allocate_rho_final_scf; // LiuXh add 20180606
154155
#ifdef __MPI
155156
private:

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void Charge::init_rho(const UnitCell& ucell,
3232

3333
std::cout << " START CHARGE : " << PARAM.inp.init_chg << std::endl;
3434
bool read_error = false;
35+
this->omega = ucell.omega;
36+
this->tpiba2 = ucell.tpiba2;
3537
if (PARAM.inp.init_chg == "file" || PARAM.inp.init_chg == "auto")
3638
{
3739
GlobalV::ofs_running << " try to read charge from file : " << std::endl;

source/module_esolver/esolver_ks.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ void ESolver_KS<T, Device>::iter_finish(UnitCell& ucell, const int istep, int& i
552552
}
553553

554554
// compute magnetization, only for LSDA(spin==2)
555-
ucell.magnet.compute_magnetization(this->pelec->charge->nrxx,
555+
ucell.magnet.compute_magnetization(ucell.omega,
556+
this->pelec->charge->nrxx,
556557
this->pelec->charge->nxyz,
557558
this->pelec->charge->rho,
558559
this->pelec->nelec_spin.data());

0 commit comments

Comments
 (0)