Skip to content

Commit d965aca

Browse files
authored
Fix module_hs sparse output controls (#7510)
* fix: align module hs sparse output with threshold * fix: stabilize module hs sparse output controls * test: fix module hs regression test builds
1 parent 43e4e78 commit d965aca

25 files changed

Lines changed: 1113 additions & 277 deletions

docs/advanced/input_files/input-main.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@
19641964

19651965
- **Type**: Boolean \[Integer\](optional)
19661966
- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)*
1967-
- **Description**: Whether to print the matrix representation of the position matrix into files named rxrs1_nao.csr, ryrs1_nao.csr, rzrs1_nao.csr in the directory OUT.${suffix}. If calculation is set to get_s, the position matrix can be obtained without scf iterations. For more information, please refer to position_matrix.md.
1967+
- **Description**: Whether to print the matrix representation of the position matrix into files named rxrs1_nao.csr, ryrs1_nao.csr, rzrs1_nao.csr in the directory OUT.${suffix}. The optional second parameter controls text output precision. If calculation is set to get_s, the position matrix can be obtained without scf iterations. For more information, please refer to position_matrix.md.
19681968

19691969
> Note: In the 3.10-LTS version, the file name is data-rR-sparse.csr.
19701970
- **Default**: False 8
@@ -1974,17 +1974,17 @@
19741974

19751975
- **Type**: Boolean \[Integer\](optional)
19761976
- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)*
1977-
- **Description**: Generate files containing the kinetic energy matrix. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be trs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
1977+
- **Description**: Generate files containing the kinetic energy matrix. The optional second parameter controls text output precision. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be trs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
19781978

19791979
> Note: In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr.
19801980
- **Default**: False 8
19811981
- **Unit**: Ry
19821982

19831983
### out_mat_dh
19841984

1985-
- **Type**: Integer
1985+
- **Type**: Boolean \[Integer\](optional)
19861986
- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)*
1987-
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be dhrxs1_nao.csr, dhrys1_nao.csr, dhrzs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
1987+
- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The optional second parameter controls text output precision. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be dhrxs1_nao.csr, dhrys1_nao.csr, dhrzs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
19881988

19891989
> Note: In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on.
19901990
- **Default**: 0 8
@@ -1994,7 +1994,7 @@
19941994

19951995
- **Type**: Boolean \[Integer\](optional)
19961996
- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)*
1997-
- **Description**: Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix as mentioned in out_mat_dh. The name of the files will be dsxrs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. This feature can be used with calculation get_s.
1997+
- **Description**: Whether to print files containing the derivatives of the overlap matrix. The optional second parameter controls text output precision. The format will be the same as the overlap matrix as mentioned in out_mat_dh. The name of the files will be dsxrs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. This feature can be used with calculation get_s.
19981998

19991999
> Note: In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on.
20002000
- **Default**: False 8

