forked from deepmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsep.cpp
More file actions
122 lines (109 loc) · 2.8 KB
/
sep.cpp
File metadata and controls
122 lines (109 loc) · 2.8 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
#include "sep.h"
#include "source_base/global_variable.h"
#include "source_base/parallel_common.h"
#include "source_base/tool_title.h"
#include "source_io/module_output/output.h"
#include <fstream>
#include <sstream>
#include <string>
SepPot::SepPot()
{
}
SepPot::~SepPot()
{
delete[] r;
r = nullptr;
delete[] rv;
rv = nullptr;
}
int SepPot::read_sep(std::ifstream& ifs)
{
std::string line;
while (std::getline(ifs, line))
{
std::istringstream iss(line);
std::string key;
iss >> key;
if (key == "Sep.Element")
{
iss >> label;
}
else if (key == "Sep.XcType")
{
iss >> xc_type;
}
else if (key == "Sep.Orbital")
{
iss >> orbital;
}
else if (key == "Sep.Points")
{
iss >> mesh;
delete[] r;
r = new double[mesh];
delete[] rv;
rv = new double[mesh];
}
else if (key == "Sep.StripAmount")
{
iss >> strip_elec;
}
else if (key == "<Sep.Potential")
{
double r_val, rv_val;
int idx = 0;
while (std::getline(ifs, line) && line != "Sep.Potential>")
{
std::istringstream data_line(line);
if (data_line >> r_val >> rv_val)
{
r[idx] = r_val;
rv[idx] = rv_val;
idx++;
}
}
break;
}
}
return 0;
}
void SepPot::print_sep_info(std::ofstream& ofs) const
{
ofs << "\n sep_vl:";
ofs << "\n sep_info:";
ofs << "\n label " << label;
ofs << "\n xc " << xc_type;
ofs << "\n orbital " << orbital;
ofs << "\n strip electron" << strip_elec;
}
void SepPot::print_sep_vsep(std::ofstream& ofs) const
{
ofs << "\n mesh " << mesh;
output::printr1_d(ofs, " r : ", r, mesh);
output::printr1_d(ofs, " vsep : ", rv, mesh);
ofs << "\n -----------------------------";
}
#ifdef __MPI
void SepPot::bcast_sep()
{
ModuleBase::TITLE("SepPot", "bcast_sep");
Parallel_Common::bcast_bool(is_enable);
Parallel_Common::bcast_double(r_in);
Parallel_Common::bcast_double(r_out);
Parallel_Common::bcast_double(r_power);
Parallel_Common::bcast_double(enhence_a);
Parallel_Common::bcast_string(label);
Parallel_Common::bcast_string(xc_type);
Parallel_Common::bcast_string(orbital);
Parallel_Common::bcast_int(strip_elec);
Parallel_Common::bcast_int(mesh);
if (GlobalV::MY_RANK != 0 && mesh > 0)
{
r = new double[mesh];
rv = new double[mesh];
}
Parallel_Common::bcast_double(r, mesh);
Parallel_Common::bcast_double(rv, mesh);
return;
}
#endif // __MPI