Skip to content

Commit 2ba4117

Browse files
authored
restart from HexxR.csr produced by out_chg (#5586)
1 parent 4ac1e8a commit 2ba4117

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,25 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
157157
{
158158
for (int is = 0; is < PARAM.inp.nspin; ++is)
159159
{
160-
GlobalC::restart.load_disk("charge", is, this->nrxx, rho[is]);
160+
try
161+
{
162+
GlobalC::restart.load_disk("charge", is, this->nrxx, rho[is]);
163+
}
164+
catch (const std::exception& e)
165+
{
166+
// try to load from the output of `out_chg`
167+
std::stringstream ssc;
168+
ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube";
169+
if (ModuleIO::read_vdata_palgrid(GlobalC::Pgrid,
170+
(PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_STOGROUP : GlobalV::MY_RANK),
171+
GlobalV::ofs_running,
172+
ssc.str(),
173+
this->rho[is],
174+
GlobalC::ucell.nat))
175+
{
176+
GlobalV::ofs_running << " Read in the charge density: " << ssc.str() << std::endl;
177+
}
178+
}
161179
}
162180
GlobalC::restart.info_load.load_charge_finish = true;
163181
}

source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ OperatorEXX<OperatorLCAO<TK, TR>>::OperatorEXX(HS_Matrix_K<TK>* hsk_in,
205205
else if (this->add_hexx_type == Add_Hexx_Type::R)
206206
{
207207
// read in Hexx(R)
208-
const std::string restart_HR_path = GlobalC::restart.folder + "HexxR" + std::to_string(GlobalV::MY_RANK);
208+
const std::string restart_HR_path = PARAM.globalv.global_readin_dir + "HexxR" + std::to_string(GlobalV::MY_RANK);
209209
bool all_exist = true;
210210
for (int is = 0; is < PARAM.inp.nspin; ++is)
211211
{

source/module_ri/Exx_LRI_interface.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,14 @@ void Exx_LRI_Interface<T, Tdata>::exx_hamilt2density(elecstate::ElecState& elec,
141141
if (GlobalC::restart.info_load.load_H_finish && !GlobalC::restart.info_load.restart_exx
142142
&& this->two_level_step == 0 && iter == 1)
143143
{
144-
if (GlobalV::MY_RANK == 0) {GlobalC::restart.load_disk("Eexx", 0, 1, &this->exx_ptr->Eexx);
145-
}
144+
if (GlobalV::MY_RANK == 0)
145+
{
146+
try { GlobalC::restart.load_disk("Eexx", 0, 1, &this->exx_ptr->Eexx); }
147+
catch (const std::exception& e)
148+
{
149+
std::cout << "WARNING: Cannot read Eexx from disk, the energy of the 1st loop will be wrong, sbut it does not influence the subsequent loops." << std::endl;
150+
}
151+
}
146152
Parallel_Common::bcast_double(this->exx_ptr->Eexx);
147153
this->exx_ptr->Eexx /= GlobalC::exx_info.info_global.hybrid_alpha;
148154
}

0 commit comments

Comments
 (0)