Skip to content

Commit e245b26

Browse files
committed
add the pesduo
1 parent a48e9fc commit e245b26

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

source/source_cell/pseudo.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@ pseudo::~pseudo()
99
{
1010
}
1111

12+
void pseudo::check_pseudo()
13+
{
14+
for (int ib = 0; ib < nbeta; ib++)
15+
{
16+
int flag = mesh+1;
17+
for (int ir = 0; ir < mesh; ir++)
18+
{
19+
if (std::abs(betar(ib, ir)) < 1.0e-30)
20+
{
21+
flag = ir;
22+
break;
23+
}
24+
}
25+
if (flag<mesh)
26+
{
27+
ModuleBase::WARNING_QUIT("pseudo::check_pseudo",
28+
"beta function is set to zero for beta after " + std::to_string(falg + 1));
29+
}
30+
for (int ir = flag; ir < mesh; ir++)
31+
{
32+
betar(ib, ir) = 0.0;
33+
}
34+
}
35+
}
36+
1237
void pseudo::print_pseudo(std::ofstream& ofs)
1338
{
1439
print_pseudo_vl(ofs);

source/source_cell/pseudo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class pseudo
7474
// uspp
7575
ModuleBase::realArray qfuncl; // qfuncl(2*lmax+1,nbeta*(nbeta+1)/2,mesh) Q_{mu,nu}(|r|) function for |r|> r_L
7676
ModuleBase::matrix qqq; // qqq(nbeta,nbeta) q_{mu,nu}
77+
/**
78+
* @brief Check the input data for non-normal numbers in the betar.
79+
* Subsequent values following non-normal numbers will be reset to zero
80+
* to prevent potential computational issues arising from invalid data.
81+
*/
82+
void check_betar();
7783

7884
void print_pseudo_h(std::ofstream& ofs);
7985
void print_pseudo_atom(std::ofstream& ofs);

source/source_cell/read_pp_upf100.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ void Pseudopot_upf::read_pseudo_nl(std::ifstream& ifs, Atom_pseudo& pp)
319319
ModuleBase::GlobalFunc::SCAN_END(ifs, "</PP_BETA>");
320320
pp.kkbeta = (this->kbeta[i] > pp.kkbeta) ? this->kbeta[i] : pp.kkbeta;
321321
}
322-
322+
//check the betar for non-normal number
323+
pp.check_pseudo();
323324
// DIJ
324325
ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_DIJ>", false);
325326
ModuleBase::GlobalFunc::READ_VALUE(ifs, this->nd); // nl_4

source/source_cell/read_pp_upf201.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ void Pseudopot_upf::read_pseudo_upf201_nonlocal(std::ifstream& ifs, Atom_pseudo&
530530
word = "</PP_BETA." + std::to_string(ib + 1) + ">";
531531
ModuleBase::GlobalFunc::SCAN_END(ifs, word);
532532
}
533-
533+
//check the betar for non-normal number
534+
pp.check_pseudo();
534535
// Read the hamiltonian terms D_ij
535536
if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "<PP_DIJ", true, false))
536537
{

0 commit comments

Comments
 (0)