diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 407bda3d6e..bfc5f023b9 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -496,7 +496,6 @@ OBJS_IO=input_conv.o\ td_current_io.o\ write_wfc_r.o\ output_log.o\ - output_potential.o\ output_mat_sparse.o\ para_json.o\ abacusjson.o\ diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 2ac69e7080..3ed8aa347b 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -687,30 +687,6 @@ bool ESolver_KS::get_conv_elec() return this->conv_elec; } -//------------------------------------------------------------------------------ -//! the 15th function of ESolver_KS: create_Output_Potential -//! mohan add 2024-05-12 -//------------------------------------------------------------------------------ -template -ModuleIO::Output_Potential ESolver_KS::create_Output_Potential(int iter, const std::string& prefix) -{ - const int precision = 3; - std::string tag = "POT"; - return ModuleIO::Output_Potential(this->pw_big, - this->pw_rhod, - GlobalV::NSPIN, - iter, - GlobalV::out_pot, - this->pelec->pot->get_effective_v(), - this->pelec->pot->get_fixed_v(), - &(GlobalC::ucell), - pelec->charge, - precision, - GlobalV::global_out_dir, - tag, - prefix); -} - //------------------------------------------------------------------------------ //! the 16th-20th functions of ESolver_KS //! mohan add 2024-05-12 diff --git a/source/module_esolver/esolver_ks.h b/source/module_esolver/esolver_ks.h index 11e09cbb43..6765275552 100644 --- a/source/module_esolver/esolver_ks.h +++ b/source/module_esolver/esolver_ks.h @@ -8,7 +8,6 @@ #include "module_hamilt_pw/hamilt_pwdft/wavefunc.h" #include "module_hsolver/hsolver.h" #include "module_io/cal_test.h" -#include "module_io/output_potential.h" #include "module_psi/psi.h" #include @@ -104,9 +103,6 @@ class ESolver_KS : public ESolver_FP const int istep, const int iter); - /// @brief create a new ModuleIO::Output_Potential object to print potential - ModuleIO::Output_Potential create_Output_Potential(int iter, const std::string& prefix = "None"); - //! Solve Hamitonian hsolver::HSolver* phsol = nullptr; diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index e665a88ee1..6ef25b4ca4 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -13,6 +13,7 @@ #include "module_io/write_HS.h" #include "module_io/write_eband_terms.hpp" #include "module_io/write_istate_info.h" +#include "module_io/write_pot.h" #include "module_io/write_proj_band_lcao.h" #include "module_io/write_vxc.hpp" #include "module_parameter/parameter.h" @@ -1186,7 +1187,47 @@ void ESolver_KS_LCAO::after_scf(const int istep) #endif // 6) write potential - this->create_Output_Potential(istep).write(); + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::string fn = GlobalV::global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + + ModuleIO::write_cube( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, +#endif + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + istep, + fn, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 3, // precision + 0); // out_fermi + } + } + else if (PARAM.inp.out_pot == 2) + { + std::string fn = GlobalV::global_out_dir + "/ElecStaticPot.cube"; + ModuleIO::write_elecstat_pot( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, +#endif + fn, + this->pw_rhod, + this->pelec->charge, + &(GlobalC::ucell), + this->pelec->pot->get_fixed_v()); + } // 7) write convergence ModuleIO::output_convergence_after_scf(this->conv_elec, this->pelec->f_en.etot); diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 0d9bae2f05..6dd73ed37d 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -221,6 +221,7 @@ void ESolver_KS_PW::before_scf(const int istep) //! calculate the total local pseudopotential in real space this->pelec->init_scf(istep, this->sf.strucFac); + //! output the initial charge density if (PARAM.inp.out_chg == 2) { for (int is = 0; is < GlobalV::NSPIN; is++) @@ -231,35 +232,50 @@ void ESolver_KS_PW::before_scf(const int istep) #ifdef __MPI this->pw_big->bz, this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif this->pelec->charge->rho[is], is, GlobalV::NSPIN, 0, ss.str(), - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, this->pelec->eferm.ef, &(GlobalC::ucell)); } } - ModuleIO::write_pot(GlobalV::out_pot, - GlobalV::NSPIN, - GlobalV::global_out_dir, + //! output total local potential of the initial charge density + if (PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::stringstream ss; + ss << GlobalV::global_out_dir << "SPIN" << is + 1 << "_POT_INI.cube"; + ModuleIO::write_cube( #ifdef __MPI - this->pw_big->bz, - this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pelec->pot->get_effective_v()); + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + 0, // iter + ss.str(), + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 11, // precsion + 0); // out_fermi + } + } //! Symmetry_rho should behind init_scf, because charge should be //! initialized first. liuyu comment: Symmetry_rho should be located between @@ -518,7 +534,47 @@ void ESolver_KS_PW::after_scf(const int istep) // 1) call after_scf() of ESolver_FP ESolver_FP::after_scf(istep); - this->create_Output_Potential(istep).write(); + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::string fn = GlobalV::global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + + ModuleIO::write_cube( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, +#endif + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + istep, + fn, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 3, // precision + 0); // out_fermi + } + } + else if (PARAM.inp.out_pot == 2) + { + std::string fn = GlobalV::global_out_dir + "/ElecStaticPot.cube"; + ModuleIO::write_elecstat_pot( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, +#endif + fn, + this->pw_rhod, + this->pelec->charge, + &(GlobalC::ucell), + this->pelec->pot->get_fixed_v()); + } if (PARAM.inp.out_chg) { @@ -707,17 +763,17 @@ void ESolver_KS_PW::after_scf(const int istep) #ifdef __MPI this->pw_big->bz, this->pw_big->nbz, - this->pw_big->nplane, - this->pw_big->startz_current, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif rho_band, 0, GlobalV::NSPIN, 0, ssc.str(), - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, 0.0, &(GlobalC::ucell)); } diff --git a/source/module_esolver/esolver_of.cpp b/source/module_esolver/esolver_of.cpp index 3aa874911e..cc4ab23dd3 100644 --- a/source/module_esolver/esolver_of.cpp +++ b/source/module_esolver/esolver_of.cpp @@ -516,47 +516,49 @@ void ESolver_OF::after_opt(const int istep, UnitCell& ucell) #ifdef __MPI this->pw_big->bz, this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif this->pelec->charge->rho[is], is, GlobalV::NSPIN, - this->iter_, + istep, ssc.str(), - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, this->mu_[is], &(ucell), 3, 1); } - if (GlobalV::out_pot == 1 || GlobalV::out_pot == 3) // output the effective potential, sunliang 2023-03-16 + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) // output the effective potential, sunliang 2023-03-16 { - int precision = 3; // be consistent with esolver_ks_lcao.cpp - std::stringstream ssp; - ssp << GlobalV::global_out_dir << "SPIN" << is + 1 << "_POT.cube"; - ModuleIO::write_pot_spin( - GlobalV::out_pot, + std::string fn = GlobalV::global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + + ModuleIO::write_cube( #ifdef __MPI this->pw_big->bz, this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif + this->pelec->pot->get_effective_v(is), is, - 0, - ssp.str(), - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pelec->pot->get_effective_v(), - precision); + GlobalV::NSPIN, + istep, + fn, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(ucell), + 3, // precision + 0); // out_fermi } } - if (GlobalV::out_pot == 2) // output the static electronic potential, sunliang 2023-08-11 + if (PARAM.inp.out_pot == 2) // output the static electronic potential, sunliang 2023-08-11 { int precision = 3; std::stringstream ssp; @@ -567,7 +569,7 @@ void ESolver_OF::after_opt(const int istep, UnitCell& ucell) this->pw_big->nbz, #endif ssp.str(), - this->pw_rho, + this->pw_rhod, this->pelec->charge, &(ucell), this->pelec->pot->get_fixed_v()); diff --git a/source/module_esolver/esolver_sdft_pw.cpp b/source/module_esolver/esolver_sdft_pw.cpp index 143792a4e1..87606369dd 100644 --- a/source/module_esolver/esolver_sdft_pw.cpp +++ b/source/module_esolver/esolver_sdft_pw.cpp @@ -159,17 +159,17 @@ void ESolver_SDFT_PW::after_scf(const int istep) #ifdef __MPI pw_big->bz, pw_big->nbz, - pw_rho->nplane, - pw_rho->startz_current, + pw_rhod->nplane, + pw_rhod->startz_current, #endif pelec->charge->rho_save[is], is, GlobalV::NSPIN, 0, ssc.str(), - pw_rho->nx, - pw_rho->ny, - pw_rho->nz, + pw_rhod->nx, + pw_rhod->ny, + pw_rhod->nz, ef_tmp, &(GlobalC::ucell)); } diff --git a/source/module_esolver/lcao_before_scf.cpp b/source/module_esolver/lcao_before_scf.cpp index 0b22280dbd..a76dcd3f9e 100644 --- a/source/module_esolver/lcao_before_scf.cpp +++ b/source/module_esolver/lcao_before_scf.cpp @@ -217,6 +217,8 @@ void ESolver_KS_LCAO::before_scf(const int istep) #endif // __EXX this->pelec->init_scf(istep, this->sf.strucFac); + + //! output the initial charge density if (PARAM.inp.out_chg == 2) { for (int is = 0; is < GlobalV::NSPIN; is++) @@ -227,35 +229,50 @@ void ESolver_KS_LCAO::before_scf(const int istep) #ifdef __MPI this->pw_big->bz, // bz first, then nbz this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif this->pelec->charge->rho[is], is, GlobalV::NSPIN, 0, ss.str(), - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, this->pelec->eferm.ef, &(GlobalC::ucell)); } } - ModuleIO::write_pot(GlobalV::out_pot, - GlobalV::NSPIN, - GlobalV::global_out_dir, + //! output total local potential of the initial charge density + if (PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::stringstream ss; + ss << GlobalV::global_out_dir << "SPIN" << is + 1 << "_POT_INI.cube"; + ModuleIO::write_cube( #ifdef __MPI - this->pw_big->bz, - this->pw_big->nbz, - this->pw_rho->nplane, - this->pw_rho->startz_current, + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, #endif - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pelec->pot->get_effective_v()); + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + 0, // iter + ss.str(), + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 11, // precsion + 0); // out_fermi + } + } // initalize DMR // DMR should be same size with Hamiltonian(R) diff --git a/source/module_esolver/lcao_nscf.cpp b/source/module_esolver/lcao_nscf.cpp index f04a7af130..a528e39635 100644 --- a/source/module_esolver/lcao_nscf.cpp +++ b/source/module_esolver/lcao_nscf.cpp @@ -8,11 +8,13 @@ #include "module_cell/module_neighbor/sltk_atom_arrange.h" #include "module_cell/module_neighbor/sltk_grid_driver.h" #include "module_io/berryphase.h" +#include "module_io/cube_io.h" #include "module_io/get_pchg.h" #include "module_io/get_wf.h" #include "module_io/to_wannier90_lcao.h" #include "module_io/to_wannier90_lcao_in_pw.h" #include "module_io/write_HS_R.h" +#include "module_io/write_pot.h" #include "module_parameter/parameter.h" #ifdef __DEEPKS #include "module_hamilt_lcao/module_deepks/LCAO_deepks.h" @@ -193,7 +195,47 @@ void ESolver_KS_LCAO::nscf() { } /// write potential - this->create_Output_Potential(0).write(); + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::string fn = GlobalV::global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + + ModuleIO::write_cube( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, +#endif + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + istep, + fn, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 3, // precision + 0); // out_fermi + } + } + else if (PARAM.inp.out_pot == 2) + { + std::string fn = GlobalV::global_out_dir + "/ElecStaticPot.cube"; + ModuleIO::write_elecstat_pot( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, +#endif + fn, + this->pw_rhod, + this->pelec->charge, + &(GlobalC::ucell), + this->pelec->pot->get_fixed_v()); + } // write wfc if (PARAM.inp.out_wfc_lcao) diff --git a/source/module_esolver/lcao_others.cpp b/source/module_esolver/lcao_others.cpp index 8e167507b7..08a6ebaeec 100644 --- a/source/module_esolver/lcao_others.cpp +++ b/source/module_esolver/lcao_others.cpp @@ -91,75 +91,82 @@ void ESolver_KS_LCAO::others(const int istep) if (GlobalV::CALCULATION == "nscf") { this->nscf(); - } else if (cal_type == "get_pchg") { + } + else if (cal_type == "get_pchg") + { std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "getting partial charge"); IState_Charge ISC(this->psi, &(this->pv)); - if (GlobalV::GAMMA_ONLY_LOCAL) { + if (GlobalV::GAMMA_ONLY_LOCAL) + { ISC.begin(this->GG, - this->pelec->charge->rho, - this->pelec->wg, - this->pelec->eferm.get_all_ef(), - this->pw_rho->nrxx, - this->pw_rho->nplane, - this->pw_rho->startz_current, - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pw_big->bz, - this->pw_big->nbz, - GlobalV::GAMMA_ONLY_LOCAL, - PARAM.inp.nbands_istate, - PARAM.inp.bands_to_print, - GlobalV::NBANDS, - GlobalV::nelec, - GlobalV::NSPIN, - GlobalV::NLOCAL, - GlobalV::global_out_dir, - GlobalV::MY_RANK, - GlobalV::ofs_warning, - &GlobalC::ucell, - &GlobalC::GridD, - this->kv); - } else { + this->pelec->charge->rho, + this->pelec->wg, + this->pelec->eferm.get_all_ef(), + this->pw_rhod->nrxx, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + this->pw_big->bz, + this->pw_big->nbz, + GlobalV::GAMMA_ONLY_LOCAL, + PARAM.inp.nbands_istate, + PARAM.inp.bands_to_print, + GlobalV::NBANDS, + GlobalV::nelec, + GlobalV::NSPIN, + GlobalV::NLOCAL, + GlobalV::global_out_dir, + GlobalV::MY_RANK, + GlobalV::ofs_warning, + &GlobalC::ucell, + &GlobalC::GridD, + this->kv); + } + else + { ISC.begin(this->GK, - this->pelec->charge->rho, - this->pelec->charge->rhog, - this->pelec->wg, - this->pelec->eferm.get_all_ef(), - this->pw_rho, - this->pw_rho->nrxx, - this->pw_rho->nplane, - this->pw_rho->startz_current, - this->pw_rho->nx, - this->pw_rho->ny, - this->pw_rho->nz, - this->pw_big->bz, - this->pw_big->nbz, - GlobalV::GAMMA_ONLY_LOCAL, - PARAM.inp.nbands_istate, - PARAM.inp.bands_to_print, - GlobalV::NBANDS, - GlobalV::nelec, - GlobalV::NSPIN, - GlobalV::NLOCAL, - GlobalV::global_out_dir, - GlobalV::MY_RANK, - GlobalV::ofs_warning, - &GlobalC::ucell, - &GlobalC::GridD, - this->kv, - PARAM.inp.if_separate_k, - &GlobalC::Pgrid, - this->pelec->charge->ngmc); + this->pelec->charge->rho, + this->pelec->charge->rhog, + this->pelec->wg, + this->pelec->eferm.get_all_ef(), + this->pw_rhod, + this->pw_rhod->nrxx, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + this->pw_big->bz, + this->pw_big->nbz, + GlobalV::GAMMA_ONLY_LOCAL, + PARAM.inp.nbands_istate, + PARAM.inp.bands_to_print, + GlobalV::NBANDS, + GlobalV::nelec, + GlobalV::NSPIN, + GlobalV::NLOCAL, + GlobalV::global_out_dir, + GlobalV::MY_RANK, + GlobalV::ofs_warning, + &GlobalC::ucell, + &GlobalC::GridD, + this->kv, + PARAM.inp.if_separate_k, + &GlobalC::Pgrid, + this->pelec->charge->ngmc); } std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "getting partial charge"); - } else if (cal_type == "get_wf") { + } + else if (cal_type == "get_wf") + { std::cout << FmtCore::format("\n * * * * * *\n << Start %s.\n", "getting wave function"); IState_Envelope IEP(this->pelec); if (GlobalV::GAMMA_ONLY_LOCAL) { IEP.begin(this->psi, - this->pw_rho, + this->pw_rhod, this->pw_wfc, this->pw_big, this->pv, @@ -178,7 +185,7 @@ void ESolver_KS_LCAO::others(const int istep) else { IEP.begin(this->psi, - this->pw_rho, + this->pw_rhod, this->pw_wfc, this->pw_big, this->pv, @@ -195,7 +202,9 @@ void ESolver_KS_LCAO::others(const int istep) GlobalV::global_out_dir); } std::cout << FmtCore::format(" >> Finish %s.\n * * * * * *\n", "getting wave function"); - } else { + } + else + { ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::others", "CALCULATION type not supported"); } diff --git a/source/module_esolver/pw_nscf.cpp b/source/module_esolver/pw_nscf.cpp index 88c29cc04c..7a87ab67b4 100644 --- a/source/module_esolver/pw_nscf.cpp +++ b/source/module_esolver/pw_nscf.cpp @@ -1,7 +1,7 @@ #include "esolver_ks_pw.h" - #include "module_base/global_variable.h" #include "module_hamilt_pw/hamilt_pwdft/elecond.h" +#include "module_io/cube_io.h" #include "module_io/input_conv.h" #include "module_io/nscf_band.h" #include "module_io/output_log.h" @@ -160,7 +160,47 @@ void ESolver_KS_PW::nscf() { } /// write potential - this->create_Output_Potential(0).write(); + if (PARAM.inp.out_pot == 1 || PARAM.inp.out_pot == 3) + { + for (int is = 0; is < GlobalV::NSPIN; is++) + { + std::string fn = GlobalV::global_out_dir + "/SPIN" + std::to_string(is + 1) + "_POT.cube"; + + ModuleIO::write_cube( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, + this->pw_rhod->nplane, + this->pw_rhod->startz_current, +#endif + this->pelec->pot->get_effective_v(is), + is, + GlobalV::NSPIN, + 0, + fn, + this->pw_rhod->nx, + this->pw_rhod->ny, + this->pw_rhod->nz, + 0.0, // efermi + &(GlobalC::ucell), + 3, // precision + 0); // out_fermi + } + } + else if (PARAM.inp.out_pot == 2) + { + std::string fn = GlobalV::global_out_dir + "/ElecStaticPot.cube"; + ModuleIO::write_elecstat_pot( +#ifdef __MPI + this->pw_big->bz, + this->pw_big->nbz, +#endif + fn, + this->pw_rhod, + this->pelec->charge, + &(GlobalC::ucell), + this->pelec->pot->get_fixed_v()); + } ModuleBase::timer::tick("ESolver_KS_PW", "nscf"); return; diff --git a/source/module_io/CMakeLists.txt b/source/module_io/CMakeLists.txt index 408d6cbe14..f97a3ce012 100644 --- a/source/module_io/CMakeLists.txt +++ b/source/module_io/CMakeLists.txt @@ -24,7 +24,6 @@ list(APPEND objects td_current_io.cpp write_wfc_r.cpp output_log.cpp - output_potential.cpp para_json.cpp parse_args.cpp ) diff --git a/source/module_io/output_potential.cpp b/source/module_io/output_potential.cpp deleted file mode 100644 index 8694213c5f..0000000000 --- a/source/module_io/output_potential.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "output_potential.h" -#include "write_pot.h" - -namespace ModuleIO -{ - -Output_Potential::Output_Potential(const ModulePW::PW_Basis_Big* pw_big, - ModulePW::PW_Basis* pw_rho, - int nspin, - int iter, - int out_pot, - const ModuleBase::matrix& v_effective, - const double* v_effective_fixed, - const UnitCell* ucell, - const Charge* const charge, - int precision, - const std::string directory, - const std::string tag, - const std::string prefix) - : _pw_big(pw_big), - _pw_rho(pw_rho), - _nspin(nspin), - _iter(iter), - _out_pot(out_pot), - _v_effective(v_effective), - _v_effective_fixed(v_effective_fixed), - _ucell(ucell), - _charge(charge), - _precision(precision), - _directory(directory), - _prefix(prefix), - _tag(tag) -{ - _fn_ElecStatic = _directory + "/" + "ElecStaticPot.cube"; -} - -void Output_Potential::write() -{ - if (_out_pot == 1 || _out_pot == 3) - { - for (int is = 0; is < _nspin; is++) - { - if (_prefix != "None") - { - _fn_Pot = _directory + "/" + _prefix + "SPIN" + std::to_string(is + 1) + "_" + _tag + ".cube"; - } - else - { - _fn_Pot = _directory + "/SPIN" + std::to_string(is + 1) + "_" + _tag + ".cube"; - } - ModuleIO::write_pot_spin( - _out_pot, // mohan add 2024-06-09 -#ifdef __MPI - _pw_big->bz, - _pw_big->nbz, - _pw_rho->nplane, - _pw_rho->startz_current, -#endif - is, - _iter, - _fn_Pot, - _pw_rho->nx, - _pw_rho->ny, - _pw_rho->nz, - _v_effective, - _precision); - } - } - else if (_out_pot == 2) - { - ModuleIO::write_elecstat_pot( -#ifdef __MPI - _pw_big->bz, - _pw_big->nbz, -#endif - _fn_ElecStatic, - _pw_rho, - _charge, - _ucell, - _v_effective_fixed); // output 'Hartree + local pseudopot' - } -} - -} // namespace ModuleIO diff --git a/source/module_io/output_potential.h b/source/module_io/output_potential.h deleted file mode 100644 index e315f78c05..0000000000 --- a/source/module_io/output_potential.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef OUTPUT_POTENTIAL_H -#define OUTPUT_POTENTIAL_H - -#include "module_basis/module_pw/pw_basis.h" -#include "module_cell/unitcell.h" -#include "module_elecstate/module_charge/charge.h" - -#include - -namespace ModuleIO -{ - -/// @brief the output interface to write the potential -class Output_Potential -{ - public: - Output_Potential(const ModulePW::PW_Basis_Big* pw_big, - ModulePW::PW_Basis* pw_rho, - int nspin, - int iter, - int out_pot, - const ModuleBase::matrix& v_effective, - const double* v_effective_fixed, - const UnitCell* ucell, - const Charge* const charge, - int precision, - const std::string directory, - const std::string tag, - const std::string prefix = "None"); - void write(); - - private: - const ModulePW::PW_Basis_Big* _pw_big; - ModulePW::PW_Basis* _pw_rho; - int _nspin; - int _iter; - int _out_pot; - const ModuleBase::matrix& _v_effective; - const double* _v_effective_fixed; - const UnitCell* _ucell; - const Charge* const _charge; - int _precision; - const std::string _directory; - const std::string _prefix; - const std::string _tag; - std::string _fn_Pot; - std::string _fn_ElecStatic; -}; - -} // namespace ModuleIO - -#endif \ No newline at end of file diff --git a/source/module_io/write_pot.cpp b/source/module_io/write_pot.cpp index d309117365..bd574ab33b 100644 --- a/source/module_io/write_pot.cpp +++ b/source/module_io/write_pot.cpp @@ -11,115 +11,6 @@ namespace ModuleIO { -void write_pot( - const int &out_pot, - const int &nspin, - const std::string &global_out_dir, -#ifdef __MPI - const int& bz, - const int& nbz, - const int& nplane, - const int& startz_current, -#endif - const int& nx, - const int& ny, - const int& nz, - const ModuleBase::matrix& v) -{ - ModuleBase::TITLE("ModuleIO", "write_pot"); - if(out_pot == 3) - { - for(int is = 0; is < nspin; is++) - { - std::stringstream ss; - ss << global_out_dir << "SPIN" << is+1 << "_POT_INI.cube"; - ModuleIO::write_pot_spin( - out_pot, -#ifdef __MPI - bz, - nbz, - nplane, - startz_current, -#endif - is, - 0, // iter - ss.str(), - nx, - ny, - nz, - v, - 11); // precsion - } - } - - ModuleBase::TITLE("ModuleIO", "write_pot"); - return; -} - - - -void write_pot_spin( - const int& out_pot, -#ifdef __MPI - const int& bz, - const int& nbz, - const int& nplane, - const int& startz_current, -#endif - const int& is, - const int& iter, - const std::string& fn, - const int& nx, - const int& ny, - const int& nz, - const ModuleBase::matrix& v, - const int& precision, - const int& hartree) -{ - ModuleBase::TITLE("ModuleIO", "write_pot_spin"); - if (out_pot != 1 && out_pot != 3) - { - return; - } - ModuleBase::timer::tick("ModuleIO", "write_pot_spin"); - - double* temp_v = nullptr; - if (is == 0) - { - temp_v = v.c; - } - else if (is == 1) - { - temp_v = &(v.c[nx * ny * nz]); - } - - double ef_tmp = 0.0; - int out_fermi = 0; - - ModuleIO::write_cube( -#ifdef __MPI - bz, - nbz, - nplane, - startz_current, -#endif - temp_v, - is, - GlobalV::NSPIN, - iter, - fn, - nx, - ny, - nz, - ef_tmp, - &(GlobalC::ucell), - precision, - out_fermi); - - ModuleBase::timer::tick("ModuleIO", "write_pot_spin"); - return; -} - void write_elecstat_pot( #ifdef __MPI const int& bz, diff --git a/source/module_io/write_pot.h b/source/module_io/write_pot.h index 8781312775..0bcebac621 100644 --- a/source/module_io/write_pot.h +++ b/source/module_io/write_pot.h @@ -8,54 +8,6 @@ namespace ModuleIO { -void write_pot( - const int &out_pot, - const int &nspin, - const std::string &global_out_dir, -#ifdef __MPI - const int& bz, - const int& nbz, - const int& nplane, - const int& startz_current, -#endif - const int& nx, - const int& ny, - const int& nz, - const ModuleBase::matrix& v); - -/// @brief write potential to file -/// @param[in] out_pot -/// @param[in] bz -/// @param[in] nbz -/// @param[in] nplane -/// @param[in] startz_current -/// @param[in] is -/// @param[in] iter -/// @param[in] fn -/// @param[in] nx -/// @param[in] ny -/// @param[in] nz -/// @param[in] v -/// @param[in] precision -/// @param[in] hartree -void write_pot_spin( - const int& out_pot, -#ifdef __MPI - const int& bz, - const int& nbz, - const int& nplane, - const int& startz_current, -#endif - const int& is, - const int& iter, - const std::string& fn, - const int& nx, - const int& ny, - const int& nz, - const ModuleBase::matrix& v, - const int& precision, - const int& hartree = 0); - /// @brief write electric static potential to file /// @param bz /// @param nbz