-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpseudo.cpp
More file actions
125 lines (106 loc) · 2.49 KB
/
pseudo.cpp
File metadata and controls
125 lines (106 loc) · 2.49 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
#include "input.h"
#include "pseudo.h"
void Pseudo::Routine()
{
TITLE("Pseudo","Routine");
cal();
return;
}
void Pseudo::cal()
{
TITLE("Pseudo","cal");
const double pi = 3.1415926535897;
ifstream ifs(INPUT.pseudo_in.c_str());
if(!ifs)
{
cout << " Can not find the file: " << INPUT.pseudo_in << endl;
exit(0);
}
else
{
cout << " Find the file: " << INPUT.pseudo_in << endl;
}
// get first line;
string line;
std::getline(ifs,line);
std::getline(ifs,line);
std::getline(ifs,line);
std::getline(ifs,line);
cout << " Ignore the first 4 lines" << endl;
// get second line;
double v1,v2;
ifs >> v1 >> v2;
std::getline(ifs,line);
// get third line;
double Gmax;
ifs >> Gmax;
cout << " Gmax = " << Gmax << endl;
assert(Gmax>0.0);
// get the local pseudopotentials unitl the mark '1000'
int nline=0;
double a,b,c;
while(!ifs.eof() )
{
ifs >> a;
if( abs(a-1000.0) < 1.0e-5 ) break;
ifs >> b;
READ_VALUE(ifs, c);
++nline;
}
cout << " Nubmer of lines : " << nline << endl;
//---------------------------------------
// read in the pseudopotentials.
//---------------------------------------
if(!ifs.good())
{
cout << " Something is wrong during reading" << endl;
cout << " Check the last number of pseudopotential" << endl;
exit(0);
}
cout << " Rewind the readin pointer." << endl;
string line2;
assert(nline>0);
// to the top again.
ifs.seekg(0);
std::getline(ifs,line2);
std::getline(ifs,line2);
std::getline(ifs,line2);
std::getline(ifs,line2);
double t1,t2,t3;
ifs >> t1 >> t2 >> t3;
cout << " trash=" << t1 << " " << t2 << " " << t3 << endl;
double* pp = new double [3*nline];
for(int i=0; i<3*nline; ++i)
{
ifs >> pp[i];
}
ifs.close();
// output the pseudopotential file.
ofstream ofs(INPUT.pseudo_out.c_str());
if(!ofs)
{
cout << " Can not open file : " << INPUT.pseudo_out << endl;
exit(0);
}
else
{
assert(Gmax > 0.0);
double dg = Gmax / (nline*3-1) * 0.529177; // mohan fix bug 2013-03-30
double mev_ang3 = 13.6058*2*0.529177*0.529177*0.529177;
int z = INPUT.pseudo_z;
cout << " z = " << z << endl;
if(INPUT.pseudo_z<=0)
{
cout << " check the input value of pseudo_z" << endl;
exit(0);
}
cout << " the output data format : G, vloc(G) [contains -4*PI*Z/G^2], vloc(G)+4*PI*Z/G^2 [pure local LPS]" << endl;
for(int i=1; i<3*nline; ++i)
{
double g_norm=dg*(double)i;
ofs << g_norm << " " << pp[i]/mev_ang3 << " " << pp[i]/mev_ang3 + 4.0*pi*(double)z/g_norm/g_norm << endl;
}
}
ofs.close();
delete[] pp;
}