forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_pp_complete.cpp
More file actions
164 lines (130 loc) · 3.04 KB
/
read_pp_complete.cpp
File metadata and controls
164 lines (130 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#include "read_pp.h"
#include "source_io/module_parameter/parameter.h"
void Pseudopot_upf::complete_default(Atom_pseudo& pp)
{
ModuleBase::TITLE("Pseudopot_upf", "complete_default");
// call subroutines
this->complete_default_h(pp);
this->complete_default_atom(pp);
this->complete_default_vl(pp);
if (pp.nbeta == 0) {
return;
}
if (pp.lll.empty())
{
pp.lll = std::vector<int>(pp.nbeta, 0);
}
pp.nh = 0;
for (int nb = 0; nb < pp.nbeta;nb++)
{
pp.nh += 2 * pp.lll [nb] + 1;
}
return;
}
void Pseudopot_upf::complete_default_h(Atom_pseudo& pp)
{
ModuleBase::TITLE("Pseudopot_upf","complete_default_h");
// mohan update 2021-02-22
// max number of points in the atomic radial mesh
int ndmx = 200000;
if (pp.mesh > ndmx)
{
std::cout << "\n complete_default_h, too many grid points,";
}
if (pp.els.empty())
{
pp.els = std::vector<std::string>(pp.nchi, "");
}
if (pp.lchi.empty())
{
pp.lchi = std::vector<int>(pp.nchi, 0);
}
if (pp.oc.empty())
{
pp.oc = std::vector<double>(pp.nchi, 0.0);
}
if (pp.jjj.empty()) {
pp.jjj = std::vector<double>(pp.nbeta, 0.0);
assert(!pp.has_so or pp.nbeta == 0);
for (int i=0; i<pp.nbeta; i++)
{
pp.jjj[i] = 0;
}
}
if (pp.nn.empty()) {
pp.nn = std::vector<int>(pp.nchi, 0);
assert(!pp.has_so or pp.nchi == 0);
for (int i=0; i<pp.nchi; i++)
{
pp.nn[i] = 0;
}
}
if (pp.jchi.empty()) {
pp.jchi = std::vector<double>(pp.nchi, 0.0);
assert(!pp.has_so or pp.nchi == 0);
for (int i=0; i<pp.nchi; i++)
{
pp.jchi[i] = 0;
}
}
return;
}
void Pseudopot_upf::complete_default_atom(Atom_pseudo& pp)
{
ModuleBase::TITLE("Pseudopot_upf","complete_default_atom");
// mohan 2009-12-15
// mohan update again 2011-05-23,
// in order to calculate more accurate Vna.
pp.rcut = PARAM.inp.pseudo_rcut;//(a.u.);
// remember to update here if you need it.
// rcut = 25.0;
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"PAO radial cut off (Bohr)", pp.rcut);
if(pp.rcut <= 0.0)
{
ModuleBase::WARNING_QUIT("Pseudopot_upf::complete_default_atom","PAO rcut<=0.0");
}
// chi.create(nchi, mesh);
if (pp.r.empty()) {
pp.r = std::vector<double>(pp.mesh, 0.0);
}
if (pp.rab.empty()) {
pp.rab = std::vector<double>(pp.mesh, 0.0);
}
if (pp.rho_at.empty()) {
pp.rho_at = std::vector<double>(pp.mesh, 0.0);
}
if (pp.rho_atc.empty()) {
pp.rho_atc = std::vector<double>(pp.mesh, 0.0);
assert(!pp.nlcc or pp.mesh == 0);
}
bool br = false;
pp.msh = 0;
for (int ir = 0;ir < pp.mesh;ir++)
{
if (pp.r [ir] > pp.rcut)
{
pp.msh = ir + 1;
br = true;
break;
}
}
if (br)
{
// force msh to be odd for simpson integration
pp.msh = 2 * static_cast<int>((pp.msh + 1) / 2) - 1; // Use static_cast instead of C-style cast for type safety
}
else
{
pp.msh = pp.mesh ;
}
return;
}
void Pseudopot_upf::complete_default_vl(Atom_pseudo& pp)
{
ModuleBase::TITLE("Pseudopot_upf","complete_default_vl");
assert(pp.mesh>0);//mohan add 2021-05-01
if (pp.vloc_at.empty()) {
pp.vloc_at = std::vector<double>(pp.mesh, 0.0);
}
return;
}