diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index f7b762fe5d..27690ffdc9 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -86,7 +86,6 @@ - [mixing\_tau](#mixing_tau) - [mixing\_dftu](#mixing_dftu) - [gamma\_only](#gamma_only) - - [printe](#printe) - [scf\_nmax](#scf_nmax) - [scf\_thr](#scf_thr) - [scf\_ene\_thr](#scf_ene_thr) @@ -1252,12 +1251,6 @@ Note: In new angle mixing, you should set `mixing_beta_mag >> mixing_beta`. The - **Default**: 0 -### printe - -- **Type**: Integer -- **Description**: Print out energy for each band for every printe step -- **Default**: `scf_nmax` - ### scf_nmax - **Type**: Integer @@ -1771,7 +1764,7 @@ These variables are used to control the output of properties. ### out_band - **Type**: Boolean \[Integer\](optional) -- **Description**: Whether to output the eigenvalues of Hamiltonian matrix (in eV), optionally output precision can be set by a second parameter, default is 8. The output file names are: +- **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 = 2: `eigs1.txt` and `eigs2.txt`; - For more information, refer to the [band.md](../elec_properties/band.md) @@ -1863,7 +1856,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.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_interval](#out_interval) 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. @@ -1872,7 +1865,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.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_interval](#out_interval) 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. diff --git a/examples/relax/lcao_output/INPUT b/examples/relax/lcao_output/INPUT index 76265bb7bc..5230bd6365 100644 --- a/examples/relax/lcao_output/INPUT +++ b/examples/relax/lcao_output/INPUT @@ -3,9 +3,9 @@ INPUT_PARAMETERS suffix autotest nbands 8 -calculation cell-relax +calculation relax #cell-relax ecutwfc 10 -scf_nmax 20 +scf_nmax 2 basis_type lcao relax_nmax 5 @@ -20,6 +20,7 @@ mixing_type broyden mixing_beta 0.7 relax_new 0 +relax_method bfgs pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB diff --git a/examples/relax/lcao_output/STRU b/examples/relax/lcao_output/STRU index 375d2513e8..7e9164b324 100644 --- a/examples/relax/lcao_output/STRU +++ b/examples/relax/lcao_output/STRU @@ -15,7 +15,7 @@ LATTICE_VECTORS ATOMIC_POSITIONS Cartesian #Cartesian(Unit is LATTICE_CONSTANT) Si #Name of element -0.0 #Magnetic for this element. +4.0 #Magnetic for this element. 2 #Number of atoms -0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z -0.25 0.25 0.25 0 0 0 +0.00 0.00 0.00 1 1 1 #x,y,z, move_x, move_y, move_z +0.27 0.25 0.25 1 1 1 diff --git a/examples/relax/pw_output/INPUT b/examples/relax/pw_output/INPUT index e3d961ec04..cae2080431 100644 --- a/examples/relax/pw_output/INPUT +++ b/examples/relax/pw_output/INPUT @@ -3,7 +3,7 @@ INPUT_PARAMETERS suffix autotest nbands 8 -calculation cell-relax +calculation relax ecutwfc 10 scf_nmax 20 @@ -20,6 +20,7 @@ mixing_type broyden mixing_beta 0.7 relax_new 0 +relax_method lbfgs pseudo_dir ../../../tests/PP_ORB orbital_dir ../../../tests/PP_ORB @@ -30,8 +31,12 @@ out_chg 1 out_pot 1 out_wfc_pw 1 out_dos 1 -out_band 1 out_stru 1 out_app_flag 0 out_interval 1 +kpar 2 +symmetry -1 + +#out_freq_elec 2 +#out_band 1 diff --git a/examples/relax/pw_output/STRU b/examples/relax/pw_output/STRU index 375d2513e8..59b8a3e1a2 100644 --- a/examples/relax/pw_output/STRU +++ b/examples/relax/pw_output/STRU @@ -18,4 +18,4 @@ Si #Name of element 0.0 #Magnetic for this element. 2 #Number of atoms 0.00 0.00 0.00 0 0 0 #x,y,z, move_x, move_y, move_z -0.25 0.25 0.25 0 0 0 +0.27 0.243 0.233 1 1 1 diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 71d29a0495..4430902fae 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -571,7 +571,7 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\ write_orb_info.o\ write_dos_lcao.o\ write_proj_band_lcao.o\ - write_istate_info.o\ + write_eig_occ.o\ get_pchg_lcao.o\ get_wf_lcao.o\ io_dmk.o\ diff --git a/source/module_elecstate/cal_nelec_nband.cpp b/source/module_elecstate/cal_nelec_nband.cpp index cd956ac474..397a569294 100644 --- a/source/module_elecstate/cal_nelec_nband.cpp +++ b/source/module_elecstate/cal_nelec_nband.cpp @@ -7,22 +7,22 @@ namespace elecstate { void cal_nelec(const Atom* atoms, const int& ntype, double& nelec) { ModuleBase::TITLE("UnitCell", "cal_nelec"); - GlobalV::ofs_running << "\n SETUP THE ELECTRONS NUMBER" << std::endl; + //GlobalV::ofs_running << "\n Setup number of electrons" << std::endl; if (nelec == 0) { for (int it = 0; it < ntype; it++) { std::stringstream ss1, ss2; - ss1 << "electron number of element " << atoms[it].label; + ss1 << "Electron number of element " << atoms[it].label; const double nelec_it = atoms[it].ncpp.zv * atoms[it].na; nelec += nelec_it; - ss2 << "total electron number of element " << atoms[it].label; + ss2 << "Total electron number of element " << atoms[it].label; ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, ss1.str(), atoms[it].ncpp.zv); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, ss2.str(), nelec_it); } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "AUTOSET number of electrons: ", nelec); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Autoset the number of electrons", nelec); } if (PARAM.inp.nelec_delta != 0) { @@ -42,20 +42,22 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector& { return; } + //======================================= // calculate number of bands (setup.f90) //======================================= double occupied_bands = static_cast(nelec / ModuleBase::DEGSPIN); - if (PARAM.inp.lspinorb == 1) { - occupied_bands = static_cast(nelec); - } + if (PARAM.inp.lspinorb == 1) + { + occupied_bands = static_cast(nelec); + } if ((occupied_bands - std::floor(occupied_bands)) > 0.0) { occupied_bands = std::floor(occupied_bands) + 1.0; // mohan fix 2012-04-16 } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "occupied bands", occupied_bands); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Occupied electronic states", occupied_bands); if (nbands == 0) { @@ -89,8 +91,6 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector& } ModuleBase::GlobalFunc::AUTO_SET("NBANDS", nbands); } - // else if ( PARAM.inp.calculation=="scf" || PARAM.inp.calculation=="md" || PARAM.inp.calculation=="relax") //pengfei - // 2014-10-13 else { if (nbands < occupied_bands) { @@ -112,7 +112,6 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector& } // mohan add 2010-09-04 - // std::cout << "nbands(this-> = " <& { if (nbands > nlocal) { - ModuleBase::WARNING_QUIT("ElecState::cal_nbandsc", "NLOCAL < NBANDS"); + ModuleBase::WARNING_QUIT("ElecState::cal_nbands", + "Number of basis (NLOCAL) < Number of electronic states (NBANDS)"); } else { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NLOCAL", nlocal); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NBANDS", nbands); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of basis (NLOCAL)", nlocal); } } - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "NBANDS", nbands); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of electronic states (NBANDS)", nbands); } -} \ No newline at end of file +} diff --git a/source/module_elecstate/cal_wfc.cpp b/source/module_elecstate/cal_wfc.cpp index 03a7e26b51..ff069397a0 100644 --- a/source/module_elecstate/cal_wfc.cpp +++ b/source/module_elecstate/cal_wfc.cpp @@ -41,8 +41,8 @@ namespace elecstate } } - log << " " << std::setw(40) << "NLOCAL" - << " = " << nlocal_tmp << std::endl; +// log << " " << std::setw(40) << "NLOCAL" + // << " = " << nlocal_tmp << std::endl; //======================================================== // (4) set index for itia2iat, itiaiw2iwt //======================================================== @@ -140,33 +140,38 @@ namespace elecstate void cal_natomwfc(std::ofstream& log,int& natomwfc,const int ntype,const Atom* atoms) { natomwfc = 0; - for (int it = 0; it < ntype; it++) { - //============================ - // Use pseudo-atomic orbitals - //============================ - int tmp = 0; - for (int l = 0; l < atoms[it].ncpp.nchi; l++) { - if (atoms[it].ncpp.oc[l] >= 0) { - if (PARAM.inp.nspin == 4) { - if (atoms[it].ncpp.has_so) { - tmp += 2 * atoms[it].ncpp.lchi[l]; - if (fabs(atoms[it].ncpp.jchi[l] - atoms[it].ncpp.lchi[l] - 0.5)< 1e-6) - { - tmp += 2; - } - } else { - tmp += 2 * (2 * atoms[it].ncpp.lchi[l] + 1); - } - } else { - tmp += 2 * atoms[it].ncpp.lchi[l] + 1; - } - } - } - natomwfc += tmp * atoms[it].na; - } - ModuleBase::GlobalFunc::OUT(log, - "initial pseudo atomic orbital number", - natomwfc); - return; + for (int it = 0; it < ntype; it++) + { + //============================ + // Use pseudo-atomic orbitals + //============================ + int tmp = 0; + for (int l = 0; l < atoms[it].ncpp.nchi; l++) + { + if (atoms[it].ncpp.oc[l] >= 0) + { + if (PARAM.inp.nspin == 4) + { + if (atoms[it].ncpp.has_so) + { + tmp += 2 * atoms[it].ncpp.lchi[l]; + if (fabs(atoms[it].ncpp.jchi[l] - atoms[it].ncpp.lchi[l] - 0.5)< 1e-6) + { + tmp += 2; + } + } else + { + tmp += 2 * (2 * atoms[it].ncpp.lchi[l] + 1); + } + } else + { + tmp += 2 * atoms[it].ncpp.lchi[l] + 1; + } + } + } + natomwfc += tmp * atoms[it].na; + } + ModuleBase::GlobalFunc::OUT(log, "Number of pseudo atomic orbitals", natomwfc); + return; } -} \ No newline at end of file +} diff --git a/source/module_elecstate/elecstate_print.cpp b/source/module_elecstate/elecstate_print.cpp index da168a73db..b0c3b54936 100644 --- a/source/module_elecstate/elecstate_print.cpp +++ b/source/module_elecstate/elecstate_print.cpp @@ -149,56 +149,6 @@ void print_scf_iterinfo(const std::string& ks_solver, std::cout << buf; } -/// @brief function for printing eigenvalues : ekb -/// @param ik: index of kpoints -/// @param printe: print energy every 'printe' electron iteration. -/// @param iter: index of iterations -void print_band(const ModuleBase::matrix& ekb, - const ModuleBase::matrix& wg, - const K_Vectors* klist, - const int& ik, - const int& printe, - const int& iter, - std::ofstream &ofs) -{ - const double largest_eig = 1.0e10; - - // check the band energy. - bool wrong = false; - for (int ib = 0; ib < PARAM.globalv.nbands_l; ++ib) - { - if (std::abs(ekb(ik, ib)) > largest_eig) - { - GlobalV::ofs_warning << " ik=" << ik + 1 << " ib=" << ib + 1 << " " << ekb(ik, ib) << " Ry" << std::endl; - wrong = true; - } - } - if (wrong) - { - ModuleBase::WARNING_QUIT("print_eigenvalue", "Eigenvalues are too large!"); - } - - if (GlobalV::MY_RANK == 0) - { - if (printe > 0 && ((iter + 1) % printe == 0)) - { - ofs << std::setprecision(6); - ofs << " Energy (eV) & Occupations for spin=" << klist->isk[ik] + 1 - << " k-point=" << ik + 1 << std::endl; - ofs << std::setiosflags(std::ios::showpoint); - for (int ib = 0; ib < PARAM.globalv.nbands_l; ib++) - { - ofs << " " << std::setw(6) << ib + 1 << std::setw(15) - << ekb(ik, ib) * ModuleBase::Ry_to_eV; - // for the first electron iteration, we don't have the energy - // spectrum, so we can't get the occupations. - ofs << std::setw(15) << wg(ik, ib); - ofs << std::endl; - } - } - } - return; -} /// @brief print total free energy and other energies /// @param ucell: unit cell @@ -216,7 +166,6 @@ void print_etot(const Magnetism& magnet, const double& scf_thr, const double& scf_thr_kin, const double& duration, - const int printe, const double& pw_diag_thr, const double& avg_iter, const bool print) @@ -228,7 +177,8 @@ void print_etot(const Magnetism& magnet, GlobalV::ofs_running << std::setprecision(12); GlobalV::ofs_running << std::setiosflags(std::ios::right); - GlobalV::ofs_running << " Electron density deviation is " << scf_thr << std::endl; + + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Electron density deviation",scf_thr); if (PARAM.inp.basis_type == "pw") { @@ -239,8 +189,8 @@ void print_etot(const Magnetism& magnet, std::vector energies_Ry; std::vector energies_eV; - if (printe > 0 && ((iter + 1) % printe == 0 || converged || iter == PARAM.inp.scf_nmax)) - { + if( (iter % PARAM.inp.out_freq_elec == 0) || converged || iter == PARAM.inp.scf_nmax ) + { int n_order = std::max(0, Occupy::gaussian_type); titles.push_back("E_KohnSham"); energies_Ry.push_back(elec.f_en.etot); @@ -350,7 +300,7 @@ void print_etot(const Magnetism& magnet, FmtTable table(/*titles=*/{"Energy", "Rydberg", "eV"}, /*nrows=*/titles.size(), /*formats=*/{"%-14s", "%20.10f", "%20.10f"}, - /*indents=*/0, + /*indents=*/1, /*align=*/{/*value*/FmtTable::Align::LEFT, /*title*/FmtTable::Align::CENTER}); // print out the titles table << titles << energies_Ry << energies_eV; diff --git a/source/module_elecstate/elecstate_print.h b/source/module_elecstate/elecstate_print.h index fcf8ec91a2..cf85136f66 100644 --- a/source/module_elecstate/elecstate_print.h +++ b/source/module_elecstate/elecstate_print.h @@ -5,14 +5,6 @@ namespace elecstate { - void print_band(const ModuleBase::matrix& ekb, - const ModuleBase::matrix& wg, - const K_Vectors* klist, - const int& ik, - const int& printe, - const int& iter, - std::ofstream &ofs); - void print_format(const std::string& name, const double& value); @@ -23,7 +15,6 @@ namespace elecstate const double& scf_thr, const double& scf_thr_kin, const double& duration, - const int printe, const double& pw_diag_thr = 0, const double& avg_iter = 0, bool print = true); diff --git a/source/module_elecstate/magnetism.cpp b/source/module_elecstate/magnetism.cpp index 2ed58de787..a45b73246d 100644 --- a/source/module_elecstate/magnetism.cpp +++ b/source/module_elecstate/magnetism.cpp @@ -83,18 +83,18 @@ void Magnetism::compute_mag(const double& omega, for(int i=0;i<3;i++) { this->tot_mag_nc[i] *= omega/ nxyz; + // mohan add 2025-06-21 + if( abs(this->tot_mag_nc[i]) < 1.0e-16) + { + this->tot_mag_nc[i] = 0.0; + } } this->abs_mag *= omega/ nxyz; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism along x (Bohr mag/cell)", - this->tot_mag_nc[0]); - - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running," y (Bohr mag/cell)", - this->tot_mag_nc[1]); - - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running," z (Bohr mag/cell)", - this->tot_mag_nc[2]); + // mohan update 2025-06-21 + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Total magnetism (Bohr mag/cell)", + this->tot_mag_nc[0], this->tot_mag_nc[1], this->tot_mag_nc[2]); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Absolute magnetism (Bohr mag/cell)",this->abs_mag); } diff --git a/source/module_elecstate/module_charge/charge_mixing.cpp b/source/module_elecstate/module_charge/charge_mixing.cpp index 40fa49e8da..8bc062ec35 100644 --- a/source/module_elecstate/module_charge/charge_mixing.cpp +++ b/source/module_elecstate/module_charge/charge_mixing.cpp @@ -58,7 +58,20 @@ void Charge_Mixing::set_mixing(const std::string& mixing_mode_in, } // print into running.log - GlobalV::ofs_running<<"\n ----------- Charge Mixing Parameters ------------"<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + ">>>>" << std::endl; + GlobalV::ofs_running << " | " + " |" << std::endl; + GlobalV::ofs_running << " | Setup charge mixing parameters " + " |" << std::endl; + GlobalV::ofs_running << " | " + " |" << std::endl; + GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + "<<<<" << std::endl; + GlobalV::ofs_running << "\n"; + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_type", this->mixing_mode); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "mixing_beta", this->mixing_beta); diff --git a/source/module_elecstate/read_pseudo.cpp b/source/module_elecstate/read_pseudo.cpp index d98deb3a34..e50a23f967 100644 --- a/source/module_elecstate/read_pseudo.cpp +++ b/source/module_elecstate/read_pseudo.cpp @@ -12,66 +12,39 @@ namespace elecstate { void read_pseudo(std::ofstream& ofs, UnitCell& ucell) { // read in non-local pseudopotential and ouput the projectors. ofs << "\n\n"; - ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " | Reading pseudopotentials files: " - " |" - << std::endl; - ofs << " | The pseudopotential file is in UPF format. The 'NC' indicates " - "that |" - << std::endl; - ofs << " | the type of pseudopotential is 'norm conserving'. Functional of " - " |" - << std::endl; - ofs << " | exchange and correlation is decided by 4 given parameters in " - "UPF |" - << std::endl; - ofs << " | file. We also read in the 'core correction' if there exists. " - " |" - << std::endl; - ofs << " | Also we can read the valence electrons number and the maximal " - " |" - << std::endl; - ofs << " | angular momentum used in this pseudopotential. We also read in " - "the |" - << std::endl; - ofs << " | trail wave function, trail atomic density and " - "local-pseudopotential|" - << std::endl; - ofs << " | on logrithmic grid. The non-local pseudopotential projector is " - "also|" - << std::endl; - ofs << " | read in if there is any. " - " |" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - "<<<<" - << std::endl; - ofs << "\n\n"; + ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs << " | |" << std::endl; + ofs << " | #Read Pseudopotentials Files# |" << std::endl; + ofs << " | ABACUS supports norm-conserving (NC) pseudopotentials for both |" << std::endl; + ofs << " | plane wave basis and numerical atomic orbital basis sets. |" << std::endl; + ofs << " | In addition, ABACUS supports ultrasoft pseudopotentials (USPP) |" << std::endl; + ofs << " | for plane wave basis set. |" << std::endl; + ofs << " | |" << std::endl; + ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + ofs << "\n"; read_cell_pseudopots(PARAM.inp.pseudo_dir, ofs, ucell); - if (GlobalV::MY_RANK == 0) { - for (int it = 0; it < ucell.ntype; it++) { - Atom* atom = &ucell.atoms[it]; - if (!(atom->label_orb.empty())) { + if (GlobalV::MY_RANK == 0) + { + for (int it = 0; it < ucell.ntype; it++) + { + Atom* atom = &ucell.atoms[it]; + if (!(atom->label_orb.empty())) + { ucell.compare_atom_labels(atom->label_orb, atom->ncpp.psd); } } - if (PARAM.inp.out_element_info) { - for (int i = 0; i < ucell.ntype; i++) { - ModuleBase::Global_File::make_dir_atom(ucell.atoms[i].label); + if (PARAM.inp.out_element_info) + { + for (int i = 0; i < ucell.ntype; i++) + { + ModuleBase::Global_File::make_dir_atom(ucell.atoms[i].label); } - for (int it = 0; it < ucell.ntype; it++) { - Atom* atom = &ucell.atoms[it]; + for (int it = 0; it < ucell.ntype; it++) + { + Atom* atom = &ucell.atoms[it]; std::stringstream ss; ss << PARAM.globalv.global_out_dir << atom->label << "/" << atom->label << ".NONLOCAL"; @@ -81,7 +54,7 @@ void read_pseudo(std::ofstream& ofs, UnitCell& ucell) { ofs << std::setw(10) << atom->label << "\t" << "label" << std::endl; ofs << std::setw(10) << atom->ncpp.pp_type << "\t" - << "pseudopotential type" << std::endl; + << "Pseudopotential type" << std::endl; ofs << std::setw(10) << atom->ncpp.lmax << "\t" << "lmax" << std::endl; ofs << "" << std::endl; @@ -163,15 +136,20 @@ void read_pseudo(std::ofstream& ofs, UnitCell& ucell) { cal_nwfc(ofs,ucell,ucell.atoms); // Check whether the number of valence is minimum - if (GlobalV::MY_RANK == 0) { - int abtype = 0; - for (int it = 0; it < ucell.ntype; it++) { - if (ModuleBase::MinZval.find(ucell.atoms[it].ncpp.psd) - != ModuleBase::MinZval.end()) { - if (ucell.atoms[it].ncpp.zv - > ModuleBase::MinZval.at(ucell.atoms[it].ncpp.psd)) { + if (GlobalV::MY_RANK == 0) + { + int abtype = 0; + for (int it = 0; it < ucell.ntype; it++) + { + if (ModuleBase::MinZval.find(ucell.atoms[it].ncpp.psd) + != ModuleBase::MinZval.end()) + { + if (ucell.atoms[it].ncpp.zv + > ModuleBase::MinZval.at(ucell.atoms[it].ncpp.psd)) + { abtype += 1; - if (abtype == 1) { + if (abtype == 1) + { std::cout << "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" "%%%%%%%%%%%%%%%%%%%%%%%%%%" @@ -196,8 +174,9 @@ void read_pseudo(std::ofstream& ofs, UnitCell& ucell) { } } } - if (abtype > 0) { - std::cout << " Pseudopotentials with additional electrons can " + if (abtype > 0) + { + std::cout << " Pseudopotentials with additional electrons can " "yield (more) accurate outcomes, but may be " "less efficient." << std::endl; @@ -282,23 +261,23 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel if (error_ap) { - ModuleBase::WARNING_QUIT("UnitCell::read_cell_pseudopots", "error when average the pseudopotential."); + ModuleBase::WARNING_QUIT("read_cell_pseudopots", "error when average the pseudopotential."); } if (error == 1) { std::cout << " Pseudopotential directory now is : " << pp_address << std::endl; GlobalV::ofs_warning << " Pseudopotential directory now is : " << pp_address << std::endl; - ModuleBase::WARNING_QUIT("UnitCell::read_cell_pseudopots", "Couldn't find pseudopotential file."); + ModuleBase::WARNING_QUIT("read_cell_pseudopots", "Couldn't find pseudopotential file."); } else if (error == 2) { - ModuleBase::WARNING_QUIT("UnitCell::read_cell_pseudopots", "Pseudopotential data do not match."); + ModuleBase::WARNING_QUIT("read_cell_pseudopots", "Pseudopotential data do not match."); } else if (error == 3) { ModuleBase::WARNING_QUIT( - "UnitCell::read_cell_pseudopots", + "read_cell_pseudopots", "Check the reference states in pseudopotential .vwr file.\n Also the norm of the read in pseudo wave " "functions\n explicitly please check S, P and D channels.\n If the norm of the wave function is \n " "unreasonable large (should be near 1.0), ABACUS would quit. \n The solution is to turn off the wave " @@ -306,21 +285,22 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel } else if (error == 4) { - ModuleBase::WARNING_QUIT("UnitCell::read_cell_pseudopots", "Unknown pseudopotential type."); + ModuleBase::WARNING_QUIT("read_cell_pseudopots", "Unknown pseudopotential type."); } if (GlobalV::MY_RANK == 0) { upf.complete_default(ucell.atoms[i].ncpp); - log << "\n Read in pseudopotential file is " << ucell.pseudo_fn[i] << std::endl; - ModuleBase::GlobalFunc::OUT(log, "pseudopotential type", ucell.atoms[i].ncpp.pp_type); - ModuleBase::GlobalFunc::OUT(log, "exchange-correlation functional", ucell.atoms[i].ncpp.xc_func); - ModuleBase::GlobalFunc::OUT(log, "nonlocal core correction", ucell.atoms[i].ncpp.nlcc); + + ModuleBase::GlobalFunc::OUT(log, "Pseudopotential file", ucell.pseudo_fn[i]); + ModuleBase::GlobalFunc::OUT(log, "Pseudopotential type", ucell.atoms[i].ncpp.pp_type); + ModuleBase::GlobalFunc::OUT(log, "Exchange-correlation functional", ucell.atoms[i].ncpp.xc_func); + ModuleBase::GlobalFunc::OUT(log, "Nonlocal core correction", ucell.atoms[i].ncpp.nlcc); // ModuleBase::GlobalFunc::OUT(log, "spin orbital", ucell.atoms[i].has_so); - ModuleBase::GlobalFunc::OUT(log, "valence electrons", ucell.atoms[i].ncpp.zv); - ModuleBase::GlobalFunc::OUT(log, "lmax", ucell.atoms[i].ncpp.lmax); - ModuleBase::GlobalFunc::OUT(log, "number of zeta", ucell.atoms[i].ncpp.nchi); - ModuleBase::GlobalFunc::OUT(log, "number of projectors", ucell.atoms[i].ncpp.nbeta); + ModuleBase::GlobalFunc::OUT(log, "Valence electrons", ucell.atoms[i].ncpp.zv); + ModuleBase::GlobalFunc::OUT(log, "Lmax", ucell.atoms[i].ncpp.lmax); + ModuleBase::GlobalFunc::OUT(log, "Number of zeta", ucell.atoms[i].ncpp.nchi); + ModuleBase::GlobalFunc::OUT(log, "Number of projectors", ucell.atoms[i].ncpp.nbeta); for (int ib = 0; ib < ucell.atoms[i].ncpp.nbeta; ib++) { ModuleBase::GlobalFunc::OUT(log, "L of projector", ucell.atoms[i].ncpp.lll[ib]); @@ -354,10 +334,7 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel void print_unitcell_pseudo(const std::string& fn, UnitCell& ucell) { - if (PARAM.inp.test_pseudo_cell) - { - ModuleBase::TITLE("UnitCell", "print_unitcell_pseudo"); - } + ModuleBase::TITLE("elecstate", "print_unitcell_pseudo"); std::ofstream ofs(fn.c_str()); ucell.print_cell(ofs); diff --git a/source/module_elecstate/test/elecstate_print_test.cpp b/source/module_elecstate/test/elecstate_print_test.cpp index bf343288af..d8aec36492 100644 --- a/source/module_elecstate/test/elecstate_print_test.cpp +++ b/source/module_elecstate/test/elecstate_print_test.cpp @@ -112,49 +112,6 @@ TEST_F(ElecStatePrintTest, PrintFormat) std::remove("test.dat"); } -TEST_F(ElecStatePrintTest, PrintBand) -{ - PARAM.input.nspin = 1; - PARAM.input.nbands = 2; - PARAM.sys.nbands_l = 2; - GlobalV::MY_RANK = 0; - - std::ofstream ofs; - ofs.open("test.dat", std::ios::out); - // print eigenvalues - elecstate::print_band(elecstate.ekb,elecstate.wg,elecstate.klist, 0, 1, 0, ofs); - ofs.close(); - - ifs.open("test.dat", std::ios::in); - std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("Energy (eV) & Occupations for spin=1 k-point=1")); - EXPECT_THAT(str, testing::HasSubstr("1 13.6057 0.100000")); - EXPECT_THAT(str, testing::HasSubstr("2 27.2114 0.200000")); - ifs.close(); - std::remove("test.dat"); -} - - -TEST_F(ElecStatePrintTest, PrintBandWarning) -{ - elecstate.ekb(0, 0) = 1.0e11; - PARAM.input.nspin = 4; - - std::ofstream ofs; - ofs.open("test.dat", std::ios::out); - testing::internal::CaptureStdout(); - - EXPECT_EXIT(elecstate::print_band(elecstate.ekb,elecstate.wg,elecstate.klist, 0, 1, 0, ofs), - ::testing::ExitedWithCode(1), ""); - - output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("Eigenvalues are too large!")); - - ofs.close(); - - std::remove("test.dat"); -} - TEST_F(ElecStatePrintTest, PrintEtot) { GlobalV::ofs_running.open("test.dat", std::ios::out); @@ -163,13 +120,13 @@ TEST_F(ElecStatePrintTest, PrintEtot) double scf_thr = 0.1; double scf_thr_kin = 0.0; double duration = 2.0; - int printe = 1; double pw_diag_thr = 0.1; int avg_iter = 2; bool print = true; elecstate.charge = new Charge; elecstate.charge->nrxx = 100; elecstate.charge->nxyz = 1000; + PARAM.input.out_freq_elec = 1; PARAM.input.imp_sol = true; PARAM.input.efield_flag = true; PARAM.input.gate_flag = true; @@ -178,20 +135,26 @@ TEST_F(ElecStatePrintTest, PrintEtot) GlobalV::MY_RANK = 0; PARAM.input.basis_type = "pw"; PARAM.input.nspin = 2; + // iteration of different vdw_method std::vector vdw_methods = {"d2", "d3_0", "d3_bj"}; for (int i = 0; i < vdw_methods.size(); i++) { PARAM.input.vdw_method = vdw_methods[i]; - elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, false); + elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, + scf_thr_kin, duration, pw_diag_thr, avg_iter, false); } + // iteration of different ks_solver std::vector ks_solvers = {"cg", "lapack", "genelpa", "dav", "scalapack_gvx", "cusolver"}; for (int i = 0; i < ks_solvers.size(); i++) { PARAM.input.ks_solver = ks_solvers[i]; testing::internal::CaptureStdout(); - elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print); + + elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, + scf_thr_kin, duration, pw_diag_thr, avg_iter, print); + output = testing::internal::GetCapturedStdout(); if (PARAM.input.ks_solver == "cg") { @@ -221,7 +184,7 @@ TEST_F(ElecStatePrintTest, PrintEtot) GlobalV::ofs_running.close(); ifs.open("test.dat", std::ios::in); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("Electron density deviation is 0.1")); + EXPECT_THAT(str, testing::HasSubstr("Electron density deviation = 0.1")); EXPECT_THAT(str, testing::HasSubstr("Diago Threshold = 0.1")); EXPECT_THAT(str, testing::HasSubstr("E_KohnSham")); EXPECT_THAT(str, testing::HasSubstr("E_vdwD2")); @@ -235,6 +198,7 @@ TEST_F(ElecStatePrintTest, PrintEtot) std::remove("test.dat"); } +/* TEST_F(ElecStatePrintTest, PrintEtot2) { GlobalV::ofs_running.open("test.dat", std::ios::out); @@ -243,10 +207,10 @@ TEST_F(ElecStatePrintTest, PrintEtot2) double scf_thr = 0.1; double scf_thr_kin = 0.0; double duration = 2.0; - int printe = 0; double pw_diag_thr = 0.1; int avg_iter = 2; bool print = true; + PARAM.input.out_freq_elec = 0; elecstate.charge = new Charge; elecstate.charge->nrxx = 100; elecstate.charge->nxyz = 1000; @@ -259,11 +223,13 @@ TEST_F(ElecStatePrintTest, PrintEtot2) PARAM.input.basis_type = "pw"; PARAM.input.scf_nmax = 100; - elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print); + elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, + pw_diag_thr, avg_iter, print); + GlobalV::ofs_running.close(); ifs.open("test.dat", std::ios::in); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("Electron density deviation is 0.1")); + EXPECT_THAT(str, testing::HasSubstr("Electron density deviation = 0.1")); EXPECT_THAT(str, testing::HasSubstr("Diago Threshold = 0.1")); EXPECT_THAT(str, testing::HasSubstr("E_KohnSham")); EXPECT_THAT(str, testing::HasSubstr("E_Harris")); @@ -273,6 +239,7 @@ TEST_F(ElecStatePrintTest, PrintEtot2) delete elecstate.charge; std::remove("test.dat"); } +*/ TEST_F(ElecStatePrintTest, PrintEtotColorS2) { @@ -281,13 +248,14 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2) double scf_thr = 2.0; double scf_thr_kin = 0.0; double duration = 2.0; - int printe = 1; double pw_diag_thr = 0.1; int avg_iter = 2; bool print = true; elecstate.charge = new Charge; elecstate.charge->nrxx = 100; elecstate.charge->nxyz = 1000; + + PARAM.input.out_freq_elec = 1; PARAM.input.imp_sol = true; PARAM.input.efield_flag = true; PARAM.input.gate_flag = true; @@ -295,10 +263,14 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS2) PARAM.input.out_bandgap = true; PARAM.input.nspin = 2; GlobalV::MY_RANK = 0; - elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print); + + elecstate::print_etot(ucell.magnet,elecstate,converged, iter, scf_thr, + scf_thr_kin, duration, pw_diag_thr, avg_iter, print); + delete elecstate.charge; } + TEST_F(ElecStatePrintTest, PrintEtotColorS4) { bool converged = false; @@ -306,13 +278,14 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4) double scf_thr = 0.1; double scf_thr_kin = 0.0; double duration = 2.0; - int printe = 1; double pw_diag_thr = 0.1; int avg_iter = 2; bool print = true; elecstate.charge = new Charge; elecstate.charge->nrxx = 100; elecstate.charge->nxyz = 1000; + + PARAM.input.out_freq_elec = 1; PARAM.input.imp_sol = true; PARAM.input.efield_flag = true; PARAM.input.gate_flag = true; @@ -321,6 +294,9 @@ TEST_F(ElecStatePrintTest, PrintEtotColorS4) PARAM.input.nspin = 4; PARAM.input.noncolin = true; GlobalV::MY_RANK = 0; - elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin, duration, printe, pw_diag_thr, avg_iter, print); + + elecstate::print_etot(ucell.magnet,elecstate, converged, iter, scf_thr, scf_thr_kin, + duration, pw_diag_thr, avg_iter, print); + delete elecstate.charge; } diff --git a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp index 87c4d2ce42..dd552942ff 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/hamilt_pw.cpp @@ -400,13 +400,9 @@ void HamiltPW::set_exx_helper(Exx_Helper &exx_helper) template class HamiltPW, base_device::DEVICE_CPU>; template class HamiltPW, base_device::DEVICE_CPU>; -// template HamiltPW, base_device::DEVICE_CPU>::HamiltPW(const HamiltPW, -// base_device::DEVICE_CPU> *hamilt); #if ((defined __CUDA) || (defined __ROCM)) template class HamiltPW, base_device::DEVICE_GPU>; template class HamiltPW, base_device::DEVICE_GPU>; -// template HamiltPW, base_device::DEVICE_GPU>::HamiltPW(const HamiltPW, -// base_device::DEVICE_GPU> *hamilt); #endif -} // namespace hamilt \ No newline at end of file +} // namespace hamilt diff --git a/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp b/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp index 6e0c94fb2c..bbbb644df1 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/stress_pw.cpp @@ -147,7 +147,7 @@ void Stress_PW::cal_stress(ModuleBase::matrix& sigmatot, const bool ry = false; const bool screen = PARAM.inp.test_stress; - ModuleIO::print_stress("TOTAL-STRESS", sigmatot, true, ry, GlobalV::ofs_running); + ModuleIO::print_stress("TOTAL-STRESS", sigmatot, screen, ry, GlobalV::ofs_running); if (screen) { diff --git a/source/module_io/CMakeLists.txt b/source/module_io/CMakeLists.txt index a41c1b5179..33ef23f987 100644 --- a/source/module_io/CMakeLists.txt +++ b/source/module_io/CMakeLists.txt @@ -9,7 +9,7 @@ list(APPEND objects write_dos_pw.cpp nscf_band.cpp nscf_fermi_surf.cpp - write_istate_info.cpp + write_eig_occ.cpp numerical_basis.cpp numerical_basis_jyjy.cpp numerical_descriptor.cpp diff --git a/source/module_io/bessel_basis.cpp b/source/module_io/bessel_basis.cpp index 57fa1b1c82..cc82d533ef 100644 --- a/source/module_io/bessel_basis.cpp +++ b/source/module_io/bessel_basis.cpp @@ -365,7 +365,8 @@ void Bessel_Basis::readin_C4( if(!ifs) { GlobalV::ofs_warning << " File name : " << name << std::endl; - ModuleBase::WARNING_QUIT("Bessel_Basis::readin_C4","Can not find file."); + std::string fn = "Cannot find C4 file: " + name; + ModuleBase::WARNING_QUIT("Bessel_Basis::readin_C4",fn); } if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "")) diff --git a/source/module_io/cal_dos.cpp b/source/module_io/cal_dos.cpp index 8b252d13f6..17f672f59f 100644 --- a/source/module_io/cal_dos.cpp +++ b/source/module_io/cal_dos.cpp @@ -16,19 +16,15 @@ void ModuleIO::prepare_dos(std::ofstream& ofs_running, double &emax, double &emin) { - ofs_running << " DOS CALCULATIONS BEGINS" << std::endl; - ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - ofs_running << " | " - " |" << std::endl; + ofs_running << "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs_running << " | |" << std::endl; + ofs_running << " | #Calcualte Density of States (DOS)# |" << std::endl; ofs_running << " | DOS stands for Density of States. It represents the number of |" << std::endl; ofs_running << " | available electronic states per unit energy range. |" << std::endl; ofs_running << " | By analyzing the DOS, we can gain insights into how electrons are |" << std::endl; ofs_running << " | distributed among different energy levels within the material. |" << std::endl; - ofs_running << " | " - " |" << std::endl; - ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs_running << " | |" << std::endl; + ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; ofs_running << std::setprecision(6); @@ -86,8 +82,8 @@ void ModuleIO::prepare_dos(std::ofstream& ofs_running, assert(dos_edelta_ev>0.0); - ModuleBase::GlobalFunc::OUT(ofs_running, "Minimal energy is (eV)", emin); - ModuleBase::GlobalFunc::OUT(ofs_running, "Maximal energy is (eV)", emax); + ModuleBase::GlobalFunc::OUT(ofs_running, "Minimal energy (eV)", emin); + ModuleBase::GlobalFunc::OUT(ofs_running, "Maximal energy (eV)", emax); ModuleBase::GlobalFunc::OUT(ofs_running, "Energy interval (eV)", dos_edelta_ev); } diff --git a/source/module_io/nscf_band.cpp b/source/module_io/nscf_band.cpp index d45e067d3e..b93b09937b 100644 --- a/source/module_io/nscf_band.cpp +++ b/source/module_io/nscf_band.cpp @@ -11,7 +11,7 @@ void ModuleIO::nscf_band( const int &is, - const std::string &out_band_dir, + const std::string &eig_file, const int &nband, const double &fermie, const int &precision, @@ -22,18 +22,15 @@ void ModuleIO::nscf_band( ModuleBase::timer::tick("ModuleIO", "nscf_band"); GlobalV::ofs_running << "\n"; - GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " | Print out the eigenvalues. " - " |" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - "<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out the eigenvalues for each spin# |" << std::endl; + 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; + // number of k points without spin; // nspin = 1,2, nkstot = nkstot_np * nspin; // nspin = 4, nkstot = nkstot_np @@ -43,7 +40,7 @@ void ModuleIO::nscf_band( #ifdef __MPI if(GlobalV::MY_RANK==0) { - std::ofstream ofs(out_band_dir.c_str());//make the file clear!! + std::ofstream ofs(eig_file.c_str());//make the file clear!! ofs.close(); } @@ -71,7 +68,7 @@ void ModuleIO::nscf_band( assert( kv.isk[ik_now+is*nks_np] == is ); if ( GlobalV::RANK_IN_POOL == 0) { - std::ofstream ofs(out_band_dir.c_str(), std::ios::app); + std::ofstream ofs(eig_file.c_str(), std::ios::app); ofs << FmtCore::format("%4d", ik+1); int width = precision + 4; std::string fmtstr = " %." + std::to_string(precision) + "f"; @@ -91,7 +88,7 @@ void ModuleIO::nscf_band( std::vector klength; klength.resize(nkstot_np); klength[0] = 0.0; - std::ofstream ofs(out_band_dir.c_str()); + std::ofstream ofs(eig_file.c_str()); for(int ik=0;ik force_z; std::string table; - ofs_running << " " << name << std::endl; + ofs_running << "\n #" << name << "#" << std::endl; std::vector titles({"Atoms", "Force_x", "Force_y", "Force_z"}); int iat = 0; @@ -291,7 +293,7 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, std::vector stress_z; std::string table; - ofs << " " << title << std::endl; + ofs << "\n #" << title << "#" << std::endl; std::vector titles({"Stress_x", "Stress_y", "Stress_z"}); for (int i = 0; i < 3; i++) @@ -316,7 +318,7 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, ofs << table; if (name == "TOTAL-STRESS") { - ofs << " TOTAL-PRESSURE (DO NOT INCLUDE KINETIC PART OF IONS): " << std::fixed + ofs << " #TOTAL-PRESSURE# (EXCLUDE KINETIC PART OF IONS): " << std::fixed << std::setprecision(6) << pressure << unit << std::endl; } @@ -325,7 +327,7 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, std::cout << table; if (name == "TOTAL-STRESS") { - std::cout << " TOTAL-PRESSURE (DO NOT INCLUDE KINETIC PART OF IONS): " << std::fixed + std::cout << " TOTAL-PRESSURE (EXCLUDE KINETIC PART OF IONS): " << std::fixed << std::setprecision(6) << pressure << unit << std::endl; } @@ -335,8 +337,14 @@ void print_stress(const std::string& name, const ModuleBase::matrix& scs, void write_head(std::ofstream& ofs, const int& istep, const int& iter, const std::string& basisname) { - ofs << "\n " << basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 - << " ELEC=" << std::setw(4) << iter << "--------------------------------\n"; + ofs << "\n"; + ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; + ofs << " --> IONIC RELAXATION STEP=" << std::setw(6) << istep+1 + << " ELECTRONIC ITERATION STEP=" << std::setw(6) << iter << "\n"; + ofs << " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<< std::endl; + +// ofs << "\n " << basisname << " ALGORITHM --------------- ION=" << std::setw(4) << istep + 1 +// << " ELEC=" << std::setw(4) << iter << "--------------------------------\n"; } }// namespace ModuleIO diff --git a/source/module_io/print_info.cpp b/source/module_io/print_info.cpp index b93c6ea190..b5b3dfb101 100644 --- a/source/module_io/print_info.cpp +++ b/source/module_io/print_info.cpp @@ -209,61 +209,37 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod, } ofs << "\n\n"; - ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " | Setup plane waves of charge/potential: " - " |" - << std::endl; - ofs << " | Use the energy cutoff and the lattice vectors to generate the " - " |" - << std::endl; - ofs << " | dimensions of FFT grid. The number of FFT grid on each " - "processor |" - << std::endl; - ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space " - "is |" - << std::endl; - ofs << " | different for charege/potential and wave functions. We also set " - " |" - << std::endl; - ofs << " | the 'sticks' for the parallel of FFT. The number of plane waves " - " |" - << std::endl; - ofs << " | is 'npw' in each processor. " - " |" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - "<<<<" - << std::endl; - ofs << "\n\n"; - ofs << "\n SETUP THE PLANE WAVE BASIS" << std::endl; + ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs << " | |" << std::endl; + ofs << " | #Setup Plane Waves of Charge/Potential# |" << std::endl; + ofs << " | Use the kinetic energy cutoff and the lattice vectors to generate |" << std::endl; + ofs << " | the dimensions of FFT grid, which is used to represent the charge |" << std::endl; + ofs << " | density or potential. If USPP is used, a double grid technique |" << std::endl; + ofs << " | is applied. |" << std::endl; + ofs << " | |" << std::endl; + ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + ofs << "\n"; + ofs << " SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl; + double ecut = 4 * PARAM.inp.ecutwfc; if (PARAM.inp.nx * PARAM.inp.ny * PARAM.inp.nz > 0) { ecut = pw_rho->gridecut_lat * pw_rho->tpiba2; - ofs << "use input fft dimensions for wave functions." << std::endl; - ofs << "calculate energy cutoff from nx, ny, nz:" << std::endl; + ofs << " FFT DIMENSIONS ARE FROM INPUT" << std::endl; + ofs << " KINETIC ENEGY CUTOFF IS DETERMINED FROM nx, ny, nz" << std::endl; } - ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for charge/potential (unit:Ry)", ecut); + ModuleBase::GlobalFunc::OUT(ofs, "Energy cutoff for charge/potential (Ry)", ecut); - ModuleBase::GlobalFunc::OUT(ofs, "fft grid for charge/potential", pw_rho->nx, pw_rho->ny, pw_rho->nz); - ModuleBase::GlobalFunc::OUT(ofs, "fft grid division", pw_big->bx, pw_big->by, pw_big->bz); - ModuleBase::GlobalFunc::OUT(ofs, "big fft grid for charge/potential", pw_big->nbx, pw_big->nby, pw_big->nbz); - ModuleBase::GlobalFunc::OUT(ofs, "nbxx", pw_big->nbxx); - ModuleBase::GlobalFunc::OUT(ofs, "nrxx", pw_rho->nrxx); + ModuleBase::GlobalFunc::OUT(ofs, "FFT grid for charge/potential", pw_rho->nx, pw_rho->ny, pw_rho->nz); + ModuleBase::GlobalFunc::OUT(ofs, "Number of FFT grids this proc.", pw_rho->nrxx); + ModuleBase::GlobalFunc::OUT(ofs, "Division for big FFT grid", pw_big->bx, pw_big->by, pw_big->bz); + ModuleBase::GlobalFunc::OUT(ofs, "FFT (big) grid for charge/potential", pw_big->nbx, pw_big->nby, pw_big->nbz); + ModuleBase::GlobalFunc::OUT(ofs, "Number of FFT (big) grids this proc.", pw_big->nbxx); - ofs << "\n SETUP PLANE WAVES FOR CHARGE/POTENTIAL" << std::endl; - ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_rho->npwtot); - ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_rho->nstot); + ModuleBase::GlobalFunc::OUT(ofs, "Number of plane waves", pw_rho->npwtot); + ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks on FFT x-y plane", pw_rho->nstot); ofs << "\n PARALLEL PW FOR CHARGE/POTENTIAL" << std::endl; ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl; @@ -273,13 +249,14 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod, ofs << " " << std::setw(8) << i + 1 << std::setw(15) << pw_rho->nst_per[i] << std::setw(15) << pw_rho->npw_per[i] << std::endl; } - ofs << " --------------- sum -------------------" << std::endl; + ofs << " --------------- SUM -------------------" << std::endl; ofs << " " << std::setw(8) << GlobalV::NPROC_IN_POOL << std::setw(15) << pw_rho->nstot << std::setw(15) << pw_rho->npwtot << std::endl; - ModuleBase::GlobalFunc::OUT(ofs, "number of |g|", pw_rho->ngg); - ModuleBase::GlobalFunc::OUT(ofs, "max |g|", pw_rho->gg_uniq[pw_rho->ngg - 1]); - ModuleBase::GlobalFunc::OUT(ofs, "min |g|", pw_rho->gg_uniq[0]); + ofs << std::endl; + ModuleBase::GlobalFunc::OUT(ofs, "Number of |g|", pw_rho->ngg); + ModuleBase::GlobalFunc::OUT(ofs, "Max |g|", pw_rho->gg_uniq[pw_rho->ngg - 1]); + ModuleBase::GlobalFunc::OUT(ofs, "Min |g|", pw_rho->gg_uniq[0]); if (PARAM.globalv.double_grid) { @@ -301,9 +278,9 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod, ModuleBase::GlobalFunc::OUT(ofs, "nrxx", pw_rhod->nrxx); - ofs << "\n SETUP PLANE WAVES FOR dense CHARGE/POTENTIAL" << std::endl; - ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_rhod->npwtot); - ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_rhod->nstot); + ofs << "\n SETUP PLANE WAVES FOR DENSE CHARGE/POTENTIAL" << std::endl; + ModuleBase::GlobalFunc::OUT(ofs, "Number of plane waves", pw_rhod->npwtot); + ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks", pw_rhod->nstot); ofs << "\n PARALLEL PW FOR dense CHARGE/POTENTIAL" << std::endl; ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl; @@ -326,41 +303,16 @@ void print_rhofft(ModulePW::PW_Basis* pw_rhod, void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofstream& ofs) { ofs << "\n\n"; - ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " | Setup plane waves of wave functions: " - " |" - << std::endl; - ofs << " | Use the energy cutoff and the lattice vectors to generate the " - " |" - << std::endl; - ofs << " | dimensions of FFT grid. The number of FFT grid on each " - "processor |" - << std::endl; - ofs << " | is 'nrxx'. The number of plane wave basis in reciprocal space " - "is |" - << std::endl; - ofs << " | different for charege/potential and wave functions. We also set " - " |" - << std::endl; - ofs << " | the 'sticks' for the parallel of FFT. The number of plane wave " - "of |" - << std::endl; - ofs << " | each k-point is 'npwk[ik]' in each processor " - " |" - << std::endl; - ofs << " | " - " |" - << std::endl; - ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - "<<<<" - << std::endl; - ofs << "\n\n"; - ofs << "\n SETUP PLANE WAVES FOR WAVE FUNCTIONS" << std::endl; + ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs << " | |" << std::endl; + ofs << " | #Setup Plane Waves of Wave Functions# |" << std::endl; + ofs << " | Use the kinetic energy cutoff and the lattice vectors to generate |" << std::endl; + ofs << " | the dimensions of FFT grid, which is used to represent the wave |" << std::endl; + ofs << " | functions of electrons. |" << std::endl; + ofs << " | |" << std::endl; + ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + ofs << "\n"; + ofs << " SETUP PLANE WAVES FOR WAVE FUNCTIONS" << std::endl; double ecut = inp.ecutwfc; if (std::abs(ecut - pw_wfc.gk_ecut * pw_wfc.tpiba2) > 1e-6) @@ -370,10 +322,10 @@ void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofst "it will be reduced!" << std::endl; } - ModuleBase::GlobalFunc::OUT(ofs, "energy cutoff for wavefunc (unit:Ry)", ecut); - ModuleBase::GlobalFunc::OUT(ofs, "fft grid for wave functions", pw_wfc.nx, pw_wfc.ny, pw_wfc.nz); - ModuleBase::GlobalFunc::OUT(ofs, "number of plane waves", pw_wfc.npwtot); - ModuleBase::GlobalFunc::OUT(ofs, "number of sticks", pw_wfc.nstot); + ModuleBase::GlobalFunc::OUT(ofs, "Energy cutoff for wavefunc (unit:Ry)", ecut); + ModuleBase::GlobalFunc::OUT(ofs, "FFT grid for wave functions", pw_wfc.nx, pw_wfc.ny, pw_wfc.nz); + ModuleBase::GlobalFunc::OUT(ofs, "Number of total plane waves", pw_wfc.npwtot); + ModuleBase::GlobalFunc::OUT(ofs, "Number of sticks on FFT x-y plane", pw_wfc.nstot); ofs << "\n PARALLEL PW FOR WAVE FUNCTIONS" << std::endl; ofs << " " << std::setw(8) << "PROC" << std::setw(15) << "COLUMNS(POT)" << std::setw(15) << "PW" << std::endl; @@ -392,34 +344,29 @@ void print_wfcfft(const Input_para& inp, ModulePW::PW_Basis_K& pw_wfc, std::ofst void print_screen(const int& stress_step, const int& force_step, const int& istep) { - std::cout << " -------------------------------------------" << std::endl; - GlobalV::ofs_running << "\n -------------------------------------------" << std::endl; + std::cout << " ======================================================================" << std::endl; + GlobalV::ofs_running << " ======================================================================" << std::endl; - if(PARAM.inp.calculation=="scf") //add 4 lines 2015-09-06, xiaohui + if(PARAM.inp.calculation=="scf") { - std::cout << " SELF-CONSISTENT : " << std::endl; + std::cout << " SELF-CONSISTENT: " << std::endl; GlobalV::ofs_running << " SELF-CONSISTENT" << std::endl; } - else if(PARAM.inp.calculation=="nscf") //add 4 lines 2015-09-06, xiaohui + else if(PARAM.inp.calculation=="nscf") { - std::cout << " NONSELF-CONSISTENT : " << std::endl; + std::cout << " NONSELF-CONSISTENT: " << std::endl; GlobalV::ofs_running << " NONSELF-CONSISTENT" << std::endl; } else if(PARAM.inp.calculation=="md") { - std::cout << " STEP OF MOLECULAR DYNAMICS : " << unsigned(istep) << std::endl; - GlobalV::ofs_running << " STEP OF MOLECULAR DYNAMICS : " << unsigned(istep) << std::endl; + std::cout << " STEP OF MOLECULAR DYNAMICS: " << unsigned(istep) << std::endl; + GlobalV::ofs_running << " STEP OF MOLECULAR DYNAMICS: " << unsigned(istep) << std::endl; } else { - if(PARAM.inp.relax_new) - { - std::cout << " STEP OF RELAXATION : " << unsigned(istep) << std::endl; - GlobalV::ofs_running << " STEP OF RELAXATION : " << unsigned(istep) << std::endl; - } - else if(PARAM.inp.calculation=="relax") //pengfei 2014-10-13 + if(PARAM.inp.calculation=="relax") { - std::cout << " STEP OF ION RELAXATION : " << unsigned(istep) << std::endl; + std::cout << " STEP OF ION RELAXATION: " << unsigned(istep) << std::endl; GlobalV::ofs_running << " STEP OF ION RELAXATION : " << unsigned(istep) << std::endl; } else if(PARAM.inp.calculation=="cell-relax") @@ -431,8 +378,8 @@ void print_screen(const int& stress_step, const int& force_step, const int& iste } } - std::cout << " -------------------------------------------" << std::endl; - GlobalV::ofs_running << " -------------------------------------------" << std::endl; + std::cout << " ======================================================================" << std::endl; + GlobalV::ofs_running << " ======================================================================" << std::endl; } } // namespace ModuleIO diff --git a/source/module_io/read_input_item_output.cpp b/source/module_io/read_input_item_output.cpp index 10947eaf5d..7da923f6b4 100644 --- a/source/module_io/read_input_item_output.cpp +++ b/source/module_io/read_input_item_output.cpp @@ -78,18 +78,6 @@ void ReadInput::item_output() read_sync_int(input.out_wfc_pw); this->add_item(item); } - { - Input_Item item("printe"); - item.annotation = "Print out energy for each band for every printe steps"; - item.reset_value = [](const Input_Item& item, Parameter& para) { - if (para.input.printe <= 0) // default is scf_nmax - { - para.input.printe = para.input.scf_nmax; - } - }; - read_sync_int(input.printe); - this->add_item(item); - } { Input_Item item("out_band"); item.annotation = "output energy and band structure (with precision 8)"; diff --git a/source/module_io/test/CMakeLists.txt b/source/module_io/test/CMakeLists.txt index 26951e9d3c..aedbedaa3b 100644 --- a/source/module_io/test/CMakeLists.txt +++ b/source/module_io/test/CMakeLists.txt @@ -46,9 +46,9 @@ AddTest( ) AddTest( - TARGET MODULE_IO_write_istate_info_test + TARGET MODULE_IO_write_eig_occ_test LIBS parameter ${math_libs} base device symmetry - SOURCES write_istate_info_test.cpp ../write_istate_info.cpp ../output.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/klist.cpp ../../source_cell/k_vector_utils.cpp + SOURCES write_eig_occ_test.cpp ../write_eig_occ.cpp ../output.cpp ../../source_cell/parallel_kpoints.cpp ../../source_cell/klist.cpp ../../source_cell/k_vector_utils.cpp ../cif_io.cpp ) diff --git a/source/module_io/test/binstream_test.cpp b/source/module_io/test/binstream_test.cpp index 504d27ca86..c83ea07114 100644 --- a/source/module_io/test/binstream_test.cpp +++ b/source/module_io/test/binstream_test.cpp @@ -60,6 +60,8 @@ TEST_F(BinstreamTest, variable) Binstream *p = new Binstream("wfc" , "r"); delete p; + + remove("wfc"); // mohan add 2025-06-22 } TEST_F(BinstreamTest, array) @@ -88,4 +90,4 @@ TEST_F(BinstreamTest, array) } wwfc.open("wfc", "w"); -} \ No newline at end of file +} diff --git a/source/module_io/test/outputlog_test.cpp b/source/module_io/test/outputlog_test.cpp index f311aa5143..d6ebc9fafc 100644 --- a/source/module_io/test/outputlog_test.cpp +++ b/source/module_io/test/outputlog_test.cpp @@ -36,8 +36,7 @@ TEST(OutputConvergenceAfterSCFTest, TestConvergence) { std::string file_content = ss.str(); ifs_running.close(); - std::string expected_content = "\n charge density convergence is achieved\n" - " final etot is 27.211396 eV\n"; + std::string expected_content = " #SCF IS CONVERGED#\n"; EXPECT_EQ(file_content, expected_content); std::remove("test_output_convergence.txt"); @@ -58,34 +57,14 @@ TEST(OutputConvergenceAfterSCFTest, TestNotConvergence) { std::string file_content = ss.str(); ifs_running.close(); - std::string expected_content = " !! convergence has not been achieved @_@\n"; - std::string expected_content_screen = " !! CONVERGENCE HAS NOT BEEN ACHIEVED !!\n"; + std::string expected_content = " !!SCF IS NOT CONVERGED!!\n"; + std::string expected_content_screen = " !!SCF IS NOT CONVERGED!!\n"; EXPECT_EQ(file_content, expected_content); EXPECT_EQ(screen_output, expected_content_screen); std::remove("test_output_convergence_noconvergence.txt"); } -// Test the output_efermi function -TEST(OutputEfermiTest, TestConvergence) { - bool convergence = true; - double efermi = 1.0; - std::ofstream ofs_running("test_output_efermi.txt"); - ModuleIO::output_efermi(convergence, efermi, ofs_running); - ofs_running.close(); - - std::ifstream ifs_running("test_output_efermi.txt"); - std::stringstream ss; - ss << ifs_running.rdbuf(); - std::string file_content = ss.str(); - ifs_running.close(); - - std::string expected_content = " EFERMI = 13.605698 eV\n"; - - EXPECT_EQ(file_content, expected_content); - std::remove("test_output_efermi.txt"); -} - // Test the output_efermi function TEST(OutputAfterRelaxTest, TestConvergence) { @@ -243,7 +222,7 @@ TEST(PrintForce, PrintForce) { UnitCell ucell; PARAM.input.test_force = 1; - std::string name = "test"; + std::string name = "TOTAL-FORCE"; ModuleBase::matrix force(2, 3); force(0, 0) = 1.0; force(0, 1) = 2.0; @@ -260,7 +239,8 @@ TEST(PrintForce, PrintForce) std::string output_str; getline(ifs, output_str); - EXPECT_THAT(output_str, testing::HasSubstr(" test")); + getline(ifs, output_str); // mohan add 2025-06-22 + EXPECT_THAT(output_str, testing::HasSubstr("#TOTAL-FORCE#")); getline(ifs, output_str); EXPECT_THAT(output_str, @@ -303,15 +283,16 @@ TEST(PrintStress, PrintStress) stress(2, 1) = 0.0; stress(2, 2) = 0.0; - std::ofstream ofs("running_stress.txt"); - ModuleIO::print_stress("TOTAL-STRESS", stress, true, false, ofs); + bool screen = false; + ModuleIO::print_stress("TOTAL-STRESS", stress, screen, false, ofs); ofs.close(); std::ifstream ifs("running_stress.txt"); std::string output_str; getline(ifs, output_str); - EXPECT_THAT(output_str, testing::HasSubstr(" TOTAL-STRESS (KBAR)")); + getline(ifs, output_str); // mohan add 2025-06-22 + EXPECT_THAT(output_str, testing::HasSubstr(" #TOTAL-STRESS (KBAR)#")); getline(ifs, output_str); EXPECT_THAT(output_str, testing::HasSubstr("----------------------------------------------------------------")); @@ -335,7 +316,7 @@ TEST(PrintStress, PrintStress) EXPECT_THAT(output_str, testing::HasSubstr("----------------------------------------------------------------")); getline(ifs, output_str); - EXPECT_THAT(output_str, testing::HasSubstr(" TOTAL-PRESSURE (DO NOT INCLUDE KINETIC PART OF IONS): 49035.075992 KBAR")); + EXPECT_THAT(output_str, testing::HasSubstr(" #TOTAL-PRESSURE# (EXCLUDE KINETIC PART OF IONS): 49035.075992 KBAR")); ifs.close(); std::remove("running_stress.txt"); } diff --git a/source/module_io/test/print_info_test.cpp b/source/module_io/test/print_info_test.cpp index 7c7757b3a0..f26045000e 100644 --- a/source/module_io/test/print_info_test.cpp +++ b/source/module_io/test/print_info_test.cpp @@ -91,7 +91,7 @@ TEST_F(PrintInfoTest, SetupParameters) else { PARAM.sys.gamma_only_local = true; - PARAM.input.calculation = cal_type[i]; + PARAM.input.calculation = cal_type[i]; for(int j=0; j= 0) of electronic iter to output charge density and wavefunction. 0: output only when converged dft_plus_dmft 0 #true:DFT+DMFT; false: standard DFT calcullation(default) rpa 0 #true:generate output files used in rpa calculation; false:(default) -printe 100 #Print out energy for each band for every printe steps mem_saver 0 #Only for nscf calculations. if set to 1, then a memory saving technique will be used for many k point calculations. diago_proc 4 #the number of procs used to do diagonalization nbspline -1 #the order of B-spline basis diff --git a/source/module_io/test/write_istate_info_test.cpp b/source/module_io/test/write_eig_occ_test.cpp similarity index 95% rename from source/module_io/test/write_istate_info_test.cpp rename to source/module_io/test/write_eig_occ_test.cpp index 171ecc7fbd..ca67acd9ec 100644 --- a/source/module_io/test/write_istate_info_test.cpp +++ b/source/module_io/test/write_eig_occ_test.cpp @@ -11,16 +11,16 @@ #include "source_cell/parallel_kpoints.h" #include "mpi.h" #endif -#include "../write_istate_info.h" +#include "../write_eig_occ.h" #include "for_testing_klist.h" /************************************************ - * unit test of write_istate_info + * unit test of write_eig_occ ***********************************************/ /** * - Tested Functions: - * - write_istate_info() + * - write_eig_occ() * - print out electronic eigen energies and * - occupation */ @@ -98,7 +98,7 @@ TEST_F(IstateInfoTest, OutIstateInfoS1) } // write eigenvalues and occupations - ModuleIO::write_istate_info(ekb, wg, *kv); + ModuleIO::write_eig_file(ekb, wg, *kv); // check the output files std::ifstream ifs; diff --git a/source/module_io/write_HS.hpp b/source/module_io/write_HS.hpp index 03cfe29d1d..db087c1bba 100644 --- a/source/module_io/write_HS.hpp +++ b/source/module_io/write_HS.hpp @@ -24,7 +24,6 @@ void ModuleIO::write_hsk( std::ofstream &ofs_running) { - ofs_running << "\n WRITE H(k) OR S(k) BEGINS" << std::endl; ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; ofs_running << " | " @@ -35,6 +34,7 @@ void ModuleIO::write_hsk( " |" << std::endl; ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + ofs_running << "\n WRITE H(k) OR S(k)" << std::endl; for (int ik = 0; ik < nks; ++ik) { diff --git a/source/module_io/write_HS_R.cpp b/source/module_io/write_HS_R.cpp index 90349de747..ebd91a3d35 100644 --- a/source/module_io/write_HS_R.cpp +++ b/source/module_io/write_HS_R.cpp @@ -34,17 +34,12 @@ void ModuleIO::output_HSR(const UnitCell& ucell, ModuleBase::TITLE("ModuleIO", "output_HSR"); ModuleBase::timer::tick("ModuleIO", "output_HSR"); - GlobalV::ofs_running << "\n WRITE H(R) OR S(R) BEGINS" << std::endl; - GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " | Write Hamiltonian matrix H(R) or overlap matrix S(R) in numerical |" << std::endl; - GlobalV::ofs_running << " | atomic orbitals, where R is the Bravis lattice vector. |" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out Hamiltonian matrix H(R) or overlap matrix S(R)# |" << std::endl; + GlobalV::ofs_running << " | Use numerical atomic orbitals basis. Here R is the Bravis lattice |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; const int nspin = PARAM.inp.nspin; @@ -145,6 +140,12 @@ void ModuleIO::output_dHR(const int& istep, ModuleBase::TITLE("ModuleIO", "output_dHR"); ModuleBase::timer::tick("ModuleIO", "output_dHR"); + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out dH/dR# |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + gint_k.allocate_pvdpR(); const int nspin = PARAM.inp.nspin; @@ -216,19 +217,14 @@ void ModuleIO::output_SR(Parallel_Orbitals& pv, ModuleBase::TITLE("ModuleIO", "output_SR"); ModuleBase::timer::tick("ModuleIO", "output_SR"); - GlobalV::ofs_running << " OUTPUT S(R) BEGINS" << std::endl; - GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " | Print out the overlap matrix S(R) in the CSR format |" << std::endl; - GlobalV::ofs_running << " | " - " |" << std::endl; - GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out overlap matrix S(R)# |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; - std::cout << " The overlap file is saved in " << SR_filename << std::endl; - GlobalV::ofs_running << " The overlap file is saved in " << SR_filename << std::endl; + std::cout << " Overlap matrix file is in " << SR_filename << std::endl; + GlobalV::ofs_running << " Overlap matrix file is in " << SR_filename << std::endl; LCAO_HS_Arrays HS_Arrays; @@ -286,14 +282,22 @@ void ModuleIO::output_TR(const int istep, ModuleBase::TITLE("ModuleIO", "output_TR"); ModuleBase::timer::tick("ModuleIO", "output_TR"); + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out kinetic energy term matrix T(R)# |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + std::stringstream sst; if (PARAM.inp.calculation == "md" && !PARAM.inp.out_app_flag) { - sst << PARAM.globalv.global_matrix_dir << istep << "_" << TR_filename; + sst << PARAM.globalv.global_matrix_dir << TR_filename << "g" << istep; + GlobalV::ofs_running << " T(R) data are in file: " << sst.str() << std::endl; } else { sst << PARAM.globalv.global_out_dir << TR_filename; + GlobalV::ofs_running << " T(R) data are in file: " << sst.str() << std::endl; } sparse_format::cal_TR(ucell, diff --git a/source/module_io/write_HS_sparse.cpp b/source/module_io/write_HS_sparse.cpp index f6a6f264e8..371afd26c8 100644 --- a/source/module_io/write_HS_sparse.cpp +++ b/source/module_io/write_HS_sparse.cpp @@ -411,73 +411,85 @@ void ModuleIO::save_dH_sparse(const int& istep, Parallel_Reduce::reduce_all(dHz_nonzero_num[ispin], total_R_num); } - if (PARAM.inp.nspin == 2) { - for (int index = 0; index < total_R_num; ++index) { - if (dHx_nonzero_num[0][index] != 0 || dHx_nonzero_num[1][index] != 0 - || dHy_nonzero_num[0][index] != 0 - || dHy_nonzero_num[1][index] != 0 - || dHz_nonzero_num[0][index] != 0 - || dHz_nonzero_num[1][index] != 0) { - output_R_number++; - } - } - } else { - for (int index = 0; index < total_R_num; ++index) { - if (dHx_nonzero_num[0][index] != 0 || dHy_nonzero_num[0][index] != 0 - || dHz_nonzero_num[0][index] != 0) { - output_R_number++; - } - } + if (PARAM.inp.nspin == 2) + { + for (int index = 0; index < total_R_num; ++index) + { + if (dHx_nonzero_num[0][index] != 0 || dHx_nonzero_num[1][index] != 0 + || dHy_nonzero_num[0][index] != 0 + || dHy_nonzero_num[1][index] != 0 + || dHz_nonzero_num[0][index] != 0 + || dHz_nonzero_num[1][index] != 0) + { + output_R_number++; + } + } + } else + { + for (int index = 0; index < total_R_num; ++index) + { + if (dHx_nonzero_num[0][index] != 0 || dHy_nonzero_num[0][index] != 0 + || dHz_nonzero_num[0][index] != 0) + { + output_R_number++; + } + } } std::stringstream sshx[2]; std::stringstream sshy[2]; std::stringstream sshz[2]; + if (PARAM.inp.calculation == "md" && !PARAM.inp.out_app_flag) { sshx[0] << PARAM.globalv.global_matrix_dir - << "d"<(&step), sizeof(int)); @@ -498,14 +510,22 @@ void ModuleIO::save_dH_sparse(const int& istep, g1z[ispin].write(reinterpret_cast(&output_R_number), sizeof(int)); } - } else { - for (int ispin = 0; ispin < spin_loop; ++ispin) { - if (PARAM.inp.calculation == "md" && PARAM.inp.out_app_flag - && step) { - g1x[ispin].open(sshx[ispin].str().c_str(), std::ios::app); + } + else + { + for (int ispin = 0; ispin < spin_loop; ++ispin) + { + if (PARAM.inp.calculation == "md" && PARAM.inp.out_app_flag && step) + { + g1x[ispin].open(sshx[ispin].str().c_str(), std::ios::app); g1y[ispin].open(sshy[ispin].str().c_str(), std::ios::app); g1z[ispin].open(sshz[ispin].str().c_str(), std::ios::app); - } else { + } + else + { + GlobalV::ofs_running << " dH/dRx data are in file: " << sshx[ispin].str() << std::endl; + GlobalV::ofs_running << " dH/dRy data are in file: " << sshy[ispin].str() << std::endl; + GlobalV::ofs_running << " dH/dRz data are in file: " << sshz[ispin].str() << std::endl; g1x[ispin].open(sshx[ispin].str().c_str()); g1y[ispin].open(sshy[ispin].str().c_str()); g1z[ispin].open(sshz[ispin].str().c_str()); diff --git a/source/module_io/write_dos_lcao.cpp b/source/module_io/write_dos_lcao.cpp index 850e3edc7b..e5b59871fe 100644 --- a/source/module_io/write_dos_lcao.cpp +++ b/source/module_io/write_dos_lcao.cpp @@ -99,7 +99,7 @@ void write_dos_lcao( } } - ofs_running << " DOS CALCULATIONS ENDS." << std::endl; + ofs_running << " #DOS CALCULATIONS ENDS# " << std::endl; return; } diff --git a/source/module_io/write_dos_pw.cpp b/source/module_io/write_dos_pw.cpp index 8560455c8d..218c8e673d 100644 --- a/source/module_io/write_dos_pw.cpp +++ b/source/module_io/write_dos_pw.cpp @@ -75,5 +75,5 @@ void ModuleIO::write_dos_pw( } } - ofs_running << " DOS CALCULATIONS ENDS." << std::endl; + ofs_running << " #DOS CALCULATIONS ENDS# " << std::endl; } diff --git a/source/module_io/write_eig_occ.cpp b/source/module_io/write_eig_occ.cpp new file mode 100644 index 0000000000..0c9c8ddc2f --- /dev/null +++ b/source/module_io/write_eig_occ.cpp @@ -0,0 +1,187 @@ +#include "write_eig_occ.h" + +#include "module_parameter/parameter.h" +#include "source_base/global_function.h" +#include "source_base/global_variable.h" +#include "source_base/timer.h" +#include "source_base/parallel_comm.h" // use POOL_WORLD + +#ifdef __MPI +#include // use MPI_Barrier +#endif + +void ModuleIO::write_eig_iter(const ModuleBase::matrix &ekb,const ModuleBase::matrix &wg, const K_Vectors& kv) +{ + ModuleBase::TITLE("ModuleIO","write_eig_iter"); + ModuleBase::timer::tick("ModuleIO", "write_eig_iter"); + + GlobalV::ofs_running << "\n PRINT #EIGENVALUES# AND #OCCUPATIONS#" << std::endl; + + const int nspin = PARAM.inp.nspin; + const int nks = kv.get_nks(); + const int nkstot = kv.get_nkstot(); + + std::vector ngk_tot = kv.ngk; + +#ifdef __MPI + MPI_Allreduce(MPI_IN_PLACE, ngk_tot.data(), nks, MPI_INT, MPI_SUM, POOL_WORLD); +#endif + + 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; + + for (int is = 0; is < nk_fac; ++is) + { + for (int ip = 0; ip < kpar; ++ip) + { +#ifdef __MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + bool ip_flag = PARAM.inp.out_alllog || (GlobalV::RANK_IN_POOL == 0 && GlobalV::MY_BNDGROUP == 0); + + if (GlobalV::MY_POOL == ip && ip_flag) + { + GlobalV::ofs_running << std::setprecision(8); +// ofs_eig << std::setiosflags(std::ios::showpoint); + + const int start_ik = nks_np * is; + const int end_ik = nks_np * (is + 1); + for (int ik = start_ik; ik < end_ik; ++ik) + { + GlobalV::ofs_running << " spin=" << is+1 << " k-point=" + << kv.ik2iktot[ik] + 1 - is * nkstot_np << std::endl; + + GlobalV::ofs_running << std::setw(8) << "Index" + << std::setw(18) << "Eigenvalues(eV)" + << std::setw(18) << "Occupations" << std::endl; + + for (int ib = 0; ib < ekb.nc; ib++) + { + GlobalV::ofs_running << std::setw(8) << ib + 1 + << std::setw(18) << ekb(ik, ib) * ModuleBase::Ry_to_eV + << std::setw(18) << wg(ik, ib) << std::endl; + } + GlobalV::ofs_running << std::endl; + } + } + } +#ifdef __MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + } + + ModuleBase::timer::tick("ModuleIO", "write_eig_iter"); +} + +void ModuleIO::write_eig_file(const ModuleBase::matrix &ekb,const ModuleBase::matrix &wg, const K_Vectors& kv) +{ + 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; + GlobalV::ofs_running << " | #Print out the eigenvalues and occupations# |" << std::endl; + 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(); + const int nkstot = kv.get_nkstot(); + + bool wrong = false; + + for (int ik = 0; ik < nks; ++ik) + { + for (int ib = 0; ib < ekb.nc; ++ib) + { + if (std::abs(ekb(ik, ib)) > 1.0e10) + { + GlobalV::ofs_warning << " ik=" << ik + 1 << " ib=" << ib + 1 + << " " << ekb(ik, ib) << " Ry" << std::endl; + wrong = true; + } + } + } + +#ifdef __MPI + MPI_Allreduce(MPI_IN_PLACE, &wrong, 1, MPI_C_BOOL, MPI_LOR, MPI_COMM_WORLD); +#endif + if (wrong) + { + ModuleBase::WARNING_QUIT("ModuleIO::write_eig_file", "Eigenvalues are too large!"); + } + + std::vector ngk_tot = kv.ngk; + +#ifdef __MPI + MPI_Allreduce(MPI_IN_PLACE, ngk_tot.data(), nks, MPI_INT, MPI_SUM, POOL_WORLD); +#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; + + if (GlobalV::MY_RANK == 0) + { + std::ofstream ofs_eig0(filename.c_str()); // clear eig.txt + 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 nks_np = nks / nk_fac; + const int nkstot_np = nkstot / nk_fac; + const int kpar = GlobalV::KPAR; + + for (int is = 0; is < nk_fac; ++is) + { + for (int ip = 0; ip < kpar; ++ip) + { +#ifdef __MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + + bool ip_flag = PARAM.inp.out_alllog || (GlobalV::RANK_IN_POOL == 0 && GlobalV::MY_BNDGROUP == 0); + + if (GlobalV::MY_POOL == ip && ip_flag) + { + std::ofstream ofs_eig(filename.c_str(), std::ios::app); + ofs_eig << std::setprecision(8); + ofs_eig << std::setiosflags(std::ios::showpoint); + + const int start_ik = nks_np * is; + const int end_ik = nks_np * (is + 1); + for (int ik = start_ik; ik < end_ik; ++ik) + { + ofs_eig << " spin=" << is+1 << " k-point=" + << kv.ik2iktot[ik] + 1 - is * nkstot_np << "/" << nkstot_np + << " Cartesian=" << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y + << " " << kv.kvec_c[ik].z << " (" << ngk_tot[ik] << " plane wave)" << std::endl; + + ofs_eig << std::setprecision(16); + ofs_eig << std::setiosflags(std::ios::showpoint); + for (int ib = 0; ib < ekb.nc; ib++) + { + ofs_eig << " " << ib + 1 << " " << ekb(ik, ib) * ModuleBase::Ry_to_eV + << " " << wg(ik, ib) << std::endl; + } + ofs_eig << std::endl; + } + + ofs_eig.close(); + } + } +#ifdef __MPI + MPI_Barrier(MPI_COMM_WORLD); +#endif + } + + ModuleBase::timer::tick("ModuleIO", "write_eig_file"); + return; +} diff --git a/source/module_io/write_eig_occ.h b/source/module_io/write_eig_occ.h new file mode 100644 index 0000000000..fe1ffca90c --- /dev/null +++ b/source/module_io/write_eig_occ.h @@ -0,0 +1,18 @@ +#ifndef WRITE_EIG_OCC_H +#define WRITE_EIG_OCC_H +#include "source_base/matrix.h" +#include "source_cell/klist.h" +#include "source_cell/parallel_kpoints.h" + +namespace ModuleIO +{ + void write_eig_iter(const ModuleBase::matrix &ekb, + const ModuleBase::matrix &wg, + const K_Vectors& kv); + + void write_eig_file(const ModuleBase::matrix &ekb, + const ModuleBase::matrix &wg, + const K_Vectors& kv); +} + +#endif diff --git a/source/module_io/write_istate_info.cpp b/source/module_io/write_istate_info.cpp deleted file mode 100644 index 3cb187bf6a..0000000000 --- a/source/module_io/write_istate_info.cpp +++ /dev/null @@ -1,113 +0,0 @@ -#include "write_istate_info.h" - -#include "module_parameter/parameter.h" -#include "source_base/global_function.h" -#include "source_base/global_variable.h" -#include "source_base/timer.h" -#include "source_base/parallel_comm.h" // use POOL_WORLD - -#ifdef __MPI -#include // use MPI_Barrier -#endif - -void ModuleIO::write_istate_info(const ModuleBase::matrix &ekb,const ModuleBase::matrix &wg, const K_Vectors& kv) -{ - ModuleBase::TITLE("ModuleIO","write_istate_info"); - ModuleBase::timer::tick("ModuleIO", "write_istate_info"); - - const int nspin = PARAM.inp.nspin; - const int nks = kv.get_nks(); - const int nkstot = kv.get_nkstot(); - - bool wrong = false; - - for (int ik = 0; ik < nks; ++ik) - { - for (int ib = 0; ib < ekb.nc; ++ib) - { - if (std::abs(ekb(ik, ib)) > 1.0e10) - { - GlobalV::ofs_warning << " ik=" << ik + 1 << " ib=" << ib + 1 - << " " << ekb(ik, ib) << " Ry" << std::endl; - wrong = true; - } - } - } - -#ifdef __MPI - MPI_Allreduce(MPI_IN_PLACE, &wrong, 1, MPI_C_BOOL, MPI_LOR, MPI_COMM_WORLD); -#endif - if (wrong) - { - ModuleBase::WARNING_QUIT("ModuleIO::write_istate_info", "Eigenvalues are too large!"); - } - - std::vector ngk_tot = kv.ngk; - -#ifdef __MPI - MPI_Allreduce(MPI_IN_PLACE, ngk_tot.data(), nks, MPI_INT, MPI_SUM, POOL_WORLD); -#endif - - // file name to store eigenvalues - std::string filename = PARAM.globalv.global_out_dir + "eig.txt"; - GlobalV::ofs_running << " The eigenvalues and occupations are in file: " << filename << std::endl; - - if (GlobalV::MY_RANK == 0) - { - std::ofstream ofs_eig0(filename.c_str()); // clear eig.txt - 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 nks_np = nks / nk_fac; - const int nkstot_np = nkstot / nk_fac; - const int kpar = GlobalV::KPAR; - - for (int is = 0; is < nk_fac; ++is) - { - for (int ip = 0; ip < kpar; ++ip) - { -#ifdef __MPI - MPI_Barrier(MPI_COMM_WORLD); -#endif - - bool ip_flag = PARAM.inp.out_alllog || (GlobalV::RANK_IN_POOL == 0 && GlobalV::MY_BNDGROUP == 0); - - if (GlobalV::MY_POOL == ip && ip_flag) - { - std::ofstream ofs_eig(filename.c_str(), std::ios::app); - ofs_eig << std::setprecision(8); - ofs_eig << std::setiosflags(std::ios::showpoint); - - const int start_ik = nks_np * is; - const int end_ik = nks_np * (is + 1); - for (int ik = start_ik; ik < end_ik; ++ik) - { - ofs_eig << " spin=" << is+1 << " k-point=" - << kv.ik2iktot[ik] + 1 - is * nkstot_np << "/" << nkstot_np - << " Cartesian=" << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y - << " " << kv.kvec_c[ik].z << " (" << ngk_tot[ik] << " plane wave)" << std::endl; - - ofs_eig << std::setprecision(16); - ofs_eig << std::setiosflags(std::ios::showpoint); - for (int ib = 0; ib < ekb.nc; ib++) - { - ofs_eig << " " << ib + 1 << " " << ekb(ik, ib) * ModuleBase::Ry_to_eV - << " " << wg(ik, ib) << std::endl; - } - ofs_eig << std::endl; - } - - ofs_eig.close(); - } - } -#ifdef __MPI - MPI_Barrier(MPI_COMM_WORLD); -#endif - } - - ModuleBase::timer::tick("ModuleIO", "write_istate_info"); - return; -} diff --git a/source/module_io/write_istate_info.h b/source/module_io/write_istate_info.h deleted file mode 100644 index 50eb315793..0000000000 --- a/source/module_io/write_istate_info.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef WRITE_ISTATE_INFO_H -#define WRITE_ISTATE_INFO_H -#include "source_base/matrix.h" -#include "source_cell/klist.h" -#include "source_cell/parallel_kpoints.h" - -namespace ModuleIO -{ - void write_istate_info(const ModuleBase::matrix &ekb, - const ModuleBase::matrix &wg, - const K_Vectors& kv); -} - -#endif diff --git a/source/module_io/write_proj_band_lcao.cpp b/source/module_io/write_proj_band_lcao.cpp index 21dddc051c..868385ffaa 100644 --- a/source/module_io/write_proj_band_lcao.cpp +++ b/source/module_io/write_proj_band_lcao.cpp @@ -21,6 +21,14 @@ void ModuleIO::write_proj_band_lcao( ModuleBase::TITLE("ModuleIO", "write_proj_band_lcao"); ModuleBase::timer::tick("ModuleIO", "write_proj_band_lcao"); + GlobalV::ofs_running << "\n"; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out projected bands (psi in double)# |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + GlobalV::ofs_running << "\n"; + // get the date pointer of SK const double* sk = dynamic_cast*>(p_ham)->getSk(); @@ -100,23 +108,27 @@ void ModuleIO::write_proj_band_lcao( if (GlobalV::MY_RANK == 0) { std::stringstream ps2; - ps2 << PARAM.globalv.global_out_dir << "PBANDS_" << is + 1; - GlobalV::ofs_running << "\n Output projected bands in file: " << ps2.str() << std::endl; + ps2 << PARAM.globalv.global_out_dir << "pbands" << is + 1 << ".xml"; + GlobalV::ofs_running << " Output projected bands are in file: " << ps2.str() << std::endl; std::ofstream out(ps2.str().c_str()); out << "" << std::endl; out << "" << PARAM.inp.nspin << "" << std::endl; - if (PARAM.inp.nspin == 4) { - out << "" << std::setw(2) << PARAM.globalv.nlocal / 2 << "" << std::endl; - } else { - out << "" << std::setw(2) << PARAM.globalv.nlocal << "" << std::endl; -} + if (PARAM.inp.nspin == 4) + { + out << "" << std::setw(2) << PARAM.globalv.nlocal / 2 << "" << std::endl; + } + else + { + out << "" << std::setw(2) << PARAM.globalv.nlocal << "" << std::endl; + } out << "" << std::endl; - for (int ib = 0; ib < PARAM.inp.nbands; ib++) { - out << " " << (pelec->ekb(is * nks, ib)) * ModuleBase::Ry_to_eV; -} - out << std::endl; + for (int ib = 0; ib < PARAM.inp.nbands; ib++) + { + out << " " << (pelec->ekb(is * nks, ib)) * ModuleBase::Ry_to_eV; + } + out << std::endl; out << "" << std::endl; for (int i = 0; i < ucell.nat; i++) @@ -182,11 +194,20 @@ void ModuleIO::write_proj_band_lcao( ModuleBase::TITLE("ModuleIO", "write_proj_band_lcao"); ModuleBase::timer::tick("ModuleIO", "write_proj_band_lcao"); + GlobalV::ofs_running << "\n"; + GlobalV::ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " | #Print out projected bands (psi in complex)# |" << std::endl; + GlobalV::ofs_running << " | |" << std::endl; + GlobalV::ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + GlobalV::ofs_running << "\n"; + int nspin0 = 1; - if (PARAM.inp.nspin == 2) { - nspin0 = 2; -} - int nks = 0; + if (PARAM.inp.nspin == 2) + { + nspin0 = 2; + } + int nks = 0; if (nspin0 == 1) { nks = kv.get_nkstot(); @@ -292,8 +313,8 @@ void ModuleIO::write_proj_band_lcao( if (GlobalV::MY_RANK == 0) { std::stringstream ps2; - ps2 << PARAM.globalv.global_out_dir << "PBANDS_" << is + 1; - GlobalV::ofs_running << "\n Output projected bands in file: " << ps2.str() << std::endl; + ps2 << PARAM.globalv.global_out_dir << "pbands" << is + 1 << ".xml"; + GlobalV::ofs_running << " Output projected bands in file: " << ps2.str() << std::endl; std::ofstream out(ps2.str().c_str()); out << "" << std::endl; diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index b240135d97..e80f66f1ec 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -364,7 +364,6 @@ struct Input_para 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 int out_wfc_pw = 0; ///< 0: no; 1: txt; 2: dat - int printe = 0; ///< Print out energy for each band for every printe step, default is scf_nmax std::vector out_band = {0, 8}; ///< band calculation pengfei 2014-10-13 int out_dos = 0; ///< dos calculation. mohan add 20090909 std::vector out_ldos = {0, 3}; ///< ldos calculation diff --git a/source/module_relax/bfgs.cpp b/source/module_relax/bfgs.cpp index ff11659449..147798817a 100644 --- a/source/module_relax/bfgs.cpp +++ b/source/module_relax/bfgs.cpp @@ -71,7 +71,6 @@ void BFGS::relax_step(const ModuleBase::matrix& _force,UnitCell& ucell) this->IsRestrain(dpos); // print out geometry information during bfgs_trad relax unitcell::print_tau(ucell.atoms,ucell.Coordinate,ucell.ntype,ucell.lat0,GlobalV::ofs_running); - // } void BFGS::GetPos(UnitCell& ucell,std::vector>& pos) diff --git a/source/module_relax/lbfgs.cpp b/source/module_relax/lbfgs.cpp index 75351ef79a..156e04bd33 100644 --- a/source/module_relax/lbfgs.cpp +++ b/source/module_relax/lbfgs.cpp @@ -4,6 +4,7 @@ #include "module_parameter/parameter.h" #include "ions_move_basic.h" #include "source_cell/update_cell.h" +#include "source_cell/print_cell.h" // mohan add 2025-06-19 void LBFGS::allocate(const int _size) // initialize H0、H、pos0、force0、force { @@ -64,6 +65,8 @@ void LBFGS::relax_step(const ModuleBase::matrix _force,UnitCell& ucell,const dou this->update_pos(ucell); this->calculate_largest_grad(_force,ucell); this->is_restrain(dpos); + // mohan add 2025-06-22 + unitcell::print_tau(ucell.atoms,ucell.Coordinate,ucell.ntype,ucell.lat0,GlobalV::ofs_running); } void LBFGS::get_pos(UnitCell& ucell,std::vector>& pos) diff --git a/source/source_cell/cal_atoms_info.h b/source/source_cell/cal_atoms_info.h index 97ab717c06..2baf5391ce 100644 --- a/source/source_cell/cal_atoms_info.h +++ b/source/source_cell/cal_atoms_info.h @@ -66,6 +66,7 @@ class CalAtomsInfo nelec_spin[1] = (para.inp.nelec - para.inp.nupdown ) / 2.0; } elecstate::cal_nbands(para.inp.nelec, para.sys.nlocal, nelec_spin, para.input.nbands); + // calculate the number of nbands_local para.sys.nbands_l = para.inp.nbands; if (para.inp.ks_solver == "bpcg") // only bpcg support band parallel @@ -84,4 +85,4 @@ class CalAtomsInfo return; } }; -#endif \ No newline at end of file +#endif diff --git a/source/source_cell/k_vector_utils.cpp b/source/source_cell/k_vector_utils.cpp index db80488979..0b7754ae92 100644 --- a/source/source_cell/k_vector_utils.cpp +++ b/source/source_cell/k_vector_utils.cpp @@ -242,18 +242,18 @@ void kvec_mpi_k(K_Vectors& kv) kv.nks = kv.para_k.nks_pool[GlobalV::MY_POOL]; GlobalV::ofs_running << std::endl; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "k-point number in this process", kv.nks); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of k-points in this process", kv.nks); int nks_minimum = kv.nks; Parallel_Reduce::gather_min_int_all(GlobalV::NPROC, nks_minimum); if (nks_minimum == 0) { - ModuleBase::WARNING_QUIT("K_Vectors::mpi_k()", " nks == 0, some processor have no k point!"); + ModuleBase::WARNING_QUIT("K_Vectors::mpi_k()", " nks == 0, some processor have no k points!"); } else { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "minimum distributed K point number", nks_minimum); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Minimum distributed k-point number", nks_minimum); } std::vector isk_aux(kv.nkstot); @@ -421,10 +421,9 @@ void kvec_ibz_kpoint(K_Vectors& kv, ucell.atoms, false, nullptr); - GlobalV::ofs_running << "\n For reciprocal-space lattice:" << std::endl; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "BRAVAIS TYPE", recip_brav_type); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "BRAVAIS LATTICE NAME", recip_brav_name); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "ibrav", recip_brav_type); + GlobalV::ofs_running << "\n For reciprocal-space lattice" << std::endl; + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Bravais lattice type", recip_brav_type); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Bravais lattice name", recip_brav_name); // the map of bravis lattice from real to reciprocal space // for example, 3(fcc) in real space matches 2(bcc) in reciprocal space @@ -466,10 +465,9 @@ void kvec_ibz_kpoint(K_Vectors& kv, ucell.atoms, false, nullptr); - GlobalV::ofs_running << "\n For k vectors:" << std::endl; - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "BRAVAIS TYPE", k_brav_type); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "BRAVAIS LATTICE NAME", k_brav_name); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "ibrav", k_brav_type); + GlobalV::ofs_running << "\n For k-vectors" << std::endl; + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Bravais lattice type", k_brav_type); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Bravais lattice name", k_brav_name); } // point-group analysis of reciprocal lattice ModuleBase::Matrix3 bsymop[48]; @@ -543,7 +541,7 @@ void kvec_ibz_kpoint(K_Vectors& kv, nrotkm = 2 * symm.nrotk; } } - else if (kv.get_is_mp()) // only include for mp grid + else if (kv.get_is_mp()) // only include for Monkhorst-Pack grid { nrotkm = 2; kgmatrix[0] = ind; @@ -780,10 +778,10 @@ void kvec_ibz_kpoint(K_Vectors& kv, } ss << table << std::endl; skpt = ss.str(); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "nkstot_ibz", nkstot_ibz); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "Number of irreducible k-points", nkstot_ibz); table.clear(); - table += "\n K-POINTS REDUCTION ACCORDING TO SYMMETRY:\n"; + table += "\n K-POINTS REDUCTION ACCORDING TO SYMMETRY\n"; table += FmtCore::format("%8s%12s%12s%12s%8s%8s\n", "IBZ", "DIRECT_X", "DIRECT_Y", "DIRECT_Z", "WEIGHT", "ibz2bz"); for (int ik = 0; ik < nkstot_ibz; ik++) { diff --git a/source/source_cell/klist.cpp b/source/source_cell/klist.cpp index 6742ad8f1d..8b7b6f0b37 100644 --- a/source/source_cell/klist.cpp +++ b/source/source_cell/klist.cpp @@ -50,16 +50,16 @@ void K_Vectors::set(const UnitCell& ucell, { ModuleBase::TITLE("K_Vectors", "set"); - ofs << "\n\n"; + ofs << "\n"; ofs << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; ofs << " | |" << std::endl; - ofs << " | Setup K-points |" << std::endl; + ofs << " | #Setup K-points# |" << std::endl; ofs << " | We setup the k-points according to input parameters. |" << std::endl; ofs << " | The reduced k-points are set according to symmetry operations. |" << std::endl; ofs << " | We treat the spin as another set of k-points. |" << std::endl; ofs << " | |" << std::endl; ofs << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; - ofs << "\n\n"; + ofs << "\n"; ofs << "\n SETUP K-POINTS" << std::endl; @@ -626,4 +626,4 @@ void K_Vectors::set_kup_and_kdw() } return; -} // end subroutine set_kup_and_kdw \ No newline at end of file +} // end subroutine set_kup_and_kdw diff --git a/source/source_cell/module_neighbor/sltk_atom_arrange.cpp b/source/source_cell/module_neighbor/sltk_atom_arrange.cpp index f22bc6e657..5f88c9a3e8 100644 --- a/source/source_cell/module_neighbor/sltk_atom_arrange.cpp +++ b/source/source_cell/module_neighbor/sltk_atom_arrange.cpp @@ -40,20 +40,20 @@ double atom_arrange::set_sr_NL(std::ofstream& ofs_in, ofs_in << "\n\n"; ofs_in << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; ofs_in << " | |" << std::endl; - ofs_in << " | Search adjacent atoms: |" << std::endl; + ofs_in << " | #Search Adjacent Atoms# |" << std::endl; ofs_in << " | Set the adjacent atoms for each atom and set the periodic boundary |" << std::endl; ofs_in << " | condition for the atoms on real space FFT grid. For k-dependent |" << std::endl; ofs_in << " | algorithm, we also need to set the sparse H and S matrix element |" << std::endl; ofs_in << " | for each atom. |" << std::endl; ofs_in << " | |" << std::endl; ofs_in << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; - ofs_in << "\n\n"; + ofs_in << "\n"; - ofs_in << "\n SETUP SEARCHING RADIUS FOR PROGRAM TO SEARCH ADJACENT ATOMS" << std::endl; + ofs_in << " SETUP SEARCHING RADIUS" << std::endl; ofs_in << std::setprecision(3); - ModuleBase::GlobalFunc::OUT(ofs_in, "longest orb rcut (Bohr)", rcutmax_Phi); - ModuleBase::GlobalFunc::OUT(ofs_in, "longest nonlocal projector rcut (Bohr)", rcutmax_Beta); - ModuleBase::GlobalFunc::OUT(ofs_in, "search radius (Bohr)", sr); + ModuleBase::GlobalFunc::OUT(ofs_in, "Orbital max radius cutoff (Bohr)", rcutmax_Phi); + ModuleBase::GlobalFunc::OUT(ofs_in, "Nonlocal proj. max radius cutoff (Bohr)", rcutmax_Beta); + ModuleBase::GlobalFunc::OUT(ofs_in, "Search radius (Bohr)", sr); } return sr; } @@ -75,8 +75,8 @@ void atom_arrange::search(const bool pbc_flag, } ofs_in << " SEARCH ADJACENT ATOMS" << std::endl; - ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius is (Bohr)", search_radius_bohr); - ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius unit is (Bohr)", ucell.lat0); + ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius (Bohr)", search_radius_bohr); +// ModuleBase::GlobalFunc::OUT(ofs_in, "searching radius unit is (Bohr)", ucell.lat0); assert(ucell.nat > 0); diff --git a/source/source_cell/module_neighbor/sltk_grid.cpp b/source/source_cell/module_neighbor/sltk_grid.cpp index 9b1d86b957..61e6e4a1aa 100644 --- a/source/source_cell/module_neighbor/sltk_grid.cpp +++ b/source/source_cell/module_neighbor/sltk_grid.cpp @@ -16,22 +16,22 @@ Grid::~Grid() void Grid::init(std::ofstream& ofs_in, const UnitCell& ucell, const double radius_in, const bool boundary) { - ModuleBase::TITLE("SLTK_Grid", "init"); - ModuleBase::timer::tick("atom_arrange", "grid_d.init"); + ModuleBase::TITLE("Grid", "init"); + ModuleBase::timer::tick("Grid", "init"); this->pbc = boundary; this->sradius2 = radius_in * radius_in; this->sradius = radius_in; - ModuleBase::GlobalFunc::OUT(ofs_in, "PeriodicBoundary", this->pbc); - ModuleBase::GlobalFunc::OUT(ofs_in, "Radius(unit:lat0)", sradius); +// ModuleBase::GlobalFunc::OUT(ofs_in, "PeriodicBoundary", this->pbc); + ModuleBase::GlobalFunc::OUT(ofs_in, "Radius (unit: lattice constant)", sradius); this->Check_Expand_Condition(ucell); - ModuleBase::GlobalFunc::OUT(ofs_in, "glayer", glayerX, glayerY, glayerZ); - ModuleBase::GlobalFunc::OUT(ofs_in, "glayer_minus", glayerX_minus, glayerY_minus, glayerZ_minus); + ModuleBase::GlobalFunc::OUT(ofs_in, "Max number of cells", glayerX, glayerY, glayerZ); + ModuleBase::GlobalFunc::OUT(ofs_in, "Min number of cells", glayerX_minus, glayerY_minus, glayerZ_minus); this->setMemberVariables(ofs_in, ucell); this->Construct_Adjacent(ucell); - ModuleBase::timer::tick("atom_arrange", "grid_d.init"); + ModuleBase::timer::tick("Grid", "init"); } void Grid::Check_Expand_Condition(const UnitCell& ucell) @@ -196,9 +196,9 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs } } - ofs_in << " RANGE OF ATOMIC COORDINATES (unit: lat0)" << std::endl; - ModuleBase::GlobalFunc::OUT(ofs_in, "smallest coordinates of atoms", x_min, y_min, z_min); - ModuleBase::GlobalFunc::OUT(ofs_in, "largest coordinates of atoms", x_max, y_max, z_max); +// ofs_in << " RANGE OF ATOMIC COORDINATES (unit: lat0)" << std::endl; + ModuleBase::GlobalFunc::OUT(ofs_in, "Min coordinates of atoms", x_min, y_min, z_min); + ModuleBase::GlobalFunc::OUT(ofs_in, "Max coordinates of atoms", x_max, y_max, z_max); this->box_edge_length = sradius + 0.1; // To avoid edge cases, the size of the box is slightly increased. @@ -221,7 +221,7 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs this->box_nx = glayerX + glayerX_minus; this->box_ny = glayerY + glayerY_minus; this->box_nz = glayerZ + glayerZ_minus; - ModuleBase::GlobalFunc::OUT(ofs_in, "number of needed cells", box_nx, box_ny, box_nz); + ModuleBase::GlobalFunc::OUT(ofs_in, "Number of needed cells", box_nx, box_ny, box_nz); atoms_in_box.resize(this->box_nx); for (int i = 0; i < this->box_nx; i++) diff --git a/source/source_cell/module_neighbor/test/sltk_atom_arrange_test.cpp b/source/source_cell/module_neighbor/test/sltk_atom_arrange_test.cpp index 7a1eeb8084..b8ac024e19 100644 --- a/source/source_cell/module_neighbor/test/sltk_atom_arrange_test.cpp +++ b/source/source_cell/module_neighbor/test/sltk_atom_arrange_test.cpp @@ -100,10 +100,10 @@ TEST_F(SltkAtomArrangeTest, setsrNL) std::string test2, s; ifs.open("./to_test_arrange.txt"); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - EXPECT_THAT(str, testing::HasSubstr("longest orb rcut (Bohr) = 1")); - EXPECT_THAT(str, testing::HasSubstr("longest nonlocal projector rcut (Bohr) = 2")); + EXPECT_THAT(str, testing::HasSubstr("Orbital max radius cutoff (Bohr) = 1")); + EXPECT_THAT(str, testing::HasSubstr("Nonlocal proj. max radius cutoff (Bohr) = 2")); ifs.close(); - remove("./to_test_arrange"); + //remove("./to_test_arrange"); } TEST_F(SltkAtomArrangeTest, Search) diff --git a/source/source_cell/module_symmetry/symm_analysis.cpp b/source/source_cell/module_symmetry/symm_analysis.cpp index 43d200a4df..b375864388 100644 --- a/source/source_cell/module_symmetry/symm_analysis.cpp +++ b/source/source_cell/module_symmetry/symm_analysis.cpp @@ -11,10 +11,10 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms, ModuleBase::TITLE("Symmetry","analy_sys"); ModuleBase::timer::tick("Symmetry","analy_sys"); - ofs_running << "\n\n\n\n"; + ofs_running << "\n\n"; ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; ofs_running << " | |" << std::endl; - ofs_running << " | Performing symmetry analysis: |" << std::endl; + ofs_running << " | #Symmetry Analysis# |" << std::endl; ofs_running << " | We calculate the norm of 3 vectors and the angles between them, |" << std::endl; ofs_running << " | the type of Bravais lattice is given. We can judge if the unticell |" << std::endl; ofs_running << " | is a primitive cell. Finally we give the point group operation for |" << std::endl; @@ -22,7 +22,7 @@ void Symmetry::analy_sys(const Lattice& lat, const Statistics& st, Atom* atoms, ofs_running << " | symmetry analysis on given k-point mesh and the charge density. |" << std::endl; ofs_running << " | |" << std::endl; ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; - ofs_running << "\n\n\n\n"; + ofs_running << "\n"; // -------------------------------- // 1. copy data and allocate memory diff --git a/source/source_cell/module_symmetry/symm_lattice.cpp b/source/source_cell/module_symmetry/symm_lattice.cpp index 7ab5388b5e..d541aaf833 100644 --- a/source/source_cell/module_symmetry/symm_lattice.cpp +++ b/source/source_cell/module_symmetry/symm_lattice.cpp @@ -305,7 +305,7 @@ void Symmetry::lattice_type( //---------------------------------------------- const bool right = Symm_Other::right_hand_sense(v1, v2, v3); - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"RIGHT HAND LATTICE",right); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Right-handed lattice",right); //------------------------------------------------- // (2) save and copy the original lattice vectors. diff --git a/source/source_cell/module_symmetry/symmetry_basic.cpp b/source/source_cell/module_symmetry/symmetry_basic.cpp index 955e2a2157..dbbb3650f8 100644 --- a/source/source_cell/module_symmetry/symmetry_basic.cpp +++ b/source/source_cell/module_symmetry/symmetry_basic.cpp @@ -428,7 +428,7 @@ void Symmetry_Basic::setgroup(ModuleBase::Matrix3* symop, int &nop, const int &i if(test_brav) { - ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"ROTATION MATRICES",nop); + ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running,"Number of rotation matrices",nop); } if(PARAM.inp.test_symmetry > 1) diff --git a/source/source_cell/print_cell.cpp b/source/source_cell/print_cell.cpp index 5580f28f23..b9c3abdf21 100644 --- a/source/source_cell/print_cell.cpp +++ b/source/source_cell/print_cell.cpp @@ -28,7 +28,7 @@ namespace unitcell // print atom positions //---------------------- std::string table; - table += direct? " DIRECT COORDINATES\n": FmtCore::format(" CARTESIAN COORDINATES ( UNIT = %15.8f Bohr ).\n", lat0); + table += direct? " DIRECT COORDINATES\n": FmtCore::format(" CARTESIAN COORDINATES ( UNIT = %15.8f Bohr )\n", lat0); table += FmtCore::format("%5s%19s%19s%19s%8s\n", "atom", "x", "y", "z", "mag"); for(int it = 0; it < ntype; it++) { diff --git a/source/source_cell/read_atom_species.cpp b/source/source_cell/read_atom_species.cpp index 1ff82d3667..0389091131 100644 --- a/source/source_cell/read_atom_species.cpp +++ b/source/source_cell/read_atom_species.cpp @@ -22,7 +22,7 @@ bool read_atom_species(std::ifstream& ifa, //========================================== if( ModuleBase::GlobalFunc::SCAN_LINE_BEGIN(ifa, "ATOMIC_SPECIES") ) { - ModuleBase::GlobalFunc::OUT(ofs_running,"ntype",ntype); + ModuleBase::GlobalFunc::OUT(ofs_running,"Number of elements",ntype); for (int i = 0;i < ntype;i++) { std::string one_line; @@ -138,11 +138,11 @@ bool read_lattice_constant(std::ifstream& ifa, ModuleBase::GlobalFunc::READ_VALUE(ifa, lat0); if(lat0<=0.0) { - ModuleBase::WARNING_QUIT("read_atom_species","lattice constant <= 0.0"); + ModuleBase::WARNING_QUIT("read_atom_species","Lattice constant <= 0.0"); } lat0_angstrom = lat0 * 0.529177; - ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Bohr)",lat0); - ModuleBase::GlobalFunc::OUT(ofs_running,"lattice constant (Angstrom)",lat0_angstrom); + ModuleBase::GlobalFunc::OUT(ofs_running,"Lattice constant (Bohr)",lat0); + ModuleBase::GlobalFunc::OUT(ofs_running,"Lattice constant (Angstrom)",lat0_angstrom); lat.tpiba = ModuleBase::TWO_PI / lat0; lat.tpiba2 = lat.tpiba * lat.tpiba; } diff --git a/source/source_cell/read_atoms.cpp b/source/source_cell/read_atoms.cpp index a33825ada1..2727a4a926 100644 --- a/source/source_cell/read_atoms.cpp +++ b/source/source_cell/read_atoms.cpp @@ -80,7 +80,7 @@ bool unitcell::read_atom_positions(UnitCell& ucell, ofs_warning << " Label from ATOMIC_SPECIES is " << ucell.atom_label[it] << std::endl; return false; } - ModuleBase::GlobalFunc::OUT(ofs_running, "atom label", ucell.atoms[it].label); + ModuleBase::GlobalFunc::OUT(ofs_running, "Atom label", ucell.atoms[it].label); bool set_element_mag_zero = false; ModuleBase::GlobalFunc::READ_VALUE(ifpos, ucell.magnet.start_mag[it]); @@ -132,7 +132,7 @@ bool unitcell::read_atom_positions(UnitCell& ucell, ModuleBase::GlobalFunc::READ_VALUE(ifpos, na); ucell.atoms[it].na = na; - ModuleBase::GlobalFunc::OUT(ofs_running,"number of atom for this type",na); + ModuleBase::GlobalFunc::OUT(ofs_running,"Number of atoms for this type",na); ucell.nat += na; @@ -369,7 +369,7 @@ bool unitcell::read_atom_positions(UnitCell& ucell, { //use a stringstream to generate string: "concollinear magnetization of element it is:" std::stringstream ss; - ss << "magnetization of element " << it+1; + ss << "Magnetization for this type"; if(ia!=0) { ss<<" (atom"<1e-6) - {error++; std::cout<<"warning_quit! error chi function 1 !"<1e-6) - {error++; std::cout<<"warning_quit! error chi function 2 !"<1e-6) - {error++; std::cout<<"warning_quit! error chi function 1 !"<1e-6) - {error++; std::cout<<"warning_quit! error chi function 2 !"<> temp; } -} \ No newline at end of file +} diff --git a/source/source_cell/read_pp_vwr.cpp b/source/source_cell/read_pp_vwr.cpp index 68ef04fd81..b6e0e7847e 100644 --- a/source/source_cell/read_pp_vwr.cpp +++ b/source/source_cell/read_pp_vwr.cpp @@ -19,7 +19,6 @@ int Pseudopot_upf::read_pseudo_vwr(std::ifstream &ifs, Atom_pseudo& pp) std::cout << " READ IN VWR TYPE PSEUDOPOTENTIALS." << std::endl; GlobalV::ofs_running << " Read in vwr type pseudopotentials " << std::endl; - // -------------------------------------- // (1) read in data // -------------------------------------- diff --git a/source/source_cell/setup_nonlocal.cpp b/source/source_cell/setup_nonlocal.cpp index 5a31200b17..17db44b209 100644 --- a/source/source_cell/setup_nonlocal.cpp +++ b/source/source_cell/setup_nonlocal.cpp @@ -200,7 +200,7 @@ void InfoNonlocal::Read_NonLocal(const int& it, } else { - // GlobalV::ofs_running << " open nonLocal pseudopotential file: " << nonlocal_file[it] << std::endl; +// GlobalV::ofs_running << " Open nonlocal pseudopotential file: " << nonlocalFile << std::endl; } std::string label; @@ -241,8 +241,6 @@ void InfoNonlocal::Read_NonLocal(const int& it, { if (nlmax == atom->ncpp.lll[ic]) { - // std::cout << " nlmax = " << nlmax << std::endl; - // std::cout << " lchi = " << atom->lll[ic] << std::endl; find_lmax = true; break; } @@ -260,9 +258,7 @@ void InfoNonlocal::Read_NonLocal(const int& it, } } - // OUT(GlobalV::ofs_running,"Type",it); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "label", label); - // OUT(GlobalV::ofs_running,"ps_type",ps_type); ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "nlmax", nlmax); //------------------------------------------- @@ -273,8 +269,6 @@ void InfoNonlocal::Read_NonLocal(const int& it, ModuleBase::matrix coefficient_D_in(nproj_allowed, nproj_allowed); ModuleBase::ComplexMatrix coefficient_D_nc_in(nproj_allowed * 2, nproj_allowed * 2); - // OUT(GlobalV::ofs_running,"nproj_allowed",nproj_allowed); - if (my_rank == 0) { if (ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "")) @@ -298,8 +292,6 @@ void InfoNonlocal::Read_NonLocal(const int& it, ifs >> coefficient_D_in(L1_read, L2_read); - // GlobalV::ofs_running << " L1=" << L1_read << " L2=" << L2_read << " Coef=" << - // coefficient_D_in(L1_read,L2_read) << std::endl; } } ModuleBase::GlobalFunc::SCAN_END(ifs, ""); @@ -308,7 +300,6 @@ void InfoNonlocal::Read_NonLocal(const int& it, #ifdef __MPI Parallel_Common::bcast_int(n_projectors); // mohan add 2010-12-20 -// Parallel_Common::bcast_double(coefficient_D_in.c, coefficient_D_in.nr * coefficient_D_in.nc); #endif Numerical_Nonlocal_Lm* tmpBeta_lm = new Numerical_Nonlocal_Lm[n_projectors]; @@ -347,8 +338,6 @@ void InfoNonlocal::Read_NonLocal(const int& it, } } // end my_rank==0 - // OUT(GlobalV::ofs_running,"meshr_ps",meshr_ps); - #ifdef __MPI Parallel_Common::bcast_int(meshr_ps); Parallel_Common::bcast_int(LfromBeta[p1]); @@ -377,9 +366,7 @@ void InfoNonlocal::Read_NonLocal(const int& it, Parallel_Common::bcast_double(rab_ps, meshr_ps); #endif - // OUT(GlobalV::ofs_running,"radial_ps max",radial_ps[meshr_ps-1]); - // std::cout << this->kmesh << std::endl; tmpBeta_lm[p1].set_NL_proj(label, it, // type LfromBeta[p1], // angular momentum L @@ -391,9 +378,10 @@ void InfoNonlocal::Read_NonLocal(const int& it, dk, dr_uniform); // delta k mesh in reciprocal space - if (PARAM.inp.out_element_info) { - tmpBeta_lm[p1].plot(my_rank); -} + if (PARAM.inp.out_element_info) + { + tmpBeta_lm[p1].plot(my_rank); + } delete[] radial_ps; delete[] rab_ps; @@ -463,9 +451,10 @@ void InfoNonlocal::setupNonlocal(const int& ntype, Atom* atoms, std::ofstream& l this->rcutmax_Beta = std::max(this->rcutmax_Beta, this->Beta[it].get_rcut_max()); } - log << " max number of nonlocal projetors among all species is " << this->nprojmax << std::endl; + ModuleBase::GlobalFunc::OUT(log, "Max number of nonlocal projectors (all elements)", this->nprojmax); + } return; } -#endif \ No newline at end of file +#endif diff --git a/source/source_cell/test/unitcell_test.cpp b/source/source_cell/test/unitcell_test.cpp index 54d2a1f3fb..24f1ca8bf4 100644 --- a/source/source_cell/test/unitcell_test.cpp +++ b/source/source_cell/test/unitcell_test.cpp @@ -1202,17 +1202,17 @@ TEST_F(UcellTestReadStru, ReadLatticeConstantWarning1) std::string fn = "./support/STRU_MgO_Warning2"; std::ifstream ifa(fn.c_str()); std::ofstream ofs_running; - ofs_running.open("read_atom_species.tmp"); + ofs_running.open("read_atom_species1.tmp"); ucell->ntype = 2; ucell->atoms = new Atom[ucell->ntype]; ucell->set_atom_flag = true; testing::internal::CaptureStdout(); EXPECT_EXIT(unitcell::read_lattice_constant(ifa, ofs_running,ucell->lat), ::testing::ExitedWithCode(1), ""); output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("lattice constant <= 0.0")); + EXPECT_THAT(output, testing::HasSubstr("Lattice constant <= 0.0")); ofs_running.close(); ifa.close(); - remove("read_atom_species.tmp"); + remove("read_atom_species1.tmp"); } TEST_F(UcellTestReadStru, ReadLatticeConstantWarning2) diff --git a/source/source_cell/test/unitcell_test_readpp.cpp b/source/source_cell/test/unitcell_test_readpp.cpp index 4aa1228275..b9a9c2d281 100644 --- a/source/source_cell/test/unitcell_test_readpp.cpp +++ b/source/source_cell/test/unitcell_test_readpp.cpp @@ -201,14 +201,14 @@ TEST_F(UcellTest, ReadCellPP) { std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); EXPECT_THAT(str, - testing::HasSubstr("Read in pseudopotential file is C.upf")); - EXPECT_THAT(str, testing::HasSubstr("pseudopotential type = NC")); + testing::HasSubstr("Pseudopotential file = C.upf")); + EXPECT_THAT(str, testing::HasSubstr("Pseudopotential type = NC")); EXPECT_THAT(str, - testing::HasSubstr("exchange-correlation functional = PBE")); - EXPECT_THAT(str, testing::HasSubstr("valence electrons = 4")); + testing::HasSubstr("Exchange-correlation functional = PBE")); + EXPECT_THAT(str, testing::HasSubstr("Valence electrons = 4")); EXPECT_THAT(str, - testing::HasSubstr("Read in pseudopotential file is H.upf")); - EXPECT_THAT(str, testing::HasSubstr("valence electrons = 0")); + testing::HasSubstr("Pseudopotential file = H.upf")); + EXPECT_THAT(str, testing::HasSubstr("Valence electrons = 0")); } TEST_F(UcellTest, CalMeshx) { @@ -461,7 +461,7 @@ TEST_F(UcellTest, CalNbandsLCAOINPW) testing::internal::CaptureStdout(); EXPECT_EXIT(elecstate::cal_nbands(PARAM.input.nelec, PARAM.sys.nlocal, nelec_spin, PARAM.input.nbands), ::testing::ExitedWithCode(1), ""); output = testing::internal::GetCapturedStdout(); - EXPECT_THAT(output, testing::HasSubstr("NLOCAL < NBANDS")); + EXPECT_THAT(output, testing::HasSubstr("Number of basis (NLOCAL) < Number of electronic states (NBANDS)")); } TEST_F(UcellTest, CalNbandsWarning1) diff --git a/source/source_cell/unitcell.cpp b/source/source_cell/unitcell.cpp old mode 100755 new mode 100644 index d003418feb..337eab349b --- a/source/source_cell/unitcell.cpp +++ b/source/source_cell/unitcell.cpp @@ -220,46 +220,20 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) if (ok) { log << "\n\n"; - log << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - ">>>>>>>>>>>>" - << std::endl; - log << " | " - " |" - << std::endl; - log << " | Reading atom information in unitcell: " - " |" - << std::endl; - log << " | From the input file and the structure file we know the " - "number of |" - << std::endl; - log << " | different elments in this unitcell, then we list the " - "detail |" - << std::endl; - log << " | information for each element, especially the zeta and " - "polar atomic |" - << std::endl; - log << " | orbital number for each element. The total atom number " - "is counted. |" - << std::endl; - log << " | We calculate the nearest atom distance for each atom " - "and show the |" - << std::endl; - log << " | Cartesian and Direct coordinates for each atom. We list " - "the file |" - << std::endl; - log << " | address for atomic orbitals. The volume and the lattice " - "vectors |" - << std::endl; - log << " | in real and reciprocal space is also shown. " - " |" - << std::endl; - log << " | " - " |" - << std::endl; - log << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - "<<<<<<<<<<<<" - << std::endl; - log << "\n\n"; + log << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << std::endl; + log << " | |" << std::endl; + log << " | #Setup Unitcell# |" << std::endl; + log << " | From the input file and the structure file we know the number of |" << std::endl; + log << " | different elments in this unitcell, then we list the detail |" << std::endl; + log << " | information for each element, especially the zeta and polar atomic |" << std::endl; + log << " | orbital number for each element. The total atom number is counted. |" << std::endl; + log << " | We calculate the nearest atom distance for each atom and show the |" << std::endl; + log << " | Cartesian and Direct coordinates for each atom. We list the file |" << std::endl; + log << " | address for atomic orbitals. The volume and the lattice vectors |" << std::endl; + log << " | in real and reciprocal space is also shown. |" << std::endl; + log << " | |" << std::endl; + log << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl; + log << "\n"; log << " READING UNITCELL INFORMATION" << std::endl; //======================== @@ -322,9 +296,8 @@ void UnitCell::setup_cell(const std::string& fn, std::ofstream& log) } else { - log << std::endl; - ModuleBase::GlobalFunc::OUT(log, "Volume (Bohr^3)", this->omega); - ModuleBase::GlobalFunc::OUT(log, "Volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3)); + ModuleBase::GlobalFunc::OUT(log, "Cell volume (Bohr^3)", this->omega); + ModuleBase::GlobalFunc::OUT(log, "Cell volume (A^3)", this->omega * pow(ModuleBase::BOHR_TO_A, 3)); } //========================================================== diff --git a/source/source_cell/update_cell.cpp b/source/source_cell/update_cell.cpp index 723f765d31..95b2f50c47 100644 --- a/source/source_cell/update_cell.cpp +++ b/source/source_cell/update_cell.cpp @@ -294,9 +294,8 @@ void setup_cell_after_vc(UnitCell& ucell, std::ofstream& log) { { ModuleBase::WARNING_QUIT("setup_cell_after_vc", "Cell volume <= 0 ."); } else { - log << std::endl; - ModuleBase::GlobalFunc::OUT(log, "Volume (Bohr^3)", ucell.omega); - ModuleBase::GlobalFunc::OUT(log, "Volume (A^3)", + ModuleBase::GlobalFunc::OUT(log, "Cell volume (Bohr^3)", ucell.omega); + ModuleBase::GlobalFunc::OUT(log, "Cell volume (A^3)", ucell.omega * pow(ModuleBase::BOHR_TO_A, 3)); } diff --git a/source/source_esolver/esolver.cpp b/source/source_esolver/esolver.cpp index 44247224de..bac35d027b 100644 --- a/source/source_esolver/esolver.cpp +++ b/source/source_esolver/esolver.cpp @@ -96,7 +96,7 @@ std::string determine_type() ModuleBase::WARNING_QUIT("ESolver", "No such esolver_type combined with basis_type"); } - GlobalV::ofs_running << "\n Energy Solver:" << esolver_type << std::endl; + GlobalV::ofs_running << "\n #ENERGY SOLVER# " << esolver_type << std::endl; auto device_info = PARAM.inp.device; diff --git a/source/source_esolver/esolver_dp.cpp b/source/source_esolver/esolver_dp.cpp index bb9666aeaf..169242a4f9 100644 --- a/source/source_esolver/esolver_dp.cpp +++ b/source/source_esolver/esolver_dp.cpp @@ -148,7 +148,7 @@ void ESolver_DP::cal_stress(UnitCell& ucell, ModuleBase::matrix& stress) void ESolver_DP::after_all_runners(UnitCell& ucell) { - GlobalV::ofs_running << "\n\n --------------------------------------------" << std::endl; + GlobalV::ofs_running << "\n --------------------------------------------" << std::endl; GlobalV::ofs_running << std::setprecision(16); GlobalV::ofs_running << " !FINAL_ETOT_IS " << dp_potential * ModuleBase::Ry_to_eV << " eV" << std::endl; GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl; diff --git a/source/source_esolver/esolver_fp.cpp b/source/source_esolver/esolver_fp.cpp index a60e49e3ae..cf4cff7dd0 100644 --- a/source/source_esolver/esolver_fp.cpp +++ b/source/source_esolver/esolver_fp.cpp @@ -444,7 +444,7 @@ void ESolver_FP::iter_finish(UnitCell& ucell, const int istep, int& iter, bool& void ESolver_FP::after_all_runners(UnitCell& ucell) { - GlobalV::ofs_running << "\n\n --------------------------------------------" << std::endl; + GlobalV::ofs_running << "\n --------------------------------------------" << std::endl; GlobalV::ofs_running << std::setprecision(16); GlobalV::ofs_running << " !FINAL_ETOT_IS " << this->pelec->f_en.etot * ModuleBase::Ry_to_eV << " eV" << std::endl; GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl; diff --git a/source/source_esolver/esolver_ks.cpp b/source/source_esolver/esolver_ks.cpp index 46f295ee36..2efe9ae727 100644 --- a/source/source_esolver/esolver_ks.cpp +++ b/source/source_esolver/esolver_ks.cpp @@ -20,7 +20,7 @@ // for output log information #include "module_io/output_log.h" #include "module_io/print_info.h" -#include "module_io/write_istate_info.h" +#include "module_io/write_eig_occ.h" // for jason output information #include "module_io/json_output/init_info.h" #include "module_io/json_output/output_info.h" @@ -331,31 +331,32 @@ void ESolver_KS::iter_init(UnitCell& ucell, const int istep, const in template void ESolver_KS::iter_finish(UnitCell& ucell, const int istep, int& iter, bool &conv_esolver) { - //---------------------------------------------------------------- - // 1) print out band gap - //---------------------------------------------------------------- - if (PARAM.inp.out_bandgap) - { - if (!PARAM.globalv.two_fermi) - { - this->pelec->cal_bandgap(); - } - else - { - this->pelec->cal_bandgap_updw(); - } - } - for (int ik = 0; ik < this->kv.get_nks(); ++ik) - { - elecstate::print_band(this->pelec->ekb, - this->pelec->wg, - this->pelec->klist, - ik, - PARAM.inp.printe, - iter, - GlobalV::ofs_running); - } + if(iter % PARAM.inp.out_freq_elec == 0) + { + //---------------------------------------------------------------- + // 1) print out band gap + //---------------------------------------------------------------- + if (PARAM.inp.out_bandgap) + { + if (!PARAM.globalv.two_fermi) + { + this->pelec->cal_bandgap(); + } + else + { + this->pelec->cal_bandgap_updw(); + } + } + + //---------------------------------------------------------------- + // 2) print out eigenvalues and occupations + //---------------------------------------------------------------- + if (PARAM.inp.out_band[0] || iter == PARAM.inp.scf_nmax || conv_esolver) + { + ModuleIO::write_eig_iter(this->pelec->ekb,this->pelec->wg,*this->pelec->klist); + } + } //---------------------------------------------------------------- // 2) compute magnetization, only for LSDA(spin==2) @@ -502,7 +503,8 @@ void ESolver_KS::iter_finish(UnitCell& ucell, const int istep, int& i } // pint energy - elecstate::print_etot(ucell.magnet, *pelec,conv_esolver, iter, drho, dkin, duration, PARAM.inp.printe, diag_ethr); + elecstate::print_etot(ucell.magnet, *pelec,conv_esolver, iter, drho, + dkin, duration, diag_ethr); #ifdef __RAPIDJSON @@ -565,7 +567,7 @@ void ESolver_KS::after_all_runners(UnitCell& ucell) ESolver_FP::after_all_runners(ucell); // 2) write eigenvalue information - ModuleIO::write_istate_info(this->pelec->ekb, this->pelec->wg, this->kv); + ModuleIO::write_eig_file(this->pelec->ekb, this->pelec->wg, this->kv); // 3) write band information if (PARAM.inp.out_band[0]) @@ -575,7 +577,6 @@ void ESolver_KS::after_all_runners(UnitCell& ucell) { std::stringstream ss2; ss2 << PARAM.globalv.global_out_dir << "eigs" << is + 1 << ".txt"; - GlobalV::ofs_running << "\n Eigenvalues for plot are saved in file: " << ss2.str() << std::endl; const double eshift = 0.0; ModuleIO::nscf_band(is, ss2.str(), diff --git a/source/source_esolver/esolver_ks_lcao.cpp b/source/source_esolver/esolver_ks_lcao.cpp index 37c8575bc8..f44d07f697 100644 --- a/source/source_esolver/esolver_ks_lcao.cpp +++ b/source/source_esolver/esolver_ks_lcao.cpp @@ -400,7 +400,7 @@ void ESolver_KS_LCAO::after_all_runners(UnitCell& ucell) ModuleIO::write_proj_band_lcao(this->psi, this->pv, this->pelec, this->kv, ucell, this->p_hamilt); } - // out ldos + // 2) out ldos if (PARAM.inp.out_ldos[0]) { ModuleIO::Cal_ldos::cal_ldos_lcao(reinterpret_cast*>(this->pelec), @@ -409,7 +409,7 @@ void ESolver_KS_LCAO::after_all_runners(UnitCell& ucell) ucell); } - // 6) print out exchange-correlation potential + // 3) print out exchange-correlation potential if (PARAM.inp.out_mat_xc) { ModuleIO::write_Vxc(PARAM.inp.nspin, @@ -437,6 +437,7 @@ void ESolver_KS_LCAO::after_all_runners(UnitCell& ucell) #endif ); } + if (PARAM.inp.out_mat_xc2) { ModuleIO::write_Vxc_R(PARAM.inp.nspin, @@ -461,7 +462,7 @@ void ESolver_KS_LCAO::after_all_runners(UnitCell& ucell) ); } - // 7) write eband terms + // write eband terms if (PARAM.inp.out_eband_terms) { ModuleIO::write_eband_terms(PARAM.inp.nspin, diff --git a/source/source_esolver/esolver_ks_lcaopw.cpp b/source/source_esolver/esolver_ks_lcaopw.cpp index d9ddcdb52c..6fcd503e01 100644 --- a/source/source_esolver/esolver_ks_lcaopw.cpp +++ b/source/source_esolver/esolver_ks_lcaopw.cpp @@ -2,7 +2,6 @@ #include "module_hamilt_pw/hamilt_pwdft/elecond.h" #include "module_io/input_conv.h" -#include "module_io/nscf_band.h" #include "module_io/output_log.h" #include diff --git a/source/source_esolver/esolver_lj.cpp b/source/source_esolver/esolver_lj.cpp index 70976ac205..996d4095b5 100644 --- a/source/source_esolver/esolver_lj.cpp +++ b/source/source_esolver/esolver_lj.cpp @@ -120,7 +120,7 @@ void ESolver_LJ::runner(UnitCell& ucell, const int istep) void ESolver_LJ::after_all_runners(UnitCell& ucell) { - GlobalV::ofs_running << "\n\n --------------------------------------------" << std::endl; + GlobalV::ofs_running << "\n --------------------------------------------" << std::endl; GlobalV::ofs_running << std::setprecision(16); GlobalV::ofs_running << " !FINAL_ETOT_IS " << lj_potential * ModuleBase::Ry_to_eV << " eV" << std::endl; GlobalV::ofs_running << " --------------------------------------------\n\n" << std::endl; diff --git a/source/source_esolver/esolver_of_tool.cpp b/source/source_esolver/esolver_of_tool.cpp index efa3980b8f..37ff15fbfa 100644 --- a/source/source_esolver/esolver_of_tool.cpp +++ b/source/source_esolver/esolver_of_tool.cpp @@ -425,8 +425,8 @@ void ESolver_OF::print_info(const bool conv_esolver) std::vector titles; std::vector energies_Ry; std::vector energies_eV; - if ((PARAM.inp.printe > 0 && - ((this->iter_ + 1) % PARAM.inp.printe == 0 || + if ((PARAM.inp.out_band[0] > 0 && + ((this->iter_ + 1) % PARAM.inp.out_band[0] == 0 || conv_esolver || this->iter_ == PARAM.inp.scf_nmax)) || PARAM.inp.init_chg == "file") diff --git a/source/source_esolver/esolver_sdft_pw.cpp b/source/source_esolver/esolver_sdft_pw.cpp index f8bd9d1864..6775f4b8b3 100644 --- a/source/source_esolver/esolver_sdft_pw.cpp +++ b/source/source_esolver/esolver_sdft_pw.cpp @@ -8,7 +8,6 @@ #include "module_hamilt_pw/hamilt_stodft/sto_forces.h" #include "module_hamilt_pw/hamilt_stodft/sto_stress_pw.h" #include "source_hsolver/diago_iter_assist.h" -#include "module_io/write_istate_info.h" #include "module_parameter/parameter.h" #include diff --git a/source/source_esolver/pw_others.cpp b/source/source_esolver/pw_others.cpp index 53556d229b..e9bda0e8eb 100644 --- a/source/source_esolver/pw_others.cpp +++ b/source/source_esolver/pw_others.cpp @@ -3,7 +3,6 @@ #include "source_base/global_variable.h" #include "module_hamilt_pw/hamilt_pwdft/elecond.h" #include "module_io/input_conv.h" -#include "module_io/nscf_band.h" #include "module_io/output_log.h" #include diff --git a/source/source_esolver/test/esolver_dp_test.cpp b/source/source_esolver/test/esolver_dp_test.cpp index 513e0a9d74..5010c9ccf4 100644 --- a/source/source_esolver/test/esolver_dp_test.cpp +++ b/source/source_esolver/test/esolver_dp_test.cpp @@ -166,7 +166,7 @@ TEST_F(ESolverDPTest, Postprocess) GlobalV::ofs_running.close(); std::string expected_output - = "\n\n --------------------------------------------\n !FINAL_ETOT_IS 133.3358404000000235 eV\n " + = "\n --------------------------------------------\n !FINAL_ETOT_IS 133.3358404000000235 eV\n " "--------------------------------------------\n\n\n"; std::ifstream ifs("log"); std::string output((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); diff --git a/tests/01_PW/083_PW_sol_H2/INPUT b/tests/01_PW/083_PW_sol_H2/INPUT index c2ef3d4335..f0a5f54268 100644 --- a/tests/01_PW/083_PW_sol_H2/INPUT +++ b/tests/01_PW/083_PW_sol_H2/INPUT @@ -13,8 +13,8 @@ ecutwfc 20 scf_nmax 50 #Parameters (Solvation Model) -imp_sol 1 -eb_k 80 -tau 0.000010798 -sigma_k 0.6 -nc_k 0.00037 +imp_sol 1 +eb_k 80 +tau 0.000010798 +sigma_k 0.6 +nc_k 0.00037 diff --git a/tests/01_PW/084_PW_sol_H2O/INPUT b/tests/01_PW/084_PW_sol_H2O/INPUT index 94d7e0e357..8b1175fe87 100644 --- a/tests/01_PW/084_PW_sol_H2O/INPUT +++ b/tests/01_PW/084_PW_sol_H2O/INPUT @@ -1,22 +1,21 @@ INPUT_PARAMETERS -#Parameters (General) -suffix autotest -pseudo_dir ../../PP_ORB -nbands 20 calculation scf basis_type pw -cal_force 1 - -#Parameters (Accuracy) +pw_seed 1 +cal_force 1 +nbands 20 ecutwfc 20 scf_nmax 50 #Parameters (Solvation Model) -imp_sol 1 -eb_k 80 -tau 0.000010798 -sigma_k 0.6 -nc_k 0.00037 +imp_sol 1 +eb_k 80 +tau 0.000010798 +sigma_k 0.6 +nc_k 0.00037 + -pw_seed 1 +#Parameters (General) +suffix autotest +pseudo_dir ../../PP_ORB diff --git a/tests/03_NAO_multik/22_NO_KP_OTdH/dhrxs1.csr.ref b/tests/03_NAO_multik/22_NO_KP_OTdH/dhrxs1_nao.csr.ref similarity index 100% rename from tests/03_NAO_multik/22_NO_KP_OTdH/dhrxs1.csr.ref rename to tests/03_NAO_multik/22_NO_KP_OTdH/dhrxs1_nao.csr.ref diff --git a/tests/03_NAO_multik/22_NO_KP_OTdH/dhrys1.csr.ref b/tests/03_NAO_multik/22_NO_KP_OTdH/dhrys1_nao.csr.ref similarity index 100% rename from tests/03_NAO_multik/22_NO_KP_OTdH/dhrys1.csr.ref rename to tests/03_NAO_multik/22_NO_KP_OTdH/dhrys1_nao.csr.ref diff --git a/tests/03_NAO_multik/22_NO_KP_OTdH/dhrzs1.csr.ref b/tests/03_NAO_multik/22_NO_KP_OTdH/dhrzs1_nao.csr.ref similarity index 100% rename from tests/03_NAO_multik/22_NO_KP_OTdH/dhrzs1.csr.ref rename to tests/03_NAO_multik/22_NO_KP_OTdH/dhrzs1_nao.csr.ref diff --git a/tests/integrate/tools/catch_properties.sh b/tests/integrate/tools/catch_properties.sh index 44be939584..6b88b326b5 100755 --- a/tests/integrate/tools/catch_properties.sh +++ b/tests/integrate/tools/catch_properties.sh @@ -358,11 +358,11 @@ fi #----------------------------------- #echo $has_mat_dh if ! test -z "$has_mat_dh" && [ $has_mat_dh == 1 ]; then - python3 $COMPARE_SCRIPT dhrxs1.csr.ref OUT.autotest/dhrxs1.csr 8 + python3 $COMPARE_SCRIPT dhrxs1_nao.csr.ref OUT.autotest/dhrxs1_nao.csr 8 echo "ComparerdHRx_pass $?" >>$1 - python3 $COMPARE_SCRIPT dhrys1.csr.ref OUT.autotest/dhrys1.csr 8 + python3 $COMPARE_SCRIPT dhrys1_nao.csr.ref OUT.autotest/dhrys1_nao.csr 8 echo "ComparerdHRy_pass $?" >>$1 - python3 $COMPARE_SCRIPT dhrzs1.csr.ref OUT.autotest/dhrzs1.csr 8 + python3 $COMPARE_SCRIPT dhrzs1_nao.csr.ref OUT.autotest/dhrzs1_nao.csr 8 echo "ComparerdHRz_pass $?" >>$1 fi @@ -559,7 +559,7 @@ bash ${script_dir}/catch_deepks_properties.sh $1 if ! test -z "$symmetry" && [ $symmetry == 1 ]; then pointgroup=`grep 'POINT GROUP' $running_path | tail -n 2 | head -n 1 | awk '{print $4}'` spacegroup=`grep 'SPACE GROUP' $running_path | tail -n 1 | awk '{print $7}'` - nksibz=`grep ' nkstot_ibz ' $running_path | awk '{print $3}'` + nksibz=`grep 'Number of irreducible k-points' $running_path | awk '{print $6}'` echo "pointgroupref $pointgroup" >>$1 echo "spacegroupref $spacegroup" >>$1 echo "nksibzref $nksibz" >>$1