Skip to content

Commit f2b9645

Browse files
committed
Fix: Fix the I/O problem of pseudopotential caused by the change of mesh.
1 parent ffdc617 commit f2b9645

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

source/module_cell/read_pp.h

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class Pseudopot_upf
7272
void complete_default(Atom_pseudo& pp);
7373

7474
private:
75+
bool mesh_changed = false; // if the mesh is even, it will be changed to odd
76+
7577
int set_pseudo_type(const std::string& fn, std::string& type);
7678
std::string& trim(std::string& in_str);
7779
std::string trimend(std::string& in_str);

source/module_cell/read_pp_blps.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ int Pseudopot_upf::read_pseudo_blps(std::ifstream &ifs, Atom_pseudo& pp)
4242

4343
int pspcod, pspxc, lloc, r2well;
4444
ifs >> pspcod >> pspxc >> pp.lmax >> lloc >> pp.mesh >> r2well;
45+
this->mesh_changed = false;
4546
if (pp.mesh%2 == 0)
4647
{
4748
pp.mesh -= 1;
49+
this->mesh_changed = true;
4850
}
4951

5052
if (pspxc == 2)

source/module_cell/read_pp_upf100.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ int Pseudopot_upf::read_pseudo_upf(std::ifstream &ifs, Atom_pseudo& pp)
77
std::string dummy;
88
pp.has_so = false;
99
this->q_with_l = false;
10+
this->mesh_changed = false;
1011

1112
// addinfo_loop
1213
ifs.rdstate();
@@ -196,6 +197,7 @@ void Pseudopot_upf::read_pseudo_header(std::ifstream &ifs, Atom_pseudo& pp)
196197
if (pp.mesh%2 == 0)
197198
{
198199
pp.mesh -= 1;
200+
this->mesh_changed = true;
199201
}
200202

201203
ifs >> pp.nchi >> pp.nbeta ;
@@ -439,6 +441,11 @@ void Pseudopot_upf::read_pseudo_pswfc(std::ifstream &ifs, Atom_pseudo& pp)
439441
{
440442
ifs >> pp.chi(i, ir);
441443
}
444+
if (this->mesh_changed)
445+
{
446+
double temp = 0.0;
447+
ifs >> temp;
448+
}
442449
}
443450
return;
444451
}

source/module_cell/read_pp_upf201.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,11 @@ void Pseudopot_upf::read_pseudo_upf201_header(std::ifstream& ifs, Atom_pseudo& p
312312
else if (name[ip] == "mesh_size")
313313
{
314314
pp.mesh = atoi(val[ip].c_str());
315+
this->mesh_changed = false;
315316
if (pp.mesh % 2 == 0)
316317
{
317318
pp.mesh -= 1;
319+
this->mesh_changed = true;
318320
}
319321
}
320322
else if (name[ip] == "number_of_wfc")
@@ -357,9 +359,11 @@ void Pseudopot_upf::read_pseudo_upf201_mesh(std::ifstream& ifs, Atom_pseudo& pp)
357359
else if (name[ip] == "mesh")
358360
{
359361
pp.mesh = atoi(val[ip].c_str());
362+
this->mesh_changed = false;
360363
if (pp.mesh % 2 == 0)
361364
{
362365
pp.mesh -= 1;
366+
this->mesh_changed = true;
363367
}
364368
}
365369
else if (name[ip] == "xmin")

source/module_cell/read_pp_vwr.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ int Pseudopot_upf::read_pseudo_vwr(std::ifstream &ifs, Atom_pseudo& pp)
3333
ifs >> value; length = value.find(","); value.erase(length,1);
3434
pp.mesh = std::atoi( value.c_str() );
3535
//the mesh should be odd, which is forced in Simpson integration
36+
this->mesh_changed = false;
3637
if(pp.mesh%2==0)
3738
{
3839
pp.mesh=pp.mesh-1;
40+
this->mesh_changed = true;
3941
GlobalV::ofs_running << " Mesh number - 1, we need odd number, \n this may affect some polar atomic orbitals." << std::endl;
4042
}
4143
GlobalV::ofs_running << std::setw(15) << "MESH" << std::setw(15) << pp.mesh << std::endl;

0 commit comments

Comments
 (0)