Skip to content

Commit 3c10b04

Browse files
committed
Add HR output for DeePKS.
1 parent f01be02 commit 3c10b04

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -279,54 +279,39 @@ void LCAO_Deepks_Interface<TK, TR>::out_deepks_labels(const double& etot,
279279
} // end deepks_scf == 0
280280
} // end bandgap label
281281

282-
// H(R) matrix part, not realized now
282+
// H(R) matrix part, for HR, base will not be calculated since they are HContainer objects
283283
if (PARAM.inp.deepks_v_delta < 0)
284284
{
285-
const std::string file_hrtot = PARAM.globalv.global_out_dir + "deepks_hrtot.npy";
285+
// set the output
286+
const double sparse_threshold = 1e-10;
287+
const int precision = 8;
288+
const std::string file_hrtot = PARAM.globalv.global_out_dir + "deepks_hrtot.csr";
286289
hamilt::HContainer<TR>* hR_tot = (p_ham->getHR());
287290

288-
// How to save H(R)?
289-
// LCAO_deepks_io::save_npy_hr<TK, TR>(hR_tot, file_hrtot, rank);
290-
if constexpr (std::is_same<TR, double>::value)
291+
if (rank == 0)
291292
{
292-
// For test only
293-
if (rank == 0)
294-
{
295-
std::ofstream ofs_hr("HR_outtest", std::ios::out);
296-
double sparse_threshold = 1e-10;
297-
int precision = 8;
298-
hamilt::Output_HContainer<TR> out_hr(hR_tot, ofs_hr, sparse_threshold, precision);
299-
out_hr.write();
300-
ofs_hr.close();
301-
}
293+
std::ofstream ofs_hr(file_hrtot, std::ios::out);
294+
ofs_hr << "Matrix Dimension of H(R): " << hR_tot->get_nbasis() << std::endl;
295+
ofs_hr << "Matrix number of H(R): " << hR_tot->size_R_loop() << std::endl;
296+
hamilt::Output_HContainer<TR> out_hr(hR_tot, ofs_hr, sparse_threshold, precision);
297+
out_hr.write();
298+
ofs_hr.close();
302299
}
303300

304301
if (PARAM.inp.deepks_scf)
305302
{
306-
const std::string file_vdeltar = PARAM.globalv.global_out_dir + "deepks_vdeltar.npy";
307-
// LCAO_deepks_io::save_npy_hr<TK, TR>(hR_delta, file_vdeltar, rank);
303+
const std::string file_vdeltar = PARAM.globalv.global_out_dir + "deepks_hrdelta.csr";
308304
hamilt::HContainer<TR>* h_deltaR = p_ham->get_V_delta_R();
309-
if constexpr (std::is_same<TR, double>::value)
305+
306+
if (rank == 0)
310307
{
311-
// For test only
312-
if (rank == 0)
313-
{
314-
std::ofstream ofs_hr("HR_delta_outtest", std::ios::out);
315-
double sparse_threshold = 1e-10;
316-
int precision = 8;
317-
hamilt::Output_HContainer<TR> out_hr(h_deltaR, ofs_hr, sparse_threshold, precision);
318-
out_hr.write();
319-
ofs_hr.close();
320-
}
308+
std::ofstream ofs_hr(file_vdeltar, std::ios::out);
309+
ofs_hr << "Matrix Dimension of H_delta(R): " << h_deltaR->get_nbasis() << std::endl;
310+
ofs_hr << "Matrix number of H_delta(R): " << h_deltaR->size_R_loop() << std::endl;
311+
hamilt::Output_HContainer<TR> out_hr(h_deltaR, ofs_hr, sparse_threshold, precision);
312+
out_hr.write();
313+
ofs_hr.close();
321314
}
322-
323-
const std::string file_hrbase = PARAM.globalv.global_out_dir + "deepks_hrbase.npy";
324-
// LCAO_deepks_io::save_npy_hr<TK, TR>(?, file_hrbase, rank);
325-
}
326-
else
327-
{
328-
const std::string file_hrbase = PARAM.globalv.global_out_dir + "deepks_hrbase.npy";
329-
// LCAO_deepks_io::save_npy_hr<TK, TR>(hR_tot, file_hrbase, rank);
330315
}
331316
}
332317

source/module_hamilt_lcao/module_hcontainer/output_hcontainer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ void Output_HContainer<T>::write_single_R(int rx, int ry, int rz)
119119
this->_hcontainer->unfix_R();
120120
}
121121

122-
// explicit instantiation of template class with double type
123122
template class Output_HContainer<double>;
124-
// to do: explicit instantiation of template class with std::complex<double> type
125-
// template class Output_HContainer<std::complex<double>>;
123+
template class Output_HContainer<std::complex<double>>;
126124

127125
} // namespace hamilt

0 commit comments

Comments
 (0)