Skip to content

Commit 0480df4

Browse files
committed
1. add file_name in namespace HS_Matrix
1 parent ef3aa66 commit 0480df4

File tree

4 files changed

+36
-26
lines changed

4 files changed

+36
-26
lines changed

source/src_io/write_HS.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#include "../src_parallel/parallel_reduce.h"
44
#include "../module_base/timer.h"
55

6-
void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_hs)
6+
void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, const bool bit, const int &out_hs, const std::string &file_name)
77
{
88
if(out_hs==1)
99
{
10-
save_HS(Hloc, Sloc, bit);
10+
save_HS(Hloc, Sloc, bit, file_name);
1111
}
1212
else if(out_hs==2)
1313
{
14-
save_HS(Hloc, Sloc, bit);
14+
save_HS(Hloc, Sloc, bit, file_name);
1515
}
1616
else if(out_hs==3)
1717
{
@@ -108,7 +108,7 @@ void HS_Matrix::save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_
108108

109109
// mohan add 2010/3/20, output H and S matrix, convinence for diagonalization
110110
// test or save the middle information for next start.
111-
void HS_Matrix::save_HS(const double *H, const double *S, bool bit)
111+
void HS_Matrix::save_HS(const double *H, const double *S, const bool bit, const std::string &file_name)
112112
{
113113
ModuleBase::TITLE("HS_Matrix","save_HS_bit");
114114
ModuleBase::timer::tick("HS_Matrix","save_HS_bit");
@@ -119,13 +119,13 @@ void HS_Matrix::save_HS(const double *H, const double *S, bool bit)
119119

120120
if(bit)
121121
{
122-
ssh << GlobalV::global_out_dir << "data-H-bit";
123-
sss << GlobalV::global_out_dir << "data-S-bit";
122+
ssh << GlobalV::global_out_dir << file_name+"-H-bit";
123+
sss << GlobalV::global_out_dir << file_name+"-S-bit";
124124
}
125125
else
126126
{
127-
ssh << GlobalV::global_out_dir << "data-H";
128-
sss << GlobalV::global_out_dir << "data-S";
127+
ssh << GlobalV::global_out_dir << file_name+"-H";
128+
sss << GlobalV::global_out_dir << file_name+"-S";
129129
}
130130

131131
if (bit)
@@ -369,11 +369,11 @@ void HS_Matrix::save_HS(const double *H, const double *S, bool bit)
369369
}
370370

371371
//LiuXh, 2017-03-21
372-
void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_hs)
372+
void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, const bool bit, const int &out_hs, const std::string &file_name)
373373
{
374374
if(out_hs==1)
375375
{
376-
save_HS_complex(Hloc, Sloc, bit);
376+
save_HS_complex(Hloc, Sloc, bit, file_name);
377377
}
378378
else if(out_hs==0)
379379
{
@@ -387,7 +387,7 @@ void HS_Matrix::saving_HS_complex(std::complex<double> *Hloc, std::complex<doubl
387387
}
388388

389389
//LiuXh, 2017-03-21
390-
void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S, bool bit)
390+
void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S, const bool bit, const std::string &file_name)
391391
{
392392
ModuleBase::TITLE("HS_Matrix","save_HS_bit");
393393
ModuleBase::timer::tick("HS_Matrix","save_HS_bit");
@@ -398,13 +398,13 @@ void HS_Matrix::save_HS_complex(std::complex<double> *H, std::complex<double> *S
398398

399399
if(bit)
400400
{
401-
ssh << GlobalV::global_out_dir << "data-H-bit";
402-
sss << GlobalV::global_out_dir << "data-S-bit";
401+
ssh << GlobalV::global_out_dir << file_name+"-H-bit";
402+
sss << GlobalV::global_out_dir << file_name+"-S-bit";
403403
}
404404
else
405405
{
406-
ssh << GlobalV::global_out_dir << "data-H";
407-
sss << GlobalV::global_out_dir << "data-S";
406+
ssh << GlobalV::global_out_dir << file_name+"-H";
407+
sss << GlobalV::global_out_dir << file_name+"-S";
408408
}
409409

410410
if (bit)

source/src_io/write_HS.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
#include "../module_base/global_function.h"
55
#include "../module_base/global_variable.h"
66

7+
#include <string>
8+
79
// mohan add this file 2010-09-10
810
namespace HS_Matrix
911
{
10-
void saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_hs);
12+
void saving_HS(const double *Hloc, const double* Sloc, const bool bit, const int &out_hs, const std::string &file_name);
1113

12-
void save_HS(const double *H, const double *S, bool bit);
14+
void save_HS(const double *H, const double *S, const bool bit, const std::string &file_name);
1315

14-
void save_HS_complex(const std::complex<double> *H, const std::complex<double> *S, bool bit);
16+
void save_HS_complex(const std::complex<double> *H, const std::complex<double> *S, const bool bit, const std::string &file__name);
1517

1618
void save_HSR_tr(const int current_spin); //LiuXh add 2019-07-15
1719

@@ -35,9 +37,9 @@ namespace HS_Matrix
3537
// void save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_H, const int *rowind_H,
3638
// const double *nzval_H, const double *nzval_S, bool bit);
3739

38-
void saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_hs); //LiuXh, 2017-03-21
40+
void saving_HS_complex(std::complex<double> *Hloc, std::complex<double>* Sloc, bool bit, const int &out_hs, const std::string &file__name); //LiuXh, 2017-03-21
3941

40-
void save_HS_complex(std::complex<double> *H, std::complex<double> *S, bool bit); //LiuXh, 2017-03-21
42+
void save_HS_complex(std::complex<double> *H, std::complex<double> *S, const bool bit, const std::string &file__name); //LiuXh, 2017-03-21
4143
}
4244

