Skip to content

Commit dd7585a

Browse files
author
abacus_fixer
committed
update tab of write_HS.hpp
1 parent b6f1c90 commit dd7585a

2 files changed

Lines changed: 121 additions & 121 deletions

File tree

source/source_esolver/esolver_ks_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,15 @@ void ESolver_KS_LCAO<TK, TR>::before_scf(UnitCell& ucell, const int istep)
176176
if(PARAM.inp.init_chg == "dm")
177177
{
178178
//! 13.1.1) init density matrix from file
179-
std::string dmfile = PARAM.globalv.global_readin_dir + "/dmrs1_nao.csr";
179+
std::string dmfile = PARAM.globalv.global_readin_dir + "dmrs1_nao.csr";
180180
LCAO_domain::init_dm_from_file<TK>(dmfile, this->dmat, ucell, &(this->pv));
181181
GlobalV::ofs_running << " Read density matrix (real space) from file: "
182182
<< dmfile << std::endl;
183183
}
184184
if(PARAM.inp.init_chg == "hr")
185185
{
186186
//! 13.1.2) init HR from file
187-
std::string hrfile = PARAM.globalv.global_readin_dir + "/hrs1_nao.csr";
187+
std::string hrfile = PARAM.globalv.global_readin_dir + "hrs1_nao.csr";
188188
LCAO_domain::init_hr_from_file<TR>(
189189
hrfile,
190190
dynamic_cast<hamilt::HamiltLCAO<TK, TR>*>(this->p_hamilt)->getHR(),

source/source_io/module_hs/write_HS.hpp

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -13,83 +13,83 @@ void ModuleIO::write_hsk(
1313
const int nspin,
1414
const int nks,
1515
const int nkstot,
16-
const std::vector<int> &ik2iktot,
16+
const std::vector<int> &ik2iktot,
1717
const std::vector<int> &isk,
18-
hamilt::Hamilt<T>* p_hamilt,
19-
const Parallel_Orbitals &pv,
18+
hamilt::Hamilt<T>* p_hamilt,
19+
const Parallel_Orbitals &pv,
2020
const bool gamma_only,
2121
const bool out_app_flag,
2222
const int istep,
23-
std::ofstream &ofs_running)
23+
std::ofstream &ofs_running)
2424
{
2525

26-
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
27-
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
28-
ofs_running << " | "
29-
" |" << 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;
32-
ofs_running << " | "
33-
" |" << std::endl;
34-
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
35-
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
36-
ofs_running << "\n WRITE H(k) OR S(k)" << std::endl;
37-
38-
for (int ik = 0; ik < nks; ++ik)
39-
{
40-
p_hamilt->updateHk(ik);
41-
bool bit = false; // LiuXh, 2017-03-21
42-
// if set bit = true, there would be error in soc-multi-core
43-
// calculation, noted by zhengdy-soc
44-
45-
hamilt::MatrixBlock<T> h_mat;
46-
hamilt::MatrixBlock<T> s_mat;
47-
48-
p_hamilt->matrix(h_mat, s_mat);
49-
50-
const int out_label=1; // 1: .txt, 2: .dat
51-
52-
std::string h_fn = ModuleIO::filename_output(global_out_dir,
53-
"hk","nao",ik,ik2iktot,nspin,nkstot,
54-
out_label,out_app_flag,gamma_only,istep);
55-
56-
ModuleIO::save_mat(istep,
57-
h_mat.p,
58-
PARAM.globalv.nlocal,
59-
bit,
60-
PARAM.inp.out_mat_hs[1],
61-
1,
62-
out_app_flag,
63-
h_fn,
64-
pv,
65-
GlobalV::DRANK);
26+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
27+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
28+
ofs_running << " | "
29+
" |" << 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;
32+
ofs_running << " | "
33+
" |" << std::endl;
34+
ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
35+
">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl;
36+
ofs_running << "\n WRITE H(k) OR S(k)" << std::endl;
37+
38+
for (int ik = 0; ik < nks; ++ik)
39+
{
40+
p_hamilt->updateHk(ik);
41+
bool bit = false; // LiuXh, 2017-03-21
42+
// if set bit = true, there would be error in soc-multi-core
43+
// calculation, noted by zhengdy-soc
44+
45+
hamilt::MatrixBlock<T> h_mat;
46+
hamilt::MatrixBlock<T> s_mat;
47+
48+
p_hamilt->matrix(h_mat, s_mat);
49+
50+
const int out_label=1; // 1: .txt, 2: .dat
51+
52+
std::string h_fn = ModuleIO::filename_output(global_out_dir,
53+
"hk","nao",ik,ik2iktot,nspin,nkstot,
54+
out_label,out_app_flag,gamma_only,istep);
55+
56+
ModuleIO::save_mat(istep,
57+
h_mat.p,
58+
PARAM.globalv.nlocal,
59+
bit,
60+
PARAM.inp.out_mat_hs[1],
61+
1,
62+
out_app_flag,
63+
h_fn,
64+
pv,
65+
GlobalV::DRANK);
6666

6767
// mohan note 2025-06-02
6868
// for overlap matrix, the two spin channels yield the same matrix
6969
// so we only need to print matrix from one spin channel.
70-
const int current_spin = isk[ik];
71-
if(current_spin == 1)
72-
{
73-
continue;
74-
}
75-
76-
std::string s_fn = ModuleIO::filename_output(global_out_dir,
77-
"sk","nao",ik,ik2iktot,nspin,nkstot,
78-
out_label,out_app_flag,gamma_only,istep);
79-
80-
ofs_running << " The output filename is " << s_fn << std::endl;
81-
82-
ModuleIO::save_mat(istep,
83-
s_mat.p,
84-
PARAM.globalv.nlocal,
85-
bit,
86-
PARAM.inp.out_mat_hs[1],
87-
1,
88-
out_app_flag,
89-
s_fn,
90-
pv,
91-
GlobalV::DRANK);
92-
} // end ik
70+
const int current_spin = isk[ik];
71+
if(current_spin == 1)
72+
{
73+
continue;
74+
}
75+
76+
std::string s_fn = ModuleIO::filename_output(global_out_dir,
77+
"sk","nao",ik,ik2iktot,nspin,nkstot,
78+
out_label,out_app_flag,gamma_only,istep);
79+
80+
ofs_running << " The output filename is " << s_fn << std::endl;
81+
82+
ModuleIO::save_mat(istep,
83+
s_mat.p,
84+
PARAM.globalv.nlocal,
85+
bit,
86+
PARAM.inp.out_mat_hs[1],
87+
1,
88+
out_app_flag,
89+
s_fn,
90+
pv,
91+
GlobalV::DRANK);
92+
} // end ik
9393
}
9494

9595

@@ -113,8 +113,8 @@ void ModuleIO::save_mat(const int istep,
113113
const bool gamma_only = std::is_same<T, double>::value;
114114

115115
// write .dat file
116-
if (bit)
117-
{
116+
if (bit)
117+
{
118118
// write .dat file with MPI
119119
#ifdef __MPI
120120
FILE* out_matrix = nullptr;
@@ -155,10 +155,10 @@ void ModuleIO::save_mat(const int istep,
155155
}
156156
}
157157

158-
if (reduce)
159-
{
160-
Parallel_Reduce::reduce_all(line, tri ? dim - i : dim);
161-
}
158+
if (reduce)
159+
{
160+
Parallel_Reduce::reduce_all(line, tri ? dim - i : dim);
161+
}
162162

163163
if (drank == 0)
164164
{
@@ -172,10 +172,10 @@ void ModuleIO::save_mat(const int istep,
172172
MPI_Barrier(DIAG_WORLD);
173173
}
174174

175-
if (drank == 0)
176-
{
177-
fclose(out_matrix);
178-
}
175+
if (drank == 0)
176+
{
177+
fclose(out_matrix);
178+
}
179179
// write .dat file without MPI
180180
#else
181181
FILE* out_matrix = fopen(filename.c_str(), "wb");
@@ -194,28 +194,28 @@ void ModuleIO::save_mat(const int istep,
194194
} // end writing .dat file
195195
else // write .txt file
196196
{
197-
std::ofstream out_matrix;
198-
out_matrix << std::scientific << std::setprecision(precision);
197+
std::ofstream out_matrix;
198+
out_matrix << std::scientific << std::setprecision(precision);
199199
#ifdef __MPI
200200
if (drank == 0)
201201
{
202-
if (app && istep > 0)
203-
{
204-
out_matrix.open(filename.c_str(), std::ofstream::app);
205-
}
206-
else
207-
{
208-
out_matrix.open(filename.c_str());
209-
}
202+
if (app && istep > 0)
203+
{
204+
out_matrix.open(filename.c_str(), std::ofstream::app);
205+
}
206+
else
207+
{
208+
out_matrix.open(filename.c_str());
209+
}
210210
out_matrix << "#------------------------------------------------------------------------" << std::endl;
211211
out_matrix << "# ionic step " << istep+1 << std::endl; // istep starts from 0
212212
out_matrix << "# filename " << filename << std::endl;
213213
out_matrix << "# gamma only " << gamma_only << std::endl;
214-
out_matrix << "# rows " << dim << std::endl;
215-
out_matrix << "# columns " << dim << std::endl;
214+
out_matrix << "# rows " << dim << std::endl;
215+
out_matrix << "# columns " << dim << std::endl;
216216
out_matrix << "#------------------------------------------------------------------------" << std::endl;
217217

218-
}
218+
}
219219

220220
int ir=0;
221221
int ic=0;
@@ -247,45 +247,45 @@ void ModuleIO::save_mat(const int istep,
247247
}
248248
}
249249

250-
if (reduce)
251-
{
252-
Parallel_Reduce::reduce_all(line, tri ? dim - i : dim);
253-
}
250+
if (reduce)
251+
{
252+
Parallel_Reduce::reduce_all(line, tri ? dim - i : dim);
253+
}
254254

255255
if (drank == 0)
256256
{
257257
out_matrix << "Row " << i+1 << std::endl;
258258
size_t count = 0;
259-
for (int j = (tri ? i : 0); j < dim; j++)
260-
{
261-
out_matrix << " " << line[tri ? j - i : j];
262-
++count;
263-
if(count%8==0)
264-
{
265-
if(j!=dim-1)
266-
{
267-
out_matrix << std::endl;
268-
}
269-
}
270-
}
271-
out_matrix << std::endl;
259+
for (int j = (tri ? i : 0); j < dim; j++)
260+
{
261+
out_matrix << " " << line[tri ? j - i : j];
262+
++count;
263+
if(count%8==0)
264+
{
265+
if(j!=dim-1)
266+
{
267+
out_matrix << std::endl;
268+
}
269+
}
270+
}
271+
out_matrix << std::endl;
272272
}
273273
delete[] line;
274274
}
275275

276-
if (drank == 0)
277-
{
278-
out_matrix.close();
279-
}
276+
if (drank == 0)
277+
{
278+
out_matrix.close();
279+
}
280280
#else
281-
if (app)
282-
{
283-
std::ofstream out_matrix(filename.c_str(), std::ofstream::app);
284-
}
285-
else
286-
{
287-
std::ofstream out_matrix(filename.c_str());
288-
}
281+
if (app)
282+
{
283+
std::ofstream out_matrix(filename.c_str(), std::ofstream::app);
284+
}
285+
else
286+
{
287+
std::ofstream out_matrix(filename.c_str());
288+
}
289289

290290
out_matrix << dim;
291291
out_matrix << std::setprecision(precision);

0 commit comments

Comments
 (0)