From 53d9c14441c06c4c3003fb3e661b7c4e48c97905 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 25 May 2025 15:01:08 +0800 Subject: [PATCH 1/8] fix a bug, when out_chg becomes 2, the read in function fails --- source/module_io/read_input_item_output.cpp | 2 +- tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/INPUT | 1 + tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/KPT | 0 tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/README | 0 tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/STRU | 0 tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/result.ref | 0 tests/03_NAO_multik/CASES_CPU.txt | 2 +- 7 files changed, 3 insertions(+), 2 deletions(-) rename tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/INPUT (96%) rename tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/KPT (100%) rename tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/README (100%) rename tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/STRU (100%) rename tests/03_NAO_multik/{05_NO_KP_DJ => 05_NO_KP_DJ_OC2}/result.ref (100%) diff --git a/source/module_io/read_input_item_output.cpp b/source/module_io/read_input_item_output.cpp index d94d17b641..e6f198afd8 100644 --- a/source/module_io/read_input_item_output.cpp +++ b/source/module_io/read_input_item_output.cpp @@ -49,7 +49,7 @@ void ReadInput::item_output() { ModuleBase::WARNING_QUIT("ReadInput", "out_chg should have 1 or 2 values"); } - para.input.out_chg[0] = (item.str_values[0] == "-1") ? -1 : assume_as_boolean(item.str_values[0]); + para.input.out_chg[0] = (item.str_values[0] == "-1") ? -1 : std::stoi(item.str_values[0]); para.input.out_chg[1] = (count == 2) ? std::stoi(item.str_values[1]) : 3; }; item.reset_value = [](const Input_Item& item, Parameter& para) { diff --git a/tests/03_NAO_multik/05_NO_KP_DJ/INPUT b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/INPUT similarity index 96% rename from tests/03_NAO_multik/05_NO_KP_DJ/INPUT rename to tests/03_NAO_multik/05_NO_KP_DJ_OC2/INPUT index 72d74ae808..c4c1bb16c4 100644 --- a/tests/03_NAO_multik/05_NO_KP_DJ/INPUT +++ b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/INPUT @@ -26,6 +26,7 @@ basis_type lcao ks_solver scalapack_gvx chg_extrap second-order out_dm 0 +out_chg 2 3 pw_diag_thr 0.00001 mixing_type broyden diff --git a/tests/03_NAO_multik/05_NO_KP_DJ/KPT b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/KPT similarity index 100% rename from tests/03_NAO_multik/05_NO_KP_DJ/KPT rename to tests/03_NAO_multik/05_NO_KP_DJ_OC2/KPT diff --git a/tests/03_NAO_multik/05_NO_KP_DJ/README b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/README similarity index 100% rename from tests/03_NAO_multik/05_NO_KP_DJ/README rename to tests/03_NAO_multik/05_NO_KP_DJ_OC2/README diff --git a/tests/03_NAO_multik/05_NO_KP_DJ/STRU b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/STRU similarity index 100% rename from tests/03_NAO_multik/05_NO_KP_DJ/STRU rename to tests/03_NAO_multik/05_NO_KP_DJ_OC2/STRU diff --git a/tests/03_NAO_multik/05_NO_KP_DJ/result.ref b/tests/03_NAO_multik/05_NO_KP_DJ_OC2/result.ref similarity index 100% rename from tests/03_NAO_multik/05_NO_KP_DJ/result.ref rename to tests/03_NAO_multik/05_NO_KP_DJ_OC2/result.ref diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index d4085376b7..f8a7857fe0 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -2,7 +2,7 @@ 02_NO_KP_15 03_NO_KP_15_kpar 04_NO_KP_GTH -05_NO_KP_DJ +05_NO_KP_DJ_OC2 06_NO_KP_OU 07_NO_KP_UPF201 08_NO_KP_bspline From 9263c66b78b76dd2ffc4f108f3c068314b1baed5 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 25 May 2025 17:51:06 +0800 Subject: [PATCH 2/8] update out_dm and out_dm1 parameters and documents --- docs/advanced/input_files/input-main.md | 15 ++++++------ source/module_esolver/esolver_ks_lcao.cpp | 1 - source/module_io/io_dmk.cpp | 6 +++-- source/module_io/write_dmr.cpp | 15 ++++++------ tests/03_NAO_multik/04_NO_KP_GTH/INPUT | 22 ----------------- tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT | 24 +++++++++++++++++++ .../{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/KPT | 0 .../{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/README | 0 .../{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/STRU | 0 .../result.ref | 0 .../INPUT | 3 +++ .../KPT | 0 .../STRU | 0 .../result.ref | 0 .../wfs1k1g3_nao_mod.txt.ref | 0 tests/03_NAO_multik/CASES_CPU.txt | 4 ++-- 16 files changed, 49 insertions(+), 41 deletions(-) delete mode 100644 tests/03_NAO_multik/04_NO_KP_GTH/INPUT create mode 100644 tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT rename tests/03_NAO_multik/{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/KPT (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/README (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/STRU (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH => 04_NO_KP_GTH_ODM}/result.ref (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW => 44_NO_KP_MD_OW_ODM}/INPUT (85%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW => 44_NO_KP_MD_OW_ODM}/KPT (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW => 44_NO_KP_MD_OW_ODM}/STRU (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW => 44_NO_KP_MD_OW_ODM}/result.ref (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW => 44_NO_KP_MD_OW_ODM}/wfs1k1g3_nao_mod.txt.ref (100%) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 6edba8159e..4e7c4d4a9a 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -1643,21 +1643,22 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis -- **Description**: Whether to output the density matrix of localized orbitals into files in the folder `OUT.${suffix}`. The files are named as: +- **Description**: Whether to output the density matrix for each k-point into files in the folder `OUT.${suffix}`. The files are named as: - For gamma only case: - - nspin = 1: SPIN1_DM; - - nspin = 2: SPIN1_DM, and SPIN2_DM. + - nspin = 1: `dms1_nao.csr`; + - nspin = 2: `dms1_nao.csr` and `dms2_nao.csr` for the two spin channels. - For multi-k points case: - - SPIN\*_K\*_DM, where \* stands for index of spin and kpoints; + - nspin = 1: `dms1k1_nao.csr`, `dms1k2_nao.csr`, ...; + - nspin = 2: `dms1k1_nao.csr`... and `dms2k1_nao.csr`... for the two spin channels. - **Default**: False ### out_dm1 - **Type**: Boolean - **Availability**: Numerical atomic orbital basis (multi-k points) -- **Description**: Whether to output the density matrix of localized orbitals into files in the folder `OUT.${suffix}`. The density matrices are written in the format of sparse matrices, as mentioned in [out_mat_hs2](#out_mat_hs2). The files are named as: - - nspin = 1: data-DMR-sparse_SPIN0.csr; - - nspin = 2: data-DMR-sparse_SPIN0.csr, and data-DMR-sparse_SPIN1.csr. +- **Description**: Whether to output the density matrix with Bravias lattice vector R, labelled as DM(R), into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps: + - nspin = 1: `dmrs1_nao.csr`; + - nspin = 2: `dmrs1_nao.csr` and `dmrs2_nao.csr` for the two spin channels. - **Default**: False ### out_wfc_pw diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 6de9664686..666f587a99 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -26,7 +26,6 @@ #include "module_io/to_wannier90_lcao.h" #include "module_io/to_wannier90_lcao_in_pw.h" #include "module_io/write_HS.h" -#include "module_io/write_dmr.h" #include "module_io/write_elecstat_pot.h" #include "module_io/write_istate_info.h" #include "module_io/write_proj_band_lcao.h" diff --git a/source/module_io/io_dmk.cpp b/source/module_io/io_dmk.cpp index 47e274ab03..72ccb97090 100644 --- a/source/module_io/io_dmk.cpp +++ b/source/module_io/io_dmk.cpp @@ -59,11 +59,13 @@ std::string ModuleIO::dmk_gen_fname(const bool gamma_only, const int ispin, cons { if (gamma_only) { - return "SPIN" + std::to_string(ispin + 1) + "_DM"; + return std::string("dm") + "s" + std::to_string(ispin + 1) + "_nao.txt"; } else { - return "SPIN" + std::to_string(ispin + 1) + "_K" + std::to_string(ik + 1) + "_DM"; + // mohan update 2025-05-25, the index of 'ik' should be the correct 'ik' without spin + return std::string("dm") + "s" + std::to_string(ispin + 1) + + "k" + std::to_string(ik + 1) + "_nao.txt"; } } diff --git a/source/module_io/write_dmr.cpp b/source/module_io/write_dmr.cpp index b7ce1124eb..d57b09c599 100644 --- a/source/module_io/write_dmr.cpp +++ b/source/module_io/write_dmr.cpp @@ -16,20 +16,21 @@ std::string dmr_gen_fname(const int out_type, const int ispin, const bool append { if (!append && istep >= 0) { - fname = std::to_string(istep + 1) + "_data-DMR-sparse_SPIN" + std::to_string(ispin) + ".csr"; + // spa stands for sparse + fname = "dmrs" + std::to_string(ispin+1) + "g" + std::to_string(istep + 1) + "_nao.csr"; } else { - fname = "data-DMR-sparse_SPIN" + std::to_string(ispin) + ".csr"; + fname = "dmrs" + std::to_string(ispin+1) + "_nao.csr"; } } else if (out_type == 2) { - fname = "output_DM" + std::to_string(ispin) + ".npz"; + fname = "dmrs" + std::to_string(ispin+1) + "_nao.npz"; } else { - ModuleBase::WARNING("write_dmr", "the output type of DMR should be npz or csr."); + ModuleBase::WARNING("write_dmr", "the output type of density matrix DM(R) should be csr or npz."); } return fname; } @@ -38,13 +39,13 @@ void write_dmr_csr(std::string& fname, hamilt::HContainer* dm_serial, co { // write the head: ION step number, basis number and R loop number std::ofstream ofs(fname, std::ios::app); - ofs << "STEP: " << istep << std::endl; + ofs << "STEP: " << istep+1 << std::endl; ofs << "Matrix Dimension of DM(R): " << dm_serial->get_nbasis() << std::endl; ofs << "Matrix number of DM(R): " << dm_serial->size_R_loop() << std::endl; // write HR_serial to ofs - double sparse_threshold = 1e-10; - int precision = 8; + const double sparse_threshold = 1e-10; + const int precision = 8; hamilt::Output_HContainer out_dm(dm_serial, ofs, sparse_threshold, precision); out_dm.write(); ofs.close(); diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/INPUT b/tests/03_NAO_multik/04_NO_KP_GTH/INPUT deleted file mode 100644 index 76dc37e4be..0000000000 --- a/tests/03_NAO_multik/04_NO_KP_GTH/INPUT +++ /dev/null @@ -1,22 +0,0 @@ -INPUT_PARAMETERS -#Parameters (General) -suffix autotest - -calculation scf - -#Parameters (Accuracy) -ecutwfc 50 -scf_nmax 50 -scf_thr 1.0e-8 - -basis_type lcao - -cal_stress 1 -cal_force 1 - -mixing_type broyden -mixing_beta 0.7 -mixing_gg0 1.5 -pseudo_dir ../../PP_ORB -orbital_dir ../../PP_ORB - diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT new file mode 100644 index 0000000000..9e69f9d5f2 --- /dev/null +++ b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT @@ -0,0 +1,24 @@ +INPUT_PARAMETERS +#Parameters (General) +suffix autotest +calculation scf +nspin 2 + +#Parameters (Accuracy) +ecutwfc 20 +scf_nmax 50 +scf_thr 1.0e-8 + +basis_type lcao + +cal_stress 1 +cal_force 1 + +mixing_type broyden +mixing_beta 0.7 +mixing_gg0 1.5 +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB + +out_dm1 1 +out_dm 1 diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/KPT b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/KPT similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH/KPT rename to tests/03_NAO_multik/04_NO_KP_GTH_ODM/KPT diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/README b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/README similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH/README rename to tests/03_NAO_multik/04_NO_KP_GTH_ODM/README diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/STRU b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/STRU similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH/STRU rename to tests/03_NAO_multik/04_NO_KP_GTH_ODM/STRU diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/result.ref b/tests/03_NAO_multik/04_NO_KP_GTH_ODM/result.ref similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH/result.ref rename to tests/03_NAO_multik/04_NO_KP_GTH_ODM/result.ref diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT similarity index 85% rename from tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT rename to tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT index 60f3225fe8..13e8deeb7c 100644 --- a/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT +++ b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT @@ -1,4 +1,5 @@ INPUT_PARAMETERS + #Parameters (General) suffix autotest pseudo_dir ../../PP_ORB @@ -27,6 +28,8 @@ mixing_gg0 0.0 out_wfc_lcao 1 out_interval 2 out_app_flag 0 +out_dm1 1 # print out density matrix (R) +out_dm 1 # print out density matrix (k) md_type nve md_tfirst 10 diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/KPT b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/KPT similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW/KPT rename to tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/KPT diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/STRU b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/STRU similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW/STRU rename to tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/STRU diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/result.ref b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/result.ref similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW/result.ref rename to tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/result.ref diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/wfs1k1g3_nao_mod.txt.ref b/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/wfs1k1g3_nao_mod.txt.ref similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW/wfs1k1g3_nao_mod.txt.ref rename to tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/wfs1k1g3_nao_mod.txt.ref diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index f8a7857fe0..d4e8d702b3 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -1,7 +1,7 @@ 01_NO_KP_15_f 02_NO_KP_15 03_NO_KP_15_kpar -04_NO_KP_GTH +04_NO_KP_GTH_ODM 05_NO_KP_DJ_OC2 06_NO_KP_OU 07_NO_KP_UPF201 @@ -41,7 +41,7 @@ 41_NO_KP_MSST 42_NO_KP_MSST2 43_NO_KP_NVT -44_NO_KP_MD_OW +44_NO_KP_MD_OW_ODM 45_NO_KP_QO 46_NO_0atom 47_NO_KP_15_SO From f4c8e5f9ad93519f591489b0f976bc47275b3cca Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 25 May 2025 20:07:40 +0800 Subject: [PATCH 3/8] update io_dmk unittests --- source/module_io/io_dmk.cpp | 16 +++++-- source/module_io/io_dmk.h | 5 +- source/module_io/test/io_dmk_test.cpp | 46 +++++++++++-------- .../test/support/{SPIN1_DM => dms1_nao.txt} | 0 .../support/{SPIN1_K1_DM => dms1k1_nao.txt} | 0 5 files changed, 41 insertions(+), 26 deletions(-) rename source/module_io/test/support/{SPIN1_DM => dms1_nao.txt} (100%) rename source/module_io/test/support/{SPIN1_K1_DM => dms1k1_nao.txt} (100%) diff --git a/source/module_io/io_dmk.cpp b/source/module_io/io_dmk.cpp index 72ccb97090..5fa54e3380 100644 --- a/source/module_io/io_dmk.cpp +++ b/source/module_io/io_dmk.cpp @@ -150,7 +150,8 @@ bool ModuleIO::read_dmk(const int nspin, const int nk, const Parallel_2D& pv, const std::string& dmk_dir, - std::vector>& dmk) + std::vector>& dmk, + std::ofstream &ofs_running) { ModuleBase::TITLE("ModuleIO", "read_dmk"); ModuleBase::timer::tick("ModuleIO", "read_dmk"); @@ -189,10 +190,15 @@ bool ModuleIO::read_dmk(const int nspin, if (!ifs) { - ModuleBase::WARNING("ModuleIO::read_dmk", "Can't open DENSITY MATRIX File < " + fn + " >."); + ofs_running << " Cannot find density matrix file " << fn << " for k-point " << ik+1 << std::endl; + ModuleBase::WARNING("ModuleIO::read_dmk", "Can't open density matrix (k) file < " + fn + " >."); read_success = false; break; } + else + { + ofs_running << " Read density matrix file " << fn << " for k-point " << ik+1 << std::endl; + } // read the UnitCell dmk_read_ucell(ifs); @@ -374,13 +380,15 @@ template bool ModuleIO::read_dmk(const int nspin, const int nk, const Parallel_2D& pv, const std::string& dmk_dir, - std::vector>& dmk); + std::vector>& dmk, + std::ofstream &ofs); template bool ModuleIO::read_dmk>(const int nspin, const int nk, const Parallel_2D& pv, const std::string& dmk_dir, - std::vector>>& dmk); + std::vector>>& dmk, + std::ofstream &ofs); template void ModuleIO::write_dmk(const std::vector>& dmk, const int precision, diff --git a/source/module_io/io_dmk.h b/source/module_io/io_dmk.h index 3e75843d62..df24e9c587 100644 --- a/source/module_io/io_dmk.h +++ b/source/module_io/io_dmk.h @@ -61,8 +61,9 @@ template bool read_dmk(const int nspin, const int nk, const Parallel_2D& pv, - const std::string& dmk_dir, - std::vector>& dmk); + const std::string& dmk_dir, + std::vector>& dmk, + std::ofstream &ofs_running); /** * @brief Writes the DMK data to a file. diff --git a/source/module_io/test/io_dmk_test.cpp b/source/module_io/test/io_dmk_test.cpp index 0e23380114..f7a4391b27 100644 --- a/source/module_io/test/io_dmk_test.cpp +++ b/source/module_io/test/io_dmk_test.cpp @@ -102,14 +102,14 @@ void gen_dmk(std::vector>& dmk, std::vector& efs, int ns TEST(DMKTest, GenFileName) { std::string fname = ModuleIO::dmk_gen_fname(true, 0, 0); - EXPECT_EQ(fname, "SPIN1_DM"); + EXPECT_EQ(fname, "dms1_nao.txt"); fname = ModuleIO::dmk_gen_fname(true, 1, 1); - EXPECT_EQ(fname, "SPIN2_DM"); + EXPECT_EQ(fname, "dms2_nao.txt"); fname = ModuleIO::dmk_gen_fname(false, 0, 0); - EXPECT_EQ(fname, "SPIN1_K1_DM"); + EXPECT_EQ(fname, "dms1k1_nao.txt"); fname = ModuleIO::dmk_gen_fname(false, 1, 1); - EXPECT_EQ(fname, "SPIN2_K2_DM"); + EXPECT_EQ(fname, "dms2k2_nao.txt"); }; @@ -139,7 +139,7 @@ TEST(DMKTest,WriteDMK) { int pass = 0; if (GlobalV::MY_RANK == 0) { - std::string fn = "SPIN1_DM"; + std::string fn = "dms1_nao.txt"; ifs.open(fn); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -158,7 +158,7 @@ TEST(DMKTest,WriteDMK) { testing::HasSubstr("1.600e+00 1.700e+00 1.800e+00 1.900e+00\n")); ifs.close(); - fn = "SPIN2_DM"; + fn = "dms2_nao.txt"; ifs.open(fn); str = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -177,7 +177,7 @@ TEST(DMKTest,WriteDMK) { testing::HasSubstr("2.600e+00 2.700e+00 2.800e+00 2.900e+00\n")); ifs.close(); - fn = "SPIN1_K1_DM"; + fn = "dms1k1_nao.txt"; ifs.open(fn); str = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -198,7 +198,7 @@ TEST(DMKTest,WriteDMK) { testing::HasSubstr("(1.600e+00,1.600e+01) (1.700e+00,1.700e+01) (1.800e+00,1.800e+01) (1.900e+00,1.900e+01)\n")); ifs.close(); - fn = "SPIN1_K2_DM"; + fn = "dms1k2_nao.txt"; ifs.open(fn); str = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -219,7 +219,7 @@ TEST(DMKTest,WriteDMK) { testing::HasSubstr("(2.600e+00,1.610e+01) (2.700e+00,1.710e+01) (2.800e+00,1.810e+01) (2.900e+00,1.910e+01)\n")); ifs.close(); - fn = "SPIN2_K1_DM"; + fn = "dms2k1_nao.txt"; ifs.open(fn); str = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -240,7 +240,7 @@ TEST(DMKTest,WriteDMK) { testing::HasSubstr("(3.600e+00,1.620e+01) (3.700e+00,1.720e+01) (3.800e+00,1.820e+01) (3.900e+00,1.920e+01)\n")); ifs.close(); - fn = "SPIN2_K2_DM"; + fn = "dms2k2_nao.txt"; ifs.open(fn); str = std::string((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); @@ -260,12 +260,12 @@ TEST(DMKTest,WriteDMK) { str, testing::HasSubstr("(4.600e+00,1.630e+01) (4.700e+00,1.730e+01) (4.800e+00,1.830e+01) (4.900e+00,1.930e+01)\n")); ifs.close(); - remove("SPIN1_DM"); - remove("SPIN2_DM"); - remove("SPIN1_K1_DM"); - remove("SPIN1_K2_DM"); - remove("SPIN2_K1_DM"); - remove("SPIN2_K2_DM"); + remove("dms1_nao.txt"); + remove("dms2_nao.txt"); + remove("dms1k1_nao.txt"); + remove("dms1k2_nao.txt"); + remove("dms2k1_nao.txt"); + remove("dms2k2_nao.txt"); } delete ucell; @@ -274,7 +274,7 @@ TEST(DMKTest,WriteDMK) { }; - +// no function in the main code calls read_dmk??? mohan note 2025-05-25 TEST(DMKTest, ReadDMK) { int nlocal = 26; std::vector> dmk; @@ -284,9 +284,12 @@ TEST(DMKTest, ReadDMK) { PARAM.sys.global_out_dir = "./"; init_pv(nlocal, pv); - EXPECT_TRUE(ModuleIO::read_dmk(1, 1, pv, "./support/", dmk)); - ModuleIO::read_dmk(1, 1, pv, "./support/", dmk_multik); - EXPECT_TRUE(ModuleIO::read_dmk(1, 1, pv, "./support/", dmk_multik)); + + std::ofstream ofs_running("running_log.txt"); + + EXPECT_TRUE(ModuleIO::read_dmk(1, 1, pv, "./support/", dmk, ofs_running)); + ModuleIO::read_dmk(1, 1, pv, "./support/", dmk_multik, ofs_running); + EXPECT_TRUE(ModuleIO::read_dmk(1, 1, pv, "./support/", dmk_multik, ofs_running)); EXPECT_EQ(dmk.size(), 1); EXPECT_EQ(dmk_multik.size(), 1); EXPECT_EQ(dmk[0].size(), pv.get_local_size()); @@ -297,6 +300,9 @@ TEST(DMKTest, ReadDMK) { EXPECT_NEAR(dmk_multik[0][1].real(), -4.479e-03, 1e-6); EXPECT_NEAR(dmk_multik[0][1].imag(), 3.208e-04, 1e-6); } + + ofs_running.close(); + remove("running_log.txt"); } diff --git a/source/module_io/test/support/SPIN1_DM b/source/module_io/test/support/dms1_nao.txt similarity index 100% rename from source/module_io/test/support/SPIN1_DM rename to source/module_io/test/support/dms1_nao.txt diff --git a/source/module_io/test/support/SPIN1_K1_DM b/source/module_io/test/support/dms1k1_nao.txt similarity index 100% rename from source/module_io/test/support/SPIN1_K1_DM rename to source/module_io/test/support/dms1k1_nao.txt From 98cfb2061894ca320fff548de6d91467a94d6e3a Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 25 May 2025 20:29:21 +0800 Subject: [PATCH 4/8] update autotests for out_dm and out_dm1 --- .../{018_NO_GO_dm_out => 018_NO_GO_ODM}/INPUT | 0 .../02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/KPT | 0 .../{018_NO_GO_dm_out => 018_NO_GO_ODM}/README | 0 .../02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/STRU | 0 .../SPIN1_DM.ref => 018_NO_GO_ODM/dms1_nao.txt.ref} | 0 .../{018_NO_GO_dm_out => 018_NO_GO_ODM}/result.ref | 0 tests/02_NAO_Gamma/CASES_CPU.txt | 2 +- .../{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/INPUT | 0 .../03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/KPT | 0 .../{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/README | 0 .../{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/STRU | 0 .../dmrs1_nao.csr.ref} | 0 .../refElecStaticPot.cube | 0 .../{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/result.ref | 0 .../{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/INPUT | 3 --- .../03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/KPT | 0 .../{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/README | 0 .../03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/STRU | 0 .../{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/result.ref | 0 .../{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/INPUT | 2 -- .../{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/KPT | 0 .../{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/STRU | 0 .../{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/result.ref | 0 .../wfs1k1g3_nao_mod.txt.ref | 0 tests/03_NAO_multik/CASES_CPU.txt | 6 +++--- tests/integrate/tools/catch_properties.sh | 8 ++++---- 26 files changed, 8 insertions(+), 13 deletions(-) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/INPUT (100%) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/KPT (100%) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/README (100%) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/STRU (100%) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out/SPIN1_DM.ref => 018_NO_GO_ODM/dms1_nao.txt.ref} (100%) rename tests/02_NAO_Gamma/{018_NO_GO_dm_out => 018_NO_GO_ODM}/result.ref (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/INPUT (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/KPT (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/README (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/STRU (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f/refdata-DMR-sparse_SPIN0.csr => 01_NO_KP_15f_ODM/dmrs1_nao.csr.ref} (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/refElecStaticPot.cube (100%) rename tests/03_NAO_multik/{01_NO_KP_15_f => 01_NO_KP_15f_ODM}/result.ref (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/INPUT (90%) rename tests/03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/KPT (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/README (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/STRU (100%) rename tests/03_NAO_multik/{04_NO_KP_GTH_ODM => 04_NO_KP_GTH}/result.ref (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/INPUT (85%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/KPT (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/STRU (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/result.ref (100%) rename tests/03_NAO_multik/{44_NO_KP_MD_OW_ODM => 44_NO_KP_MD_OW}/wfs1k1g3_nao_mod.txt.ref (100%) diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/INPUT b/tests/02_NAO_Gamma/018_NO_GO_ODM/INPUT similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/INPUT rename to tests/02_NAO_Gamma/018_NO_GO_ODM/INPUT diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/KPT b/tests/02_NAO_Gamma/018_NO_GO_ODM/KPT similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/KPT rename to tests/02_NAO_Gamma/018_NO_GO_ODM/KPT diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/README b/tests/02_NAO_Gamma/018_NO_GO_ODM/README similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/README rename to tests/02_NAO_Gamma/018_NO_GO_ODM/README diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/STRU b/tests/02_NAO_Gamma/018_NO_GO_ODM/STRU similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/STRU rename to tests/02_NAO_Gamma/018_NO_GO_ODM/STRU diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/SPIN1_DM.ref b/tests/02_NAO_Gamma/018_NO_GO_ODM/dms1_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/SPIN1_DM.ref rename to tests/02_NAO_Gamma/018_NO_GO_ODM/dms1_nao.txt.ref diff --git a/tests/02_NAO_Gamma/018_NO_GO_dm_out/result.ref b/tests/02_NAO_Gamma/018_NO_GO_ODM/result.ref similarity index 100% rename from tests/02_NAO_Gamma/018_NO_GO_dm_out/result.ref rename to tests/02_NAO_Gamma/018_NO_GO_ODM/result.ref diff --git a/tests/02_NAO_Gamma/CASES_CPU.txt b/tests/02_NAO_Gamma/CASES_CPU.txt index 8a1e64993c..f56b3e3a62 100644 --- a/tests/02_NAO_Gamma/CASES_CPU.txt +++ b/tests/02_NAO_Gamma/CASES_CPU.txt @@ -15,7 +15,7 @@ 015_NO_GO_get_pchg 016_NO_GO_OW 017_NO_GO_mulliken -018_NO_GO_dm_out +018_NO_GO_ODM 019_NO_GO_sol_H2O 020_NO_GO_SCAN_Si2 021_NO_GO_MSST diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/INPUT b/tests/03_NAO_multik/01_NO_KP_15f_ODM/INPUT similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/INPUT rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/INPUT diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/KPT b/tests/03_NAO_multik/01_NO_KP_15f_ODM/KPT similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/KPT rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/KPT diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/README b/tests/03_NAO_multik/01_NO_KP_15f_ODM/README similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/README rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/README diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/STRU b/tests/03_NAO_multik/01_NO_KP_15f_ODM/STRU similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/STRU rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/STRU diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/refdata-DMR-sparse_SPIN0.csr b/tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/refdata-DMR-sparse_SPIN0.csr rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/refElecStaticPot.cube b/tests/03_NAO_multik/01_NO_KP_15f_ODM/refElecStaticPot.cube similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/refElecStaticPot.cube rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/refElecStaticPot.cube diff --git a/tests/03_NAO_multik/01_NO_KP_15_f/result.ref b/tests/03_NAO_multik/01_NO_KP_15f_ODM/result.ref similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15_f/result.ref rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/result.ref diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT b/tests/03_NAO_multik/04_NO_KP_GTH/INPUT similarity index 90% rename from tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT rename to tests/03_NAO_multik/04_NO_KP_GTH/INPUT index 9e69f9d5f2..4b8f81dd79 100644 --- a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/INPUT +++ b/tests/03_NAO_multik/04_NO_KP_GTH/INPUT @@ -19,6 +19,3 @@ mixing_beta 0.7 mixing_gg0 1.5 pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB - -out_dm1 1 -out_dm 1 diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/KPT b/tests/03_NAO_multik/04_NO_KP_GTH/KPT similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH_ODM/KPT rename to tests/03_NAO_multik/04_NO_KP_GTH/KPT diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/README b/tests/03_NAO_multik/04_NO_KP_GTH/README similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH_ODM/README rename to tests/03_NAO_multik/04_NO_KP_GTH/README diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/STRU b/tests/03_NAO_multik/04_NO_KP_GTH/STRU similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH_ODM/STRU rename to tests/03_NAO_multik/04_NO_KP_GTH/STRU diff --git a/tests/03_NAO_multik/04_NO_KP_GTH_ODM/result.ref b/tests/03_NAO_multik/04_NO_KP_GTH/result.ref similarity index 100% rename from tests/03_NAO_multik/04_NO_KP_GTH_ODM/result.ref rename to tests/03_NAO_multik/04_NO_KP_GTH/result.ref diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT b/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT similarity index 85% rename from tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT rename to tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT index 13e8deeb7c..15816b9f56 100644 --- a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/INPUT +++ b/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT @@ -28,8 +28,6 @@ mixing_gg0 0.0 out_wfc_lcao 1 out_interval 2 out_app_flag 0 -out_dm1 1 # print out density matrix (R) -out_dm 1 # print out density matrix (k) md_type nve md_tfirst 10 diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/KPT b/tests/03_NAO_multik/44_NO_KP_MD_OW/KPT similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/KPT rename to tests/03_NAO_multik/44_NO_KP_MD_OW/KPT diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/STRU b/tests/03_NAO_multik/44_NO_KP_MD_OW/STRU similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/STRU rename to tests/03_NAO_multik/44_NO_KP_MD_OW/STRU diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/result.ref b/tests/03_NAO_multik/44_NO_KP_MD_OW/result.ref similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/result.ref rename to tests/03_NAO_multik/44_NO_KP_MD_OW/result.ref diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/wfs1k1g3_nao_mod.txt.ref b/tests/03_NAO_multik/44_NO_KP_MD_OW/wfs1k1g3_nao_mod.txt.ref similarity index 100% rename from tests/03_NAO_multik/44_NO_KP_MD_OW_ODM/wfs1k1g3_nao_mod.txt.ref rename to tests/03_NAO_multik/44_NO_KP_MD_OW/wfs1k1g3_nao_mod.txt.ref diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index d4e8d702b3..926d27191a 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -1,7 +1,7 @@ -01_NO_KP_15_f +01_NO_KP_15f_ODM 02_NO_KP_15 03_NO_KP_15_kpar -04_NO_KP_GTH_ODM +04_NO_KP_GTH 05_NO_KP_DJ_OC2 06_NO_KP_OU 07_NO_KP_UPF201 @@ -41,7 +41,7 @@ 41_NO_KP_MSST 42_NO_KP_MSST2 43_NO_KP_NVT -44_NO_KP_MD_OW_ODM +44_NO_KP_MD_OW 45_NO_KP_QO 46_NO_0atom 47_NO_KP_15_SO diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index 10d8b1229f..f3384da50a 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -157,8 +157,8 @@ fi # echo $out_dm1 #------------------------------- if ! test -z "$out_dm1" && [ $out_dm1 == 1 ]; then - dm1ref=refdata-DMR-sparse_SPIN0.csr - dm1cal=OUT.autotest/data-DMR-sparse_SPIN0.csr + dm1ref=dmrs1_nao.csr.ref + dm1cal=OUT.autotest/dmrs1_nao.csr python3 $COMPARE_SCRIPT $dm1ref $dm1cal 8 echo "CompareDM1_pass $?" >>$1 fi @@ -479,8 +479,8 @@ fi # density matrix information #-------------------------------------------- if ! test -z "$out_dm" && [ $out_dm == 1 ]; then - dmfile=OUT.autotest/SPIN1_DM - dmref=SPIN1_DM.ref + dmfile=OUT.autotest/dms1_nao.txt + dmref=dms1_nao.txt.ref if test -z "$dmfile"; then echo "Can't find DM files" exit 1 From fd7b33e61511a3e4b1001c19800874ca1c017acb Mon Sep 17 00:00:00 2001 From: mohanchen Date: Mon, 26 May 2025 09:17:29 +0800 Subject: [PATCH 5/8] update reference data --- source/module_io/io_dmk.cpp | 13 +++++++++---- source/module_io/write_dmr.cpp | 16 ++++++++++++++-- .../01_NO_KP_15f_ODM/dmrs1_nao.csr.ref | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/source/module_io/io_dmk.cpp b/source/module_io/io_dmk.cpp index 5fa54e3380..69bbd7a4b3 100644 --- a/source/module_io/io_dmk.cpp +++ b/source/module_io/io_dmk.cpp @@ -334,14 +334,19 @@ void ModuleIO::write_dmk(const std::vector>& dmk, std::ofstream ofs(fn.c_str()); if (!ofs) - { - ModuleBase::WARNING("ModuleIO::write_dmk", "Can't create DENSITY MATRIX File < " + fn + " >."); - continue; - } + { + ModuleBase::WARNING("ModuleIO::write_dmk", "Can't create DENSITY MATRIX File < " + fn + " >."); + continue; + } + else + { +// std::cout << " Write the density matrix to file " << fn << std::endl; + } // write the UnitCell information dmk_write_ucell(ofs, ucell); + ofs << "\n " << nspin; // nspin ofs << "\n " << std::fixed << std::setprecision(5) << efs[ispin] << " (fermi energy)"; diff --git a/source/module_io/write_dmr.cpp b/source/module_io/write_dmr.cpp index d57b09c599..a43dea74c4 100644 --- a/source/module_io/write_dmr.cpp +++ b/source/module_io/write_dmr.cpp @@ -38,8 +38,20 @@ std::string dmr_gen_fname(const int out_type, const int ispin, const bool append void write_dmr_csr(std::string& fname, hamilt::HContainer* dm_serial, const int istep) { // write the head: ION step number, basis number and R loop number - std::ofstream ofs(fname, std::ios::app); - ofs << "STEP: " << istep+1 << std::endl; + + std::ofstream ofs; + + // mohan update 2025-05-26 + if(istep<=0) + { + ofs.open(fname); + } + else if(istep>0) + { + ofs.open(fname, std::ios::app); + } + + ofs << "IONIC_STEP: " << istep+1 << std::endl; ofs << "Matrix Dimension of DM(R): " << dm_serial->get_nbasis() << std::endl; ofs << "Matrix number of DM(R): " << dm_serial->size_R_loop() << std::endl; diff --git a/tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref b/tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref index 5ec35459b9..8ab93e5367 100644 --- a/tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref +++ b/tests/03_NAO_multik/01_NO_KP_15f_ODM/dmrs1_nao.csr.ref @@ -1,4 +1,4 @@ -STEP: 0 +IONIC_STEP: 1 Matrix Dimension of DM(R): 34 Matrix number of DM(R): 93 -3 1 1 496 From 3c3289fa2ec527d9dfdee49797fcf27e2a401bf4 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Mon, 26 May 2025 10:05:31 +0800 Subject: [PATCH 6/8] update 04_NO_KP_GTH --- tests/03_NAO_multik/04_NO_KP_GTH/result.ref | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/03_NAO_multik/04_NO_KP_GTH/result.ref b/tests/03_NAO_multik/04_NO_KP_GTH/result.ref index 6755d3100e..5c169d6ef6 100644 --- a/tests/03_NAO_multik/04_NO_KP_GTH/result.ref +++ b/tests/03_NAO_multik/04_NO_KP_GTH/result.ref @@ -1,5 +1,5 @@ -etotref -211.6087208400119266 -etotperatomref -105.8043604200 -totalforceref 0.143742 -totalstressref 369.767775 -totaltimeref 0.96 +etotref -211.6088914359056901 +etotperatomref -105.8044457180 +totalforceref 0.143706 +totalstressref 369.626052 +totaltimeref 2.31 From 3a4dc8bb68ca727b2502302b7883af61dec0af9b Mon Sep 17 00:00:00 2001 From: mohanchen Date: Mon, 26 May 2025 12:27:36 +0800 Subject: [PATCH 7/8] update out_pot command --- docs/advanced/input_files/input-main.md | 17 ++++++++--------- source/module_esolver/esolver_fp.cpp | 6 +++--- .../{refSPIN1_POT.cube => pots1.cube.ref} | 0 .../{refSPIN1_POT.cube => pots1.cube.ref} | 0 .../03_NAO_multik/{38_NO_OP => 38_NO_OP3}/INPUT | 2 +- tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/KPT | 0 .../{38_NO_OP => 38_NO_OP3}/README | 0 .../03_NAO_multik/{38_NO_OP => 38_NO_OP3}/STRU | 0 .../pots1.cube.ref} | 0 .../{38_NO_OP => 38_NO_OP3}/result.ref | 0 .../{refSPIN1_POT.cube => pots1.cube.ref} | 0 tests/03_NAO_multik/CASES_CPU.txt | 2 +- tests/integrate/tools/catch_properties.sh | 8 ++++---- 13 files changed, 17 insertions(+), 18 deletions(-) rename tests/01_PW/087_PW_OP/{refSPIN1_POT.cube => pots1.cube.ref} (100%) rename tests/01_PW/088_PW_OP_nscf/{refSPIN1_POT.cube => pots1.cube.ref} (100%) rename tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/INPUT (97%) rename tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/KPT (100%) rename tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/README (100%) rename tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/STRU (100%) rename tests/03_NAO_multik/{38_NO_OP/refSPIN1_POT.cube => 38_NO_OP3/pots1.cube.ref} (100%) rename tests/03_NAO_multik/{38_NO_OP => 38_NO_OP3}/result.ref (100%) rename tests/03_NAO_multik/39_NO_OP_nscf/{refSPIN1_POT.cube => pots1.cube.ref} (100%) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 4e7c4d4a9a..642c297901 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -1625,16 +1625,15 @@ These variables are used to control the output of properties. - **Type**: Integer - **Description**: - 1: Output the **total local potential** (i.e., local pseudopotential + Hartree potential + XC potential + external electric field (if exists) + dipole correction potential (if exists) + ...) on real space grids (in Ry) into files in the folder `OUT.${suffix}`. The files are named as: - - nspin = 1: SPIN1_POT.cube; - - nspin = 2: SPIN1_POT.cube, and SPIN2_POT.cube; - - nspin = 4: SPIN1_POT.cube, SPIN2_POT.cube, SPIN3_POT.cube, and SPIN4_POT.cube. - - 2: Output the **electrostatic potential** on real space grids into `OUT.${suffix}/ElecStaticPot.cube`. The Python script named `tools/average_pot/aveElecStatPot.py` can be used to calculate the average electrostatic potential along the z-axis and outputs it into ElecStaticPot_AVE. - + - nspin = 1: `pots1.cube`; + - nspin = 2: `pots1.cube` and `pots2.cube`; + - nspin = 4: `pots1.cube`, `pots2.cube`, `pots3.cube`, and `pots4.cube` + - 2: Output the **electrostatic potential** on real space grids into `OUT.${suffix}/pot_es.cube`. The Python script named `tools/average_pot/aveElecStatPot.py` can be used to calculate the average electrostatic potential along the z-axis and outputs it into ElecStaticPot_AVE. Please note that the total local potential refers to the local component of the self-consistent potential, excluding the non-local pseudopotential. The distinction between the local potential and the electrostatic potential is as follows: local potential = electrostatic potential + XC potential. - 3: Apart from 1, also output the **total local potential** of the initial charge density. The files are named as: - - nspin = 1: SPIN1_POT_INI.cube; - - nspin = 2: SPIN1_POT_INI.cube, and SPIN2_POT_INI.cube; - - nspin = 4: SPIN1_POT_INI.cube, SPIN2_POT_INI.cube, SPIN3_POT_INI.cube, and SPIN4_POT_INI.cube. + - nspin = 1: `pots1_ini.cube`; + - nspin = 2: `pots1_ini.cube` and `pots2_ini.cube`; + - nspin = 4: `pots1_ini.cube`, `pots2_ini.cube`, `pots3_ini.cube`, and `pots4_ini.cube` In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval). - **Default**: 0 @@ -1656,7 +1655,7 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis (multi-k points) -- **Description**: Whether to output the density matrix with Bravias lattice vector R, labelled as DM(R), into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps: +- **Description**: Whether to output the density matrix with Bravias lattice vector R index into files in the folder `OUT.${suffix}`. The files are named as `dmr{s}{spin index}{g}{geometry index}{_nao} + {".csr"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and the sparse matrix format 'csr' is mentioned in [out_mat_hs2](#out_mat_hs2). Finally, if [out_app_flag](#out_app_flag) is set to false, the file name contains the optinal 'g' index for each ionic step that may have different geometries, and if [out_app_flag](#out_app_flag) is set to true, the density matrix with respect to Bravias lattice vector R accumulates during ionic steps: - nspin = 1: `dmrs1_nao.csr`; - nspin = 2: `dmrs1_nao.csr` and `dmrs2_nao.csr` for the two spin channels. - **Default**: False diff --git a/source/module_esolver/esolver_fp.cpp b/source/module_esolver/esolver_fp.cpp index 6cbf9f3cfd..95d0d11081 100644 --- a/source/module_esolver/esolver_fp.cpp +++ b/source/module_esolver/esolver_fp.cpp @@ -196,7 +196,7 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso { for (int is = 0; is < PARAM.inp.nspin; is++) { - std::string fn =PARAM.globalv.global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + std::string fn =PARAM.globalv.global_out_dir + "/pots" + std::to_string(is + 1) + ".cube"; ModuleIO::write_vdata_palgrid(Pgrid, this->pelec->pot->get_effective_v(is), @@ -212,7 +212,7 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso } else if (PARAM.inp.out_pot == 2) { - std::string fn =PARAM.globalv.global_out_dir + "/ElecStaticPot.cube"; + std::string fn =PARAM.globalv.global_out_dir + "/pot_es.cube"; ModuleIO::write_elecstat_pot( #ifdef __MPI this->pw_big->bz, @@ -359,7 +359,7 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep) for (int is = 0; is < PARAM.inp.nspin; is++) { std::stringstream ss; - ss << PARAM.globalv.global_out_dir << "SPIN" << is + 1 << "_POT_INI.cube"; + ss << PARAM.globalv.global_out_dir << "pots" << is + 1 << "_ini.cube"; ModuleIO::write_vdata_palgrid(this->Pgrid, this->pelec->pot->get_effective_v(is), is, diff --git a/tests/01_PW/087_PW_OP/refSPIN1_POT.cube b/tests/01_PW/087_PW_OP/pots1.cube.ref similarity index 100% rename from tests/01_PW/087_PW_OP/refSPIN1_POT.cube rename to tests/01_PW/087_PW_OP/pots1.cube.ref diff --git a/tests/01_PW/088_PW_OP_nscf/refSPIN1_POT.cube b/tests/01_PW/088_PW_OP_nscf/pots1.cube.ref similarity index 100% rename from tests/01_PW/088_PW_OP_nscf/refSPIN1_POT.cube rename to tests/01_PW/088_PW_OP_nscf/pots1.cube.ref diff --git a/tests/03_NAO_multik/38_NO_OP/INPUT b/tests/03_NAO_multik/38_NO_OP3/INPUT similarity index 97% rename from tests/03_NAO_multik/38_NO_OP/INPUT rename to tests/03_NAO_multik/38_NO_OP3/INPUT index 4be2d520ed..e7502406b4 100644 --- a/tests/03_NAO_multik/38_NO_OP/INPUT +++ b/tests/03_NAO_multik/38_NO_OP3/INPUT @@ -7,7 +7,7 @@ nbands 6 symmetry 1 pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB -out_pot 1 +out_pot 3 #Parameters (2.Iteration) ecutwfc 5 diff --git a/tests/03_NAO_multik/38_NO_OP/KPT b/tests/03_NAO_multik/38_NO_OP3/KPT similarity index 100% rename from tests/03_NAO_multik/38_NO_OP/KPT rename to tests/03_NAO_multik/38_NO_OP3/KPT diff --git a/tests/03_NAO_multik/38_NO_OP/README b/tests/03_NAO_multik/38_NO_OP3/README similarity index 100% rename from tests/03_NAO_multik/38_NO_OP/README rename to tests/03_NAO_multik/38_NO_OP3/README diff --git a/tests/03_NAO_multik/38_NO_OP/STRU b/tests/03_NAO_multik/38_NO_OP3/STRU similarity index 100% rename from tests/03_NAO_multik/38_NO_OP/STRU rename to tests/03_NAO_multik/38_NO_OP3/STRU diff --git a/tests/03_NAO_multik/38_NO_OP/refSPIN1_POT.cube b/tests/03_NAO_multik/38_NO_OP3/pots1.cube.ref similarity index 100% rename from tests/03_NAO_multik/38_NO_OP/refSPIN1_POT.cube rename to tests/03_NAO_multik/38_NO_OP3/pots1.cube.ref diff --git a/tests/03_NAO_multik/38_NO_OP/result.ref b/tests/03_NAO_multik/38_NO_OP3/result.ref similarity index 100% rename from tests/03_NAO_multik/38_NO_OP/result.ref rename to tests/03_NAO_multik/38_NO_OP3/result.ref diff --git a/tests/03_NAO_multik/39_NO_OP_nscf/refSPIN1_POT.cube b/tests/03_NAO_multik/39_NO_OP_nscf/pots1.cube.ref similarity index 100% rename from tests/03_NAO_multik/39_NO_OP_nscf/refSPIN1_POT.cube rename to tests/03_NAO_multik/39_NO_OP_nscf/pots1.cube.ref diff --git a/tests/03_NAO_multik/CASES_CPU.txt b/tests/03_NAO_multik/CASES_CPU.txt index 926d27191a..d820ed8bab 100644 --- a/tests/03_NAO_multik/CASES_CPU.txt +++ b/tests/03_NAO_multik/CASES_CPU.txt @@ -35,7 +35,7 @@ 35_NO_KP_MU_nscf 36_NO_KP_sol_H2 37_NO_KP_restart -38_NO_OP +38_NO_OP3 39_NO_OP_nscf 40_NO_ELF 41_NO_KP_MSST diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index f3384da50a..705f118890 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -167,8 +167,8 @@ fi # echo $out_pot1 #------------------------------- if ! test -z "$out_pot" && [ $out_pot == 1 ]; then - pot1ref=refSPIN1_POT.cube - pot1cal=OUT.autotest/SPIN1_POT.cube + pot1ref=pots1.cube.ref + pot1cal=OUT.autotest/pots1.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 3 echo "ComparePot1_pass $?" >>$1 fi @@ -177,8 +177,8 @@ fi #echo $out_pot2 #------------------------------- if ! test -z "$out_pot" && [ $out_pot == 2 ]; then - pot1ref=refElecStaticPot.cube - pot1cal=OUT.autotest/ElecStaticPot.cube + pot1ref=pot_es.cube.ref + pot1cal=OUT.autotest/pot_es.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 8 echo "ComparePot_pass $?" >>$1 fi From 630f243f4fc6adf8750550f155771b3907a91830 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Mon, 26 May 2025 14:01:37 +0800 Subject: [PATCH 8/8] update ref pot --- .../01_NO_KP_15f_ODM/{refElecStaticPot.cube => pot_es.cube.ref} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/03_NAO_multik/01_NO_KP_15f_ODM/{refElecStaticPot.cube => pot_es.cube.ref} (100%) diff --git a/tests/03_NAO_multik/01_NO_KP_15f_ODM/refElecStaticPot.cube b/tests/03_NAO_multik/01_NO_KP_15f_ODM/pot_es.cube.ref similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15f_ODM/refElecStaticPot.cube rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/pot_es.cube.ref