-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileABACUS.cpp
111 lines (93 loc) · 2.93 KB
/
FileABACUS.cpp
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
#include "File.h"
#include "input.h"
#include "gfun.h"
bool File::CheckGeometry_ABACUS( Cell &cel )
{
TITLE("CellFile","CheckGeometry_ABACUS");
const int ntype = INPUT.ntype;
// (1) open the file.
stringstream ss;
ss << INPUT.msd_directory;
ss << cel.file_name;
ifstream ifs(ss.str().c_str());
if(!ifs) return false;
else return true;
}
bool File::ReadGeometry_ABACUS( Cell &cel )
{
TITLE("CellFile","ReadGeometry_ABACUS");
const int ntype = INPUT.ntype;
// (1) open the file.
stringstream ss;
ss << INPUT.ABACUS_directory << "/";
ss << "md_pos_";
ss << cel.file_name;
ss << ".cif";
cout << " ReadGeometry : " << ss.str() << endl;
ifstream ifs(ss.str().c_str());
if(!ifs) return false;
// many files does not exist, so we don't print
// every file's name.
cout << " File name is " << ss.str() << endl;
cel.atom = new Atoms[ntype];
getline(ifs, cel.system_name);
// cout << " Name is " << cel.system_name << endl;
string useless;
getline(ifs, useless);
// cout << useless << endl;
getline(ifs, useless);
getline(ifs, useless);
ifs >> useless >> cel.a1.x;
ifs >> useless >> cel.a2.y;
ifs >> useless >> cel.a3.z;
cel.a1.y = 0.0;
cel.a1.z = 0.0;
cel.a2.x = 0.0;
cel.a2.z = 0.0;
cel.a3.x = 0.0;
cel.a3.y = 0.0;
cout << " Cell: " << endl;
cout << " " << cel.a1.x << " " << cel.a1.y << " " << cel.a1.z << endl;
cout << " " << cel.a2.x << " " << cel.a2.y << " " << cel.a2.z << endl;
cout << " " << cel.a3.x << " " << cel.a3.y << " " << cel.a3.z << endl;
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
getline(ifs, useless);
// (3) read in atom species and the pseudopotential file.
cel.nat = INPUT.natom;
if(ntype==1)
{
cel.atom[0].na=INPUT.natom;
}
else if(ntype==2)
{
cel.atom[0].na=INPUT.atom[0];
cel.atom[1].na=INPUT.atom[1];
}
cout << " Total atom number is " << cel.nat << endl;
cel.coordinate = "Direct";
// (4) read in the atom positions.
Vector3<double> add1,add2,add3;
for(int it=0; it<ntype; ++it)
{
cel.atom[it].read_pos_3(ifs);
for(int ia2=0; ia2<cel.atom[it].na; ++ia2)
{
cel.direct2cartesian(it, ia2);
}
}
ifs.close();
return true;
}
void File::ReadDeltaR(Cell &cel)
{}