docs/parameters.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,7 @@ parameters:
30583058
category: Output information
30593059
type: "Boolean \\[Integer\\](optional)"
30603060
description: |
3061-
Whether to print the matrix representation of the position matrix into files named rxrs1_nao.csr, ryrs1_nao.csr, rzrs1_nao.csr in the directory OUT.${suffix}. If calculation is set to get_s, the position matrix can be obtained without scf iterations. For more information, please refer to position_matrix.md.
3061+
Whether to print the matrix representation of the position matrix into files named rxrs1_nao.csr, ryrs1_nao.csr, rzrs1_nao.csr in the directory OUT.${suffix}. The optional second parameter controls text output precision. If calculation is set to get_s, the position matrix can be obtained without scf iterations. For more information, please refer to position_matrix.md.
30623062
30633063
[NOTE] In the 3.10-LTS version, the file name is data-rR-sparse.csr.
30643064
default_value: False 8
@@ -3068,17 +3068,17 @@ parameters:
30683068
category: Output information
30693069
type: "Boolean \\[Integer\\](optional)"
30703070
description: |
3071-
Generate files containing the kinetic energy matrix. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be trs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
3071+
Generate files containing the kinetic energy matrix. The optional second parameter controls text output precision. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be trs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
30723072
30733073
[NOTE] In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr.
30743074
default_value: False 8
30753075
unit: Ry
30763076
availability: Numerical atomic orbital basis (not gamma-only algorithm)
30773077
- name: out_mat_dh
30783078
category: Output information
3079-
type: Integer
3079+
type: "Boolean \\[Integer\\](optional)"
30803080
description: |
3081-
Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be dhrxs1_nao.csr, dhrys1_nao.csr, dhrzs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
3081+
Whether to print files containing the derivatives of the Hamiltonian matrix. The optional second parameter controls text output precision. The format will be the same as the Hamiltonian matrix and overlap matrix as mentioned in out_mat_hs2. The name of the files will be dhrxs1_nao.csr, dhrys1_nao.csr, dhrzs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag.
30823082
30833083
[NOTE] In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on.
30843084
default_value: 0 8
@@ -3088,7 +3088,7 @@ parameters:
30883088
category: Output information
30893089
type: "Boolean \\[Integer\\](optional)"
30903090
description: |
3091-
Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix as mentioned in out_mat_dh. The name of the files will be dsxrs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. This feature can be used with calculation get_s.
3091+
Whether to print files containing the derivatives of the overlap matrix. The optional second parameter controls text output precision. The format will be the same as the overlap matrix as mentioned in out_mat_dh. The name of the files will be dsxrs1_nao.csr and so on. Also controled by out_freq_ion and out_app_flag. This feature can be used with calculation get_s.
30923092
30933093
[NOTE] In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on.
30943094
default_value: False 8

source/source_esolver/esolver_gets.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
135135
{
136136
cal_r_overlap_R r_matrix;
137137
r_matrix.init(ucell, pv, orb_);
138-
r_matrix.out_rR(ucell, gd, istep);
138+
r_matrix.out_rR(ucell, gd, istep, PARAM.inp.out_mat_r[1]);
139139
}
140140

141141
if (PARAM.inp.out_mat_ds[0])
@@ -149,7 +149,10 @@ void ESolver_GetS::runner(UnitCell& ucell, const int istep)
149149
gd, // mohan add 2024-04-06
150150
two_center_bundle_,
151151
orb_,
152-
kv);
152+
kv,
153+
false,
154+
1e-10,
155+
PARAM.inp.out_mat_ds[1]);
153156
}
154157

155158
ModuleBase::timer::end("ESolver_GetS", "runner");

source/source_io/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ if(ENABLE_LCAO)
8787
module_hs/write_HS_R.cpp
8888
module_hs/write_HS_sparse.cpp
8989
module_hs/single_R_io.cpp
90+
module_hs/rr_sparse_writer.cpp
9091
module_hs/cal_r_overlap_R.cpp
9192
module_hs/output_mat_sparse.cpp
9293
module_ctrl/ctrl_scf_lcao.cpp

source/source_io/module_ctrl/ctrl_scf_lcao.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,17 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell,
232232
//------------------------------------------------------------------
233233
hamilt::Hamilt<TK>* p_ham_tk = static_cast<hamilt::Hamilt<TK>*>(p_hamilt);
234234

235-
ModuleIO::output_mat_sparse(inp.out_mat_dh[0],
236-
inp.out_mat_ds[0],
237-
inp.out_mat_t[0],
238-
inp.out_mat_r[0],
235+
ModuleIO::MatSparseOutputOptions mat_sparse_options;
236+
mat_sparse_options.out_mat_dh = inp.out_mat_dh[0];
237+
mat_sparse_options.out_mat_ds = inp.out_mat_ds[0];
238+
mat_sparse_options.out_mat_t = inp.out_mat_t[0];
239+
mat_sparse_options.out_mat_r = inp.out_mat_r[0];
240+
mat_sparse_options.dh_precision = inp.out_mat_dh[1];
241+
mat_sparse_options.ds_precision = inp.out_mat_ds[1];
242+
mat_sparse_options.t_precision = inp.out_mat_t[1];
243+
mat_sparse_options.r_precision = inp.out_mat_r[1];
244+
245+
ModuleIO::output_mat_sparse(mat_sparse_options,
239246
istep,
240247
pelec->pot->get_eff_v(),
241248
pv,

0 commit comments

Comments
 (0)