Skip to content

Commit ef3aa66

Browse files
authored
Merge pull request #111 from dyzheng/update
fix compiler error for last PR, set rigid threshold for occupations
2 parents 1e65de1 + 38a3692 commit ef3aa66

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

source/module_base/constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const double RYDBERG_SI = HARTREE_SI/2.0; //J
9494

9595
// zero up to a given accuracy
9696
//const double epsr = 1.0e-6;
97-
//const double epsg = 1.0e-10;
97+
const double threshold_wg = 1.0e-14;
9898
}
9999

100100
#endif

source/module_neighbor/sltk_grid_driver.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -315,33 +315,32 @@ ModuleBase::Vector3<double> Grid_Driver::Calculate_adjacent_site
315315
return adjacent_site;
316316
}
317317

318-
#include "../src_pw/global.h"
319-
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> Grid_Driver::get_adjs(const size_t &iat)
318+
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> Grid_Driver::get_adjs(const UnitCell_pseudo& ucell_in, const size_t &iat)
320319
{
321-
const int it = GlobalC::ucell.iat2it[iat];
322-
const int ia = GlobalC::ucell.iat2ia[iat];
323-
const ModuleBase::Vector3<double> &tau = GlobalC::ucell.atoms[it].tau[ia];
320+
const int it = ucell_in.iat2it[iat];
321+
const int ia = ucell_in.iat2ia[iat];
322+
const ModuleBase::Vector3<double> &tau = ucell_in.atoms[it].tau[ia];
324323

325324
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> adjs;
326-
GlobalC::GridD.Find_atom(GlobalC::ucell, tau, it, ia);
327-
for(int ad=0; ad<GlobalC::GridD.getAdjacentNum()+1; ad++)
325+
this->Find_atom(ucell_in, tau, it, ia);
326+
for(int ad=0; ad<this->getAdjacentNum()+1; ad++)
328327
{
329-
const size_t it_ad = GlobalC::GridD.getType(ad);
330-
const size_t ia_ad = GlobalC::GridD.getNatom(ad);
331-
const ModuleBase::Vector3<int> box_ad = GlobalC::GridD.getBox(ad);
332-
const ModuleBase::Vector3<double> tau_ad = GlobalC::GridD.getAdjacentTau(ad);
328+
const size_t it_ad = this->getType(ad);
329+
const size_t ia_ad = this->getNatom(ad);
330+
const ModuleBase::Vector3<int> box_ad = this->getBox(ad);
331+
const ModuleBase::Vector3<double> tau_ad = this->getAdjacentTau(ad);
333332

334333
adjs.push_back(std::make_tuple(it_ad, ia_ad, box_ad, tau_ad));
335334
}
336335
return adjs;
337336
}
338337

339-
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> Grid_Driver::get_adjs()
338+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> Grid_Driver::get_adjs(const UnitCell_pseudo& ucell_in)
340339
{
341-
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> adjs(GlobalC::ucell.nat);
342-
for(size_t iat=0; iat<GlobalC::ucell.nat; iat++)
340+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> adjs(ucell_in.nat);
341+
for(size_t iat=0; iat<ucell_in.nat; iat++)
343342
{
344-
adjs[iat] = Grid_Driver::get_adjs(iat);
343+
adjs[iat] = Grid_Driver::get_adjs(ucell_in, iat);
345344
}
346345
return adjs;
347346
}

source/module_neighbor/sltk_grid_driver.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
#include "sltk_atom.h"
77
#include "sltk_atom_input.h"
88
#include "sltk_grid.h"
9-
#include "../module_base/global_function.h"
10-
#include "../module_base/global_variable.h"
11-
#include "../module_base/vector3.h"
12-
#include "../src_pw/pw_basis.h"
9+
#include "module_base/global_function.h"
10+
#include "module_base/global_variable.h"
11+
#include "module_base/vector3.h"
12+
#include "src_pw/pw_basis.h"
13+
#include "module_cell/unitcell_pseudo.h"
1314
#include <tuple>
1415

1516
class Grid_Driver : public Grid
@@ -51,8 +52,8 @@ class Grid_Driver : public Grid
5152
const ModuleBase::Vector3<double>& getAdjacentTau(const int i) const { return adjacent_tau[i]; }
5253
const ModuleBase::Vector3<int>& getBox(const int i) const {return box[i];}
5354

54-
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> get_adjs(const size_t &iat);
55-
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> get_adjs();
55+
std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>> get_adjs(const UnitCell_pseudo& ucell_in, const size_t &iat);
56+
std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> get_adjs(const UnitCell_pseudo& ucell_in);
5657

5758
private:
5859

