Skip to content

Commit 67b435d

Browse files
committed
refactor read_wfc_nao (remove the dependence of pelec)
1 parent dd0dc03 commit 67b435d

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
166166
// 5) read psi from file
167167
if (PARAM.inp.init_wfc == "file")
168168
{
169-
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->pv, *(this->psi), this->pelec))
169+
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->pv, *(this->psi), this->pelec->wg, this->pelec->ekb))
170170
{
171171
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO", "read electronic wave functions failed");
172172
}

source/module_esolver/lcao_others.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void ESolver_KS_LCAO<TK, TR>::others(UnitCell& ucell, const int istep)
175175
// init wfc from file
176176
if (istep == 0 && PARAM.inp.init_wfc == "file")
177177
{
178-
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->pv, *(this->psi), this->pelec))
178+
if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->pv, *(this->psi), this->pelec->wg, this->pelec->ekb))
179179
{
180180
ModuleBase::WARNING_QUIT("ESolver_KS_LCAO<TK, TR>::others", "read wfc nao failed");
181181
}

source/module_io/read_wfc_nao.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ bool ModuleIO::read_wfc_nao(
2424
const std::string& global_readin_dir,
2525
const Parallel_Orbitals& ParaV,
2626
psi::Psi<T>& psid,
27-
elecstate::ElecState* const pelec,
27+
ModuleBase::matrix& wg,
28+
ModuleBase::matrix& ekb,
2829
const int skip_band)
2930
{
3031
ModuleBase::TITLE("ModuleIO", "read_wfc_nao");
3132
ModuleBase::timer::tick("ModuleIO", "read_wfc_nao");
32-
int nk = pelec->ekb.nr;
33+
int nk = ekb.nr;
3334
bool gamma_only = std::is_same<T, double>::value;
3435
int out_type = 1; // only support text file now
3536
bool read_success = true;
@@ -101,8 +102,8 @@ bool ModuleIO::read_wfc_nao(
101102
const int ib_read = std::max(i - skip_band, 0);
102103
int ib = 0;
103104
ModuleBase::GlobalFunc::READ_VALUE(ifs, ib);
104-
ModuleBase::GlobalFunc::READ_VALUE(ifs, pelec->ekb(ik, ib_read));
105-
ModuleBase::GlobalFunc::READ_VALUE(ifs, pelec->wg(ik, ib_read));
105+
ModuleBase::GlobalFunc::READ_VALUE(ifs, ekb(ik, ib_read));
106+
ModuleBase::GlobalFunc::READ_VALUE(ifs, wg(ik, ib_read));
106107
if (i+1 != ib)
107108
{
108109
error_message << "The band index read in from file do not match the global parameter band index!\n";
@@ -159,8 +160,8 @@ bool ModuleIO::read_wfc_nao(
159160
1,
160161
const_cast<int*>(ParaV.desc_wfc),
161162
pv_glb.blacs_ctxt);
162-
Parallel_Common::bcast_double(&(pelec->ekb(ik, 0)), nbands);
163-
Parallel_Common::bcast_double(&(pelec->wg(ik, 0)), nbands);
163+
Parallel_Common::bcast_double(&(ekb(ik, 0)), nbands);
164+
Parallel_Common::bcast_double(&(wg(ik, 0)), nbands);
164165
#else
165166
BlasConnector::copy(nbands*nlocal, ctot.data(), 1, psid.get_pointer(), 1);
166167
#endif
@@ -172,10 +173,12 @@ bool ModuleIO::read_wfc_nao(
172173
template bool ModuleIO::read_wfc_nao<double>(const std::string& global_readin_dir,
173174
const Parallel_Orbitals& ParaV,
174175
psi::Psi<double>& psid,
175-
elecstate::ElecState* const pelec,
176+
ModuleBase::matrix& wg,
177+
ModuleBase::matrix& ekb,
176178
const int skip_band);
177179
template bool ModuleIO::read_wfc_nao<std::complex<double>>(const std::string& global_readin_dir,
178180
const Parallel_Orbitals& ParaV,
179181
psi::Psi<std::complex<double>>& psid,
180-
elecstate::ElecState* const pelec,
182+
ModuleBase::matrix& wg,
183+
ModuleBase::matrix& ekb,
181184
const int skip_band);

source/module_io/read_wfc_nao.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ bool read_wfc_nao(
4040
const std::string& global_readin_dir,
4141
const Parallel_Orbitals& ParaV,
4242
psi::Psi<T>& psid,
43-
elecstate::ElecState* const pelec,
43+
ModuleBase::matrix& wg,
44+
ModuleBase::matrix& ekb,
4445
const int skip_band = 0);
4546

4647
} // namespace ModuleIO

source/module_lr/esolver_lrtd_lcao.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,8 @@ template<typename T, typename TR>
697697
void LR::ESolver_LR<T, TR>::read_ks_wfc()
698698
{
699699
assert(this->psi_ks != nullptr);
700-
this->pelec->ekb.create(this->kv.get_nks(), this->nbands);
701-
this->pelec->wg.create(this->kv.get_nks(), this->nbands);
702-
700+
this->eig_ks.create(this->kv.get_nks(), this->nbands);
701+
this->wg_ks.create(this->kv.get_nks(), this->nbands);
703702
if (input.ri_hartree_benchmark == "aims") // for aims benchmark
704703
{
705704
#ifdef __EXX
@@ -714,7 +713,7 @@ void LR::ESolver_LR<T, TR>::read_ks_wfc()
714713
ModuleBase::WARNING_QUIT("ESolver_LR", "RI benchmark is only supported when compile with LibRI.");
715714
#endif
716715
}
717-
else if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->paraMat_, *this->psi_ks, this->pelec,
716+
else if (!ModuleIO::read_wfc_nao(PARAM.globalv.global_readin_dir, this->paraMat_, *this->psi_ks, this->wg_ks, this->eig_ks,
718717
/*skip_bands=*/this->nocc_max - this->nocc_in)) {
719718
ModuleBase::WARNING_QUIT("ESolver_LR", "read ground-state wavefunction failed.");
720719
}

0 commit comments

Comments
 (0)