Skip to content

Commit f4e4336

Browse files
committed
update value of omega and tpiba in charge_mixing
1 parent d1f27a0 commit f4e4336

File tree

4 files changed

+19
-20
lines changed

4 files changed

+19
-20
lines changed

source/module_elecstate/module_charge/charge_mixing.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in,
2626
const double& mixing_gg0_min_in,
2727
const double& mixing_angle_in,
2828
const bool& mixing_dmr_in,
29-
const double& omega_in,
30-
const double& tpiba_in)
29+
double& omega_in,
30+
double& tpiba_in)
3131
{
3232
// get private mixing parameters
3333
this->mixing_mode = mixing_mode_in;
@@ -40,9 +40,8 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in,
4040
this->mixing_gg0_min = mixing_gg0_min_in;
4141
this->mixing_angle = mixing_angle_in;
4242
this->mixing_dmr = mixing_dmr_in;
43-
this->omega = omega_in;
44-
this->tpiba = tpiba_in;
45-
this->tpiba2 = tpiba_in * tpiba_in;
43+
this->omega = &omega_in;
44+
this->tpiba = &tpiba_in;
4645
// check the paramters
4746
if (this->mixing_beta > 1.0 || this->mixing_beta < 0.0)
4847
{

source/module_elecstate/module_charge/charge_mixing.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Charge_Mixing
4646
const double& mixing_gg0_min_in,
4747
const double& mixing_angle_in,
4848
const bool& mixing_dmr_in,
49-
const double& omega_in,
50-
const double& tpiba_in);
49+
double& omega_in,
50+
double& tpiba_in);
5151

5252
void close_kerker_gg0() { mixing_gg0 = 0.0; mixing_gg0_mag = 0.0; }
5353
/**
@@ -133,9 +133,9 @@ class Charge_Mixing
133133
double mixing_gg0_min = 0.1; ///< minimum kerker coefficient
134134
double mixing_angle = 0.0; ///< mixing angle for nspin=4
135135
bool mixing_dmr = false; ///< whether to mixing real space density matrix
136-
double omega = 0.0; ///< omega for non-linear core correction
137-
double tpiba = 0.0; ///< 2*pi/beta for non-linear core correction
138-
double tpiba2 = 0.0; ///< 2*pi/beta^2 for non-linear core correction
136+
double* omega = nullptr; ///< omega for non-linear core correction
137+
double* tpiba = nullptr; ///< 2*pi/beta for non-linear core correction
138+
double* tpiba2 = nullptr; ///< 2*pi/beta^2 for non-linear core correction
139139
std::vector<double> _drho_history; ///< history of drho used to determine the oscillation, size is scf_nmax
140140

141141
bool new_e_iteration = true;

source/module_elecstate/module_charge/charge_mixing_preconditioner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void Charge_Mixing::Kerker_screen_recip(std::complex<double>* drhog)
4545
amin = this->mixing_beta;
4646
}
4747

48-
gg0 = std::pow(fac * 0.529177 / this->tpiba, 2);
48+
gg0 = std::pow(fac * 0.529177 / *this->tpiba, 2);
4949
#ifdef _OPENMP
5050
#pragma omp parallel for schedule(static, 512)
5151
#endif
@@ -110,7 +110,7 @@ void Charge_Mixing::Kerker_screen_real(double* drhor)
110110
amin = this->mixing_beta;
111111
}
112112

113-
gg0 = std::pow(fac * 0.529177 / this->tpiba, 2);
113+
gg0 = std::pow(fac * 0.529177 / *this->tpiba, 2);
114114
#ifdef _OPENMP
115115
#pragma omp parallel for schedule(static, 512)
116116
#endif

source/module_elecstate/module_charge/charge_mixing_residual.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ double Charge_Mixing::get_drho(Charge* chr, const double nelec)
6060
Parallel_Reduce::reduce_pool(drho);
6161
#endif
6262
assert(nelec != 0);
63-
assert(this->omega > 0);
63+
assert(*this->omega > 0);
6464
assert(this->rhopw->nxyz > 0);
65-
drho *= this->omega / static_cast<double>(this->rhopw->nxyz);
65+
drho *= *this->omega / static_cast<double>(this->rhopw->nxyz);
6666
drho /= nelec;
6767
}
6868

@@ -99,9 +99,9 @@ double Charge_Mixing::get_dkin(Charge* chr, const double nelec)
9999
Parallel_Reduce::reduce_pool(dkin);
100100
#endif
101101
assert(nelec != 0);
102-
assert(this->omega > 0);
102+
assert(*this->omega > 0);
103103
assert(this->rhopw->nxyz > 0);
104-
dkin *= this->omega / static_cast<double>(this->rhopw->nxyz);
104+
dkin *= *this->omega / static_cast<double>(this->rhopw->nxyz);
105105
dkin /= nelec;
106106

107107
ModuleBase::timer::tick("Charge_Mixing", "get_dkin");
@@ -121,7 +121,7 @@ double Charge_Mixing::inner_product_recip_rho(std::complex<double>* rho1, std::c
121121
rhog2[is] = rho2 + is * this->rhopw->npw;
122122
}
123123

124-
static const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / this->tpiba2;
124+
static const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / ((*this->tpiba) * (*this->tpiba));
125125
static const double fac2 = ModuleBase::e2 * ModuleBase::FOUR_PI / (ModuleBase::TWO_PI * ModuleBase::TWO_PI);
126126

127127
double sum = 0.0;
@@ -245,7 +245,7 @@ double Charge_Mixing::inner_product_recip_rho(std::complex<double>* rho1, std::c
245245
#endif
246246
ModuleBase::timer::tick("Charge_Mixing", "inner_product_recip_rho");
247247

248-
sum *= this->omega * 0.5;
248+
sum *= *this->omega * 0.5;
249249

250250
delete[] rhog1;
251251
delete[] rhog2;
@@ -285,7 +285,7 @@ double Charge_Mixing::inner_product_recip_hartree(std::complex<double>* rhog1, s
285285
ModuleBase::TITLE("Charge_Mixing", "inner_product_recip_hartree");
286286
ModuleBase::timer::tick("Charge_Mixing", "inner_product_recip_hartree");
287287

288-
static const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / this->tpiba2;
288+
static const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / ((*this->tpiba) * (*this->tpiba));
289289
static const double fac2 = ModuleBase::e2 * ModuleBase::FOUR_PI / (ModuleBase::TWO_PI * ModuleBase::TWO_PI);
290290

291291
double sum = 0.0;
@@ -446,7 +446,7 @@ double Charge_Mixing::inner_product_recip_hartree(std::complex<double>* rhog1, s
446446

447447
ModuleBase::timer::tick("Charge_Mixing", "inner_product_recip_hartree");
448448

449-
sum *= this->omega * 0.5;
449+
sum *= *this->omega * 0.5;
450450

451451
return sum;
452452
}

0 commit comments

Comments
 (0)