4345
#endif

source/src_lcao/LCAO_diago.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void Diago_LCAO_Matrix::using_HPSEPS_complex(const int &ik, std::complex<double>
4545
//GlobalC::ParaO.out_hs=1;//zhengdy-soc-test
4646
bool bit = false; //LiuXh, 2017-03-21
4747
//if set bit = true, there would be error in soc-multi-core calculation, noted by zhengdy-soc
48-
HS_Matrix::saving_HS_complex(GlobalC::LM.Hloc2.data(), GlobalC::LM.Sloc2.data(), bit, GlobalC::ParaO.out_hs); //LiuXh, 2017-03-21
48+
HS_Matrix::saving_HS_complex(GlobalC::LM.Hloc2.data(), GlobalC::LM.Sloc2.data(), bit, GlobalC::ParaO.out_hs, "data-"+std::to_string(ik)); //LiuXh, 2017-03-21
4949
GlobalV::ofs_running << std::setprecision(6); //LiuXh, 2017-03-21
5050

5151
GlobalC::ParaO.diago_complex_begin(ik, wfc, wfc_2d, GlobalC::LM.Hloc2.data(), GlobalC::LM.Sloc2.data(), GlobalC::wf.ekb[ik]);
@@ -142,7 +142,7 @@ void Diago_LCAO_Matrix::using_LAPACK(const int &ik, double** wfc)const
142142
// save H and S matrix to disk.
143143
// bool bit = false;
144144
bool bit = true;//zhengdy-soc
145-
HS_Matrix::saving_HS(GlobalC::LM.Hloc.data(), GlobalC::LM.Sloc.data(), bit, GlobalC::ParaO.out_hs);
145+
HS_Matrix::saving_HS(GlobalC::LM.Hloc.data(), GlobalC::LM.Sloc.data(), bit, GlobalC::ParaO.out_hs, "data-"+std::to_string(ik));
146146

147147
ModuleBase::matrix Htmp(GlobalV::NLOCAL,GlobalV::NLOCAL);
148148
ModuleBase::matrix Stmp(GlobalV::NLOCAL,GlobalV::NLOCAL);
@@ -257,7 +257,7 @@ void Diago_LCAO_Matrix::using_HPSEPS_double(const int &ik, ModuleBase::matrix &w
257257

258258
// save H and S matrix to disk.
259259
bool bit = false;
260-
HS_Matrix::saving_HS(GlobalC::LM.Hloc.data(), GlobalC::LM.Sloc.data(), bit, GlobalC::ParaO.out_hs);
260+
HS_Matrix::saving_HS(GlobalC::LM.Hloc.data(), GlobalC::LM.Sloc.data(), bit, GlobalC::ParaO.out_hs, "data-"+std::to_string(ik));
261261
GlobalV::ofs_running << std::setprecision(6);
262262

263263
// Distribution of matrix for

source/src_lcao/wfc_dm_2d.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,23 @@ void Wfc_Dm_2d::cal_dm(const ModuleBase::matrix &wg)
128128
#ifdef TEST_DIAG
129129
{
130130
static int istep=0;
131-
std::ofstream ofs("dm_"+ModuleBase::GlobalFunc::TO_STRING(istep)+"_"+ModuleBase::GlobalFunc::TO_STRING(GlobalV::MY_RANK));
132131
if(GlobalV::GAMMA_ONLY_LOCAL)
133132
{
134-
ofs<<dm_gamma<<std::endl;
133+
for(int ik=0; ik<dm_gamma.size(); ++ik)
134+
{
135+
std::ofstream ofs("dm_"+std::to_string(istep)+"_"+std::to_string(ik)+"_"+std::to_string(GlobalV::MY_RANK));
136+
dm_gamma[ik].print(ofs,1E-10)<<std::endl;
137+
}
135138
}
136139
else
137140
{
138-
ofs<<dm_k<<std::endl;
141+
for(int ik=0; ik<dm_k.size(); ++ik)
142+
{
143+
std::ofstream ofs("dm_"+std::to_string(istep)+"_"+std::to_string(ik)+"_"+std::to_string(GlobalV::MY_RANK));
144+
dm_k[ik].print(ofs,1E-10,1E-10)<<std::endl;
145+
}
139146
}
147+
++istep;
140148
}
141149
#endif
142150

0 commit comments

Comments
 (0)