Skip to content

Commit 78e89ee

Browse files
committed
fix bug in charge
1 parent 17a7df5 commit 78e89ee

File tree

4 files changed

+54
-11
lines changed

4 files changed

+54
-11
lines changed

source/module_elecstate/module_charge/charge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ class Charge
100100
void non_linear_core_correction
101101
(
102102
const bool &numeric,
103-
const int mesh,
104103
const double omega,
105104
const double tpiba2,
105+
const int mesh,
106106
const double *r,
107107
const double *rab,
108108
const double *rhoc,

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,9 @@ void Charge::set_rho_core_paw()
329329
void Charge::non_linear_core_correction
330330
(
331331
const bool &numeric,
332-
const int mesh,
333332
const double omega,
334333
const double tpiba2,
334+
const int mesh,
335335
const double *r,
336336
const double *rab,
337337
const double *rhoc,

source/module_elecstate/module_charge/charge_mixing_preconditioner.cpp

Lines changed: 1 addition & 1 deletion
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 / tpiba, 2);
48+
gg0 = std::pow(fac * 0.529177 / tpiba2, 2);
4949
#ifdef _OPENMP
5050
#pragma omp parallel for schedule(static, 512)
5151
#endif

source/module_elecstate/test/charge_mixing_test.cpp

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ class ChargeMixingTest : public ::testing::Test
107107
PARAM.input.mixing_gg0_mag = 0.0;
108108
PARAM.input.mixing_gg0_min = 0.1;
109109
PARAM.input.mixing_angle = -10.0;
110-
PARAM.input.mixing_dmr,
111-
ucell.omega,
112-
ucell.tpiba = false;
113-
110+
PARAM.input.mixing_dmr = false;
111+
ucell.tpiba = 1.0;
112+
ucell.omega = 2.0;
114113
}
115114
ModulePW::PW_Basis pw_basis;
116115
ModulePW::PW_Basis_Sup pw_dbasis;
@@ -406,9 +405,18 @@ TEST_F(ChargeMixingTest, InnerDotRecipHartreeTest)
406405
EXPECT_NEAR(inner, 0.5 * pw_basis.nrxx * (pw_basis.nrxx - 1), 1e-8);
407406

408407
// RECIPROCAL NSPIN=1
409-
ucell.tpiba = 1.0;
410-
ucell.omega = 2.0;
411-
408+
CMtest.set_mixing(PARAM.input.mixing_mode,
409+
PARAM.input.mixing_beta,
410+
PARAM.input.mixing_ndim,
411+
PARAM.input.mixing_gg0,
412+
PARAM.input.mixing_tau,
413+
PARAM.input.mixing_beta_mag,
414+
PARAM.input.mixing_gg0_mag,
415+
PARAM.input.mixing_gg0_min,
416+
PARAM.input.mixing_angle,
417+
PARAM.input.mixing_dmr,
418+
ucell.omega,
419+
ucell.tpiba);
412420
PARAM.input.nspin = 1;
413421
std::vector<std::complex<double>> drhog1(pw_basis.npw);
414422
std::vector<std::complex<double>> drhog2(pw_basis.npw);
@@ -505,6 +513,18 @@ TEST_F(ChargeMixingTest, InnerDotRecipRhoTest)
505513
Charge_Mixing CMtest;
506514
CMtest.set_rhopw(&pw_basis, &pw_basis);
507515
PARAM.input.nspin = 1;
516+
CMtest.set_mixing(PARAM.input.mixing_mode,
517+
PARAM.input.mixing_beta,
518+
PARAM.input.mixing_ndim,
519+
PARAM.input.mixing_gg0,
520+
PARAM.input.mixing_tau,
521+
PARAM.input.mixing_beta_mag,
522+
PARAM.input.mixing_gg0_mag,
523+
PARAM.input.mixing_gg0_min,
524+
PARAM.input.mixing_angle,
525+
PARAM.input.mixing_dmr,
526+
ucell.omega,
527+
ucell.tpiba);
508528
std::vector<double> drhor1(pw_basis.nrxx);
509529
std::vector<double> drhor2(pw_basis.nrxx);
510530
for (int i = 0; i < pw_basis.nrxx; ++i)
@@ -573,6 +593,18 @@ TEST_F(ChargeMixingTest, KerkerScreenRecipTest)
573593
Charge_Mixing CMtest;
574594
CMtest.set_rhopw(&pw_basis, &pw_basis);
575595
ucell.tpiba = 1.0;
596+
CMtest.set_mixing(PARAM.input.mixing_mode,
597+
PARAM.input.mixing_beta,
598+
PARAM.input.mixing_ndim,
599+
PARAM.input.mixing_gg0,
600+
PARAM.input.mixing_tau,
601+
PARAM.input.mixing_beta_mag,
602+
PARAM.input.mixing_gg0_mag,
603+
PARAM.input.mixing_gg0_min,
604+
PARAM.input.mixing_angle,
605+
PARAM.input.mixing_dmr,
606+
ucell.omega,
607+
ucell.tpiba);
576608
// nspin = 1
577609
PARAM.input.nspin = 1;
578610
std::complex<double>* drhog = new std::complex<double>[PARAM.input.nspin*pw_basis.npw];
@@ -703,7 +735,18 @@ TEST_F(ChargeMixingTest, KerkerScreenRealTest)
703735
Charge_Mixing CMtest;
704736
CMtest.set_rhopw(&pw_basis, &pw_basis);
705737
ucell.tpiba = 1.0;
706-
738+
CMtest.set_mixing(PARAM.input.mixing_mode,
739+
PARAM.input.mixing_beta,
740+
PARAM.input.mixing_ndim,
741+
PARAM.input.mixing_gg0,
742+
PARAM.input.mixing_tau,
743+
PARAM.input.mixing_beta_mag,
744+
PARAM.input.mixing_gg0_mag,
745+
PARAM.input.mixing_gg0_min,
746+
PARAM.input.mixing_angle,
747+
PARAM.input.mixing_dmr,
748+
ucell.omega,
749+
ucell.tpiba);
707750
// nspin = 1
708751
PARAM.input.nspin = 1;
709752
double* drhor = new double[PARAM.input.nspin*pw_basis.nrxx];

0 commit comments

Comments
 (0)