source/src_lcao/LCAO_gen_fixedH.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ void LCAO_gen_fixedH::build_Nonlocal_beta_new() //update by liuyu 2021-04-07
11481148
mkl_set_num_threads(1);
11491149
#endif
11501150

1151-
const std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> adjs_all = GlobalC::GridD.get_adjs();
1151+
const std::vector<std::vector<std::tuple<int, int, ModuleBase::Vector3<int>, ModuleBase::Vector3<double>>>> adjs_all = GlobalC::GridD.get_adjs(GlobalC::ucell);
11521152

11531153
#ifdef _OPENMP
11541154
#pragma omp parallel

source/src_pw/charge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ void Charge::sum_band_k(void)
760760
///
761761
///only occupied band should be calculated.
762762
///
763-
if(GlobalC::wf.wg(ik, ibnd)<1e-8) continue;
763+
if(GlobalC::wf.wg(ik, ibnd)<ModuleBase::threshold_wg) continue;
764764
GlobalC::en.eband += GlobalC::wf.ekb[ik][ibnd] * GlobalC::wf.wg(ik, ibnd);
765765
ModuleBase::GlobalFunc::ZEROS( porter, GlobalC::pw.nrxx );
766766
for (int ig = 0;ig < GlobalC::kv.ngk[ik] ; ig++)
@@ -818,7 +818,7 @@ void Charge::sum_band_k(void)
818818
///
819819
///only occupied band should be calculated.
820820
///
821-
if(GlobalC::wf.wg(ik, ibnd)<1e-8) continue;
821+
if(GlobalC::wf.wg(ik, ibnd)<ModuleBase::threshold_wg) continue;
822822
GlobalC::en.eband += GlobalC::wf.ekb[ik][ibnd] * GlobalC::wf.wg(ik, ibnd);
823823
//std::cout << "\n ekb = " << GlobalC::wf.ekb[ik][ibnd] << " wg = " << GlobalC::wf.wg(ik, ibnd);
824824

source/src_pw/forces.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void Forces::cal_force_nl(ModuleBase::matrix& forcenl)
732732
///
733733
///only occupied band should be calculated.
734734
///
735-
if(GlobalC::wf.wg(ik, ib) < 1.0e-8) continue;
735+
if(GlobalC::wf.wg(ik, ib) < ModuleBase::threshold_wg) continue;
736736
for (int i=0; i<nkb; i++)
737737
{
738738
for (int ig=0; ig<GlobalC::wf.npw; ig++)
@@ -754,7 +754,7 @@ void Forces::cal_force_nl(ModuleBase::matrix& forcenl)
754754
///
755755
///only occupied band should be calculated.
756756
///
757-
if(GlobalC::wf.wg(ik, ib) < 1.0e-8) continue;
757+
if(GlobalC::wf.wg(ik, ib) < ModuleBase::threshold_wg) continue;
758758
double fac = GlobalC::wf.wg(ik, ib) * 2.0 * GlobalC::ucell.tpiba;
759759
int iat = 0;
760760
int sum = 0;

source/src_pw/stress_func_nl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void Stress_Func::stress_nl(ModuleBase::matrix& sigma)
5656
///
5757
///only occupied band should be calculated.
5858
///
59-
if(GlobalC::wf.wg(ik, ib) < 1.0e-8) continue;
59+
if(GlobalC::wf.wg(ik, ib) < ModuleBase::threshold_wg) continue;
6060
for (int i = 0; i < nkb; i++)
6161
{
6262
for (int ig = 0; ig < GlobalC::wf.npw; ig++) {
@@ -140,7 +140,7 @@ void Stress_Func::stress_nl(ModuleBase::matrix& sigma)
140140
///
141141
///only occupied band should be calculated.
142142
///
143-
if(GlobalC::wf.wg(ik, ib) < 1.0e-8) continue;
143+
if(GlobalC::wf.wg(ik, ib) < ModuleBase::threshold_wg) continue;
144144
for (int i=0; i<nkb; i++)
145145
{
146146
for (int ig=0; ig<GlobalC::wf.npw; ig++)
@@ -169,7 +169,7 @@ void Stress_Func::stress_nl(ModuleBase::matrix& sigma)
169169
///
170170
///only occupied band should be calculated.
171171
///
172-
if(GlobalC::wf.wg(ik, ib) < 1.0e-5) continue;
172+
if(GlobalC::wf.wg(ik, ib) < ModuleBase::threshold_wg) continue;
173173
double fac = GlobalC::wf.wg(ik, ib) * 1.0;
174174
int iat = 0;
175175
int sum = 0;

0 commit comments

Comments
 (0)