Repository navigation
Expand file tree
/
Copy pathfilename.cpp
More file actions
111 lines (97 loc) · 2.48 KB
/
Copy pathfilename.cpp
File metadata and controls
111 lines (97 loc) · 2.48 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
#include <set>
#include "filename.h"
#include "source_base/tool_quit.h"
namespace ModuleIO
{
std::string filename_output(
const std::string &directory,
const std::string &property,
const std::string &basis,
const int ik_local, // the ik index within each pool
const std::vector<int> &ik2iktot,
const int nspin,
const int nkstot,
const int out_type,
const bool out_app_flag,
const bool gamma_only,
const int istep)
{
// output filename = "{PARAM.globalv.global_out_dir}/property{s}{spin index}
// {k(optional)}{k-point index}{g(optional)}{geometry index1}{_basis(nao|pw)}
// + {".txt"/".dat"}"
std::set<std::string> valid_properties = {"wf", "chg", "hk", "sk", "tk", "vxc"};
if (valid_properties.find(property) == valid_properties.end())
{
ModuleBase::WARNING_QUIT("ModuleIO::filename_output", "unknown property in filename function");
}
std::set<std::string> valid_basis = {"pw", "nao"};
if (valid_basis.find(basis) == valid_basis.end())
{
ModuleBase::WARNING_QUIT("ModuleIO::filename_output", "unknown basis in filename function");
}
assert(ik_local>=0);
// mohan update 2025.05.07, if KPAR>1, "<" works
assert(ik2iktot.size() <= nkstot);
assert(nspin>0);
// spin index
int is0 = -1;
// ik0 is the k-point index, starting from 0
int ik0 = ik2iktot[ik_local];
if(nspin == 1)
{
is0 = 1;
}
else if(nspin == 2)
{
const int half_k = nkstot/2;
if(ik0 >= half_k)
{
is0 = 2;
ik0 -= half_k;
}
else
{
is0 = 1;
}
}
else if(nspin==4)
{
is0 = 12;
}
// spin part
std::string spin_block;
spin_block = "s" + std::to_string(is0);
// k-point part
std::string kpoint_block;
if(gamma_only)
{
// do nothing;
}
else
{
kpoint_block = "k" + std::to_string(ik0+1);
}
std::string istep_block
= (istep >= 0 && (!out_app_flag))
? "g" + std::to_string(istep + 1)
: ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file
std::string suffix_block;
if (out_type == 1)
{
suffix_block = ".txt";
}
else if (out_type == 2)
{
suffix_block = ".dat";
}
else
{
std::cout << "WARNING: the type of output wave function is not 1 or 2, so 1 is chosen." << std::endl;
suffix_block = ".txt";
}
std::string fn_out
= directory + property + spin_block + kpoint_block
+ istep_block + "_" + basis + suffix_block;
return fn_out;
}
}