Skip to content

Commit 03c1172

Browse files
committed
fix ig=0
1 parent 8c71302 commit 03c1172

File tree

6 files changed

+17
-11
lines changed

6 files changed

+17
-11
lines changed

source/module_elecstate/module_pot/H_Hartree_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ ModuleBase::matrix H_Hartree_pw::v_hartree(const UnitCell &cell,
4444
double ehart = 0.0;
4545

4646
std::vector<std::complex<double>> vh_g(rho_basis->npw);
47+
const int ig0 = rho_basis->ig_gge0;
4748
#ifdef _OPENMP
4849
#pragma omp parallel for reduction(+:ehart)
4950
#endif
5051
for (int ig = 0; ig < rho_basis->npw; ig++)
5152
{
52-
if (rho_basis->gg[ig] >= 1.0e-8) // LiuXh 20180410
53-
{
53+
if (ig == ig0) continue; // skip G=0
5454
const double fac = ModuleBase::e2 * ModuleBase::FOUR_PI / (cell.tpiba2 * rho_basis->gg[ig]);
5555

5656
ehart += (conj(Porter[ig]) * Porter[ig]).real() * fac;
5757
vh_g[ig] = fac * Porter[ig];
58-
}
58+
5959
}
6060

6161
Parallel_Reduce::reduce_pool(ehart);

source/module_hamilt_general/module_ewald/H_Ewald_pw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ double H_Ewald_pw::compute_ewald(const UnitCell& cell,
124124
fact = 1.0;
125125

126126
//GlobalV::ofs_running << "\n pwb.gstart = " << pwb.gstart << std::endl;
127-
127+
const int ig0 = rho_basis->ig_gge0;
128128
for (int ig = 0; ig < rho_basis->npw; ig++)
129129
{
130-
if(ig == rho_basis->ig_gge0)
130+
if(ig == ig0)
131131
{
132132
continue;
133133
}

source/module_hamilt_general/module_surchem/cal_pseudo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ void surchem::gauss_charge(const UnitCell& cell,
1010
Structure_Factor* sf)
1111
{
1212
sf->setup_structure_factor(&cell, pgrid, rho_basis); // call strucFac(ntype,ngmc)
13+
const int ig0 = rho_basis->ig_gge0; // G=0 index
1314
for (int it = 0; it < cell.ntype; it++)
1415
{
1516
double RCS = GetAtom.atom_RCS[cell.atoms[it].ncpp.psd];

source/module_hamilt_general/module_surchem/cal_totn.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ void surchem::cal_totn(const UnitCell& cell,
1212
ModuleBase::GlobalFunc::ZEROS(vloc_g, rho_basis->npw);
1313

1414
rho_basis->real2recip(vlocal, vloc_g); // now n is vloc in Recispace
15+
const int ig0 = rho_basis->ig_gge0; // G=0 index
1516
for (int ig = 0; ig < rho_basis->npw; ig++) {
16-
if(ig==rho_basis->ig_gge0)
17+
if(ig==ig0)
1718
{
1819
N[ig] = Porter_g[ig];
1920
continue;
@@ -39,9 +40,10 @@ void surchem::induced_charge(const UnitCell& cell, const ModulePW::PW_Basis* rho
3940
std::complex<double> *induced_rhog = new complex<double>[rho_basis->npw];
4041
ModuleBase::GlobalFunc::ZEROS(induced_rhog, rho_basis->npw);
4142
rho_basis->real2recip(delta_phi, delta_phig);
43+
const int ig0 = rho_basis->ig_gge0; // G=0 index
4244
for (int ig = 0; ig < rho_basis->npw; ig++)
4345
{
44-
if(rho_basis->ig_gge0 == ig)
46+
if(ig==ig0)
4547
{
4648
continue;
4749
}

source/module_hamilt_pw/hamilt_pwdft/forces.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,17 @@ void Forces<FPTYPE, Device>::cal_force_ew(const UnitCell& ucell,
472472
upperbound = 2.0 * charge * charge * sqrt(2.0 * alpha / ModuleBase::TWO_PI)
473473
* erfc(sqrt(ucell.tpiba2 * rho_basis->ggecut / 4.0 / alpha));
474474
} while (upperbound > 1.0e-6);
475-
475+
const int ig0 = rho_basis->ig_gge0;
476476
#ifdef _OPENMP
477477
#pragma omp parallel for
478478
#endif
479479
for (int ig = 0; ig < rho_basis->npw; ig++)
480480
{
481-
if (rho_basis->gg[ig] !=0)
481+
if (ig== ig0)
482+
{
483+
continue; // skip G=0
484+
}
485+
else
482486
{
483487
aux[ig] *= ModuleBase::libm::exp(-1.0 * rho_basis->gg[ig] * ucell.tpiba2 / alpha / 4.0)
484488
/ (rho_basis->gg[ig] * ucell.tpiba2);

source/module_hamilt_pw/hamilt_pwdft/stress_func_cc.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ void Stress_Func<FPTYPE, Device>::stress_cc(ModuleBase::matrix& sigma,
159159
for(int ig = 0;ig< rho_basis->npw;ig++)
160160
{
161161
const FPTYPE norm_g = sqrt(rho_basis->gg[ig]);
162-
if(norm_g < 1e-4) { continue;
163-
}
162+
if(norm_g < 1e-4) { continue;}
164163
for (int l = 0; l < 3; l++)
165164
{
166165
for (int m = 0;m< 3;m++)

0 commit comments

Comments
 (0)