12 const std::string &global_out_dir,
16 const std::vector<int> &ik2iktot,
17 const std::vector<int> &isk,
20 const bool gamma_only,
21 const bool out_app_flag,
23 std::ofstream &ofs_running)
26 ofs_running <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
27 ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
30 ofs_running <<
" | Write Hamiltonian matrix H(k) or overlap matrix S(k) in numerical |" << std::endl;
31 ofs_running <<
" | atomic orbitals at each k-point. |" << std::endl;
34 ofs_running <<
" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
35 ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
36 ofs_running <<
"\n WRITE H(k) OR S(k)" << std::endl;
38 for (
int ik = 0; ik < nks; ++ik)
48 p_hamilt->
matrix(h_mat, s_mat);
50 const int out_label=1;
53 "hk",
"nao",ik,ik2iktot,nspin,nkstot,
54 out_label,out_app_flag,gamma_only,istep);
70 const int current_spin = isk[ik];
77 "sk",
"nao",ik,ik2iktot,nspin,nkstot,
78 out_label,out_app_flag,gamma_only,istep);
80 ofs_running <<
" The output filename is " << s_fn << std::endl;
105 const std::string& filename,
113 const bool gamma_only = std::is_same<T, double>::value;
120 FILE* out_matrix =
nullptr;
124 out_matrix = fopen(filename.c_str(),
"wb");
125 fwrite(&dim,
sizeof(
int), 1, out_matrix);
130 for (
int i = 0;
i < dim; ++
i)
132 T* line =
new T[tri ? dim -
i : dim];
139 for (
int j = (tri ?
i : 0); j < dim; ++j)
147 iic = ir + ic * pv.
nrow;
151 iic = ir * pv.
ncol + ic;
153 line[tri ? j -
i : j] = mat[iic];
165 for (
int j = (tri ?
i : 0); j < dim; ++j)
167 fwrite(&line[tri ? j -
i : j],
sizeof(
T), 1, out_matrix);
181 FILE* out_matrix = fopen(filename.c_str(),
"wb");
183 fwrite(&dim,
sizeof(
int), 1, out_matrix);
185 for (
int i = 0;
i < dim;
i++)
187 for (
int j = (tri ?
i : 0); j < dim; j++)
189 fwrite(&mat[
i * dim + j],
sizeof(
T), 1, out_matrix);
197 std::ofstream out_matrix;
198 out_matrix << std::scientific << std::setprecision(precision);
202 if (app && istep > 0)
204 out_matrix.open(filename.c_str(), std::ofstream::app);
208 out_matrix.open(filename.c_str());
210 out_matrix <<
"#------------------------------------------------------------------------" << std::endl;
211 out_matrix <<
"# ionic step " << istep+1 << std::endl;
212 out_matrix <<
"# filename " << filename << std::endl;
213 out_matrix <<
"# gamma only " << gamma_only << std::endl;
214 out_matrix <<
"# rows " << dim << std::endl;
215 out_matrix <<
"# columns " << dim << std::endl;
216 out_matrix <<
"#------------------------------------------------------------------------" << std::endl;
222 for (
int i = 0;
i < dim;
i++)
224 T* line =
new T[tri ? dim -
i : dim];
231 for (
int j = (tri ?
i : 0); j < dim; ++j)
239 iic = ir + ic * pv.
nrow;
243 iic = ir * pv.
ncol + ic;
245 line[tri ? j -
i : j] = mat[iic];
257 out_matrix <<
"Row " <<
i+1 << std::endl;
259 for (
int j = (tri ?
i : 0); j < dim; j++)
261 out_matrix <<
" " << line[tri ? j -
i : j];
267 out_matrix << std::endl;
271 out_matrix << std::endl;
283 std::ofstream out_matrix(filename.c_str(), std::ofstream::app);
287 std::ofstream out_matrix(filename.c_str());
291 out_matrix << std::setprecision(precision);
292 for (
int i = 0;
i < dim;
i++)
294 for (
int j = (tri ?
i : 0); j < dim; j++)
296 out_matrix <<
" " << mat[
i * dim + j];
298 out_matrix << std::endl;
const std::complex< double > i
Definition cal_pLpR.cpp:46
static void start(void)
Start total time calculation.
Definition timer.cpp:44
static void end(const std::string &class_name_in, const std::string &name_in)
Definition timer.cpp:109
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:53
void updateHk(const int ik) override
for target K point, update consequence of hPsi() and matrix()
Definition hamilt.h:22
#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:98
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, const int iter)
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:11
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