Skip to content

Commit ee99e3c

Browse files
author
dyzheng
committed
Feature: add out_mat_hr0 to output H0 for first iteration
1 parent bc17385 commit ee99e3c

6 files changed

Lines changed: 68 additions & 2 deletions

File tree

docs/advanced/input_files/input-main.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
- [out\_mat\_hs](#out_mat_hs)
151151
- [out\_mat\_tk](#out_mat_tk)
152152
- [out\_mat\_r](#out_mat_r)
153+
- [out\_mat\_hr0](#out_mat_hr0)
153154
- [out\_mat\_hs2](#out_mat_hs2)
154155
- [out\_mat\_t](#out_mat_t)
155156
- [out\_mat\_dh](#out_mat_dh)
@@ -1756,6 +1757,13 @@ These variables are used to control the output of properties.
17561757
- **Description**: Whether to print the matrix representation of the position matrix (in Bohr) into a file named `data-rR-tr` in the directory `OUT.${suffix}`. If [calculation](#calculation) is set to `get_S`, the position matrix can be obtained without scf iterations. For more information, please refer to [position_matrix.md](../elec_properties/position_matrix.md#extracting-position-matrices).
17571758
- **Default**: False
17581759

1760+
### out_mat_hr0
1761+
1762+
- **Type**: Boolean
1763+
- **Availability**: Numerical atomic orbital basis (not gamma-only algorithm)
1764+
- **Description**: Whether to print files containing the initial Hamiltonian matrix $H(R)$ (in Ry) into files `data-HR0.dat` in the directory `OUT.${suffix}`.
1765+
- **Default**: False
1766+
17591767
### out_mat_hs2
17601768

17611769
- **Type**: Boolean

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,26 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
870870
this->p_chgmix->mix_dmr(dm);
871871
}
872872

873+
// output the first H(R) when out_mat_hr0 is true
874+
if(PARAM.inp.out_mat_hr0 == true && istep == 0 && iter == 1)
875+
{
876+
ModuleIO::output_mat_sparse(false,
877+
PARAM.inp.out_mat_hr0,
878+
false,
879+
false,
880+
false,
881+
istep,
882+
this->pelec->pot->get_effective_v(),
883+
this->pv,
884+
this->GK,
885+
two_center_bundle_,
886+
orb_,
887+
ucell,
888+
this->gd,
889+
this->kv,
890+
this->p_hamilt);
891+
}
892+
873893
// 2) save charge density
874894
// Peize Lin add 2020.04.04
875895
if (GlobalC::restart.info_save.save_charge)
@@ -1159,6 +1179,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11591179
{
11601180
//! Print out sparse matrix
11611181
ModuleIO::output_mat_sparse(PARAM.inp.out_mat_hs2,
1182+
false,
11621183
PARAM.inp.out_mat_dh,
11631184
PARAM.inp.out_mat_t,
11641185
PARAM.inp.out_mat_r,

source/module_io/output_mat_sparse.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace ModuleIO
88

99
template <>
1010
void output_mat_sparse(const bool& out_mat_hsR,
11+
const bool& out_mat_hr0,
1112
const bool& out_mat_dh,
1213
const bool& out_mat_t,
1314
const bool& out_mat_r,
@@ -26,6 +27,7 @@ void output_mat_sparse(const bool& out_mat_hsR,
2627

2728
template <>
2829
void output_mat_sparse(const bool& out_mat_hsR,
30+
const bool& out_mat_hr0,
2931
const bool& out_mat_dh,
3032
const bool& out_mat_t,
3133
const bool& out_mat_r,
@@ -47,6 +49,27 @@ void output_mat_sparse(const bool& out_mat_hsR,
4749
{
4850
output_HSR(ucell,istep, v_eff, pv, HS_Arrays, grid, kv, p_ham);
4951
}
52+
else if (out_mat_hr0)
53+
{
54+
output_HSR(
55+
ucell,
56+
istep,
57+
v_eff,
58+
pv,
59+
HS_Arrays,
60+
grid,
61+
kv,
62+
p_ham,
63+
#ifdef _EXX
64+
nullptr,
65+
nullptr,
66+
#endif
67+
"data-SR-sparse_SPIN0.csr",
68+
"data-HR0_SPIN0.csr",
69+
"data-HR0_SPIN1.csr"
70+
);
71+
}
72+
5073

5174
//! generate a file containing the kinetic energy matrix
5275
if (out_mat_t)

source/module_io/output_mat_sparse.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace ModuleIO
1212
/// @brief the output interface to write the sparse matrix of H, S, T, and r
1313
template <typename T>
1414
void output_mat_sparse(const bool& out_mat_hsR,
15+
const bool& out_mat_hr0,
1516
const bool& out_mat_dh,
1617
const bool& out_mat_t,
1718
const bool& out_mat_r,

source/module_io/read_input_item_output.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,26 @@ void ReadInput::item_output()
267267
sync_intvec(input.out_mat_tk, 2, 0);
268268
this->add_item(item);
269269
}
270+
{
271+
Input_Item item("out_mat_hr0");
272+
item.annotation = "output initial H(R) matrix";
273+
read_sync_bool(input.out_mat_hr0);
274+
item.check_value = [](const Input_Item& item, const Parameter& para) {
275+
if (para.input.out_mat_hr0 && para.sys.gamma_only_local)
276+
{
277+
ModuleBase::WARNING_QUIT("ReadInput", "out_mat_r is not available for gamma only calculations");
278+
}
279+
};
280+
this->add_item(item);
281+
}
270282
{
271283
Input_Item item("out_mat_hs2");
272284
item.annotation = "output H(R) and S(R) matrix";
273285
read_sync_bool(input.out_mat_hs2);
274286
item.check_value = [](const Input_Item& item, const Parameter& para) {
275-
if (para.input.out_mat_r && para.sys.gamma_only_local)
287+
if (para.input.out_mat_hs2 && para.sys.gamma_only_local)
276288
{
277-
ModuleBase::WARNING_QUIT("ReadInput", "out_mat_r is not available for gamma only calculations");
289+
ModuleBase::WARNING_QUIT("ReadInput", "out_mat_hs2 is not available for gamma only calculations");
278290
}
279291
};
280292
this->add_item(item);

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ struct Input_para
337337
std::vector<int> out_mat_tk = {0, 8}; ///< output T(k) matrix in local basis.
338338
bool out_mat_hs2 = false; ///< LiuXh add 2019-07-16, output H(R) matrix and
339339
///< S(R) matrix in local basis.
340+
bool out_mat_hr0 = false; ///< output H(R) with atomic charge
340341
bool out_mat_dh = false;
341342
bool out_mat_xc = false; ///< output exchange-correlation matrix in
342343
///< KS-orbital representation.

0 commit comments

Comments
 (0)