diff --git a/docs/advanced/elec_properties/Mulliken.md b/docs/advanced/elec_properties/Mulliken.md index 4dcf69e08f..a34bca5d07 100644 --- a/docs/advanced/elec_properties/Mulliken.md +++ b/docs/advanced/elec_properties/Mulliken.md @@ -1,7 +1,7 @@ # Mulliken Charge Analysis From version 2.1.0, ABACUS has the function of Mulliken population analysis. The example can be found in [examples/mulliken](https://github.com/deepmodeling/abacus-develop/tree/develop/examples/mulliken). \ -To use this function, set [out_mul](./input-main.md#out_mul) to `1` in the INPUT file. After calculation, there will be an output file named `mulliken.txt` in the output directory. In MD calculations, the output interval is controlled by the keyword [out_interval](./input-main.md#out_interval). In the file, there are contents like (`nspin 1`): +To use this function, set [out_mul](./input-main.md#out_mul) to `1` in the INPUT file. After calculation, there will be an output file named `mulliken.txt` in the output directory. In MD calculations, the output interval is controlled by the keyword [out_freq_ion](./input-main.md#out_freq_ion). In the file, there are contents like (`nspin 1`): ``` STEP: 0 diff --git a/docs/advanced/elec_properties/hs_matrix.md b/docs/advanced/elec_properties/hs_matrix.md index 2bfd807ad9..9e19121f00 100644 --- a/docs/advanced/elec_properties/hs_matrix.md +++ b/docs/advanced/elec_properties/hs_matrix.md @@ -45,7 +45,7 @@ The CSR format stores a sparse m × n matrix M in row form using three (one-dime - The arrays V and COL_INDEX are of length NNZ, and contain the non-zero values and the column indices of those values respectively. - The array ROW_INDEX is of length m + 1 and encodes the index in V and COL_INDEX where the given row starts. This is equivalent to ROW_INDEX[j] encoding the total number of nonzeros above row j. The last element is NNZ , i.e., the fictitious index in V immediately after the last valid index NNZ - 1. -For calculations involving ionic movements, the output frequency of the matrix is controlled by [out_interval](../input_files/input-main.md#out_interval) and [out_app_flag](../input_files/input-main.md#out_app_flag). +For calculations involving ionic movements, the output frequency of the matrix is controlled by [out_freq_ion](../input_files/input-main.md#out_freq_ion) and [out_app_flag](../input_files/input-main.md#out_app_flag). ## get_s We also offer the option of only calculating the overlap matrix without running SCF. For that purpose, in `INPUT` file we need to set the value keyword [calculation](../input_files/input-main.md#calculation) to be `get_s`. diff --git a/docs/advanced/elec_properties/position_matrix.md b/docs/advanced/elec_properties/position_matrix.md index 6920dc3f7d..c504a866b6 100644 --- a/docs/advanced/elec_properties/position_matrix.md +++ b/docs/advanced/elec_properties/position_matrix.md @@ -18,7 +18,7 @@ Each file or each section of the appended file starts with "STEP: " followed by Each block here contains the matrix for the corresponding cell. There are three columns in each block, giving the matrix elements in x, y, z directions, respectively. There are altogether nbasis * nbasis lines in each block, which emulates the matrix elements. -In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, the output frequency is controlled by [out_interval](../input_files/input-main.md#out_interval). For example, if we are running a 10-step MD with out_interval = 3, then `$x` will be 0, 3, 6, and 9. +In molecular dynamics (MD) calculations, if [out_app_flag](../input_files/input-main.md#out_app_flag) is set to true, then `data-rR-tr` is written in an append manner. Otherwise, output files will be put in a separate directory, `matrix`, and named as `$x`_data-rR-tr, where `$x` is the number of MD step. In addition, the output frequency is controlled by [out_freq_ion](../input_files/input-main.md#out_freq_ion). For example, if we are running a 10-step MD with out_freq_ion = 3, then `$x` will be 0, 3, 6, and 9. ## get_s We also offer the option of only calculating the position matrix without running SCF. For that purpose, in `INPUT` file we need to set the keyword [calculation](../input_files/input-main.md#calculation) to `get_s`, and [out_mat_r](../input_files/input-main.md#out_mat_r) to `true`. diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index c407df99d1..5e58dcbced 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -133,9 +133,9 @@ - [fixed\_atoms](#fixed_atoms) - [cell\_factor](#cell_factor) - [Output Variables](#variables-related-to-output-information) + - [out\_freq\_ion](#out_freq_ion) - [out\_freq\_elec](#out_freq_elec) - [out\_chg](#out_chg) - - [out\_xc\_r](#out_xc_r) - [out\_pot](#out_pot) - [out\_dm](#out_dmk) - [out\_dm1](#out_dmr) @@ -159,12 +159,12 @@ - [out\_mat\_xc](#out_mat_xc) - [out\_mat\_xc2](#out_mat_xc2) - [out\_mat\_l](#out_mat_l) + - [out\_xc\_r](#out_xc_r) - [out\_eband\_terms](#out_eband_terms) - [dm\_to\_rho](#dm_to_rho) - [out\_mul](#out_mul) - [out\_app\_flag](#out_app_flag) - [out\_ndigits](#out_ndigits) - - [out\_interval](#out_interval) - [out\_element\_info](#out_element_info) - [restart\_save](#restart_save) - [rpa](#rpa) @@ -1636,6 +1636,13 @@ These variables are used to control the geometry relaxation. These variables are used to control the output of properties. +### out_freq_ion + +- **Type**: Integer +- **Description**: After self-consistent-field calculations, control the interval of ionic movements for printing properties. These properties cover charge density, local potential, electrostatic potential, Hamiltonian matrix, overlap matrix, density matrix, Mulliken population analysis and so on. +- **Default**: 0 +- **Note**: If you want to use out_freq_elec, please set out_freq_ion to 1, otherwise out_freq_elec is useless + ### out_freq_elec - **Type**: Integer @@ -1665,29 +1672,10 @@ These variables are used to control the output of properties. In EXX(exact exchange) calculations, (i.e. *[dft_fuctional](#dft_functional)==hse/hf/pbe0/scan0* or *[rpa](#rpa)==True*), the Hexx(R) files will be output in the folder `OUT.${suffix}` too, which can be read in NSCF calculation. - In molecular dynamics simulations, the output frequency is controlled by [out_interval](#out_interval). + In molecular dynamics simulations, the output frequency is controlled by [out_freq_ion](#out_freq_ion). - **Default**: 0 3 - **Note**: In the 3.10-LTS version, the file names are SPIN1_CHG.cube and SPIN1_CHG_INI.cube, etc. -### out_xc_r - -- **Type**: Integer \[Integer\](optional) -- **Description**: - The first integer controls whether to output the exchange-correlation (in Bohr^-3) on real space grids using Libxc to folder `OUT.${suffix}`: - - 0: rho, amag, sigma, exc - - 1: vrho, vsigma - - 2: v2rho2, v2rhosigma, v2sigma2 - - 3: v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3 - - 4: v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4 - The meaning of the files is presented in [Libxc](https://libxc.gitlab.io/manual/libxc-5.1.x/) - - The second integer controls the precision of the charge density output, if not given, will use `3` as default. - - --- - The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest). - -- **Default**: -1 3 - ### out_pot - **Type**: Integer @@ -1703,7 +1691,7 @@ These variables are used to control the output of properties. - 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). + In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion). - **Default**: 0 - **Note**: In the 3.10-LTS version, the file names are SPIN1_POT.cube and SPIN1_POT_INI.cube, etc. @@ -1735,14 +1723,18 @@ These variables are used to control the output of properties. - **Type**: Integer - **Availability**: Output electronic wave functions in plane wave basis, or transform the real-space electronic wave function into plane wave basis (see get_wf option in [calculation](#calculation) with NAO basis) -- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{s}{spin index}{k}{k-point index}{_pw} + {".txt"/".dat"}`. Here, 's' refers to spin, where s1 means spin up channel while s2 means spin down channel, and 's12' refer to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. +- **Description**: Whether to output the electronic wavefunction coefficients into files and store them in the folder `OUT.${suffix}`. The files are named as `wf{k}{k-point index}{s}{spin index}{g}{geometry index}{e}{electronic iteration index}{_pw} + {".txt"/".dat"}`. Here, the s index refers to spin but the label will not show up for non-spin-polarized calculations, where s1 means spin up channel while s2 means spin down channel, and s4 refers to spinor wave functions that contains both spin channels with spin-orbital coupling or noncollinear calculations enabled. For scf or nscf calculations, g index will not appear, but the g index appears for geometry relaxation and molecular dynamics, where one can use the [out_freq_ion](#out_freq_ion) command to control. To print out the electroinc wave functions every few SCF iterations, use the [out_freq_elec](#out_freq_elec) command and the e index will appear in the file name. - 0: no output - 1: (txt format) - - non-gamma-only: `wfs1k1_pw.txt` or `wfs1k2_pw.txt`, ...; + - non-gamma-only with nspin=1: `wfk1_pw.txt`, `wfk2_pw.txt`, ...; + - non-gamma-only with nspin=2: `wfk1s1_pw.txt`, `wfk1s2_pw.txt`, `wfk2s1_pw.txt`, `wfk2s2_pw.txt`, ...; + - non-gamma-only with nspin=4: `wfk1s4_pw.txt`, `wfk2s4_pw.txt`, ...; - 2: (binary format) - - non-gamma-only: `wfs1k1_pw.dat` or `wfs1k2_pw.dat`, .... + - non-gamma-only with nspin=1: `wfk1_pw.dat`, `wfk2_pw.dat`, ...; + - non-gamma-only with nspin=2: `wfk1s1_pw.dat`, `wfk1s2_pw.dat`, `wfk2s1_pw.dat`, `wfk2s2_pw.dat`, ...; + - non-gamma-only with nspin=4: `wfk1s4_pw.dat`, `wfk2s4_pw.dat`, ...; - **Default**: 0 -- **Note**: In the 3.10-LTS version, the file names are WAVEFUNC1.dat, WAVEFUNC2.dat, etc. +- **Note**: In the 3.10-LTS version, the file names are `WAVEFUNC1.dat`, `WAVEFUNC2.dat`, etc. ### out_wfc_lcao @@ -1759,7 +1751,7 @@ These variables are used to control the output of properties. The corresponding sequence of the orbitals can be seen in [Basis Set](../pp_orb.md#basis-set). - Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag). + Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag). - **Default**: False - **Note**: In the 3.10-LTS version, the file names are WFC_NAO_GAMMA1_ION1.txt and WFC_NAO_K1_ION1.txt, etc. @@ -1789,7 +1781,7 @@ These variables are used to control the output of properties. - **Type**: Boolean \[Integer\](optional) - **Description**: Whether to output the eigenvalues of the Hamiltonian matrix (in eV) into the running log during electronic iterations and into a file at the end of calculations. The former can be used with the 'out_freq_elec' parameter while the latter option allows the output precision to be set via a second parameter, with a default value of 8. The output file names are: - - nspin = 1 or 4: `eigs1.txt`; + - nspin = 1 or 4: `eig.txt`; - nspin = 2: `eigs1.txt` and `eigs2.txt`; - For more information, refer to the [band.md](../elec_properties/band.md) - **Default**: False @@ -1836,7 +1828,7 @@ These variables are used to control the output of properties. - **Type**: Boolean \[Integer\](optional) - **Availability**: Numerical atomic orbital basis -- **Description**: Whether to print the upper triangular part of the Hamiltonian matrices and overlap matrices for each k-point into files in the directory `OUT.${suffix}`. The second number controls precision. For more information, please refer to [hs_matrix.md](../elec_properties/hs_matrix.md#out_mat_hs). Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag). +- **Description**: Whether to print the upper triangular part of the Hamiltonian matrices and overlap matrices for each k-point into files in the directory `OUT.${suffix}`. The second number controls precision. For more information, please refer to [hs_matrix.md](../elec_properties/hs_matrix.md#out_mat_hs). Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag). - For gamma only case: - nspin = 1: `hks1_nao.txt` for the Hamiltonian matrix and `sks1_nao.txt` for the overlap matrix; - nspin = 2: `hks1_nao.txt` and `hks2_nao.txt` for the Hamiltonian matrix and `sks1_nao.txt` for the overlap matrix. Note that the code will not output `sks2_nao.txt` because it is the same as `sks1_nao.txt`; @@ -1880,7 +1872,7 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis (not gamma-only algorithm) -- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1_nao.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag). +- **Description**: Generate files containing the kinetic energy matrix $T(R)$. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#out_mat_hs2). The name of the files will be `trs1_nao.csr` and so on. Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag). - **Default**: False - **Unit**: Ry - **Note**: In the 3.10-LTS version, the file name is data-TR-sparse_SPIN0.csr. @@ -1889,7 +1881,7 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis (not gamma-only algorithm) -- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#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_interval](#out_interval) and [out_app_flag](#out_app_flag). +- **Description**: Whether to print files containing the derivatives of the Hamiltonian matrix. The format will be the same as the Hamiltonian matrix $H(R)$ and overlap matrix $S(R)$ as mentioned in [out_mat_hs2](#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](#out_freq_ion) and [out_app_flag](#out_app_flag). - **Default**: False - **Unit**: Ry/Bohr - **Note**: In the 3.10-LTS version, the file name is data-dHRx-sparse_SPIN0.csr and so on. @@ -1898,7 +1890,7 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis (not gamma-only algorithm) -- **Description**: Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix $dH(R)$ as mentioned in [out_mat_dh](#out_mat_dh). The name of the files will be `dsrxs1.csr` and so on. Also controled by [out_interval](#out_interval) and [out_app_flag](#out_app_flag). This feature can be used with `calculation get_s`. +- **Description**: Whether to print files containing the derivatives of the overlap matrix. The format will be the same as the overlap matrix $dH(R)$ as mentioned in [out_mat_dh](#out_mat_dh). The name of the files will be `dsrxs1.csr` and so on. Also controled by [out_freq_ion](#out_freq_ion) and [out_app_flag](#out_app_flag). This feature can be used with `calculation get_s`. - **Default**: False - **Unit**: Ry/Bohr - **Note**: In the 3.10-LTS version, the file name is data-dSRx-sparse_SPIN0.csr and so on. @@ -1928,6 +1920,25 @@ These variables are used to control the output of properties. - **Description**: Whether to print the expectation value of the angular momentum operator $\hat{L}_x$, $\hat{L}_y$, and $\hat{L}_z$ in the basis of the localized atomic orbitals. The files are named `OUT.${suffix}/${suffix}_Lx.dat`, `OUT.${suffix}/${suffix}_Ly.dat`, and `OUT.${suffix}/${suffix}_Lz.dat`. The second integer controls the precision of the output. - **Default**: False 8 +### out_xc_r + +- **Type**: Integer \[Integer\](optional) +- **Description**: + The first integer controls whether to output the exchange-correlation (in Bohr^-3) on real space grids using Libxc to folder `OUT.${suffix}`: + - 0: rho, amag, sigma, exc + - 1: vrho, vsigma + - 2: v2rho2, v2rhosigma, v2sigma2 + - 3: v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3 + - 4: v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4 + The meaning of the files is presented in [Libxc](https://libxc.gitlab.io/manual/libxc-5.1.x/) + + The second integer controls the precision of the charge density output, if not given, will use `3` as default. + + --- + The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest). + +- **Default**: -1 3 + ### out_eband_terms - **Type**: Boolean @@ -1946,7 +1957,7 @@ These variables are used to control the output of properties. - **Type**: Boolean - **Availability**: Numerical atomic orbital basis -- **Description**: Whether to print the Mulliken population analysis result into `OUT.${suffix}/mulliken.txt`. In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval). +- **Description**: Whether to print the Mulliken population analysis result into `OUT.${suffix}/mulliken.txt`. In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion). - **Default**: False ### out_app_flag @@ -1963,12 +1974,6 @@ These variables are used to control the output of properties. - **Description**: Controls the length of decimal part of output data, such as charge density, Hamiltonian matrix, Overlap matrix and so on. - **Default**: 8 -### out_interval - -- **Type**: Integer -- **Description**: After self-consistent-field calculations, control the interval of ionic movements for printing properties. These properties cover charge density, local potential, electrostatic potential, Hamiltonian matrix, overlap matrix, density matrix, Mulliken population analysis and so on. -- **Default**: 1 - ### out_element_info - **Type**: Boolean @@ -2035,7 +2040,7 @@ These variables are used to control the output of properties. The second integer controls the precision of the kinetic energy density output, if not given, will use `3` as default. For purpose restarting from this file and other high-precision involved calculation, recommend to use `10`. --- - In molecular dynamics calculations, the output frequency is controlled by [out_interval](#out_interval). + In molecular dynamics calculations, the output frequency is controlled by [out_freq_ion](#out_freq_ion). - **Default**: 0 3 ### out_spillage diff --git a/examples/relax/pw_output/INPUT b/examples/relax/pw_output/INPUT index cae2080431..7f77f31358 100644 --- a/examples/relax/pw_output/INPUT +++ b/examples/relax/pw_output/INPUT @@ -8,7 +8,7 @@ ecutwfc 10 scf_nmax 20 basis_type pw -relax_nmax 5 +relax_nmax 4 cal_stress 1 stress_thr 1e-6 @@ -25,18 +25,23 @@ relax_method lbfgs pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB -nspin 2 +nspin 4 + +out_freq_ion 1 +#out_freq_elec 0 + +out_chg 1 # chg.txt g +out_pot 1 # pot.txt g +out_wfc_pw 1 # wfkx_pw.txt g +out_dos 1 # dos.txt g +out_elf 1 # elf.txt +out_band 1 # eig.txt +out_stru 1 # g +out_bandgap 1 -out_chg 1 -out_pot 1 -out_wfc_pw 1 -out_dos 1 -out_stru 1 out_app_flag 0 -out_interval 1 -kpar 2 +kpar 1 symmetry -1 -#out_freq_elec 2 -#out_band 1 + diff --git a/examples/relax/pw_output/KPT b/examples/relax/pw_output/KPT index f5f7f4ec34..adf1f61380 100644 --- a/examples/relax/pw_output/KPT +++ b/examples/relax/pw_output/KPT @@ -2,3 +2,4 @@ K_POINTS 0 Gamma 2 2 2 0 0 0 + diff --git a/source/source_esolver/esolver_fp.cpp b/source/source_esolver/esolver_fp.cpp index 97680ba8d0..46f00cf284 100644 --- a/source/source_esolver/esolver_fp.cpp +++ b/source/source_esolver/esolver_fp.cpp @@ -162,120 +162,169 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep, const bool conv_eso // 3) update delta_rho for charge extrapolation CE.update_delta_rho(ucell, &(this->chr), &(this->sf)); - if (istep % PARAM.inp.out_interval == 0) - { - // 4) write charge density - if (PARAM.inp.out_chg[0] > 0) - { - for (int is = 0; is < PARAM.inp.nspin; is++) - { - this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]); - std::string fn =PARAM.globalv.global_out_dir + "/chgs" + std::to_string(is + 1) + ".cube"; - ModuleIO::write_vdata_palgrid(Pgrid, - this->chr.rho_save[is], - is, - PARAM.inp.nspin, - istep, - fn, - this->pelec->eferm.get_efval(is), - &(ucell), - PARAM.inp.out_chg[1], - 1); - - if (XC_Functional::get_ked_flag()) - { - fn =PARAM.globalv.global_out_dir + "/taus" + std::to_string(is + 1) + ".cube"; - ModuleIO::write_vdata_palgrid(Pgrid, - this->chr.kin_r_save[is], - is, - PARAM.inp.nspin, - istep, - fn, - this->pelec->eferm.get_efval(is), - &(ucell)); - } - } - } - // 5) write potential - if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) - { - for (int is = 0; is < PARAM.inp.nspin; is++) - { - 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), - is, - PARAM.inp.nspin, - istep, - fn, - 0.0, // efermi - &(ucell), - 3, // precision - 0); // out_fermi - } - } - else if (PARAM.inp.out_pot == 2) - { - std::string fn =PARAM.globalv.global_out_dir + "/pot_es.cube"; - ModuleIO::write_elecstat_pot( + // print out the 'g' index when istep_in!=-1 + int istep_in = -1; + if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0 + { + if (istep % PARAM.inp.out_freq_ion == 0) + { + istep_in = istep; + } + } + + std::string geom_block; + if(istep_in==-1) + { + // do nothing + } + else if(istep_in>=0) + { + geom_block = "g" + std::to_string(istep + 1); + } + + // 4) write charge density + if (PARAM.inp.out_chg[0] > 0) + { + for (int is = 0; is < PARAM.inp.nspin; ++is) + { + this->pw_rhod->real2recip(this->chr.rho_save[is], this->chr.rhog_save[is]); + + std::string fn =PARAM.globalv.global_out_dir + "chg"; + + std::string spin_block; + if(PARAM.inp.nspin == 2 || PARAM.inp.nspin == 4) + { + spin_block= "s" + std::to_string(is + 1); + } + else if(PARAM.inp.nspin == 1) + { + // do nothing + } + + fn += spin_block + geom_block + ".cube"; + + ModuleIO::write_vdata_palgrid(Pgrid, + this->chr.rho_save[is], + is, + PARAM.inp.nspin, + istep_in, + fn, + this->pelec->eferm.get_efval(is), + &(ucell), + PARAM.inp.out_chg[1], + 1); + + if (XC_Functional::get_ked_flag()) + { + fn = PARAM.globalv.global_out_dir + "tau"; + + fn += spin_block + geom_block + ".cube"; + + ModuleIO::write_vdata_palgrid(Pgrid, + this->chr.kin_r_save[is], + is, + PARAM.inp.nspin, + istep, + fn, + this->pelec->eferm.get_efval(is), + &(ucell)); + } + } + } + + // 5) write potential + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) + { + for (int is = 0; is < PARAM.inp.nspin; is++) + { + std::string fn =PARAM.globalv.global_out_dir + "pot"; + + std::string spin_block; + if(PARAM.inp.nspin == 2 || PARAM.inp.nspin == 4) + { + spin_block= "s" + std::to_string(is + 1); + } + else if(PARAM.inp.nspin == 1) + { + // do nothing + } + + fn += spin_block + geom_block + ".cube"; + + ModuleIO::write_vdata_palgrid(Pgrid, + this->pelec->pot->get_effective_v(is), + is, + PARAM.inp.nspin, + istep_in, + fn, + 0.0, // efermi + &(ucell), + 3, // precision + 0); // out_fermi + } + } + else if (PARAM.inp.out_pot == 2) + { + std::string fn =PARAM.globalv.global_out_dir + "potes"; + fn += geom_block + ".cube"; + + ModuleIO::write_elecstat_pot( #ifdef __MPI - this->pw_big->bz, - this->pw_big->nbz, + this->pw_big->bz, + this->pw_big->nbz, #endif - fn, - istep, - this->pw_rhod, - &this->chr, - &(ucell), - this->pelec->pot->get_fixed_v(), - this->solvent); - } - - // 6) write ELF - if (PARAM.inp.out_elf[0] > 0) - { - this->chr.cal_elf = true; - Symmetry_rho srho; - for (int is = 0; is < PARAM.inp.nspin; is++) - { - srho.begin(is, this->chr, this->pw_rhod, ucell.symm); - } - - std::string out_dir =PARAM.globalv.global_out_dir; - ModuleIO::write_elf( + fn, + istep, + this->pw_rhod, + &this->chr, + &(ucell), + this->pelec->pot->get_fixed_v(), + this->solvent); + } + + // 6) write ELF + if (PARAM.inp.out_elf[0] > 0) + { + this->chr.cal_elf = true; + Symmetry_rho srho; + for (int is = 0; is < PARAM.inp.nspin; is++) + { + srho.begin(is, this->chr, this->pw_rhod, ucell.symm); + } + + std::string out_dir =PARAM.globalv.global_out_dir; + ModuleIO::write_elf( #ifdef __MPI - this->pw_big->bz, - this->pw_big->nbz, + this->pw_big->bz, + this->pw_big->nbz, #endif - out_dir, - istep, - PARAM.inp.nspin, - this->chr.rho, - this->chr.kin_r, - this->pw_rhod, - this->Pgrid, - &(ucell), - PARAM.inp.out_elf[1]); - } + out_dir, + istep, + PARAM.inp.nspin, + this->chr.rho, + this->chr.kin_r, + this->pw_rhod, + this->Pgrid, + &(ucell), + PARAM.inp.out_elf[1]); + } #ifdef USE_LIBXC - // 7) write xc(r) - if(PARAM.inp.out_xc_r[0]>=0) - { - ModuleIO::write_libxc_r( - PARAM.inp.out_xc_r[0], - XC_Functional::get_func_id(), - this->pw_rhod->nrxx, // number of real-space grid - ucell.omega, // volume of cell - ucell.tpiba, - this->chr, - *this->pw_big, - *this->pw_rhod); - } + // 7) write xc(r) + if(PARAM.inp.out_xc_r[0]>=0) + { + ModuleIO::write_libxc_r( + PARAM.inp.out_xc_r[0], + XC_Functional::get_func_id(), + this->pw_rhod->nrxx, // number of real-space grid + ucell.omega, // volume of cell + ucell.tpiba, + this->chr, + *this->pw_big, + *this->pw_rhod); + } #endif - } } void ESolver_FP::before_scf(UnitCell& ucell, const int istep) @@ -361,7 +410,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 << "/chgs" << is + 1 << "_ini.cube"; + ss << PARAM.globalv.global_out_dir << "chgs" << is + 1 << "_ini.cube"; ModuleIO::write_vdata_palgrid(this->Pgrid, this->chr.rho[is], is, diff --git a/source/source_esolver/esolver_ks.cpp b/source/source_esolver/esolver_ks.cpp index 12452cfd68..ba919399e7 100644 --- a/source/source_esolver/esolver_ks.cpp +++ b/source/source_esolver/esolver_ks.cpp @@ -237,8 +237,15 @@ void ESolver_KS::runner(UnitCell& ucell, const int istep) bool conv_esolver = false; this->niter = this->maxniter; this->diag_ethr = PARAM.inp.pw_diag_thr; + this->scf_nmax_flag = false; // mohan add 2025-09-21 for (int iter = 1; iter <= this->maxniter; ++iter) - { + { + // mohan add 2025-09-21 + if(iter == this->maxniter) + { + this->scf_nmax_flag=true; + } + //---------------------------------------------------------------- // 3) initialization of SCF iterations //---------------------------------------------------------------- @@ -556,40 +563,49 @@ void ESolver_KS::after_scf(UnitCell& ucell, const int istep, const bo // 2) call after_scf() of ESolver_FP ESolver_FP::after_scf(ucell, istep, conv_esolver); - // 3) write eigenvalues - if (istep % PARAM.inp.out_interval == 0) - { -// elecstate::print_eigenvalue(this->pelec->ekb,this->pelec->wg,this->pelec->klist,GlobalV::ofs_running); - } -} - -template -void ESolver_KS::after_all_runners(UnitCell& ucell) -{ - // 1) write Etot information - ESolver_FP::after_all_runners(ucell); - - // 2) write eigenvalue information - ModuleIO::write_eig_file(this->pelec->ekb, this->pelec->wg, this->kv); + // 3) write eigenvalues and occupations to eig_occ.txt + ModuleIO::write_eig_file(this->pelec->ekb, this->pelec->wg, this->kv, istep); - // 3) write band information + // 3) write band information to band.txt if (PARAM.inp.out_band[0]) { const int nspin0 = (PARAM.inp.nspin == 2) ? 2 : 1; for (int is = 0; is < nspin0; is++) { - std::stringstream ss2; - ss2 << PARAM.globalv.global_out_dir << "eigs" << is + 1 << ".txt"; + std::stringstream ss; + ss << PARAM.globalv.global_out_dir << "band"; + + if(nspin0==1) + { + // do nothing + } + else if(nspin0==2) + { + ss << "s" << is + 1; + } + + ss << ".txt"; + const double eshift = 0.0; ModuleIO::nscf_band(is, - ss2.str(), + ss.str(), PARAM.inp.nbands, eshift, - PARAM.inp.out_band[1], + PARAM.inp.out_band[1], // precision this->pelec->ekb, this->kv); } } + + + +} + +template +void ESolver_KS::after_all_runners(UnitCell& ucell) +{ + // 1) write Etot information + ESolver_FP::after_all_runners(ucell); } //------------------------------------------------------------------------------ diff --git a/source/source_esolver/esolver_ks.h b/source/source_esolver/esolver_ks.h index ef26d986c6..974351a4a7 100644 --- a/source/source_esolver/esolver_ks.h +++ b/source/source_esolver/esolver_ks.h @@ -83,6 +83,8 @@ class ESolver_KS : public ESolver_FP int maxniter; //! maximum iter steps for scf int niter; //! iter steps actually used in scf bool oscillate_esolver = false; // whether esolver is oscillated + + bool scf_nmax_flag = false; // whether scf has reached nmax, mohan add 20250921 }; } // namespace ModuleESolver #endif diff --git a/source/source_esolver/esolver_ks_lcao_tddft.cpp b/source/source_esolver/esolver_ks_lcao_tddft.cpp index 88b7e5136b..857da73913 100644 --- a/source/source_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/source_esolver/esolver_ks_lcao_tddft.cpp @@ -524,10 +524,13 @@ void ESolver_KS_LCAO_TDDFT::after_scf(UnitCell& ucell, const int ist std::cout << " Potential (Ry): " << std::setprecision(15) << this->pelec->f_en.etot <out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep); - } + if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0 + { + if(istep % PARAM.inp.out_freq_ion == 0) + { + td_p->out_restart_info(istep, elecstate::H_TDDFT_pw::At, elecstate::H_TDDFT_pw::At_laststep); + } + } ModuleBase::timer::tick("ESolver_LCAO_TDDFT", "after_scf"); } diff --git a/source/source_esolver/esolver_ks_pw.cpp b/source/source_esolver/esolver_ks_pw.cpp index 1d479b8de2..5c29df7827 100644 --- a/source/source_esolver/esolver_ks_pw.cpp +++ b/source/source_esolver/esolver_ks_pw.cpp @@ -647,26 +647,51 @@ void ESolver_KS_PW::iter_finish(UnitCell& ucell, const int istep, int //---------------------------------------------------------- // 3) Print out electronic wavefunctions in pw basis + // we only print information every few ionic steps //---------------------------------------------------------- - if (iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax) - { - // conv_esolver == true has already been dealt with in after_scf - ModuleIO::write_wfc_pw(GlobalV::KPAR, - GlobalV::MY_POOL, - GlobalV::MY_RANK, - PARAM.inp.nbands, - PARAM.inp.nspin, - PARAM.globalv.npol, - GlobalV::RANK_IN_POOL, - GlobalV::NPROC_IN_POOL, - PARAM.inp.out_wfc_pw, - PARAM.inp.ecutwfc, - PARAM.globalv.global_out_dir, - this->psi[0], - this->kv, - this->pw_wfc, - GlobalV::ofs_running); - } + + // if istep_in = -1, istep will not appear in file name + // if iter_in = -1, iter will not appear in file name + int istep_in = -1; + int iter_in = -1; + bool out_wfc_flag = false; + if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0 + { + if (istep % PARAM.inp.out_freq_ion == 0) + { + if(iter % PARAM.inp.out_freq_elec == 0 || iter == PARAM.inp.scf_nmax || conv_esolver) + { + istep_in = istep; + iter_in = iter; + out_wfc_flag = true; + } + } + } + else if(iter == PARAM.inp.scf_nmax || conv_esolver) + { + out_wfc_flag = true; + } + + + if (out_wfc_flag) + { + ModuleIO::write_wfc_pw(istep_in, iter_in, + GlobalV::KPAR, + GlobalV::MY_POOL, + GlobalV::MY_RANK, + PARAM.inp.nbands, + PARAM.inp.nspin, + PARAM.globalv.npol, + GlobalV::RANK_IN_POOL, + GlobalV::NPROC_IN_POOL, + PARAM.inp.out_wfc_pw, + PARAM.inp.ecutwfc, + PARAM.globalv.global_out_dir, + this->psi[0], + this->kv, + this->pw_wfc, + GlobalV::ofs_running); + } //---------------------------------------------------------- // 4) check if oscillate for delta_spin method @@ -719,8 +744,62 @@ void ESolver_KS_PW::after_scf(UnitCell& ucell, const int istep, const this->psi[0].size()); } + //---------------------------------------------------------- + //! 4) Compute density of states (DOS) + //---------------------------------------------------------- + if (PARAM.inp.out_dos) + { + bool out_dos_tmp = false; + + int istep_in = -1; + + // default value of out_freq_ion is 0 + if(PARAM.inp.out_freq_ion==0) + { + out_dos_tmp = true; + } + else if (PARAM.inp.out_freq_ion>0) + { + if (istep % PARAM.inp.out_freq_ion == 0) + { + out_dos_tmp = true; + istep_in=istep; + } + else + { + out_dos_tmp = false; + } + } + else + { + out_dos_tmp = false; + } + + // the above is only valid for KSDFT, not SDFT + // this part needs update in the near future + if (PARAM.inp.esolver_type == "sdft") + { + out_dos_tmp = false; + } + + if(out_dos_tmp) + { + ModuleIO::write_dos_pw(ucell, + this->pelec->ekb, + this->pelec->wg, + this->kv, + PARAM.inp.nbands, + istep_in, + this->pelec->eferm, + PARAM.inp.dos_edelta_ev, + PARAM.inp.dos_scale, + PARAM.inp.dos_sigma, + GlobalV::ofs_running); + } + } + //------------------------------------------------------------------ - // 4) calculate band-decomposed (partial) charge density in pw basis + // 5) calculate band-decomposed (partial) charge density in pw basis //------------------------------------------------------------------ if (PARAM.inp.out_pchg.size() > 0) { @@ -753,25 +832,8 @@ void ESolver_KS_PW::after_scf(UnitCell& ucell, const int istep, const &this->chr); } - // tmp 2025-05-17, mohan note - ModuleIO::write_wfc_pw(GlobalV::KPAR, - GlobalV::MY_POOL, - GlobalV::MY_RANK, - PARAM.inp.nbands, - PARAM.inp.nspin, - PARAM.globalv.npol, - GlobalV::RANK_IN_POOL, - GlobalV::NPROC_IN_POOL, - PARAM.inp.out_wfc_pw, - PARAM.inp.ecutwfc, - PARAM.globalv.global_out_dir, - this->psi[0], - this->kv, - this->pw_wfc, - GlobalV::ofs_running); - //------------------------------------------------------------------ - //! 5) calculate Wannier functions in pw basis + //! 6) calculate Wannier functions in pw basis //------------------------------------------------------------------ if (PARAM.inp.calculation == "nscf" && PARAM.inp.towannier90) { @@ -789,7 +851,7 @@ void ESolver_KS_PW::after_scf(UnitCell& ucell, const int istep, const } //------------------------------------------------------------------ - //! 6) calculate Berry phase polarization in pw basis + //! 7) calculate Berry phase polarization in pw basis //------------------------------------------------------------------ if (PARAM.inp.calculation == "nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1) { @@ -800,7 +862,7 @@ void ESolver_KS_PW::after_scf(UnitCell& ucell, const int istep, const } //------------------------------------------------------------------ - // 7) write spin constrian results in pw basis + // 8) write spin constrian results in pw basis // spin constrain calculations, write atomic magnetization and magnetic force. //------------------------------------------------------------------ if (PARAM.inp.sc_mag_switch) @@ -812,7 +874,7 @@ void ESolver_KS_PW::after_scf(UnitCell& ucell, const int istep, const } //------------------------------------------------------------------ - // 8) write onsite occupations for charge and magnetizations + // 9) write onsite occupations for charge and magnetizations //------------------------------------------------------------------ if (PARAM.inp.onsite_radius > 0) { // float type has not been implemented @@ -904,24 +966,7 @@ void ESolver_KS_PW::after_all_runners(UnitCell& ucell) ESolver_KS::after_all_runners(ucell); //---------------------------------------------------------- - //! 2) Compute density of states (DOS) - //---------------------------------------------------------- - if (PARAM.inp.out_dos) - { - ModuleIO::write_dos_pw(ucell, - this->pelec->ekb, - this->pelec->wg, - this->kv, - PARAM.inp.nbands, - this->pelec->eferm, - PARAM.inp.dos_edelta_ev, - PARAM.inp.dos_scale, - PARAM.inp.dos_sigma, - GlobalV::ofs_running); - } - - //---------------------------------------------------------- - //! 3) Compute LDOS + //! 2) Compute LDOS //---------------------------------------------------------- if (PARAM.inp.out_ldos[0]) { @@ -932,7 +977,7 @@ void ESolver_KS_PW::after_all_runners(UnitCell& ucell) } //---------------------------------------------------------- - //! 4) Calculate the spillage value, + //! 3) Calculate the spillage value, //! which are used to generate numerical atomic orbitals //---------------------------------------------------------- if (PARAM.inp.basis_type == "pw" && PARAM.inp.out_spillage) @@ -955,7 +1000,7 @@ void ESolver_KS_PW::after_all_runners(UnitCell& ucell) } //---------------------------------------------------------- - //! 5) Print out electronic wave functions in real space + //! 4) Print out electronic wave functions in real space //---------------------------------------------------------- if (PARAM.inp.out_wfc_norm.size() > 0 || PARAM.inp.out_wfc_re_im.size() > 0) { @@ -986,7 +1031,7 @@ void ESolver_KS_PW::after_all_runners(UnitCell& ucell) } //---------------------------------------------------------- - //! 6) Use Kubo-Greenwood method to compute conductivities + //! 5) Use Kubo-Greenwood method to compute conductivities //---------------------------------------------------------- if (PARAM.inp.cal_cond) { diff --git a/source/source_esolver/lcao_after_scf.cpp b/source/source_esolver/lcao_after_scf.cpp index c2cc359336..30a4cd6997 100644 --- a/source/source_esolver/lcao_after_scf.cpp +++ b/source/source_esolver/lcao_after_scf.cpp @@ -26,10 +26,31 @@ void ESolver_KS_LCAO::after_scf(UnitCell& ucell, const int istep, const ModuleBase::WARNING_QUIT("ModuleIO::ctrl_output_lcao","pelec does not exist"); } - if(istep % PARAM.inp.out_interval == 0) - { - ModuleIO::ctrl_output_lcao(ucell, + //***** + // if istep_in = -1, istep will not appear in file name + // if iter_in = -1, iter will not appear in file name + int istep_in = -1; + int iter_in = -1; + bool out_flag = false; + if (PARAM.inp.out_freq_ion>0) // default value of out_freq_ion is 0 + { + if (istep % PARAM.inp.out_freq_ion == 0) + { + istep_in = istep; + out_flag = true; + } + } + else if(conv_esolver || this->scf_nmax_flag) // mohan add scf_nmax_flag on 20250921 + { + out_flag = true; + } + //***** + + if (out_flag) + { + ModuleIO::ctrl_output_lcao(ucell, + PARAM.inp, this->kv, estate, this->pv, @@ -53,7 +74,7 @@ void ESolver_KS_LCAO::after_scf(UnitCell& ucell, const int istep, const *this->exc, #endif istep); - } + } //------------------------------------------------------------------ //! 3) Clean up RA, which is used to serach for adjacent atoms diff --git a/source/source_estate/module_charge/charge_init.cpp b/source/source_estate/module_charge/charge_init.cpp index 93f89fec81..5294a4d376 100644 --- a/source/source_estate/module_charge/charge_init.cpp +++ b/source/source_estate/module_charge/charge_init.cpp @@ -59,8 +59,18 @@ void Charge::init_rho(elecstate::efermi& eferm_iout, { for (int is = 0; is < nspin; ++is) { - std::stringstream ssc; - ssc << PARAM.globalv.global_readin_dir << "chgs" << is + 1 << ".cube"; + std::stringstream ssc; + + if(nspin==1) + { + ssc << PARAM.globalv.global_readin_dir << "chg.cube"; + } + else + { + ssc << PARAM.globalv.global_readin_dir << "chgs" << is + 1 << ".cube"; + } + + if (ModuleIO::read_vdata_palgrid(pgrid, (PARAM.inp.esolver_type == "sdft" ? GlobalV::RANK_IN_BPGROUP : GlobalV::MY_RANK), GlobalV::ofs_running, diff --git a/source/source_estate/test/support/chgs1.cube b/source/source_estate/test/support/chg.cube similarity index 100% rename from source/source_estate/test/support/chgs1.cube rename to source/source_estate/test/support/chg.cube diff --git a/source/source_io/cal_dos.cpp b/source/source_io/cal_dos.cpp index 78268103e2..6c109f06d2 100644 --- a/source/source_io/cal_dos.cpp +++ b/source/source_io/cal_dos.cpp @@ -90,7 +90,7 @@ void ModuleIO::prepare_dos(std::ofstream& ofs_running, bool ModuleIO::cal_dos(const int& is, // index for spin const std::string& fn, // file name for DOS - const double& de_ev, // delta energy in ev + const double& de_ev, // delta energy in ev const double& emax_ev, // maximal energy in eV const double& emin_ev, // minimal energy in ev. const double& bcoeff, @@ -100,17 +100,24 @@ bool ModuleIO::cal_dos(const int& is, // index for spin const std::vector& isk, // index of spin for each k-point const int& nbands, // number of bands const ModuleBase::matrix& ekb, // energy for each k point and each band - const ModuleBase::matrix& wg // weight of k-points and bands - ) + const ModuleBase::matrix& wg, // weight of k-points and bands + const int istep) // ionic step { ModuleBase::TITLE("ModuleIO", "cal_dos"); std::ofstream ofs_dos; - std::ofstream ofs_smear; if (GlobalV::MY_RANK == 0) { - ofs_dos.open(fn.c_str()); + if(PARAM.inp.out_app_flag==true) + { + ofs_dos.open(fn.c_str(), std::ios::app); + } + else + { + ofs_dos.open(fn.c_str()); + } + ofs_dos << istep+1 << " # ionic step" << std::endl; } std::vector dos; diff --git a/source/source_io/cal_dos.h b/source/source_io/cal_dos.h index 9df1eb8d0d..569d038df2 100644 --- a/source/source_io/cal_dos.h +++ b/source/source_io/cal_dos.h @@ -24,13 +24,14 @@ namespace ModuleIO const double &emax_ev,// maximal energy in ev. const double &emin_ev,// minimal energy in ev. const double &bcoeff, - const int &nks,//number of k points - const int &nkstot, + const int &nks, //number of k points + const int &nkstot, // total number of k points const std::vector &wk,//weight of k points const std::vector &isk, const int &nbands,// number of bands const ModuleBase::matrix &ekb, //store energy for each k point and each band - const ModuleBase::matrix &wg); //weight of (kpoint,bands)) + const ModuleBase::matrix &wg, //weight of (kpoint,bands)) + const int istep_in); // ionic_step } diff --git a/source/source_io/ctrl_output_fp.cpp b/source/source_io/ctrl_output_fp.cpp index 9f0a7edba5..477612ed27 100644 --- a/source/source_io/ctrl_output_fp.cpp +++ b/source/source_io/ctrl_output_fp.cpp @@ -8,6 +8,7 @@ void ctrl_output_fp(UnitCell& ucell, elecstate::ElecStateLCAO* pelec, const int istep) { +/* ModuleBase::TITLE("ModuleIO", "ctrl_output_fp"); ModuleBase::timer::tick("ModuleIO", "ctrl_output_fp"); @@ -115,6 +116,9 @@ void ctrl_output_fp(UnitCell& ucell, } ModuleBase::timer::tick("ModuleIO", "ctrl_output_fp"); + +*/ + } } // End ModuleIO diff --git a/source/source_io/ctrl_output_lcao.cpp b/source/source_io/ctrl_output_lcao.cpp index 673e767198..5722265307 100644 --- a/source/source_io/ctrl_output_lcao.cpp +++ b/source/source_io/ctrl_output_lcao.cpp @@ -34,7 +34,8 @@ namespace ModuleIO { template -void ctrl_output_lcao(UnitCell& ucell, +void ctrl_output_lcao(UnitCell& ucell, + const Input_para& inp, K_Vectors& kv, elecstate::ElecStateLCAO* pelec, Parallel_Orbitals& pv, @@ -62,66 +63,66 @@ void ctrl_output_lcao(UnitCell& ucell, ModuleBase::TITLE("ModuleIO", "ctrl_output_lcao"); ModuleBase::timer::tick("ModuleIO", "ctrl_output_lcao"); - const bool out_app_flag = PARAM.inp.out_app_flag; + const bool out_app_flag = inp.out_app_flag; const bool gamma_only = PARAM.globalv.gamma_only_local; - const int nspin = PARAM.inp.nspin; + const int nspin = inp.nspin; const std::string global_out_dir = PARAM.globalv.global_out_dir; //------------------------------------------------------------------ - // print out density of states (DOS) + //! 1) print out density of states (DOS) //------------------------------------------------------------------ - if (PARAM.inp.out_dos) + if (inp.out_dos) { ModuleIO::write_dos_lcao(psi, p_hamilt, pv, ucell, kv, - PARAM.inp.nbands, + inp.nbands, pelec->eferm, pelec->ekb, pelec->wg, - PARAM.inp.dos_edelta_ev, - PARAM.inp.dos_scale, - PARAM.inp.dos_sigma, + inp.dos_edelta_ev, + inp.dos_scale, + inp.dos_sigma, out_app_flag, istep, GlobalV::ofs_running); } //------------------------------------------------------------------ - //! 1) Output density matrix DM(R) + //! 2) Output density matrix DM(R) //------------------------------------------------------------------ - if(PARAM.inp.out_dmr[0]) + if(inp.out_dmr[0]) { const auto& dmr_vector = pelec->get_DM()->get_DMR_vector(); - const int precision = PARAM.inp.out_dmr[1]; + const int precision = inp.out_dmr[1]; ModuleIO::write_dmr(dmr_vector, precision, pv, out_app_flag, ucell.get_iat2iwt(), ucell.nat, istep); } //------------------------------------------------------------------ - //! 2) Output density matrix DM(k) + //! 3) Output density matrix DM(k) //------------------------------------------------------------------ - if (PARAM.inp.out_dmk[0]) + if (inp.out_dmk[0]) { std::vector efermis(nspin == 2 ? 2 : 1); for (int ispin = 0; ispin < efermis.size(); ispin++) { efermis[ispin] = pelec->eferm.get_efval(ispin); } - const int precision = PARAM.inp.out_dmk[1]; + const int precision = inp.out_dmk[1]; ModuleIO::write_dmk(pelec->get_DM()->get_DMK_vector(), precision, efermis, &(ucell), pv, istep); } //------------------------------------------------------------------ - // 3) Output H(k) and S(k) matrices for each k-point + // 4) Output H(k) and S(k) matrices for each k-point //------------------------------------------------------------------ - if (PARAM.inp.out_mat_hs[0]) + if (inp.out_mat_hs[0]) { ModuleIO::write_hsk(global_out_dir, nspin, @@ -138,7 +139,7 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - // 4) Output electronic wavefunctions Psi(k) + //! 5) Output electronic wavefunctions Psi(k) //------------------------------------------------------------------ if (elecstate::ElecStateLCAO::out_wfc_lcao) { @@ -156,7 +157,7 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 5) Output DeePKS information + //! 6) Output DeePKS information //------------------------------------------------------------------ #ifdef __MLALGO // need control parameter @@ -184,16 +185,16 @@ void ctrl_output_lcao(UnitCell& ucell, #endif //------------------------------------------------------------------ - //! 6) Output matrices, where O can be chosen as + //! 7) Output matrices, where O can be chosen as //! H, S, dH, dS, T, r. The format is CSR format. //------------------------------------------------------------------ hamilt::Hamilt* p_ham_tk = static_cast*>(p_hamilt); - ModuleIO::output_mat_sparse(PARAM.inp.out_mat_hs2, - PARAM.inp.out_mat_dh, - PARAM.inp.out_mat_ds, - PARAM.inp.out_mat_t, - PARAM.inp.out_mat_r, + ModuleIO::output_mat_sparse(inp.out_mat_hs2, + inp.out_mat_dh, + inp.out_mat_ds, + inp.out_mat_t, + inp.out_mat_r, istep, pelec->pot->get_effective_v(), pv, @@ -206,9 +207,9 @@ void ctrl_output_lcao(UnitCell& ucell, p_ham_tk); //------------------------------------------------------------------ - //! 7) Output kinetic matrix + //! 8) Output kinetic matrix //------------------------------------------------------------------ - if (PARAM.inp.out_mat_tk[0]) + if (inp.out_mat_tk[0]) { hamilt::HS_Matrix_K hsk(&pv, true); hamilt::HContainer hR(&pv); @@ -230,7 +231,7 @@ void ctrl_output_lcao(UnitCell& ucell, std::string t_fn = ModuleIO::filename_output(global_out_dir, "tk","nao",ik,kv.ik2iktot, - PARAM.inp.nspin,kv.get_nkstot(), + inp.nspin,kv.get_nkstot(), out_label,out_app_flag, gamma_only,istep); @@ -238,9 +239,9 @@ void ctrl_output_lcao(UnitCell& ucell, hsk.get_hk(), PARAM.globalv.nlocal, false, // bit - PARAM.inp.out_mat_tk[1], + inp.out_mat_tk[1], 1, // true for upper triangle matrix - PARAM.inp.out_app_flag, + inp.out_app_flag, t_fn, pv, GlobalV::DRANK); @@ -250,32 +251,32 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 8) Output expectation of angular momentum operator + //! 9) Output expectation of angular momentum operator //------------------------------------------------------------------ - if (PARAM.inp.out_mat_l[0]) + if (inp.out_mat_l[0]) { ModuleIO::AngularMomentumCalculator mylcalculator( - PARAM.inp.orbital_dir, + inp.orbital_dir, ucell, - PARAM.inp.search_radius, - PARAM.inp.test_deconstructor, - PARAM.inp.test_grid, - PARAM.inp.test_atom_input, + inp.search_radius, + inp.test_deconstructor, + inp.test_grid, + inp.test_atom_input, PARAM.globalv.search_pbc, &GlobalV::ofs_running, GlobalV::MY_RANK ); - mylcalculator.calculate(PARAM.inp.suffix, + mylcalculator.calculate(inp.suffix, global_out_dir, ucell, - PARAM.inp.out_mat_l[1], + inp.out_mat_l[1], GlobalV::MY_RANK); } //------------------------------------------------------------------ - //! 9) Output Mulliken charge + //! 10) Output Mulliken charge //------------------------------------------------------------------ - if (PARAM.inp.out_mul) + if (inp.out_mul) { ModuleIO::cal_mag(&pv, p_hamilt, @@ -290,9 +291,9 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 10) Output atomic magnetization by using 'spin_constraint' + //! 11) Output atomic magnetization by using 'spin_constraint' //------------------------------------------------------------------ - if (PARAM.inp.sc_mag_switch) + if (inp.sc_mag_switch) { spinconstrain::SpinConstrain& sc = spinconstrain::SpinConstrain::getScInstance(); sc.cal_mi_lcao(istep); @@ -301,9 +302,9 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 11) Output Berry phase + //! 12) Output Berry phase //------------------------------------------------------------------ - if (PARAM.inp.calculation == "nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1) + if (inp.calculation == "nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1) { std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Berry phase calculation"); berryphase bp(&pv); @@ -314,34 +315,34 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 12) Wannier90 interface in LCAO basis + //! 13) Wannier90 interface in LCAO basis // added by jingan in 2018.11.7 //------------------------------------------------------------------ - if (PARAM.inp.calculation == "nscf" && PARAM.inp.towannier90) + if (inp.calculation == "nscf" && inp.towannier90) { std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "Wave function to Wannier90"); - if (PARAM.inp.wannier_method == 1) + if (inp.wannier_method == 1) { - toWannier90_LCAO_IN_PW wan(PARAM.inp.out_wannier_mmn, - PARAM.inp.out_wannier_amn, - PARAM.inp.out_wannier_unk, - PARAM.inp.out_wannier_eig, - PARAM.inp.out_wannier_wvfn_formatted, - PARAM.inp.nnkpfile, - PARAM.inp.wannier_spin); + toWannier90_LCAO_IN_PW wan(inp.out_wannier_mmn, + inp.out_wannier_amn, + inp.out_wannier_unk, + inp.out_wannier_eig, + inp.out_wannier_wvfn_formatted, + inp.nnkpfile, + inp.wannier_spin); wan.set_tpiba_omega(ucell.tpiba, ucell.omega); wan.calculate(ucell,pelec->ekb,pw_wfc,pw_big, sf,kv,psi,&pv); } - else if (PARAM.inp.wannier_method == 2) + else if (inp.wannier_method == 2) { - toWannier90_LCAO wan(PARAM.inp.out_wannier_mmn, - PARAM.inp.out_wannier_amn, - PARAM.inp.out_wannier_unk, - PARAM.inp.out_wannier_eig, - PARAM.inp.out_wannier_wvfn_formatted, - PARAM.inp.nnkpfile, - PARAM.inp.wannier_spin, + toWannier90_LCAO wan(inp.out_wannier_mmn, + inp.out_wannier_amn, + inp.out_wannier_unk, + inp.out_wannier_eig, + inp.out_wannier_wvfn_formatted, + inp.nnkpfile, + inp.wannier_spin, orb); wan.calculate(ucell, gd, pelec->ekb, kv, *psi, &pv); @@ -352,12 +353,12 @@ void ctrl_output_lcao(UnitCell& ucell, #ifdef __EXX //------------------------------------------------------------------ - //! 13) Output Hexx matrix in LCAO basis + //! 14) Output Hexx matrix in LCAO basis // (see `out_chg` in docs/advanced/input_files/input-main.md) //------------------------------------------------------------------ - if (PARAM.inp.out_chg[0]) + if (inp.out_chg[0]) { - if (GlobalC::exx_info.info_global.cal_exx && PARAM.inp.calculation != "nscf") // Peize Lin add if 2022.11.14 + if (GlobalC::exx_info.info_global.cal_exx && inp.calculation != "nscf") // Peize Lin add if 2022.11.14 { const std::string file_name_exx = global_out_dir + "HexxR" + std::to_string(GlobalV::MY_RANK); @@ -373,9 +374,9 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! 14) Write RPA information in LCAO basis + //! 15) Write RPA information in LCAO basis //------------------------------------------------------------------ - if (PARAM.inp.rpa) + if (inp.rpa) { RPA_LRI rpa_lri_double(GlobalC::exx_info.info_ri); rpa_lri_double.cal_postSCF_exx(*dynamic_cast*>(pelec)->get_DM(), @@ -389,9 +390,9 @@ void ctrl_output_lcao(UnitCell& ucell, #endif //------------------------------------------------------------------ - //! 18) Perform RDMFT calculations, added by jghan, 2024-10-17 + //! 16) Perform RDMFT calculations, added by jghan, 2024-10-17 //------------------------------------------------------------------ - if (PARAM.inp.rdmft == true) + if (inp.rdmft == true) { ModuleBase::matrix occ_num(pelec->wg); for (int ik = 0; ik < occ_num.nr; ++ik) @@ -416,14 +417,14 @@ void ctrl_output_lcao(UnitCell& ucell, } //------------------------------------------------------------------ - //! Output quasi orbitals + //! 17) Output quasi orbitals //------------------------------------------------------------------ - if (PARAM.inp.qo_switch) + if (inp.qo_switch) { - toQO tqo(PARAM.inp.qo_basis, PARAM.inp.qo_strategy, PARAM.inp.qo_thr, PARAM.inp.qo_screening_coeff); + toQO tqo(inp.qo_basis, inp.qo_strategy, inp.qo_thr, inp.qo_screening_coeff); tqo.initialize(global_out_dir, - PARAM.inp.pseudo_dir, - PARAM.inp.orbital_dir, + inp.pseudo_dir, + inp.orbital_dir, &ucell, kv.kvec_d, GlobalV::ofs_running, @@ -441,6 +442,7 @@ void ctrl_output_lcao(UnitCell& ucell, // For gamma only template void ModuleIO::ctrl_output_lcao(UnitCell& ucell, + const Input_para& inp, K_Vectors& kv, elecstate::ElecStateLCAO* pelec, Parallel_Orbitals& pv, @@ -467,6 +469,7 @@ template void ModuleIO::ctrl_output_lcao(UnitCell& ucell, // For multiple k-points template void ModuleIO::ctrl_output_lcao, double>(UnitCell& ucell, + const Input_para& inp, K_Vectors& kv, elecstate::ElecStateLCAO>* pelec, Parallel_Orbitals& pv, @@ -492,6 +495,7 @@ template void ModuleIO::ctrl_output_lcao, double>(UnitCell& const int istep); template void ModuleIO::ctrl_output_lcao, std::complex>(UnitCell& ucell, + const Input_para& inp, K_Vectors& kv, elecstate::ElecStateLCAO>* pelec, Parallel_Orbitals& pv, diff --git a/source/source_io/ctrl_output_lcao.h b/source/source_io/ctrl_output_lcao.h index d783eb0b3f..a223e5381d 100644 --- a/source/source_io/ctrl_output_lcao.h +++ b/source/source_io/ctrl_output_lcao.h @@ -22,6 +22,7 @@ namespace ModuleIO // in principle, we need to add const for all of the variables, mohan note 2025-06-05 template void ctrl_output_lcao(UnitCell& ucell, + const Input_para& inp, K_Vectors& kv, elecstate::ElecStateLCAO* pelec, Parallel_Orbitals& pv, diff --git a/source/source_io/filename.cpp b/source/source_io/filename.cpp index d2b22fb084..b60012c4b0 100644 --- a/source/source_io/filename.cpp +++ b/source/source_io/filename.cpp @@ -16,7 +16,8 @@ std::string filename_output( const int out_type, const bool out_app_flag, const bool gamma_only, - const int istep) + const int istep, + const int iter) { // output filename = "{PARAM.globalv.global_out_dir}/property{s}{spin index} // {k(optional)}{k-point index}{g(optional)}{geometry index1}{_basis(nao|pw)} @@ -44,9 +45,10 @@ std::string filename_output( // ik0 is the k-point index, starting from 0 int ik0 = ik2iktot[ik_local]; + // spin part + std::string spin_block; if(nspin == 1) { - is0 = 1; } else if(nspin == 2) { @@ -60,15 +62,14 @@ std::string filename_output( { is0 = 1; } + spin_block = "s" + std::to_string(is0); } else if(nspin==4) { - is0 = 12; + is0 = 4; + spin_block = "s" + std::to_string(is0); } - // spin part - std::string spin_block; - spin_block = "s" + std::to_string(is0); // k-point part std::string kpoint_block; @@ -78,12 +79,25 @@ std::string filename_output( } else { - kpoint_block = "k" + std::to_string(ik0+1); + // mohan add 20250921 + if(property=="hk" || property=="sk" || property=="tk") + { + kpoint_block = std::to_string(ik0+1); + } + else + { + kpoint_block = "k" + std::to_string(ik0+1); + } } std::string istep_block = (istep >= 0 && (!out_app_flag)) - ? "g" + std::to_string(istep + 1) + ? "g" + std::to_string(istep + 1) // istep starts from 0 + : ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file + + std::string iter_block + = (iter >= 0 && (!out_app_flag)) + ? "e" + std::to_string(iter) // iter starts from 1 : ""; // only when istep >= 0 and out_app_flag is false will write each wfc to a separate file std::string suffix_block; @@ -102,8 +116,8 @@ std::string filename_output( } std::string fn_out - = directory + property + spin_block + kpoint_block - + istep_block + "_" + basis + suffix_block; + = directory + property + kpoint_block + spin_block + + istep_block + iter_block + "_" + basis + suffix_block; return fn_out; } diff --git a/source/source_io/filename.h b/source/source_io/filename.h index 8eba4af71a..895bf29ef0 100644 --- a/source/source_io/filename.h +++ b/source/source_io/filename.h @@ -19,6 +19,7 @@ namespace ModuleIO * @param out_app_flag: whether to append to existing file. * @param gamma_only: gamma_only algorithm or not. * @param istep: index of the ion step starting from 0. If < 0, the step number is not included in the file name. + * @param iter: index of the electronic step starting from 0. If < 0, the step number is not included in the file name. * @return The generated filename. */ std::string filename_output( @@ -32,7 +33,8 @@ std::string filename_output( const int out_type, const bool out_app_flag, const bool gamma_only, - const int istep=-1); + const int istep=-1, + const int iter=-1); } #endif diff --git a/source/source_io/get_wf_lcao.cpp b/source/source_io/get_wf_lcao.cpp index 3d6c58a300..03e40ae21a 100644 --- a/source/source_io/get_wf_lcao.cpp +++ b/source/source_io/get_wf_lcao.cpp @@ -203,7 +203,10 @@ void Get_wf_lcao::begin(const UnitCell& ucell, } } - ModuleIO::write_wfc_pw(GlobalV::KPAR, + + const int istep = -1; // -1 means ionic iteration number will not appear in file name + const int iter = -1; // -1 means electronic iteration number will not appear in file name + ModuleIO::write_wfc_pw(istep, iter, GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK, nbands, @@ -366,7 +369,9 @@ void Get_wf_lcao::begin(const UnitCell& ucell, } } - ModuleIO::write_wfc_pw(GlobalV::KPAR, + const int istep = -1; // -1 means ionic iteration number will not appear in file name + const int iter = -1; // -1 means electronic iteration number will not appear in file name + ModuleIO::write_wfc_pw(istep, iter, GlobalV::KPAR, GlobalV::MY_POOL, GlobalV::MY_RANK, nbands, diff --git a/source/source_io/module_parameter/input_parameter.h b/source/source_io/module_parameter/input_parameter.h index f76b48e182..15ab2d3a3c 100644 --- a/source/source_io/module_parameter/input_parameter.h +++ b/source/source_io/module_parameter/input_parameter.h @@ -364,9 +364,8 @@ struct Input_para = {}; ///< the number of basis functions for each atom type used in FHI-aims (for benchmark) // ============== #Parameters (11.Output) =========================== bool out_stru = false; ///< outut stru file each ion step - int out_freq_elec = 0; ///< the frequency of electronic iter to output charge and wavefunction - int out_freq_ion = 0; ///< the frequency ( >= 0 ) of ionic step to output charge density; - ///< 0: output only when ion steps are finished + int out_freq_elec = 0; ///< print information every few electronic steps + int out_freq_ion = 0; ///< print information every few ionic steps std::vector out_chg = {0, 3}; ///< output charge density. 0: no; 1: yes std::vector out_xc_r = {-1, 3}; ///< output xc(r). -1: no; >=0: output the order of xc(r) int out_pot = 0; ///< yes or no @@ -391,7 +390,6 @@ struct Input_para ///< KS-orbital representation. bool out_mat_xc2 = false; ///< output exchange-correlation matrix Vxc(R) in NAO representation. bool out_eband_terms = false; ///< output the band energy terms separately - 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 int out_ndigits = 8; ///< Assuming 8 digits precision is needed for matrices output diff --git a/source/source_io/nscf_band.cpp b/source/source_io/nscf_band.cpp index 880908f57a..b23c135f5d 100644 --- a/source/source_io/nscf_band.cpp +++ b/source/source_io/nscf_band.cpp @@ -4,6 +4,7 @@ #include "source_base/timer.h" #include "source_base/tool_title.h" #include "source_base/formatter.h" +#include "source_io/module_parameter/parameter.h" // mohan add 20250911 #ifdef __MPI #include @@ -23,6 +24,7 @@ void ModuleIO::nscf_band( assert(precision>0); +/* GlobalV::ofs_running << "\n"; GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; GlobalV::ofs_running << " | |" << std::endl; @@ -30,8 +32,9 @@ void ModuleIO::nscf_band( GlobalV::ofs_running << " | |" << std::endl; GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; GlobalV::ofs_running << "\n"; +*/ - GlobalV::ofs_running << " Eigenvalues for plot are in file: " << eig_file << std::endl; + GlobalV::ofs_running << " Write eigenvalues data for plot to file: " << eig_file << std::endl; // number of k points without spin; // nspin = 1,2, nkstot = nkstot_np * nspin; @@ -39,11 +42,19 @@ void ModuleIO::nscf_band( const int nkstot_np = kv.para_k.nkstot_np; const int nks_np = kv.para_k.nks_np; + #ifdef __MPI if(GlobalV::MY_RANK==0) - { - std::ofstream ofs(eig_file.c_str());//make the file clear!! - ofs.close(); + { + if(PARAM.inp.out_app_flag==true) + { + // do nothing + } + else + { + std::ofstream ofs(eig_file.c_str()); + ofs.close(); + } } MPI_Barrier(MPI_COMM_WORLD); @@ -90,7 +101,20 @@ void ModuleIO::nscf_band( std::vector klength; klength.resize(nkstot_np); klength[0] = 0.0; - std::ofstream ofs(eig_file.c_str()); + + std::ofstream ofs; + + if(GlobalV::MY_RANK==0) + { + if(PARAM.inp.out_app_flag==true) + { + ofs.open(eig_file.c_str(), std::ios::app); + } + else + { + ofs.open(eig_file.c_str()); + } + } for(int ik=0;ikadd_item(item); } - { - Input_Item item("out_freq_ion"); - item.annotation = "the frequency ( >= 0 ) of ionic step to output " - "charge density and wavefunction. 0: output " - "only when ion steps are finished"; - read_sync_int(input.out_freq_ion); - this->add_item(item); - } { Input_Item item("out_chg"); item.annotation = "> 0 output charge density for selected electron steps" @@ -356,15 +348,15 @@ void ReadInput::item_output() this->add_item(item); } { - Input_Item item("out_interval"); - item.annotation = "interval for printing H(R) and S(R) matrix during MD"; - read_sync_int(input.out_interval); - item.check_value = [](const Input_Item& item, const Parameter& para) { - if (para.input.out_interval <= 0) - { - ModuleBase::WARNING_QUIT("ReadInput", "out_interval should be larger than 0"); - } - }; + Input_Item item("out_freq_ion"); + item.annotation = "print information every few ionic steps"; + item.reset_value = [](const Input_Item& item, Parameter& para) { + if (para.input.out_freq_ion <= 0) + { + para.input.out_freq_ion = 0; // 0 means no output of info + } + }; + read_sync_int(input.out_freq_ion); this->add_item(item); } { diff --git a/source/source_io/read_wfc_nao.cpp b/source/source_io/read_wfc_nao.cpp index d43ca58486..9383e32905 100644 --- a/source/source_io/read_wfc_nao.cpp +++ b/source/source_io/read_wfc_nao.cpp @@ -31,7 +31,7 @@ bool ModuleIO::read_wfc_nao( const int nkstot, const int nspin, const int skip_band, - const int nstep) + const int istep) { ModuleBase::TITLE("ModuleIO", "read_wfc_nao"); ModuleBase::timer::tick("ModuleIO", "read_wfc_nao"); @@ -158,12 +158,12 @@ bool ModuleIO::read_wfc_nao( const bool out_app_flag = false; std::stringstream error_message; std::string readin_dir = global_readin_dir; - if(nstep >= 0) + if(istep >= 0) { readin_dir = readin_dir + "WFC/"; } std::string ss = ModuleIO::filename_output(readin_dir,"wf","nao", - ik,ik2iktot,nspin,nkstot,out_type,out_app_flag,gamma_only,nstep); + ik,ik2iktot,nspin,nkstot,out_type,out_app_flag,gamma_only,istep); read_success = read_one_file(ss, error_message, ik, ctot); errors = error_message.str(); @@ -211,7 +211,7 @@ template bool ModuleIO::read_wfc_nao(const std::string& global_readin_di const std::vector &ik2iktot, const int nkstot, const int nspin, - const int nstep, + const int istep, const int skip_band); template bool ModuleIO::read_wfc_nao>(const std::string& global_readin_dir, @@ -221,5 +221,5 @@ template bool ModuleIO::read_wfc_nao>(const std::string& gl const std::vector &ik2iktot, const int nkstot, const int nspin, - const int nstep, + const int istep, const int skip_band); diff --git a/source/source_io/read_wfc_nao.h b/source/source_io/read_wfc_nao.h index f1df8a7c6d..ad59e4f4f3 100644 --- a/source/source_io/read_wfc_nao.h +++ b/source/source_io/read_wfc_nao.h @@ -45,7 +45,7 @@ bool read_wfc_nao( const int nkstot, const int nspin, const int skip_band = 0, - const int nstep = -1); + const int istep = -1); } // namespace ModuleIO diff --git a/source/source_io/test/cal_dos_test.cpp b/source/source_io/test/cal_dos_test.cpp index 6395563986..f52447a6cf 100644 --- a/source/source_io/test/cal_dos_test.cpp +++ b/source/source_io/test/cal_dos_test.cpp @@ -34,6 +34,8 @@ TEST_F(DosTest,Dos) dosp.read_wk(); dosp.read_istate_info(); EXPECT_EQ(dosp.is,0); + + const int istep = 1; ModuleIO::cal_dos(dosp.is, dosp.fa, dosp.de_ev, @@ -46,7 +48,8 @@ TEST_F(DosTest,Dos) dosp.isk, dosp.nbands, dosp.ekb, - dosp.wg); + dosp.wg, + istep); #ifdef __MPI if(GlobalV::MY_RANK==0) @@ -77,6 +80,8 @@ TEST_F(DosTest,DosW1) EXPECT_EQ(dosp.is,0); EXPECT_LE(dosp.de_ev,0); GlobalV::ofs_warning.open("warning1.log"); + + const int istep = 1; EXPECT_NO_THROW(ModuleIO::cal_dos(dosp.is, dosp.fa, dosp.de_ev, @@ -89,7 +94,8 @@ TEST_F(DosTest,DosW1) dosp.isk, dosp.nbands, dosp.ekb, - dosp.wg)); + dosp.wg, + istep)); GlobalV::ofs_warning.close(); #ifdef __MPI if(GlobalV::MY_RANK==0) @@ -117,6 +123,8 @@ TEST_F(DosTest,DosW2) dosp.read_istate_info(); EXPECT_EQ(dosp.is,0); GlobalV::ofs_warning.open("warning2.log"); + + const int istep = 1; EXPECT_NO_THROW(ModuleIO::cal_dos(dosp.is, dosp.fa, dosp.de_ev, @@ -129,7 +137,9 @@ TEST_F(DosTest,DosW2) dosp.isk, dosp.nbands, dosp.ekb, - dosp.wg)); + dosp.wg, + istep)); + GlobalV::ofs_warning.close(); #ifdef __MPI if(GlobalV::MY_RANK==0) diff --git a/source/source_io/test/read_input_ptest.cpp b/source/source_io/test/read_input_ptest.cpp index ebb276265d..7e0287d90b 100644 --- a/source/source_io/test/read_input_ptest.cpp +++ b/source/source_io/test/read_input_ptest.cpp @@ -207,7 +207,7 @@ TEST_F(InputParaTest, ParaRead) EXPECT_FALSE(param.inp.out_mat_xc); EXPECT_FALSE(param.inp.out_mat_xc2); EXPECT_FALSE(param.inp.out_eband_terms); - EXPECT_EQ(param.inp.out_interval, 1); + EXPECT_EQ(param.inp.out_freq_ion, 0); EXPECT_EQ(param.inp.out_app_flag, 0); EXPECT_EQ(param.inp.out_mat_r, 0); EXPECT_FALSE(param.inp.out_wfc_lcao); diff --git a/source/source_io/test/read_wf2rho_pw_test.cpp b/source/source_io/test/read_wf2rho_pw_test.cpp index 6c1dd464a9..786efd42a4 100644 --- a/source/source_io/test/read_wf2rho_pw_test.cpp +++ b/source/source_io/test/read_wf2rho_pw_test.cpp @@ -287,7 +287,11 @@ TEST_F(ReadWfcRhoTest, ReadWfcRho) const double ecutwfc = 20; // this is a fake number - ModuleIO::write_wfc_pw( + + const int istep = -1; // -1 means ionic iteration number will not appear in file name + const int iter = -1; // -1 means electronic iteration number will not appear in file name + + ModuleIO::write_wfc_pw(istep, iter, kpar, my_pool, my_rank, nbands, nspin, npol, GlobalV::RANK_IN_POOL, GlobalV::NPROC_IN_POOL, PARAM.input.out_wfc_pw, ecutwfc, out_dir, *psi, *kv, wfcpw, diff --git a/source/source_io/test/read_wfc_nao_test.cpp b/source/source_io/test/read_wfc_nao_test.cpp index 703223b20f..57917400d8 100644 --- a/source/source_io/test/read_wfc_nao_test.cpp +++ b/source/source_io/test/read_wfc_nao_test.cpp @@ -29,7 +29,8 @@ std::string filename_output( const int out_type, const bool out_app_flag, const bool gamma_only, - const int istep) + const int istep, + const int iter) { return "./support/wfs1_nao.txt"; } diff --git a/source/source_io/test/support/INPUT b/source/source_io/test/support/INPUT index 90357fb14f..d69b67a6b3 100644 --- a/source/source_io/test/support/INPUT +++ b/source/source_io/test/support/INPUT @@ -30,6 +30,7 @@ lspinorb 0 #consider the spin-orbit interaction kpar 1 #devide all processors into kpar groups and k points will be distributed among each group bndpar 1 #devide all processors into bndpar groups and bands will be distributed among each group out_freq_elec 0 #the frequency ( >= 0) of electronic iter to output charge density and wavefunction. 0: output only when converged +out_freq_ion 0 #the frequency ( >= 0 ) of ionic step to output charge density and wavefunction. 0: output only when ion steps are finished dft_plus_dmft 0 #true:DFT+DMFT; false: standard DFT calcullation(default) rpa 0 #true:generate output files used in rpa calculation; false:(default) mem_saver 0 #Only for nscf calculations. if set to 1, then a memory saving technique will be used for many k point calculations. @@ -37,7 +38,6 @@ diago_proc 4 #the number of procs used to do diagonalization nbspline -1 #the order of B-spline basis soc_lambda 1 #The fraction of SOC based on scalar relativity (SR) of the pseudopotential cal_force 0 #if calculate the force at the end of the electronic iteration -out_freq_ion 0 #the frequency ( >= 0 ) of ionic step to output charge density and wavefunction. 0: output only when ion steps are finished device cpu #the computing device for ABACUS #Parameters (2.PW) @@ -136,7 +136,6 @@ lcao_dr 0.01 #delta r for 1D integration in LCAO lcao_rmax 30 #max R for 1D two-center integration table out_mat_hs 0 #output H and S matrix out_mat_hs2 0 #output H(R) and S(R) matrix -out_interval 1 #interval for printing H(R) and S(R) matrix during MD out_app_flag 0 #whether output r(R), H(R), S(R), T(R), and dH(R) matrices in an append manner during MD out_element_info 0 #output (projected) wavefunction of each element out_mat_r 0 #output r(R) matrix diff --git a/source/source_io/test/write_dos_pw_test.cpp b/source/source_io/test/write_dos_pw_test.cpp index 5baae72ef8..e6a26759df 100644 --- a/source/source_io/test/write_dos_pw_test.cpp +++ b/source/source_io/test/write_dos_pw_test.cpp @@ -77,6 +77,7 @@ TEST_F(DosPWTest,Dos1) dosp.wg, *kv, PARAM.inp.nbands, + -1, // istep_in fermi_energy, dosp.de_ev, dos_scale, @@ -90,13 +91,13 @@ TEST_F(DosPWTest,Dos1) { #endif std::ifstream ifs; - ifs.open("doss1_pw.txt"); + ifs.open("dos.txt"); std::string str((std::istreambuf_iterator(ifs)),std::istreambuf_iterator()); EXPECT_THAT(str, testing::HasSubstr("4801 # number of points")); EXPECT_THAT(str, testing::HasSubstr(" -4.6 0.25 0.28125 1.42515 0.159819")); EXPECT_THAT(str, testing::HasSubstr(" 18 0 16 0 16")); ifs.close(); - remove("doss1_pw.txt"); + remove("dos.txt"); #ifdef __MPI } #endif @@ -140,7 +141,8 @@ TEST_F(DosPWTest,Dos2) dosp.ekb, dosp.wg, *kv, - PARAM.inp.nbands, + PARAM.inp.nbands, + -1, // istep_in fermi_energy, dosp.de_ev, dos_scale, @@ -154,13 +156,13 @@ TEST_F(DosPWTest,Dos2) { #endif std::ifstream ifs; - ifs.open("doss1_pw.txt"); + ifs.open("dos.txt"); std::string str1((std::istreambuf_iterator(ifs)),std::istreambuf_iterator()); EXPECT_THAT(str1, testing::HasSubstr("4532 # number of points")); EXPECT_THAT(str1, testing::HasSubstr(" -5.38811 0.03125 0.03125")); EXPECT_THAT(str1, testing::HasSubstr(" 3.07189 0.1875 5.46875")); ifs.close(); - remove("doss1_pw.txt"); + remove("dos.txt"); #ifdef __MPI } #endif diff --git a/source/source_io/test/write_eig_occ_test.cpp b/source/source_io/test/write_eig_occ_test.cpp index 3598817b91..3797efe8a5 100644 --- a/source/source_io/test/write_eig_occ_test.cpp +++ b/source/source_io/test/write_eig_occ_test.cpp @@ -98,17 +98,18 @@ TEST_F(IstateInfoTest, OutIstateInfoS1) } // write eigenvalues and occupations - ModuleIO::write_eig_file(ekb, wg, *kv); + const int istep_in = -1; + ModuleIO::write_eig_file(ekb, wg, *kv, istep_in); // check the output files std::ifstream ifs; - ifs.open("eig.txt"); + ifs.open("eig_occ.txt"); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); EXPECT_THAT(str, testing::HasSubstr("Electronic state energy (eV) and occupations")); EXPECT_THAT(str, testing::HasSubstr("spin=1 k-point=1/10 Cartesian=0.0000000 0.0000000 0.0000000 (299 plane wave)")); EXPECT_THAT(str, testing::HasSubstr("1 2.040854700000000 0.000000000000000")); ifs.close(); - remove("eig.txt"); + remove("eig_occ.txt"); } #ifdef __MPI diff --git a/source/source_io/test/write_wfc_nao_test.cpp b/source/source_io/test/write_wfc_nao_test.cpp index 50258a470f..04512196e0 100644 --- a/source/source_io/test/write_wfc_nao_test.cpp +++ b/source/source_io/test/write_wfc_nao_test.cpp @@ -35,7 +35,7 @@ TEST(GenWfcLcaoFnameTest, OutType1GammaOnlyOutAppFlagTrue) nkstot, out_type, out_app_flag, gamma_only, istep); // output .txt file when out_type=1 - std::string expected_output = "wfs1_nao.txt"; + std::string expected_output = "wf_nao.txt"; EXPECT_EQ(result, expected_output); } @@ -88,7 +88,7 @@ TEST(GenWfcLcaoFnameTest, OutTypeInvalid) std::string output = testing::internal::GetCapturedStdout(); // a .txt is chosen if out_type is not 1 or 2 - std::string expected_output = "wfs1k3_nao.txt"; + std::string expected_output = "wfk3_nao.txt"; EXPECT_EQ(result, expected_output); } 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 db842bd321..8e1eaba646 100644 --- a/source/source_io/test_serial/read_input_item_test.cpp +++ b/source/source_io/test_serial/read_input_item_test.cpp @@ -968,14 +968,6 @@ TEST_F(InputTest, Item_test2) output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("NOTICE")); } - { // out_interval - auto it = find_label("out_interval", readinput.input_lists); - param.input.out_interval = 0; - testing::internal::CaptureStdout(); - EXPECT_EXIT(it->second.check_value(it->second, param), ::testing::ExitedWithCode(1), ""); - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("NOTICE")); - } { // dm_to_rho auto it = find_label("dm_to_rho", readinput.input_lists); param.input.dm_to_rho = true; diff --git a/source/source_io/test_serial/rho_io_test.cpp b/source/source_io/test_serial/rho_io_test.cpp index 2085b83f43..36232800b2 100644 --- a/source/source_io/test_serial/rho_io_test.cpp +++ b/source/source_io/test_serial/rho_io_test.cpp @@ -91,7 +91,7 @@ class RhoIOTest : public ::testing::Test TEST_F(RhoIOTest, Read) { int is = 0; - std::string fn = "./support/chgs1.cube"; + std::string fn = "./support/chg.cube"; int nx = 36; int ny = 36; int nz = 36; @@ -117,9 +117,9 @@ TEST_F(RhoIOTest, Write) ucell->atoms[0].tau[1] = ModuleBase::Vector3(-0.75, 0.75, 0.75); ucell->atoms[0].ncpp.zv = 4; Parallel_Grid pgrid(nx, ny, nz, nz, nrxx, nz, 1); - ModuleIO::read_vdata_palgrid(pgrid, my_rank, ofs_running, "support/chgs1.cube", rho[0], ucell->nat); + ModuleIO::read_vdata_palgrid(pgrid, my_rank, ofs_running, "support/chg.cube", rho[0], ucell->nat); ModuleIO::write_vdata_palgrid(pgrid, rho[0], 0, nspin, 0, "test_write_vdata_palgrid.cube", 0.461002, ucell, 11, 1); - EXPECT_EQ(system("diff -q test_write_vdata_palgrid.cube support/chgs1.cube"), 0); + EXPECT_EQ(system("diff -q test_write_vdata_palgrid.cube support/chg.cube"), 0); } TEST_F(RhoIOTest, TrilinearInterpolate) @@ -130,7 +130,7 @@ TEST_F(RhoIOTest, TrilinearInterpolate) int nx_read = 36; int ny_read = 36; int nz_read = 36; - std::ifstream ifs("./support/chgs1.cube"); + std::ifstream ifs("./support/chg.cube"); for (int i = 0; i < 8; ++i) { ifs.ignore(300, '\n'); @@ -190,7 +190,7 @@ struct CubeIOTest : public ::testing::Test std::vector atom_charge; std::vector> atom_pos; std::vector data_read; - const std::string fn = "./support/chgs1.cube"; + const std::string fn = "./support/chg.cube"; }; @@ -236,5 +236,5 @@ TEST_F(CubeIOTest, WriteCube) dx, dy, dz, atom_type, atom_charge, atom_pos, data_read, 11); - EXPECT_EQ(system("diff -q test_write.cube ./support/chgs1.cube"), 0); + EXPECT_EQ(system("diff -q test_write.cube ./support/chg.cube"), 0); } diff --git a/source/source_io/test_serial/support/chgs1.cube b/source/source_io/test_serial/support/chg.cube similarity index 100% rename from source/source_io/test_serial/support/chgs1.cube rename to source/source_io/test_serial/support/chg.cube diff --git a/source/source_io/write_cube.cpp b/source/source_io/write_cube.cpp index 99e33e03bf..ae591969d0 100644 --- a/source/source_io/write_cube.cpp +++ b/source/source_io/write_cube.cpp @@ -214,6 +214,9 @@ void ModuleIO::write_cube(const std::string& file, std::ofstream ofs(file); + // mohan add 2025-09-10 + GlobalV::ofs_running << " Write data to file: " << file << std::endl; + for (int i = 0; i < 2; ++i) { ofs << comment[i] << "\n"; diff --git a/source/source_io/write_dos_lcao.cpp b/source/source_io/write_dos_lcao.cpp index fc64f4601f..eae8e231c6 100644 --- a/source/source_io/write_dos_lcao.cpp +++ b/source/source_io/write_dos_lcao.cpp @@ -69,7 +69,8 @@ void write_dos_lcao( kv.isk, nbands, ekb, - wg); + wg, + istep); } diff --git a/source/source_io/write_dos_pw.cpp b/source/source_io/write_dos_pw.cpp index 177f2551c4..7f5d2be88d 100644 --- a/source/source_io/write_dos_pw.cpp +++ b/source/source_io/write_dos_pw.cpp @@ -10,6 +10,7 @@ void ModuleIO::write_dos_pw( const ModuleBase::matrix& wg, const K_Vectors& kv, const int nbands, + const int istep_in, const elecstate::efermi &energy_fermi, const double& dos_edelta_ev, const double& dos_scale, @@ -36,11 +37,19 @@ void ModuleIO::write_dos_pw( for (int is = 0; is < nspin0; ++is) { // DOS_ispin contains not smoothed dos - std::stringstream ss; - ss << PARAM.globalv.global_out_dir << "doss" << is + 1 << "_pw.txt"; + std::stringstream ss; + ss << PARAM.globalv.global_out_dir << "dos"; - std::stringstream ss1; - ss1 << PARAM.globalv.global_out_dir << "doss" << is + 1 << "s_pw.txt"; + if(nspin0==2) + { + ss << "s" << is + 1; + } + else + { + // do nothing; + } + + ss << ".txt"; ModuleBase::GlobalFunc::OUT(ofs_running, "DOS file", ss.str()); @@ -56,7 +65,8 @@ void ModuleIO::write_dos_pw( kv.isk, nbands, ekb, - wg); + wg, + istep_in); } diff --git a/source/source_io/write_dos_pw.h b/source/source_io/write_dos_pw.h index f6ebb398cd..7b50c0ac57 100644 --- a/source/source_io/write_dos_pw.h +++ b/source/source_io/write_dos_pw.h @@ -15,6 +15,7 @@ namespace ModuleIO const ModuleBase::matrix &wg, const K_Vectors& kv, const int nbands, + const int istep_in, const elecstate::efermi &energy_fermi, const double &dos_edelta_ev, const double &dos_scale, diff --git a/source/source_io/write_eig_occ.cpp b/source/source_io/write_eig_occ.cpp index 2bea604de0..e403448a4c 100644 --- a/source/source_io/write_eig_occ.cpp +++ b/source/source_io/write_eig_occ.cpp @@ -90,11 +90,14 @@ void ModuleIO::write_eig_iter(const ModuleBase::matrix &ekb,const ModuleBase::ma int source_rank = status.MPI_SOURCE; MPI_Recv(&recv_nbands, 1, MPI_INT, source_rank, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); int* recv_ik2iktot = new int[recv_nks_np]; - MPI_Recv(recv_ik2iktot, recv_nks_np, MPI_INT, source_rank, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(recv_ik2iktot, recv_nks_np, MPI_INT, source_rank, + 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); ModuleBase::matrix recv_ekb(recv_nks_np, recv_nbands); - MPI_Recv(recv_ekb.c, recv_nks_np * recv_nbands, MPI_DOUBLE, source_rank, 3, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(recv_ekb.c, recv_nks_np * recv_nbands, MPI_DOUBLE, + source_rank, 3, MPI_COMM_WORLD, MPI_STATUS_IGNORE); ModuleBase::matrix recv_wg(recv_nks_np, recv_nbands); - MPI_Recv(recv_wg.c, recv_nks_np * recv_nbands, MPI_DOUBLE, source_rank, 4, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(recv_wg.c, recv_nks_np * recv_nbands, MPI_DOUBLE, source_rank, 4, + MPI_COMM_WORLD, MPI_STATUS_IGNORE); // print EIGENVALUES and OCCUPATIONS of received k-points for (int ik = 0; ik < recv_nks_np; ++ik) @@ -158,11 +161,15 @@ void ModuleIO::write_eig_iter(const ModuleBase::matrix &ekb,const ModuleBase::ma ModuleBase::timer::tick("ModuleIO", "write_eig_iter"); } -void ModuleIO::write_eig_file(const ModuleBase::matrix &ekb,const ModuleBase::matrix &wg, const K_Vectors& kv) +void ModuleIO::write_eig_file(const ModuleBase::matrix &ekb, + const ModuleBase::matrix &wg, + const K_Vectors& kv, + const int istep) { ModuleBase::TITLE("ModuleIO","write_eig_file"); ModuleBase::timer::tick("ModuleIO", "write_eig_file"); +/* GlobalV::ofs_running << "\n"; GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; GlobalV::ofs_running << " | |" << std::endl; @@ -170,6 +177,7 @@ void ModuleIO::write_eig_file(const ModuleBase::matrix &ekb,const ModuleBase::ma GlobalV::ofs_running << " | |" << std::endl; GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; GlobalV::ofs_running << "\n"; +*/ const int nspin = PARAM.inp.nspin; const int nks = kv.get_nks(); @@ -205,18 +213,30 @@ void ModuleIO::write_eig_file(const ModuleBase::matrix &ekb,const ModuleBase::ma #endif // file name to store eigenvalues - std::string filename = PARAM.globalv.global_out_dir + "eig.txt"; - GlobalV::ofs_running << " Eigenvalues and occupations are in file: " << filename << std::endl; + std::string filename = PARAM.globalv.global_out_dir + "eig_occ.txt"; + + GlobalV::ofs_running << " Write eigenvalues and occupations to file: " << filename << std::endl; if (GlobalV::MY_RANK == 0) { - std::ofstream ofs_eig0(filename.c_str()); // clear eig.txt + std::ofstream ofs_eig0; + + if(PARAM.inp.out_app_flag==true) + { + ofs_eig0.open(filename.c_str(), std::ios::app); + } + else + { + ofs_eig0.open(filename.c_str()); + } + + ofs_eig0 << istep+1 << " # ionic step" << std::endl; ofs_eig0 << " Electronic state energy (eV) and occupations" << std::endl; ofs_eig0 << " Spin number " << nspin << std::endl; ofs_eig0.close(); } - const int nk_fac = nspin == 2 ? 2 : 1; + const int nk_fac = (nspin == 2) ? 2 : 1; const int nks_np = nks / nk_fac; const int nkstot_np = nkstot / nk_fac; const int kpar = GlobalV::KPAR; diff --git a/source/source_io/write_eig_occ.h b/source/source_io/write_eig_occ.h index fe1ffca90c..26b7be7394 100644 --- a/source/source_io/write_eig_occ.h +++ b/source/source_io/write_eig_occ.h @@ -11,8 +11,9 @@ namespace ModuleIO const K_Vectors& kv); void write_eig_file(const ModuleBase::matrix &ekb, - const ModuleBase::matrix &wg, - const K_Vectors& kv); + const ModuleBase::matrix &wg, + const K_Vectors& kv, + const int istep); } #endif diff --git a/source/source_io/write_elf.cpp b/source/source_io/write_elf.cpp index 8bb8acdb9c..e3c72596fa 100644 --- a/source/source_io/write_elf.cpp +++ b/source/source_io/write_elf.cpp @@ -10,7 +10,7 @@ void write_elf( const int& nbz, #endif const std::string& out_dir, - const int& istep, + const int& istep_in, const int& nspin, const double* const* rho, const double* const* tau, @@ -94,14 +94,14 @@ void write_elf( if (nspin == 1) { - std::string fn = out_dir + "/ELF.cube"; + std::string fn = out_dir + "/elf.cube"; int is = -1; ModuleIO::write_vdata_palgrid(pgrid, elf[0].data(), is, nspin, - istep, + istep_in, fn, ef_tmp, ucell_, @@ -112,14 +112,17 @@ void write_elf( { for (int is = 0; is < nspin; ++is) { - std::string fn_temp = out_dir + "/ELF_SPIN" + std::to_string(is + 1) + ".cube"; + std::string fn_temp = out_dir + "/elf"; + + fn_temp += std::to_string(is + 1) + ".cube"; + int ispin = is + 1; ModuleIO::write_vdata_palgrid(pgrid, elf[is].data(), ispin, nspin, - istep, + istep_in, fn_temp, ef_tmp, ucell_, @@ -133,14 +136,14 @@ void write_elf( elf_tot[ir] = (tau[0][ir] + tau[1][ir] - tau_vw[0][ir] - tau_vw[1][ir]) / (tau_TF[0][ir] + tau_TF[1][ir]); elf_tot[ir] = 1. / (1. + elf_tot[ir] * elf_tot[ir]); } - std::string fn = out_dir + "/ELF.cube"; + std::string fn = out_dir + "/elf.cube"; int is = -1; ModuleIO::write_vdata_palgrid(pgrid, elf_tot.data(), is, nspin, - istep, + istep_in, fn, ef_tmp, ucell_, @@ -148,4 +151,4 @@ void write_elf( out_fermi); } } -} \ No newline at end of file +} diff --git a/source/source_io/write_elf.h b/source/source_io/write_elf.h index 6cc71434f6..23a7e7c379 100644 --- a/source/source_io/write_elf.h +++ b/source/source_io/write_elf.h @@ -13,7 +13,7 @@ void write_elf( const int& nbz, #endif const std::string& out_dir, - const int& istep, + const int& istep_in, const int& nspin, const double* const* rho, const double* const* tau, @@ -23,4 +23,4 @@ void write_elf( const int& precision); } -#endif \ No newline at end of file +#endif diff --git a/source/source_io/write_wfc_pw.cpp b/source/source_io/write_wfc_pw.cpp index 5f7a254da4..c677eafcca 100644 --- a/source/source_io/write_wfc_pw.cpp +++ b/source/source_io/write_wfc_pw.cpp @@ -12,6 +12,8 @@ #include "source_io/filename.h" void ModuleIO::write_wfc_pw( + const int istep, + const int iter, const int kpar, const int my_pool, const int my_rank, @@ -43,7 +45,6 @@ void ModuleIO::write_wfc_pw( bool out_app_flag = false; // need to modify later, mohan 2025-05-17 bool gamma_only = false; // need to modify later, mohan 2025-05-17 - int istep = -1; // need to modify later, mohan 2025-05-17 std::string* wfilename = new std::string[nks]; @@ -55,9 +56,9 @@ void ModuleIO::write_wfc_pw( { std::string fn = filename_output(global_out_dir,"wf","pw", ik_local,kv.ik2iktot,nspin,nkstot, - out_wfc_pw,out_app_flag,gamma_only,istep); + out_wfc_pw,out_app_flag,gamma_only,istep,iter); - ofs_running << " Write G-space wave functions into file " + ofs_running << " Write G-space wave functions to file: " << fn << std::endl; wfilename[ik_local] = fn; diff --git a/source/source_io/write_wfc_pw.h b/source/source_io/write_wfc_pw.h index b149741f17..7e035bf82c 100644 --- a/source/source_io/write_wfc_pw.h +++ b/source/source_io/write_wfc_pw.h @@ -8,6 +8,8 @@ namespace ModuleIO { void write_wfc_pw( + const int istep, + const int iter, const int kpar, const int my_pool, const int my_rank, diff --git a/source/source_pw/module_stodft/sto_dos.cpp b/source/source_pw/module_stodft/sto_dos.cpp index ffcc24203f..8a8f2cce9b 100644 --- a/source/source_pw/module_stodft/sto_dos.cpp +++ b/source/source_pw/module_stodft/sto_dos.cpp @@ -240,7 +240,7 @@ void Sto_DOS::caldos(const double sigmain, const double de, cons #endif if (GlobalV::MY_RANK == 0) { - std::string dosfile = PARAM.globalv.global_out_dir + "doss1_pw.txt"; + std::string dosfile = PARAM.globalv.global_out_dir + "dos_sdft.txt"; ofsdos.open(dosfile.c_str()); double maxerror = 0; double sum = 0; diff --git a/tests/01_PW/051_PW_OBOD_MemSaver/eigs1.txt.ref b/tests/01_PW/051_PW_OBOD_MemSaver/band.txt.ref similarity index 100% rename from tests/01_PW/051_PW_OBOD_MemSaver/eigs1.txt.ref rename to tests/01_PW/051_PW_OBOD_MemSaver/band.txt.ref diff --git a/tests/01_PW/051_PW_OBOD_MemSaver/chgs1.cube b/tests/01_PW/051_PW_OBOD_MemSaver/chg.cube similarity index 100% rename from tests/01_PW/051_PW_OBOD_MemSaver/chgs1.cube rename to tests/01_PW/051_PW_OBOD_MemSaver/chg.cube diff --git a/tests/01_PW/052_PW_OB/eigs1.txt.ref b/tests/01_PW/052_PW_OB/band.txt.ref similarity index 100% rename from tests/01_PW/052_PW_OB/eigs1.txt.ref rename to tests/01_PW/052_PW_OB/band.txt.ref diff --git a/tests/01_PW/052_PW_OB/chgs1.cube b/tests/01_PW/052_PW_OB/chg.cube similarity index 100% rename from tests/01_PW/052_PW_OB/chgs1.cube rename to tests/01_PW/052_PW_OB/chg.cube diff --git a/tests/01_PW/053_PW_OD/chgs1.cube b/tests/01_PW/053_PW_OD/chg.cube similarity index 100% rename from tests/01_PW/053_PW_OD/chgs1.cube rename to tests/01_PW/053_PW_OD/chg.cube diff --git a/tests/01_PW/054_PW_OP_nscf/chgs1.cube b/tests/01_PW/054_PW_OP_nscf/chg.cube similarity index 100% rename from tests/01_PW/054_PW_OP_nscf/chgs1.cube rename to tests/01_PW/054_PW_OP_nscf/chg.cube diff --git a/tests/01_PW/054_PW_OP_nscf/pots1.cube.ref b/tests/01_PW/054_PW_OP_nscf/pot.cube.ref similarity index 99% rename from tests/01_PW/054_PW_OP_nscf/pots1.cube.ref rename to tests/01_PW/054_PW_OP_nscf/pot.cube.ref index cca5229b71..d0b81b19b7 100644 --- a/tests/01_PW/054_PW_OP_nscf/pots1.cube.ref +++ b/tests/01_PW/054_PW_OP_nscf/pot.cube.ref @@ -1,4 +1,4 @@ -STEP: 0 Cubefile created from ABACUS. Inner loop is z, followed by y and x +STEP: -1 Cubefile created from ABACUS. Inner loop is z, followed by y and x 1 (nspin) 1 0.0 0.0 0.0 9 0.000000 0.495556 0.495556 diff --git a/tests/01_PW/056_PW_IW/chgs1.cube b/tests/01_PW/056_PW_IW/chg.cube similarity index 100% rename from tests/01_PW/056_PW_IW/chgs1.cube rename to tests/01_PW/056_PW_IW/chg.cube diff --git a/tests/01_PW/056_PW_IW/wfs1k1_pw.dat b/tests/01_PW/056_PW_IW/wfk1_pw.dat similarity index 100% rename from tests/01_PW/056_PW_IW/wfs1k1_pw.dat rename to tests/01_PW/056_PW_IW/wfk1_pw.dat diff --git a/tests/01_PW/056_PW_IW/wfs1k2_pw.dat b/tests/01_PW/056_PW_IW/wfk2_pw.dat similarity index 100% rename from tests/01_PW/056_PW_IW/wfs1k2_pw.dat rename to tests/01_PW/056_PW_IW/wfk2_pw.dat diff --git a/tests/01_PW/057_PW_SO_IW/wfs12k1_pw.dat b/tests/01_PW/057_PW_SO_IW/wfk1s4_pw.dat similarity index 100% rename from tests/01_PW/057_PW_SO_IW/wfs12k1_pw.dat rename to tests/01_PW/057_PW_SO_IW/wfk1s4_pw.dat diff --git a/tests/01_PW/072_PW_ELF/refELF.cube b/tests/01_PW/072_PW_ELF/refelf.cube similarity index 100% rename from tests/01_PW/072_PW_ELF/refELF.cube rename to tests/01_PW/072_PW_ELF/refelf.cube diff --git a/tests/01_PW/100_PW_W90/chgs1.cube b/tests/01_PW/100_PW_W90/chg.cube similarity index 100% rename from tests/01_PW/100_PW_W90/chgs1.cube rename to tests/01_PW/100_PW_W90/chg.cube diff --git a/tests/01_PW/203_PW_OK/chgs1.cube.ref b/tests/01_PW/203_PW_OK/chg.cube.ref similarity index 99% rename from tests/01_PW/203_PW_OK/chgs1.cube.ref rename to tests/01_PW/203_PW_OK/chg.cube.ref index a67ff1a69a..3e336b20d8 100644 --- a/tests/01_PW/203_PW_OK/chgs1.cube.ref +++ b/tests/01_PW/203_PW_OK/chg.cube.ref @@ -1,11 +1,11 @@ -STEP: 0 Cubefile created from ABACUS. Inner loop is z, followed by y and x +STEP: -1 Cubefile created from ABACUS. Inner loop is z, followed by y and x 1 (nspin) 0.517574 (fermi energy, in Ry) 2 0.0 0.0 0.0 24 0.000000 0.212500 0.212500 24 0.212500 0.000000 0.212500 24 0.212500 0.212500 0.000000 - 14 4 0.000000 0.000000 0.000000 - 14 4 2.550000 2.550000 2.550000 + 14 4.000000 0.000000 0.000000 0.000000 + 14 4.000000 2.550000 2.550000 2.550000 6.306e-04 4.526e-03 1.770e-02 3.853e-02 5.728e-02 6.466e-02 6.053e-02 5.116e-02 4.192e-02 3.468e-02 2.936e-02 2.589e-02 2.464e-02 2.589e-02 2.936e-02 3.468e-02 4.192e-02 5.116e-02 diff --git a/tests/01_PW/203_PW_OK/result.ref b/tests/01_PW/203_PW_OK/result.ref index 1ebf74fa8d..785824d57e 100644 --- a/tests/01_PW/203_PW_OK/result.ref +++ b/tests/01_PW/203_PW_OK/result.ref @@ -1,5 +1,5 @@ etotref -213.3867238098172 etotperatomref -106.6933619049 -chgs1.cube_pass 0 -taus1.cube_pass 0 +chg.cube_pass 0 +tau.cube_pass 0 totaltimeref 0.84452 diff --git a/tests/01_PW/203_PW_OK/taus1.cube.ref b/tests/01_PW/203_PW_OK/tau.cube.ref similarity index 100% rename from tests/01_PW/203_PW_OK/taus1.cube.ref rename to tests/01_PW/203_PW_OK/tau.cube.ref diff --git a/tests/02_NAO_Gamma/006_NO_GO_OH/hks1_nao.txt.ref b/tests/02_NAO_Gamma/006_NO_GO_OH/hk_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/006_NO_GO_OH/hks1_nao.txt.ref rename to tests/02_NAO_Gamma/006_NO_GO_OH/hk_nao.txt.ref diff --git a/tests/02_NAO_Gamma/006_NO_GO_OH/sks1_nao.txt.ref b/tests/02_NAO_Gamma/006_NO_GO_OH/sk_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/006_NO_GO_OH/sks1_nao.txt.ref rename to tests/02_NAO_Gamma/006_NO_GO_OH/sk_nao.txt.ref diff --git a/tests/02_NAO_Gamma/007_NO_GO_OXC/vxcs1_nao.txt.ref b/tests/02_NAO_Gamma/007_NO_GO_OXC/vxc_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/007_NO_GO_OXC/vxcs1_nao.txt.ref rename to tests/02_NAO_Gamma/007_NO_GO_OXC/vxc_nao.txt.ref diff --git a/tests/02_NAO_Gamma/014_NO_GO_wfc_file/wfs1_nao.txt b/tests/02_NAO_Gamma/014_NO_GO_wfc_file/wf_nao.txt similarity index 100% rename from tests/02_NAO_Gamma/014_NO_GO_wfc_file/wfs1_nao.txt rename to tests/02_NAO_Gamma/014_NO_GO_wfc_file/wf_nao.txt diff --git a/tests/02_NAO_Gamma/015_NO_GO_get_pchg/INPUT b/tests/02_NAO_Gamma/015_NO_GO_get_pchg/INPUT index 2404831564..5aee334d31 100644 --- a/tests/02_NAO_Gamma/015_NO_GO_get_pchg/INPUT +++ b/tests/02_NAO_Gamma/015_NO_GO_get_pchg/INPUT @@ -1,5 +1,6 @@ INPUT_PARAMETERS basis_type lcao +nspin 1 gamma_only 1 calculation get_pchg @@ -15,4 +16,4 @@ read_file_dir ./ pseudo_dir ../../PP_ORB orbital_dir ../../PP_ORB -out_pchg 4*1 \ No newline at end of file +out_pchg 4*1 diff --git a/tests/02_NAO_Gamma/015_NO_GO_get_pchg/wfs1_nao.txt b/tests/02_NAO_Gamma/015_NO_GO_get_pchg/wf_nao.txt similarity index 100% rename from tests/02_NAO_Gamma/015_NO_GO_get_pchg/wfs1_nao.txt rename to tests/02_NAO_Gamma/015_NO_GO_get_pchg/wf_nao.txt diff --git a/tests/02_NAO_Gamma/016_NO_GO_OW/wfs1_nao.txt.ref b/tests/02_NAO_Gamma/016_NO_GO_OW/wf_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/016_NO_GO_OW/wfs1_nao.txt.ref rename to tests/02_NAO_Gamma/016_NO_GO_OW/wf_nao.txt.ref diff --git a/tests/02_NAO_Gamma/023_NO_GO_NVT_OW/wfs1_nao.txt.ref b/tests/02_NAO_Gamma/023_NO_GO_NVT_OW/wf_nao.txt.ref similarity index 100% rename from tests/02_NAO_Gamma/023_NO_GO_NVT_OW/wfs1_nao.txt.ref rename to tests/02_NAO_Gamma/023_NO_GO_NVT_OW/wf_nao.txt.ref diff --git a/tests/03_NAO_multik/01_NO_KP_15f_ODM/pot_es.cube.ref b/tests/03_NAO_multik/01_NO_KP_15f_ODM/potes.cube.ref similarity index 100% rename from tests/03_NAO_multik/01_NO_KP_15f_ODM/pot_es.cube.ref rename to tests/03_NAO_multik/01_NO_KP_15f_ODM/potes.cube.ref diff --git a/tests/03_NAO_multik/15_NO_KP_OB/eigs1.txt.ref b/tests/03_NAO_multik/15_NO_KP_OB/band.txt.ref similarity index 100% rename from tests/03_NAO_multik/15_NO_KP_OB/eigs1.txt.ref rename to tests/03_NAO_multik/15_NO_KP_OB/band.txt.ref diff --git a/tests/03_NAO_multik/15_NO_KP_OB/chgs1.cube b/tests/03_NAO_multik/15_NO_KP_OB/chg.cube similarity index 100% rename from tests/03_NAO_multik/15_NO_KP_OB/chgs1.cube rename to tests/03_NAO_multik/15_NO_KP_OB/chg.cube diff --git a/tests/03_NAO_multik/16_NO_KP_OD/chgs1.cube b/tests/03_NAO_multik/16_NO_KP_OD/chg.cube similarity index 100% rename from tests/03_NAO_multik/16_NO_KP_OD/chgs1.cube rename to tests/03_NAO_multik/16_NO_KP_OD/chg.cube diff --git a/tests/03_NAO_multik/17_NO_KP_OH/hks1k2_nao.txt.ref b/tests/03_NAO_multik/17_NO_KP_OH/hk2_nao.txt.ref similarity index 100% rename from tests/03_NAO_multik/17_NO_KP_OH/hks1k2_nao.txt.ref rename to tests/03_NAO_multik/17_NO_KP_OH/hk2_nao.txt.ref diff --git a/tests/03_NAO_multik/17_NO_KP_OH/sks1k2_nao.txt.ref b/tests/03_NAO_multik/17_NO_KP_OH/sk2_nao.txt.ref similarity index 100% rename from tests/03_NAO_multik/17_NO_KP_OH/sks1k2_nao.txt.ref rename to tests/03_NAO_multik/17_NO_KP_OH/sk2_nao.txt.ref diff --git a/tests/03_NAO_multik/18_NO_KP_OH2/INPUT b/tests/03_NAO_multik/18_NO_KP_OH2/INPUT index 538b7bd007..08ab40f702 100644 --- a/tests/03_NAO_multik/18_NO_KP_OH2/INPUT +++ b/tests/03_NAO_multik/18_NO_KP_OH2/INPUT @@ -5,26 +5,26 @@ calculation scf nbands 6 symmetry 0 -pseudo_dir ../../PP_ORB -orbital_dir ../../PP_ORB +pseudo_dir ../../PP_ORB +orbital_dir ../../PP_ORB gamma_only 0 #Parameters (2.Iteration) ecutwfc 20 -scf_thr 1e-8 -scf_nmax 1 +scf_thr 1e-8 +scf_nmax 1 #Parameters (3.Basis) basis_type lcao #Parameters (4.Smearing) -smearing_method gauss -smearing_sigma 0.002 +smearing_method gauss +smearing_sigma 0.002 #Parameters (5.Mixing) mixing_type broyden mixing_beta 0.7 mixing_gg0 0.0 -out_mat_hs2 1 5 +out_mat_hs2 1 5 ks_solver scalapack_gvx diff --git a/tests/03_NAO_multik/19_NO_KP_OH_nscf/chgs1.cube b/tests/03_NAO_multik/19_NO_KP_OH_nscf/chg.cube similarity index 100% rename from tests/03_NAO_multik/19_NO_KP_OH_nscf/chgs1.cube rename to tests/03_NAO_multik/19_NO_KP_OH_nscf/chg.cube diff --git a/tests/03_NAO_multik/23_NO_KP_OK/chgs1.cube.ref b/tests/03_NAO_multik/23_NO_KP_OK/chg.cube.ref similarity index 99% rename from tests/03_NAO_multik/23_NO_KP_OK/chgs1.cube.ref rename to tests/03_NAO_multik/23_NO_KP_OK/chg.cube.ref index 40d6199ff1..1db488c5a5 100644 --- a/tests/03_NAO_multik/23_NO_KP_OK/chgs1.cube.ref +++ b/tests/03_NAO_multik/23_NO_KP_OK/chg.cube.ref @@ -1,4 +1,4 @@ -STEP: 0 Cubefile created from ABACUS. Inner loop is z, followed by y and x +STEP: -1 Cubefile created from ABACUS. Inner loop is z, followed by y and x 1 (nspin) 0.644033 (fermi energy, in Ry) 2 0.0 0.0 0.0 15 0.000000 0.340000 0.340000 diff --git a/tests/03_NAO_multik/23_NO_KP_OK/result.ref b/tests/03_NAO_multik/23_NO_KP_OK/result.ref index e62d956fce..d55c773f93 100644 --- a/tests/03_NAO_multik/23_NO_KP_OK/result.ref +++ b/tests/03_NAO_multik/23_NO_KP_OK/result.ref @@ -1,5 +1,5 @@ etotref -196.4521105421520 etotperatomref -98.2260552711 -chgs1.cube_pass 0 -taus1.cube_pass 0 +chg.cube_pass 0 +tau.cube_pass 0 totaltimeref 0.62163 diff --git a/tests/03_NAO_multik/23_NO_KP_OK/taus1.cube.ref b/tests/03_NAO_multik/23_NO_KP_OK/tau.cube.ref similarity index 100% rename from tests/03_NAO_multik/23_NO_KP_OK/taus1.cube.ref rename to tests/03_NAO_multik/23_NO_KP_OK/tau.cube.ref diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k1_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk1s1_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k1_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk1s1_nao.txt diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k1_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk1s2_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k1_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk1s2_nao.txt diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k2_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk2s1_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k2_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk2s1_nao.txt diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k2_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk2s2_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k2_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk2s2_nao.txt diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k3_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk3s1_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs1k3_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk3s1_nao.txt diff --git a/tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k3_nao.txt b/tests/03_NAO_multik/32_NO_KP_get_wf/wfk3s2_nao.txt similarity index 100% rename from tests/03_NAO_multik/32_NO_KP_get_wf/wfs2k3_nao.txt rename to tests/03_NAO_multik/32_NO_KP_get_wf/wfk3s2_nao.txt diff --git a/tests/03_NAO_multik/33_NO_KP_OW/wfs1k2_nao_mod.txt.ref b/tests/03_NAO_multik/33_NO_KP_OW/wfk2_nao_mod.txt.ref similarity index 100% rename from tests/03_NAO_multik/33_NO_KP_OW/wfs1k2_nao_mod.txt.ref rename to tests/03_NAO_multik/33_NO_KP_OW/wfk2_nao_mod.txt.ref diff --git a/tests/03_NAO_multik/35_NO_KP_MU_nscf/chgs1.cube b/tests/03_NAO_multik/35_NO_KP_MU_nscf/chg.cube similarity index 100% rename from tests/03_NAO_multik/35_NO_KP_MU_nscf/chgs1.cube rename to tests/03_NAO_multik/35_NO_KP_MU_nscf/chg.cube diff --git a/tests/03_NAO_multik/39_NO_OP_nscf/chgs1.cube b/tests/03_NAO_multik/39_NO_OP_nscf/chg.cube similarity index 100% rename from tests/03_NAO_multik/39_NO_OP_nscf/chgs1.cube rename to tests/03_NAO_multik/39_NO_OP_nscf/chg.cube diff --git a/tests/03_NAO_multik/39_NO_OP_nscf/pots1.cube.ref b/tests/03_NAO_multik/39_NO_OP_nscf/pot.cube.ref similarity index 99% rename from tests/03_NAO_multik/39_NO_OP_nscf/pots1.cube.ref rename to tests/03_NAO_multik/39_NO_OP_nscf/pot.cube.ref index ac71d0f37a..eb55ecfac5 100644 --- a/tests/03_NAO_multik/39_NO_OP_nscf/pots1.cube.ref +++ b/tests/03_NAO_multik/39_NO_OP_nscf/pot.cube.ref @@ -1,4 +1,4 @@ -STEP: 0 Cubefile created from ABACUS. Inner loop is z, followed by y and x +STEP: -1 Cubefile created from ABACUS. Inner loop is z, followed by y and x 1 (nspin) 2 0.0 0.0 0.0 12 0.000000 0.425000 0.425000 diff --git a/tests/03_NAO_multik/40_NO_ELF/refELF.cube b/tests/03_NAO_multik/40_NO_ELF/refelf.cube similarity index 100% rename from tests/03_NAO_multik/40_NO_ELF/refELF.cube rename to tests/03_NAO_multik/40_NO_ELF/refelf.cube diff --git a/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT b/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT index 15816b9f56..8e0e9c9147 100644 --- a/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT +++ b/tests/03_NAO_multik/44_NO_KP_MD_OW/INPUT @@ -26,7 +26,7 @@ mixing_beta 0.7 mixing_gg0 0.0 out_wfc_lcao 1 -out_interval 2 +out_freq_ion 2 out_app_flag 0 md_type nve 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/wfk1g3_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/wfk1g3_nao_mod.txt.ref diff --git a/tests/05_rtTDDFT/02_NO_CH_OW_TDDFT/wfs1k1g3_nao_mod.txt.ref b/tests/05_rtTDDFT/02_NO_CH_OW_TDDFT/wfk1g3_nao_mod.txt.ref similarity index 100% rename from tests/05_rtTDDFT/02_NO_CH_OW_TDDFT/wfs1k1g3_nao_mod.txt.ref rename to tests/05_rtTDDFT/02_NO_CH_OW_TDDFT/wfk1g3_nao_mod.txt.ref diff --git a/tests/05_rtTDDFT/12_NO_re_TDDFT/restart/WFC/wfs1k1g6_nao.txt b/tests/05_rtTDDFT/12_NO_re_TDDFT/restart/WFC/wfk1g6_nao.txt similarity index 100% rename from tests/05_rtTDDFT/12_NO_re_TDDFT/restart/WFC/wfs1k1g6_nao.txt rename to tests/05_rtTDDFT/12_NO_re_TDDFT/restart/WFC/wfk1g6_nao.txt diff --git a/tests/06_SDFT/18_PW_NSCF_KG_100/chgs1.cube b/tests/06_SDFT/18_PW_NSCF_KG_100/chg.cube similarity index 100% rename from tests/06_SDFT/18_PW_NSCF_KG_100/chgs1.cube rename to tests/06_SDFT/18_PW_NSCF_KG_100/chg.cube diff --git a/tests/06_SDFT/20_PW_SDOS_MALL/chgs1.cube b/tests/06_SDFT/20_PW_SDOS_MALL/chg.cube similarity index 100% rename from tests/06_SDFT/20_PW_SDOS_MALL/chgs1.cube rename to tests/06_SDFT/20_PW_SDOS_MALL/chg.cube diff --git a/tests/06_SDFT/21_PW_SKG_10D10S/chgs1.cube b/tests/06_SDFT/21_PW_SKG_10D10S/chg.cube similarity index 100% rename from tests/06_SDFT/21_PW_SKG_10D10S/chgs1.cube rename to tests/06_SDFT/21_PW_SKG_10D10S/chg.cube diff --git a/tests/07_OFDFT/24_OF_out_elf/refELF.cube b/tests/07_OFDFT/24_OF_out_elf/refelf.cube similarity index 100% rename from tests/07_OFDFT/24_OF_out_elf/refELF.cube rename to tests/07_OFDFT/24_OF_out_elf/refelf.cube diff --git a/tests/08_EXX/12_KP_OXC/vxcs1k2_nao.txt.ref b/tests/08_EXX/12_KP_OXC/vxck2_nao.txt.ref similarity index 100% rename from tests/08_EXX/12_KP_OXC/vxcs1k2_nao.txt.ref rename to tests/08_EXX/12_KP_OXC/vxck2_nao.txt.ref diff --git a/tests/09_DeePKS/102_NO_GO_deepks_nscf/chgs1.cube b/tests/09_DeePKS/102_NO_GO_deepks_nscf/chg.cube similarity index 100% rename from tests/09_DeePKS/102_NO_GO_deepks_nscf/chgs1.cube rename to tests/09_DeePKS/102_NO_GO_deepks_nscf/chg.cube diff --git a/tests/09_DeePKS/102_NO_KP_deepks_nscf/chgs1.cube b/tests/09_DeePKS/102_NO_KP_deepks_nscf/chg.cube similarity index 100% rename from tests/09_DeePKS/102_NO_KP_deepks_nscf/chgs1.cube rename to tests/09_DeePKS/102_NO_KP_deepks_nscf/chg.cube diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/INPUT b/tests/11_PW_GPU/007_PW_OW_GPU/INPUT index 2e6a424a7d..891a98ce04 100644 --- a/tests/11_PW_GPU/007_PW_OW_GPU/INPUT +++ b/tests/11_PW_GPU/007_PW_OW_GPU/INPUT @@ -18,5 +18,6 @@ scf_nmax 100 basis_type pw out_wfc_pw 1 +nspin 1 pw_seed 1 diff --git a/tests/11_PW_GPU/007_PW_OW_GPU/result.ref b/tests/11_PW_GPU/007_PW_OW_GPU/result.ref index dd4a5ac692..641b31e2cf 100644 --- a/tests/11_PW_GPU/007_PW_OW_GPU/result.ref +++ b/tests/11_PW_GPU/007_PW_OW_GPU/result.ref @@ -1,11 +1,11 @@ etotref -211.8032873347885 etotperatomref -105.9016436674 -Max_wfc_1 0.9527 -Max_wfc_2 0.3675 -Max_wfc_3 0.3351 -Max_wfc_4 0.3825 -Max_wfc_5 0.4409 -Max_wfc_6 0.4752 +Max_wfc_1 0.6619 +Max_wfc_2 0.7295 +Max_wfc_3 0.2296 +Max_wfc_4 0.5042 +Max_wfc_5 0.3319 +Max_wfc_6 0.8765 pointgroupref T_d spacegroupref O_h nksibzref 3 diff --git a/tests/15_rtTDDFT_GPU/12_NO_re_TDDFT_GPU/restart/WFC/wfs1k1g6_nao.txt b/tests/15_rtTDDFT_GPU/12_NO_re_TDDFT_GPU/restart/WFC/wfk1g6_nao.txt similarity index 100% rename from tests/15_rtTDDFT_GPU/12_NO_re_TDDFT_GPU/restart/WFC/wfs1k1g6_nao.txt rename to tests/15_rtTDDFT_GPU/12_NO_re_TDDFT_GPU/restart/WFC/wfk1g6_nao.txt diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index 768feba045..ca7a423b42 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -87,6 +87,7 @@ base=$(get_input_key_value "basis_type" "INPUT") word_total_time="atomic_world" symmetry=$(get_input_key_value "symmetry" "INPUT") out_current=$(get_input_key_value "out_current" "INPUT") +nspin=$(get_input_key_value "nspin" "INPUT") test -e $1 && rm $1 #------------------------------------------------------------ @@ -143,7 +144,7 @@ fi # echo $total_charge #------------------------------- if ! test -z "$has_dos" && [ $has_dos == 1 ]; then - total_dos=`cat OUT.autotest/doss1*.txt | awk 'END {print}' | awk '{print $3}'` + total_dos=`cat OUT.autotest/dos*.txt | awk 'END {print}' | awk '{print $3}'` echo "totaldosref $total_dos" >> $1 fi @@ -162,8 +163,8 @@ fi # echo $out_dm1 #------------------------------- if ! test -z "$out_dm1" && [ $out_dm1 == 1 ]; then - dm1ref=dmrs1_nao.csr.ref - dm1cal=OUT.autotest/dmrs1_nao.csr + dm1ref=dmr_nao.csr.ref + dm1cal=OUT.autotest/dmr_nao.csr python3 $COMPARE_SCRIPT $dm1ref $dm1cal 8 echo "CompareDM1_pass $?" >>$1 fi @@ -172,8 +173,8 @@ fi # echo $out_pot1 #------------------------------- if ! test -z "$out_pot" && [ $out_pot == 1 ]; then - pot1ref=pots1.cube.ref - pot1cal=OUT.autotest/pots1.cube + pot1ref=pot.cube.ref + pot1cal=OUT.autotest/pot.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 3 echo "ComparePot1_pass $?" >>$1 fi @@ -182,8 +183,8 @@ fi #echo $out_pot2 #------------------------------- if ! test -z "$out_pot" && [ $out_pot == 2 ]; then - pot1ref=pot_es.cube.ref - pot1cal=OUT.autotest/pot_es.cube + pot1ref=potes.cube.ref + pot1cal=OUT.autotest/potes.cube python3 $COMPARE_SCRIPT $pot1ref $pot1cal 8 echo "ComparePot_pass $?" >>$1 fi @@ -193,8 +194,8 @@ fi # echo $out_elf #------------------------------- if ! test -z "$out_elf" && [ $out_elf == 1 ]; then - elf1ref=refELF.cube - elf1cal=OUT.autotest/ELF.cube + elf1ref=refelf.cube + elf1cal=OUT.autotest/elf.cube python3 $COMPARE_SCRIPT $elf1ref $elf1cal 3 echo "ComparePot1_pass $?" >>$1 fi @@ -248,8 +249,8 @@ fi # echo $has_band #------------------------------- if ! test -z "$has_band" && [ $has_band == 1 ]; then - bandref=eigs1.txt.ref - bandcal=OUT.autotest/eigs1.txt + bandref=band.txt.ref + bandcal=OUT.autotest/band.txt python3 $COMPARE_SCRIPT $bandref $bandcal 8 echo "CompareBand_pass $?" >>$1 fi @@ -261,15 +262,15 @@ fi #-------------------------------- if ! test -z "$has_hs" && [ $has_hs == 1 ]; then if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then - href=hks1_nao.txt.ref - hcal=OUT.autotest/hks1_nao.txt - sref=sks1_nao.txt.ref - scal=OUT.autotest/sks1_nao.txt + href=hk_nao.txt.ref + hcal=OUT.autotest/hk_nao.txt + sref=sk_nao.txt.ref + scal=OUT.autotest/sk_nao.txt else # multiple k-points - href=hks1k2_nao.txt.ref - hcal=OUT.autotest/hks1k2_nao.txt - sref=sks1k2_nao.txt.ref - scal=OUT.autotest/sks1k2_nao.txt + href=hk2_nao.txt.ref + hcal=OUT.autotest/hk2_nao.txt + sref=sk2_nao.txt.ref + scal=OUT.autotest/sk2_nao.txt fi python3 $COMPARE_SCRIPT $href $hcal 6 @@ -283,11 +284,11 @@ fi #-------------------------------- if ! test -z "$has_xc" && [ $has_xc == 1 ]; then if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then - xcref=vxcs1_nao.txt.ref - xccal=OUT.autotest/vxcs1_nao.txt + xcref=vxc_nao.txt.ref + xccal=OUT.autotest/vxc_nao.txt else - xcref=vxcs1k2_nao.txt.ref - xccal=OUT.autotest/vxcs1k2_nao.txt + xcref=vxck2_nao.txt.ref + xccal=OUT.autotest/vxck2_nao.txt fi oeref=vxc_out.ref oecal=OUT.autotest/vxc_out.dat @@ -377,10 +378,10 @@ fi #--------------------------------------- if ! test -z "$has_scan" && [ $has_scan == "scan" ] && \ ! test -z "$out_chg" && [ $out_chg == 1 ]; then - python3 $COMPARE_SCRIPT chgs1.cube.ref OUT.autotest/chgs1.cube 8 - echo "chgs1.cube_pass $?" >>$1 - python3 $COMPARE_SCRIPT taus1.cube.ref OUT.autotest/taus1.cube 8 - echo "taus1.cube_pass $?" >>$1 + python3 $COMPARE_SCRIPT chg.cube.ref OUT.autotest/chg.cube 8 + echo "chg.cube_pass $?" >>$1 + python3 $COMPARE_SCRIPT tau.cube.ref OUT.autotest/tau.cube 8 + echo "tau.cube_pass $?" >>$1 fi #--------------------------------------- @@ -422,8 +423,22 @@ fi # echo "$has_wfc_pw" ## test out_wfc_pw > 0 #-------------------------------------------- if ! test -z "$has_wfc_pw" && [ $has_wfc_pw == 1 ]; then - if [[ ! -f OUT.autotest/wfs1k1_pw.txt ]];then - echo "Can't find file OUT.autotest/wfs1k1_pw.txt" + + # according to nspin value + if [ "$nspin" -eq 1 ]; then + filename="wfk1_pw.txt" + elif [ "$nspin" -eq 2 ]; then + filename="wfk1s1_pw.txt" + else + # other nspin cases + echo "Unsupported nspin value: $nspin" + exit 1 + fi + + full_path="OUT.autotest/$filename" + + if [[ ! -f "$full_path" ]];then + echo "Can't find file $full_path" exit 1 fi awk 'BEGIN {max=0;read=0;band=1} @@ -438,7 +453,7 @@ if ! test -z "$has_wfc_pw" && [ $has_wfc_pw == 1 ]; then if(sqrt($i*$i)>max) {max=sqrt($i*$i)} } } - }' OUT.autotest/wfs1k1_pw.txt >> $1 + }' "$full_path" >> "$1" fi @@ -448,15 +463,15 @@ fi #-------------------------------------------- if ! test -z "$has_lowf" && [ $has_lowf == 1 ]; then if ! test -z "$gamma_only" && [ $gamma_only == 1 ]; then - wfc_cal=OUT.autotest/wfs1_nao.txt - wfc_ref=wfs1_nao.txt.ref + wfc_cal=OUT.autotest/wf_nao.txt + wfc_ref=wf_nao.txt.ref else # multi-k point case if ! test -z "$out_app_flag" && [ $out_app_flag == 0 ]; then - wfc_name=wfs1k1g3_nao - input_file=WFC/wfs1k1g3_nao + wfc_name=wfk1g3_nao + input_file=WFC/wfk1g3_nao else - wfc_name=wfs1k2_nao - input_file=wfs1k2_nao + wfc_name=wfk2_nao + input_file=wfk2_nao fi awk 'BEGIN {flag=999} { @@ -482,8 +497,8 @@ fi # density matrix information #-------------------------------------------- if ! test -z "$out_dm" && [ $out_dm == 1 ]; then - dmfile=OUT.autotest/dms1_nao.txt - dmref=dms1_nao.txt.ref + dmfile=OUT.autotest/dm_nao.txt + dmref=dm_nao.txt.ref if test -z "$dmfile"; then echo "Can't find DM files" exit 1