diff --git a/source/module_cell/read_pp.cpp b/source/module_cell/read_pp.cpp index 29c75afbe8..c6bb4ab208 100644 --- a/source/module_cell/read_pp.cpp +++ b/source/module_cell/read_pp.cpp @@ -478,4 +478,13 @@ void Pseudopot_upf::setqfnew(const int& nqf, } rho[ir] *= pow(r[ir], l + n); } +} + +void Pseudopot_upf::skip_number(std::ifstream& ifs, bool mesh_changed) +{ + if (mesh_changed) + { + double temp = 0.; + ifs >> temp; + } } \ No newline at end of file diff --git a/source/module_cell/read_pp.h b/source/module_cell/read_pp.h index a6f3d4adbf..6029269639 100644 --- a/source/module_cell/read_pp.h +++ b/source/module_cell/read_pp.h @@ -73,6 +73,7 @@ class Pseudopot_upf private: bool mesh_changed = false; // if the mesh is even, it will be changed to odd + void skip_number(std::ifstream& ifs, bool mesh_changed); // skip the last number if the mesh is even int set_pseudo_type(const std::string& fn, std::string& type); std::string& trim(std::string& in_str); diff --git a/source/module_cell/read_pp_upf100.cpp b/source/module_cell/read_pp_upf100.cpp index 8d0ac10e69..1f5d11d980 100644 --- a/source/module_cell/read_pp_upf100.cpp +++ b/source/module_cell/read_pp_upf100.cpp @@ -236,6 +236,7 @@ void Pseudopot_upf::read_pseudo_mesh(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.r[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); } @@ -245,6 +246,7 @@ void Pseudopot_upf::read_pseudo_mesh(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.rab[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); } return; @@ -258,6 +260,7 @@ void Pseudopot_upf::read_pseudo_nlcc(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.rho_atc[ir]; } + this->skip_number(ifs, this->mesh_changed); return; } @@ -270,7 +273,7 @@ void Pseudopot_upf::read_pseudo_local(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.vloc_at[ir]; } - + this->skip_number(ifs, this->mesh_changed); return; } @@ -406,6 +409,7 @@ void Pseudopot_upf::read_pseudo_nl(std::ifstream &ifs, Atom_pseudo& pp) ifs >> qfunc(nmb, ir); } } + this->skip_number(ifs, this->mesh_changed); if (this->nqf > 0) { @@ -445,11 +449,7 @@ void Pseudopot_upf::read_pseudo_pswfc(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.chi(i, ir); } - if (this->mesh_changed) - { - double temp = 0.0; - ifs >> temp; - } + this->skip_number(ifs, this->mesh_changed); } return; } @@ -461,6 +461,7 @@ void Pseudopot_upf::read_pseudo_rhoatom(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.rho_at[ir]; } + this->skip_number(ifs, this->mesh_changed); return; } diff --git a/source/module_cell/read_pp_upf201.cpp b/source/module_cell/read_pp_upf201.cpp index 854b988219..e8e6a10b16 100644 --- a/source/module_cell/read_pp_upf201.cpp +++ b/source/module_cell/read_pp_upf201.cpp @@ -32,6 +32,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.rho_atc[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); } @@ -53,6 +54,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.vloc_at[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); } @@ -90,6 +92,7 @@ int Pseudopot_upf::read_pseudo_upf201(std::ifstream &ifs, Atom_pseudo& pp) { ifs >> pp.rho_at[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); //-------------------------------------- @@ -406,6 +409,7 @@ void Pseudopot_upf::read_pseudo_upf201_mesh(std::ifstream& ifs, Atom_pseudo& pp) { ifs >> pp.r[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "> pp.rab[ir]; } + this->skip_number(ifs, this->mesh_changed); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); ModuleBase::GlobalFunc::SCAN_END(ifs, ""); } @@ -497,6 +502,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo& { ifs >> pp.betar(ib, ir); } + this->skip_number(ifs, this->mesh_changed); word = ""; ModuleBase::GlobalFunc::SCAN_END(ifs, word); } @@ -639,6 +645,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo& { ifs >> pp.qfuncl(l, nmb, ir); } + this->skip_number(ifs, this->mesh_changed); word = ""; ModuleBase::GlobalFunc::SCAN_END(ifs, word); @@ -653,6 +660,7 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo& { ifs >> this->qfunc(nmb, ir); } + this->skip_number(ifs, this->mesh_changed); word = ""; ModuleBase::GlobalFunc::SCAN_END(ifs, word); } @@ -757,6 +765,7 @@ void Pseudopot_upf::read_pseudo_upf201_pswfc(std::ifstream& ifs, Atom_pseudo& pp { assert(pp.chi.c[iw * pp.mesh + ir] == pp.chi(iw, ir)); } + this->skip_number(ifs, this->mesh_changed); word = ""; ModuleBase::GlobalFunc::SCAN_END(ifs, word); }