Skip to content

Commit aada6f6

Browse files
committed
fix error in module_lr
1 parent 76ad58a commit aada6f6

File tree

19 files changed

+69
-56
lines changed

19 files changed

+69
-56
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ ESolver_KS_LCAO<TK, TR>::ESolver_KS_LCAO()
9494
template <typename TK, typename TR>
9595
ESolver_KS_LCAO<TK, TR>::~ESolver_KS_LCAO()
9696
{
97-
#ifndef __OLD_GINT
98-
// release gint_info
99-
ModuleGint::Gint::set_gint_info(nullptr);
100-
#endif
10197
}
10298

10399
template <typename TK, typename TR>

source/module_esolver/esolver_ks_lcao.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ class ESolver_KS_LCAO : public ESolver_KS<TK>
9595
//! Grid integration: used to store some basic information
9696
Grid_Technique GridT;
9797

98+
#ifndef __OLD_GINT
99+
//! GintInfo: used to store some basic infomation about module_gint
100+
std::unique_ptr<ModuleGint::GintInfo> gint_info_;
101+
#endif
102+
98103
//! NAO orbitals: two-center integrations
99104
TwoCenterBundle two_center_bundle_;
100105

source/module_esolver/lcao_before_scf.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
104104

105105
//! 6) prepare grid integral
106106
#else
107-
auto gint_info = std::make_shared<ModuleGint::GintInfo>(
107+
gint_info_.reset(
108+
new ModuleGint::GintInfo(
108109
this->pw_big->nbx,
109110
this->pw_big->nby,
110111
this->pw_big->nbz,
@@ -119,8 +120,8 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
119120
this->pw_big->nbzp,
120121
orb_.Phi,
121122
ucell,
122-
this->gd);
123-
ModuleGint::Gint::set_gint_info(gint_info);
123+
this->gd));
124+
ModuleGint::Gint::set_gint_info(gint_info_.get());
124125
#endif
125126

126127
// 7) For each atom, calculate the adjacent atoms in different cells

source/module_esolver/lcao_others.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
134134
// prepare grid in Gint
135135
LCAO_domain::grid_prepare(this->GridT, this->GG, this->GK, ucell, orb_, *this->pw_rho, *this->pw_big);
136136
#else
137-
auto gint_info = std::make_shared<ModuleGint::GintInfo>(
137+
gint_info_.reset(
138+
new ModuleGint::GintInfo(
138139
this->pw_big->nbx,
139140
this->pw_big->nby,
140141
this->pw_big->nbz,
@@ -149,8 +150,8 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
149150
this->pw_big->nbzp,
150151
orb_.Phi,
151152
ucell,
152-
this->gd);
153-
ModuleGint::Gint::set_gint_info(gint_info);
153+
this->gd));
154+
ModuleGint::Gint::set_gint_info(gint_info_.get());
154155
#endif
155156

156157
// (2)For each atom, calculate the adjacent atoms in different cells

source/module_hamilt_lcao/module_gint/temp_gint/gint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
namespace ModuleGint
44
{
55

6-
std::shared_ptr<GintInfo> Gint::gint_info_ = nullptr;
6+
GintInfo* Gint::gint_info_ = nullptr;
77

88
}

source/module_hamilt_lcao/module_gint/temp_gint/gint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class Gint
1414

1515
// note that gint_info_ is a static member variable
1616
// it is shared by all instances of Gint
17-
static void set_gint_info(std::shared_ptr<GintInfo> gint_info)
17+
static void set_gint_info(GintInfo* gint_info)
1818
{
1919
gint_info_ = gint_info;
2020
}
2121

2222
protected:
23-
static std::shared_ptr<GintInfo> gint_info_;
23+
static GintInfo* gint_info_;
2424
};
2525

2626
}

source/module_hamilt_lcao/module_gint/temp_gint/gint_common.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,12 @@ void transfer_dm_2d_to_gint(
146146
{
147147
ModuleBase::TITLE("Gint", "transfer_dm_2d_to_gint");
148148
ModuleBase::timer::tick("Gint", "transfer_dm_2d_to_gint");
149-
assert(PARAM.inp.nspin == dm_gint.size()
150-
&& "The size of dm_gint should be equal to the number of spins!");
151-
if(PARAM.inp.nspin != 4)
152-
{
153-
assert(dm.size() == PARAM.inp.nspin);
154-
} else
155-
{
156-
assert(dm.size() == 1);
157-
}
158149

159150
if (PARAM.inp.nspin != 4)
160151
{
161-
for (int is = 0; is < PARAM.inp.nspin; is++)
152+
// dm_gint.size() usually equals to PARAM.inp.nspin,
153+
// but there is exception within module_lr
154+
for (int is = 0; is < dm_gint.size(); is++)
162155
{
163156
#ifdef __MPI
164157
hamilt::transferParallels2Serials(*dm[is], &dm_gint[is]);

source/module_hamilt_lcao/module_gint/temp_gint/gint_info.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ GintInfo::GintInfo(
4242
biggrids_.push_back(std::make_shared<BigGrid>(i));
4343
}
4444

45-
// initialize the atoms
45+
// initialize the atoms and the numerical orbital
4646
init_atoms_(ucell_->ntype, ucell_->atoms, Phi);
4747

4848
// initialize trace_lo_ and lgd_
@@ -82,12 +82,14 @@ void GintInfo::init_atoms_(int ntype, const Atom* atoms, const Numerical_Orbital
8282
int iat = 0;
8383
is_atom_in_proc_.resize(ucell_->nat, false);
8484
atoms_.resize(ucell_->nat);
85+
orbs_.resize(ntype);
8586

8687
// TODO: USE OPENMP TO PARALLELIZE THIS LOOP
8788
for(int i = 0; i < ntype; i++)
8889
{
8990
const auto& atom = atoms[i];
90-
const auto *orb = &Phi[i];
91+
orbs_[i] = Phi[i];
92+
const auto *orb = &orbs_[i];
9193

9294
// rcut extends to the maximum big grids in x, y, z directions
9395
Vec3i ext_bgrid = biggrid_info_->max_ext_bgrid_num(atom.Rcut);

source/module_hamilt_lcao/module_gint/temp_gint/gint_info.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@ class GintInfo
9292
// map the global index of atomic orbitals to local index
9393
std::vector<int> trace_lo_;
9494

95+
// store the information about Numerical orbitals
96+
std::vector<Numerical_Orbital> orbs_;
97+
9598
// total num of atomic orbitals on this proc
96-
int lgd_;
99+
int lgd_ = 0;
97100

98101
#ifdef __CUDA
99102
public:

source/module_hamilt_lcao/module_gint/temp_gint/gint_interface.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,18 @@ void cal_gint_vl_metagga(
101101
void cal_gint_rho(
102102
const std::vector<HContainer<double>*>& dm_vec,
103103
const int nspin,
104-
double **rho)
104+
double **rho,
105+
bool is_dm_symm)
105106
{
106107
#ifdef __CUDA
107108
if(PARAM.inp.device == "gpu")
108109
{
109-
Gint_rho_gpu gint_rho(dm_vec, nspin, rho);
110+
Gint_rho_gpu gint_rho(dm_vec, nspin, rho, is_dm_symm);
110111
gint_rho.cal_gint();
111112
} else
112113
#endif
113114
{
114-
Gint_rho gint_rho(dm_vec, nspin, rho);
115+
Gint_rho gint_rho(dm_vec, nspin, rho, is_dm_symm);
115116
gint_rho.cal_gint();
116117
}
117118
}

0 commit comments

Comments
 (0)