13 const std::string &global_out_dir,
17 const std::vector<int> &ik2iktot,
18 const std::vector<int> &isk,
21 const bool gamma_only,
22 const bool out_app_flag,
24 std::ofstream &ofs_running)
27 ofs_running <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
28 ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
31 ofs_running <<
" | Write Hamiltonian matrix H(k) or overlap matrix S(k) in numerical |" << std::endl;
32 ofs_running <<
" | atomic orbitals at each k-point. |" << std::endl;
35 ofs_running <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
36 ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
37 ofs_running <<
"\n WRITE H(k) OR S(k)" << std::endl;
39 for (
int ik = 0; ik < nks; ++ik)
49 p_hamilt->
matrix(h_mat, s_mat);
51 const int out_label=1;
54 "hk",
"nao",ik,ik2iktot,nspin,nkstot,
55 out_label,out_app_flag,gamma_only,istep);
71 const int current_spin = isk[ik];
78 "sk",
"nao",ik,ik2iktot,nspin,nkstot,
79 out_label,out_app_flag,gamma_only,istep);
81 ofs_running <<
" The output filename is " << s_fn << std::endl;
106 const std::string& filename,
122 g = fopen(filename.c_str(),
"wb");
123 fwrite(&dim,
sizeof(
int), 1, g);
128 for (
int i = 0; i < dim; ++i)
130 T* line =
new T[tri ? dim - i : dim];
137 for (
int j = (tri ? i : 0); j < dim; ++j)
145 iic = ir + ic * pv.
nrow;
149 iic = ir * pv.
ncol + ic;
151 line[tri ? j - i : j] = mat[iic];
163 for (
int j = (tri ? i : 0); j < dim; ++j)
165 fwrite(&line[tri ? j - i : j],
sizeof(
T), 1, g);
178 FILE* g = fopen(filename.c_str(),
"wb");
180 fwrite(&dim,
sizeof(
int), 1, g);
182 for (
int i = 0; i < dim; i++)
184 for (
int j = (tri ? i : 0); j < dim; j++)
186 fwrite(&mat[i * dim + j],
sizeof(
T), 1, g);
195 g << std::setprecision(precision);
199 if (app && istep > 0)
201 g.open(filename.c_str(), std::ofstream::app);
205 g.open(filename.c_str());
212 for (
int i = 0; i < dim; i++)
214 T* line =
new T[tri ? dim - i : dim];
221 for (
int j = (tri ? i : 0); j < dim; ++j)
229 iic = ir + ic * pv.
nrow;
233 iic = ir * pv.
ncol + ic;
235 line[tri ? j - i : j] = mat[iic];
247 for (
int j = (tri ? i : 0); j < dim; j++)
249 g <<
" " << line[tri ? j - i : j];
263 std::ofstream g(filename.c_str(), std::ofstream::app);
267 std::ofstream g(filename.c_str());
271 g << std::setprecision(precision);
272 for (
int i = 0; i < dim; i++)
274 for (
int j = (tri ? i : 0); j < dim; j++)
276 g <<
" " << mat[i * dim + j];
static void tick(const std::string &class_name_in, const std::string &name_in)
Use twice at a time: the first time, set start_flag to false; the second time, calculate the time dur...
Definition timer.cpp:57
This class packs the basic information of 2D-block-cyclic parallel distribution of an arbitrary matri...
Definition parallel_2d.h:12
int ncol
Definition parallel_2d.h:116
int nrow
local size (nloc = nrow * ncol)
Definition parallel_2d.h:115
int global2local_col(const int igc) const
get the local index of a global index (col)
Definition parallel_2d.h:51
int global2local_row(const int igr) const
get the local index of a global index (row)
Definition parallel_2d.h:45
Definition parallel_orbitals.h:9
const Input_para & inp
Definition parameter.h:26
const System_para & globalv
Definition parameter.h:30
virtual void matrix(MatrixBlock< std::complex< double > > &hk_in, MatrixBlock< std::complex< double > > &sk_in)
core function: return H(k) and S(k) matrixs for direct solving eigenvalues.
Definition hamilt.h:46
virtual void updateHk(const int ik)
for target K point, update consequence of hPsi() and matrix()
Definition hamilt.h:21
#define T
Definition exp.cpp:237
int DRANK
Definition global_variable.cpp:28
void ZEROS(std::complex< T > *u, const TI n)
Definition global_function.h:109
void TITLE(const std::string &class_name, const std::string &function_name, const bool disable)
Definition tool_title.cpp:18
void save_mat(const int istep, const T *mat, const int dim, const bool bit, const int precision, const bool tri, const bool app, const std::string &file_name, const Parallel_2D &pv, const int drank, const bool reduce=true)
save a square matrix, such as H(k) and S(k)
Definition write_HS.hpp:99
std::string filename_output(const std::string &directory, const std::string &property, const std::string &basis, const int ik_local, 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)
Definition filename.cpp:8
void write_hsk(const std::string &global_out_dir, const int nspin, const int nks, const int nkstot, const std::vector< int > &ik2iktot, const std::vector< int > &isk, hamilt::Hamilt< T > *p_hamilt, const Parallel_Orbitals &pv, const bool gamma_only, const bool out_app_flag, const int istep, std::ofstream &ofs_running)
Definition write_HS.hpp:12
void reduce_all(T &object)
reduce in all process
Definition depend_mock.cpp:14
MPI_Comm DIAG_WORLD
Definition parallel_comm.cpp:11
Parameter PARAM
Definition parameter.cpp:3
int nlocal
total number of local basis.
Definition system_parameter.h:23
Definition matrixblock.h:9
T * p
Definition matrixblock.h:12