From dadbed958dcc00c978306fc752e888cd680385e3 Mon Sep 17 00:00:00 2001 From: nscc-gz_pinchen_1 Date: Tue, 16 Jun 2026 12:16:00 +0800 Subject: [PATCH 1/3] Support NPZ output for LCAO HSR matrices --- docs/advanced/input_files/input-main.md | 25 +++++++ docs/parameters.yaml | 24 +++++++ .../source_io/module_ctrl/ctrl_scf_lcao.cpp | 30 ++++++++ source/source_io/module_ml/io_npz.cpp | 19 +++++- source/source_io/module_ml/io_npz.h | 4 ++ .../module_parameter/input_parameter.h | 3 + .../read_input_item_output.cpp | 68 ++++++++++++++++++- .../test_serial/read_input_item_test.cpp | 18 +++++ 8 files changed, 187 insertions(+), 4 deletions(-) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index a91c6dd7530..fe03d81a5d6 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -177,6 +177,9 @@ - [out\_mat\_l](#out_mat_l) - [out\_xc\_r](#out_xc_r) - [out\_eband\_terms](#out_eband_terms) + - [out\_hr\_npz](#out_hr_npz) + - [out\_hsr\_npz](#out_hsr_npz) + - [out\_dm\_npz](#out_dm_npz) - [out\_mul](#out_mul) - [out\_app\_flag](#out_app_flag) - [out\_ndigits](#out_ndigits) @@ -2049,6 +2052,28 @@ - **Description**: Whether to print the band energy terms separately in the file OUT.{term}_out.dat. The terms include the kinetic, pseudopotential (local + nonlocal), Hartree and exchange-correlation (including exact exchange if calculated). - **Default**: False +### out_hr_npz + +- **Type**: Boolean +- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Description**: Whether to print Hamiltonian matrices H(R) in npz format. The output files are named output_HR0.npz, output_HR1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. +- **Default**: False +- **Unit**: Ry + +### out_hsr_npz + +- **Type**: Boolean +- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Description**: Whether to print Hamiltonian matrices H(R) and overlap matrix S(R) in npz format. The output files are named output_SR.npz, output_HR0.npz, output_HR1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. +- **Default**: False + +### out_dm_npz + +- **Type**: Boolean +- **Availability**: *Numerical atomic orbital basis (not gamma-only algorithm)* +- **Description**: Whether to print density matrices DM(R) in npz format. The output files are named output_DM0.npz, output_DM1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. +- **Default**: False + ### out_mul - **Type**: Boolean diff --git a/docs/parameters.yaml b/docs/parameters.yaml index d8287e067c9..8509dfdb0c9 100644 --- a/docs/parameters.yaml +++ b/docs/parameters.yaml @@ -3147,6 +3147,30 @@ parameters: default_value: "False" unit: "" availability: Numerical atomic orbital basis + - name: out_hr_npz + category: Output information + type: Boolean + description: | + Whether to print Hamiltonian matrices H(R) in npz format. The output files are named output_HR0.npz, output_HR1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. + default_value: "False" + unit: Ry + availability: Numerical atomic orbital basis (not gamma-only algorithm) + - name: out_hsr_npz + category: Output information + type: Boolean + description: | + Whether to print Hamiltonian matrices H(R) and overlap matrix S(R) in npz format. The output files are named output_SR.npz, output_HR0.npz, output_HR1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. + default_value: "False" + unit: "" + availability: Numerical atomic orbital basis (not gamma-only algorithm) + - name: out_dm_npz + category: Output information + type: Boolean + description: | + Whether to print density matrices DM(R) in npz format. The output files are named output_DM0.npz, output_DM1.npz, and so on according to spin channel. This feature requires ABACUS to be built with CNPY. + default_value: "False" + unit: "" + availability: Numerical atomic orbital basis (not gamma-only algorithm) - name: out_mul category: Output information type: Boolean diff --git a/source/source_io/module_ctrl/ctrl_scf_lcao.cpp b/source/source_io/module_ctrl/ctrl_scf_lcao.cpp index 7318a3f2b7b..bda25ca8546 100644 --- a/source/source_io/module_ctrl/ctrl_scf_lcao.cpp +++ b/source/source_io/module_ctrl/ctrl_scf_lcao.cpp @@ -11,6 +11,7 @@ #include "../module_unk/berryphase.h" // use berryphase #include "../module_hs/cal_pLpR.h" // use AngularMomentumCalculator() #include "source_io/module_hs/output_mat_sparse.h" // use ModuleIO::output_mat_sparse() +#include "source_io/module_ml/io_npz.h" // use ModuleIO::output_mat_npz() #include "../module_hs/write_HS_R.h" // use ModuleIO::write_hsr() #include "../module_mulliken/output_mulliken.h" // use cal_mag() #include "../module_wannier/to_wannier90_lcao.h" // use toWannier90_LCAO @@ -228,6 +229,35 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell, out_app_flag, ucell.get_iat2iwt(), ucell.nat, istep); } + //------------------------------------------------------------------ + //! 7a.1) Output H(R), S(R), and DM(R) matrices in NPZ format + //------------------------------------------------------------------ + if (inp.out_hsr_npz) + { + std::string zipname = "output_SR.npz"; + ModuleIO::output_mat_npz(ucell, zipname, *(p_hamilt->getSR())); + } + + if (inp.out_hr_npz || inp.out_hsr_npz) + { + std::vector*> hr_vec = p_hamilt->getHR_vector(); + for (int ispin = 0; ispin < hr_vec.size(); ++ispin) + { + std::string zipname = "output_HR" + std::to_string(ispin) + ".npz"; + ModuleIO::output_mat_npz(ucell, zipname, *(hr_vec[ispin])); + } + } + + if (inp.out_dm_npz) + { + const std::vector*>& dmr_vec = dm->get_DMR_vector(); + for (int ispin = 0; ispin < dmr_vec.size(); ++ispin) + { + std::string zipname = "output_DM" + std::to_string(ispin) + ".npz"; + ModuleIO::output_mat_npz(ucell, zipname, *(dmr_vec[ispin])); + } + } + //------------------------------------------------------------------ //! 7b) Output dH, dS, T, r matrices (old sparse path, without H/S) //------------------------------------------------------------------ diff --git a/source/source_io/module_ml/io_npz.cpp b/source/source_io/module_ml/io_npz.cpp index 6933fba97a7..0fa2e3e2739 100644 --- a/source/source_io/module_ml/io_npz.cpp +++ b/source/source_io/module_ml/io_npz.cpp @@ -321,7 +321,8 @@ void read_mat_npz(const Parallel_Orbitals* paraV, #endif } -void output_mat_npz(const UnitCell& ucell, std::string& zipname, const hamilt::HContainer& hR) +template +void output_mat_npz_impl(const UnitCell& ucell, std::string& zipname, const hamilt::HContainer& hR) { ModuleBase::TITLE("ModuleIO", "output_mat_npz"); @@ -412,13 +413,13 @@ void output_mat_npz(const UnitCell& ucell, std::string& zipname, const hamilt::H //fourth block: hr(i0,jR) #ifdef __MPI - hamilt::HContainer* HR_serial; + hamilt::HContainer* HR_serial; Parallel_Orbitals serialV; serialV.set_serial(PARAM.globalv.nlocal, PARAM.globalv.nlocal); serialV.set_atomic_trace(ucell.get_iat2iwt(), ucell.nat, PARAM.globalv.nlocal); if(GlobalV::MY_RANK == 0) { - HR_serial = new hamilt::HContainer(&serialV); + HR_serial = new hamilt::HContainer(&serialV); } hamilt::gatherParallels(hR, HR_serial, 0); @@ -471,4 +472,16 @@ void output_mat_npz(const UnitCell& ucell, std::string& zipname, const hamilt::H #endif } +void output_mat_npz(const UnitCell& ucell, std::string& zipname, const hamilt::HContainer& hR) +{ + output_mat_npz_impl(ucell, zipname, hR); +} + +void output_mat_npz(const UnitCell& ucell, + std::string& zipname, + const hamilt::HContainer>& hR) +{ + output_mat_npz_impl(ucell, zipname, hR); +} + } // namespace ModuleIO diff --git a/source/source_io/module_ml/io_npz.h b/source/source_io/module_ml/io_npz.h index 60eadc46744..dd62e73fd20 100644 --- a/source/source_io/module_ml/io_npz.h +++ b/source/source_io/module_ml/io_npz.h @@ -5,6 +5,7 @@ #include "source_cell/unitcell.h" #include "source_lcao/module_hcontainer/hcontainer.h" +#include #include #include @@ -17,6 +18,9 @@ void read_mat_npz(const Parallel_Orbitals* paraV, hamilt::HContainer& hR); void output_mat_npz(const UnitCell& ucell, std::string& zipname, const hamilt::HContainer& hR); +void output_mat_npz(const UnitCell& ucell, + std::string& zipname, + const hamilt::HContainer>& hR); } // namespace ModuleIO diff --git a/source/source_io/module_parameter/input_parameter.h b/source/source_io/module_parameter/input_parameter.h index acbfeb62bf4..b6955f27f01 100644 --- a/source/source_io/module_parameter/input_parameter.h +++ b/source/source_io/module_parameter/input_parameter.h @@ -400,6 +400,9 @@ struct Input_para ///< KS-orbital representation. std::vector out_mat_xc2 = {0, 8}; ///< output Vxc(R) matrix with precision bool out_eband_terms = false; ///< output the band energy terms separately + bool out_hr_npz = false; ///< output H(R) matrix in npz format + bool out_hsr_npz = false; ///< output H(R) and S(R) matrices in npz format + bool out_dm_npz = false; ///< output DM(R) matrix in npz format int out_interval = 1; bool out_app_flag = true; ///< whether output r(R), H(R), S(R), T(R), and dH(R) matrices ///< in an append manner during MD liuyu 2023-03-20 diff --git a/source/source_io/module_parameter/read_input_item_output.cpp b/source/source_io/module_parameter/read_input_item_output.cpp index 8bc0c895499..def0f47b019 100644 --- a/source/source_io/module_parameter/read_input_item_output.cpp +++ b/source/source_io/module_parameter/read_input_item_output.cpp @@ -594,7 +594,7 @@ Also controled by out_freq_ion and out_app_flag. }; item.check_value = [](const Input_Item& item, const Parameter& para) { if ((para.inp.out_mat_r[0] || para.inp.out_mat_hs2[0] || para.inp.out_mat_t[0] || para.inp.out_mat_dh[0] - || para.inp.dm_to_rho) + || para.inp.out_hr_npz || para.inp.out_hsr_npz || para.inp.out_dm_npz || para.inp.dm_to_rho) && para.sys.gamma_only_local) { ModuleBase::WARNING_QUIT("ReadInput", @@ -816,6 +816,72 @@ The circle order of the charge density on real space grids is: x is the outer lo read_sync_bool(input.out_eband_terms); this->add_item(item); } + { + Input_Item item("out_hr_npz"); + item.annotation = "output H(R) matrix in npz format"; + item.category = "Output information"; + item.type = "Boolean"; + item.description = "Whether to print Hamiltonian matrices H(R) in npz format. This feature does not work for gamma-only calculations."; + item.default_value = "False"; + item.unit = "Ry"; + item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + read_sync_bool(input.out_hr_npz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_hr_npz) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif + } + }; + this->add_item(item); + } + { + Input_Item item("out_hsr_npz"); + item.annotation = "output H(R) and S(R) matrices in npz format"; + item.category = "Output information"; + item.type = "Boolean"; + item.description = "Whether to print Hamiltonian matrices H(R) and overlap matrix S(R) in npz format. This feature does not work for gamma-only calculations."; + item.default_value = "False"; + item.unit = "Ry"; + item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + read_sync_bool(input.out_hsr_npz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_hsr_npz) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif + } + }; + this->add_item(item); + } + { + Input_Item item("out_dm_npz"); + item.annotation = "output DM(R) matrix in npz format"; + item.category = "Output information"; + item.type = "Boolean"; + item.description = "Whether to print density matrices DM(R) in npz format. This feature does not work for gamma-only calculations."; + item.default_value = "False"; + item.unit = ""; + item.availability = "Numerical atomic orbital basis (not gamma-only algorithm)"; + read_sync_bool(input.out_dm_npz); + item.check_value = [](const Input_Item& item, const Parameter& para) { + if (para.input.out_dm_npz) + { +#ifndef __USECNPY + ModuleBase::WARNING_QUIT("ReadInput", + "to write in npz format, please " + "recompile with -DENABLE_CNPY=1"); +#endif + } + }; + this->add_item(item); + } { Input_Item item("out_mul"); item.annotation = "mulliken charge or not"; diff --git a/source/source_io/test_serial/read_input_item_test.cpp b/source/source_io/test_serial/read_input_item_test.cpp index 3909f8d1580..61673a418c7 100644 --- a/source/source_io/test_serial/read_input_item_test.cpp +++ b/source/source_io/test_serial/read_input_item_test.cpp @@ -973,6 +973,24 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.out_mat_hs[0], 1); } + { // out_hr_npz + auto it = find_label("out_hr_npz", readinput.input_lists); + it->second.str_values = {"1"}; + it->second.read_value(it->second, param); + EXPECT_EQ(param.input.out_hr_npz, true); + } + { // out_hsr_npz + auto it = find_label("out_hsr_npz", readinput.input_lists); + it->second.str_values = {"1"}; + it->second.read_value(it->second, param); + EXPECT_EQ(param.input.out_hsr_npz, true); + } + { // out_dm_npz + auto it = find_label("out_dm_npz", readinput.input_lists); + it->second.str_values = {"1"}; + it->second.read_value(it->second, param); + EXPECT_EQ(param.input.out_dm_npz, true); + } } TEST_F(InputTest, Item_test2) { From 9d5602190d98639ed5674362c49aaa50f112f38d Mon Sep 17 00:00:00 2001 From: nscc-gz_pinchen_1 Date: Mon, 29 Jun 2026 15:56:05 +0800 Subject: [PATCH 2/3] Write NPZ outputs under OUT directory --- .../source_io/module_ctrl/ctrl_scf_lcao.cpp | 8 +++-- tests/03_NAO_multik/CASES_CPU.txt | 3 ++ tests/03_NAO_multik/scf_out_dm_npz/INPUT | 30 +++++++++++++++++++ tests/03_NAO_multik/scf_out_dm_npz/KPT | 4 +++ tests/03_NAO_multik/scf_out_dm_npz/README | 1 + tests/03_NAO_multik/scf_out_dm_npz/STRU | 22 ++++++++++++++ tests/03_NAO_multik/scf_out_dm_npz/result.ref | 4 +++ tests/03_NAO_multik/scf_out_hr_npz/INPUT | 30 +++++++++++++++++++ tests/03_NAO_multik/scf_out_hr_npz/KPT | 4 +++ tests/03_NAO_multik/scf_out_hr_npz/README | 1 + tests/03_NAO_multik/scf_out_hr_npz/STRU | 22 ++++++++++++++ tests/03_NAO_multik/scf_out_hr_npz/result.ref | 4 +++ tests/03_NAO_multik/scf_out_hsr_npz/INPUT | 30 +++++++++++++++++++ tests/03_NAO_multik/scf_out_hsr_npz/KPT | 4 +++ tests/03_NAO_multik/scf_out_hsr_npz/README | 1 + tests/03_NAO_multik/scf_out_hsr_npz/STRU | 22 ++++++++++++++ .../03_NAO_multik/scf_out_hsr_npz/result.ref | 5 ++++ tests/integrate/tools/catch_properties.sh | 21 +++++++++++++ 18 files changed, 213 insertions(+), 3 deletions(-) create mode 100644 tests/03_NAO_multik/scf_out_dm_npz/INPUT create mode 100644 tests/03_NAO_multik/scf_out_dm_npz/KPT create mode 100644 tests/03_NAO_multik/scf_out_dm_npz/README create mode 100644 tests/03_NAO_multik/scf_out_dm_npz/STRU create mode 100644 tests/03_NAO_multik/scf_out_dm_npz/result.ref create mode 100644 tests/03_NAO_multik/scf_out_hr_npz/INPUT create mode 100644 tests/03_NAO_multik/scf_out_hr_npz/KPT create mode 100644 tests/03_NAO_multik/scf_out_hr_npz/README create mode 100644 tests/03_NAO_multik/scf_out_hr_npz/STRU create mode 100644 tests/03_NAO_multik/scf_out_hr_npz/result.ref create mode 100644 tests/03_NAO_multik/scf_out_hsr_npz/INPUT create mode 100644 tests/03_NAO_multik/scf_out_hsr_npz/KPT create mode 100644 tests/03_NAO_multik/scf_out_hsr_npz/README create mode 100644 tests/03_NAO_multik/scf_out_hsr_npz/STRU create mode 100644 tests/03_NAO_multik/scf_out_hsr_npz/result.ref diff --git a/source/source_io/module_ctrl/ctrl_scf_lcao.cpp b/source/source_io/module_ctrl/ctrl_scf_lcao.cpp index bda25ca8546..b5e529ec9c2 100644 --- a/source/source_io/module_ctrl/ctrl_scf_lcao.cpp +++ b/source/source_io/module_ctrl/ctrl_scf_lcao.cpp @@ -234,7 +234,7 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell, //------------------------------------------------------------------ if (inp.out_hsr_npz) { - std::string zipname = "output_SR.npz"; + std::string zipname = PARAM.globalv.global_out_dir + "output_SR.npz"; ModuleIO::output_mat_npz(ucell, zipname, *(p_hamilt->getSR())); } @@ -243,7 +243,8 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell, std::vector*> hr_vec = p_hamilt->getHR_vector(); for (int ispin = 0; ispin < hr_vec.size(); ++ispin) { - std::string zipname = "output_HR" + std::to_string(ispin) + ".npz"; + std::string zipname + = PARAM.globalv.global_out_dir + "output_HR" + std::to_string(ispin) + ".npz"; ModuleIO::output_mat_npz(ucell, zipname, *(hr_vec[ispin])); } } @@ -253,7 +254,8 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell, const std::vector*>& dmr_vec = dm->get_DMR_vector(); for (int ispin = 0; ispin < dmr_vec.size(); ++ispin) { - std::string zipname = "output_DM" + std::to_string(ispin) + ".npz"; + std::string zipname + = PARAM.globalv.global_out_dir + "output_DM" + std::to_string(ispin) + ".npz"; ModuleIO::output_mat_npz(ucell, zipname, *(dmr_vec[ispin])); } } diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index beb5b151631..38f6e2ba57d 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -31,6 +31,9 @@ scf_out_pot3 scf_out_dmr_dmk scf_out_hsk scf_out_hsr +scf_out_hr_npz +scf_out_hsr_npz +scf_out_dm_npz scf_out_hsr_spin4 scf_out_dh_t scf_out_dos_spin4 diff --git a/tests/03_NAO_multik/scf_out_dm_npz/INPUT b/tests/03_NAO_multik/scf_out_dm_npz/INPUT new file mode 100644 index 00000000000..7feeb1d14f0 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_dm_npz/INPUT @@ -0,0 +1,30 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix autotest +calculation scf + +nbands 6 +symmetry 0 +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB +gamma_only 0 + +#Parameters (2.Iteration) +ecutwfc 20 +scf_thr 1e-8 +scf_nmax 1 + +#Parameters (3.Basis) +basis_type lcao + +#Parameters (4.Smearing) +smearing_method gauss +smearing_sigma 0.002 + +#Parameters (5.Mixing) +mixing_type broyden +mixing_beta 0.7 +mixing_gg0 0.0 + +out_dm_npz 1 +ks_solver scalapack_gvx diff --git a/tests/03_NAO_multik/scf_out_dm_npz/KPT b/tests/03_NAO_multik/scf_out_dm_npz/KPT new file mode 100644 index 00000000000..e769af76382 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_dm_npz/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 1 1 0 0 0 diff --git a/tests/03_NAO_multik/scf_out_dm_npz/README b/tests/03_NAO_multik/scf_out_dm_npz/README new file mode 100644 index 00000000000..c2cc38d46ab --- /dev/null +++ b/tests/03_NAO_multik/scf_out_dm_npz/README @@ -0,0 +1 @@ +test the output of DM(R) matrix in NPZ format under OUT.autotest diff --git a/tests/03_NAO_multik/scf_out_dm_npz/STRU b/tests/03_NAO_multik/scf_out_dm_npz/STRU new file mode 100644 index 00000000000..269eea28440 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_dm_npz/STRU @@ -0,0 +1,22 @@ +ATOMIC_SPECIES +Si 14 Si_dojo_nsoc.upf upf201 + +NUMERICAL_ORBITAL +Si_dojo_6au_sz.orb + +LATTICE_CONSTANT +15.3 // add lattice constant + +LATTICE_VECTORS +0.0 0.5 0.5 +0.5 0.0 0.5 +0.5 0.5 0.0 + +ATOMIC_POSITIONS +Direct + +Si // Element type +0.0 // magnetism +2 +0.00 0.00 0.00 1 1 1 +0.25 0.25 0.25 1 1 1 diff --git a/tests/03_NAO_multik/scf_out_dm_npz/result.ref b/tests/03_NAO_multik/scf_out_dm_npz/result.ref new file mode 100644 index 00000000000..6314592784b --- /dev/null +++ b/tests/03_NAO_multik/scf_out_dm_npz/result.ref @@ -0,0 +1,4 @@ +etotref -174.1078103590385 +etotperatomref -87.0539051795 +OutputDMNPZ_pass 0 +totaltimeref 0.25 diff --git a/tests/03_NAO_multik/scf_out_hr_npz/INPUT b/tests/03_NAO_multik/scf_out_hr_npz/INPUT new file mode 100644 index 00000000000..49303b30c1c --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hr_npz/INPUT @@ -0,0 +1,30 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix autotest +calculation scf + +nbands 6 +symmetry 0 +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB +gamma_only 0 + +#Parameters (2.Iteration) +ecutwfc 20 +scf_thr 1e-8 +scf_nmax 1 + +#Parameters (3.Basis) +basis_type lcao + +#Parameters (4.Smearing) +smearing_method gauss +smearing_sigma 0.002 + +#Parameters (5.Mixing) +mixing_type broyden +mixing_beta 0.7 +mixing_gg0 0.0 + +out_hr_npz 1 +ks_solver scalapack_gvx diff --git a/tests/03_NAO_multik/scf_out_hr_npz/KPT b/tests/03_NAO_multik/scf_out_hr_npz/KPT new file mode 100644 index 00000000000..e769af76382 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hr_npz/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 1 1 0 0 0 diff --git a/tests/03_NAO_multik/scf_out_hr_npz/README b/tests/03_NAO_multik/scf_out_hr_npz/README new file mode 100644 index 00000000000..cfad14a28af --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hr_npz/README @@ -0,0 +1 @@ +test the output of H(R) matrix in NPZ format under OUT.autotest diff --git a/tests/03_NAO_multik/scf_out_hr_npz/STRU b/tests/03_NAO_multik/scf_out_hr_npz/STRU new file mode 100644 index 00000000000..269eea28440 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hr_npz/STRU @@ -0,0 +1,22 @@ +ATOMIC_SPECIES +Si 14 Si_dojo_nsoc.upf upf201 + +NUMERICAL_ORBITAL +Si_dojo_6au_sz.orb + +LATTICE_CONSTANT +15.3 // add lattice constant + +LATTICE_VECTORS +0.0 0.5 0.5 +0.5 0.0 0.5 +0.5 0.5 0.0 + +ATOMIC_POSITIONS +Direct + +Si // Element type +0.0 // magnetism +2 +0.00 0.00 0.00 1 1 1 +0.25 0.25 0.25 1 1 1 diff --git a/tests/03_NAO_multik/scf_out_hr_npz/result.ref b/tests/03_NAO_multik/scf_out_hr_npz/result.ref new file mode 100644 index 00000000000..dd2794fa735 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hr_npz/result.ref @@ -0,0 +1,4 @@ +etotref -174.1078103590385 +etotperatomref -87.0539051795 +OutputHRNPZ_pass 0 +totaltimeref 0.25 diff --git a/tests/03_NAO_multik/scf_out_hsr_npz/INPUT b/tests/03_NAO_multik/scf_out_hsr_npz/INPUT new file mode 100644 index 00000000000..de1d2b18752 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hsr_npz/INPUT @@ -0,0 +1,30 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix autotest +calculation scf + +nbands 6 +symmetry 0 +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB +gamma_only 0 + +#Parameters (2.Iteration) +ecutwfc 20 +scf_thr 1e-8 +scf_nmax 1 + +#Parameters (3.Basis) +basis_type lcao + +#Parameters (4.Smearing) +smearing_method gauss +smearing_sigma 0.002 + +#Parameters (5.Mixing) +mixing_type broyden +mixing_beta 0.7 +mixing_gg0 0.0 + +out_hsr_npz 1 +ks_solver scalapack_gvx diff --git a/tests/03_NAO_multik/scf_out_hsr_npz/KPT b/tests/03_NAO_multik/scf_out_hsr_npz/KPT new file mode 100644 index 00000000000..e769af76382 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hsr_npz/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +2 1 1 0 0 0 diff --git a/tests/03_NAO_multik/scf_out_hsr_npz/README b/tests/03_NAO_multik/scf_out_hsr_npz/README new file mode 100644 index 00000000000..e8f303fca02 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hsr_npz/README @@ -0,0 +1 @@ +test the output of H(R) and S(R) matrices in NPZ format under OUT.autotest diff --git a/tests/03_NAO_multik/scf_out_hsr_npz/STRU b/tests/03_NAO_multik/scf_out_hsr_npz/STRU new file mode 100644 index 00000000000..269eea28440 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hsr_npz/STRU @@ -0,0 +1,22 @@ +ATOMIC_SPECIES +Si 14 Si_dojo_nsoc.upf upf201 + +NUMERICAL_ORBITAL +Si_dojo_6au_sz.orb + +LATTICE_CONSTANT +15.3 // add lattice constant + +LATTICE_VECTORS +0.0 0.5 0.5 +0.5 0.0 0.5 +0.5 0.5 0.0 + +ATOMIC_POSITIONS +Direct + +Si // Element type +0.0 // magnetism +2 +0.00 0.00 0.00 1 1 1 +0.25 0.25 0.25 1 1 1 diff --git a/tests/03_NAO_multik/scf_out_hsr_npz/result.ref b/tests/03_NAO_multik/scf_out_hsr_npz/result.ref new file mode 100644 index 00000000000..5574afea0a1 --- /dev/null +++ b/tests/03_NAO_multik/scf_out_hsr_npz/result.ref @@ -0,0 +1,5 @@ +etotref -174.1078103590385 +etotperatomref -87.0539051795 +OutputSRNPZ_pass 0 +OutputHRNPZ_pass 0 +totaltimeref 0.25 diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index 21d3bb70cce..73b6e698189 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -81,6 +81,9 @@ has_dos=$(get_input_key_value "out_dos" "INPUT") has_cond=$(get_input_key_value "cal_cond" "INPUT") has_hs=$(get_input_key_value "out_mat_hs" "INPUT") has_hs2=$(get_input_key_value "out_mat_hs2" "INPUT") +out_hr_npz=$(get_input_key_value "out_hr_npz" "INPUT") +out_hsr_npz=$(get_input_key_value "out_hsr_npz" "INPUT") +out_dm_npz=$(get_input_key_value "out_dm_npz" "INPUT") has_xc=$(get_input_key_value "out_mat_xc" "INPUT") has_xc2=$(get_input_key_value "out_mat_xc2" "INPUT") has_eband_separate=$(get_input_key_value "out_eband_terms" "INPUT") @@ -423,6 +426,24 @@ if ! test -z "$has_hs2" && [ $has_hs2 == 1 ]; then echo "CompareSR_pass $?" >>$1 fi +#----------------------------------- +# H(R), S(R), and DM(R) matrices in NPZ format +#----------------------------------- +if ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; then + test -f OUT.autotest/output_SR.npz + echo "OutputSRNPZ_pass $?" >>$1 +fi + +if { ! test -z "$out_hr_npz" && [ "$out_hr_npz" == 1 ]; } || { ! test -z "$out_hsr_npz" && [ "$out_hsr_npz" == 1 ]; }; then + test -f OUT.autotest/output_HR0.npz + echo "OutputHRNPZ_pass $?" >>$1 +fi + +if ! test -z "$out_dm_npz" && [ "$out_dm_npz" == 1 ]; then + test -f OUT.autotest/output_DM0.npz + echo "OutputDMNPZ_pass $?" >>$1 +fi + #----------------------------------- # matrix #----------------------------------- From f467bd2980a71fd9414f45a1f1d65f14c3a33005 Mon Sep 17 00:00:00 2001 From: nscc-gz_pinchen_1 Date: Tue, 30 Jun 2026 15:08:09 +0800 Subject: [PATCH 3/3] Run NPZ integration tests only with CNPY --- tests/03_NAO_multik/CASES_CNPY.txt | 3 +++ tests/03_NAO_multik/CASES_CPU.txt | 3 --- tests/03_NAO_multik/CMakeLists.txt | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/03_NAO_multik/CASES_CNPY.txt diff --git a/tests/03_NAO_multik/CASES_CNPY.txt b/tests/03_NAO_multik/CASES_CNPY.txt new file mode 100644 index 00000000000..e8aa7f21d88 --- /dev/null +++ b/tests/03_NAO_multik/CASES_CNPY.txt @@ -0,0 +1,3 @@ +scf_out_hr_npz +scf_out_hsr_npz +scf_out_dm_npz diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index 38f6e2ba57d..beb5b151631 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -31,9 +31,6 @@ scf_out_pot3 scf_out_dmr_dmk scf_out_hsk scf_out_hsr -scf_out_hr_npz -scf_out_hsr_npz -scf_out_dm_npz scf_out_hsr_spin4 scf_out_dh_t scf_out_dos_spin4 diff --git a/tests/03_NAO_multik/CMakeLists.txt b/tests/03_NAO_multik/CMakeLists.txt index 005c3791eff..e563143a4f6 100644 --- a/tests/03_NAO_multik/CMakeLists.txt +++ b/tests/03_NAO_multik/CMakeLists.txt @@ -14,3 +14,11 @@ else() WORKING_DIRECTORY ${ABACUS_TEST_DIR}/03_NAO_multik ) endif() + +if(ENABLE_CNPY) + add_test( + NAME 03_NAO_multik_npz + COMMAND ${BASH} ../integrate/Autotest.sh -a ${ABACUS_BIN_PATH} -n 4 -f CASES_CNPY.txt + WORKING_DIRECTORY ${ABACUS_TEST_DIR}/03_NAO_multik + ) +endif()