From 5e8dd5f86e17d574dfe3ab709c44f66c739e2059 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Wed, 22 Jul 2026 17:58:29 +0800 Subject: [PATCH 1/4] move read_pseudo.cpp and .h from source_estate to source_cell --- source/Makefile.Objects | 4 +- source/source_cell/CMakeLists.txt | 2 + .../cal_wfc.cpp | 2 +- .../read_pseudo.cpp | 16 +++---- .../read_pseudo.h | 6 +-- source/source_cell/test/CMakeLists.txt | 4 +- source/source_cell/test/unitcell_test.cpp | 4 +- .../source_cell/test/unitcell_test_para.cpp | 4 +- .../source_cell/test/unitcell_test_readpp.cpp | 46 +++++++++---------- source/source_esolver/esolver_dm2rho.cpp | 2 +- source/source_esolver/esolver_fp.cpp | 4 +- source/source_esolver/esolver_gets.cpp | 4 +- source/source_estate/CMakeLists.txt | 2 - source/source_io/test/write_orb_info_test.cpp | 6 +-- .../module_deepks/test/deepks_test_prep.cpp | 4 +- 15 files changed, 55 insertions(+), 55 deletions(-) rename source/{source_estate => source_cell}/cal_wfc.cpp (99%) rename source/{source_estate => source_cell}/read_pseudo.cpp (97%) rename source/{source_estate => source_cell}/read_pseudo.h (96%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 7d8b5ee56b..d6a3365918 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -206,6 +206,8 @@ OBJS_CELL=atom_pseudo.o\ sep.o\ sep_cell.o\ cal_nelec_nband.o\ + read_pseudo.o\ + cal_wfc.o\ OBJS_DEEPKS=LCAO_deepks.o\ deepks_basic.o\ @@ -248,8 +250,6 @@ OBJS_ELECSTAT=elecstate.o\ pot_xc.o\ cal_ux.o\ read_orb.o\ - read_pseudo.o\ - cal_wfc.o\ setup_estate_pw.o\ update_pot.o\ diff --git a/source/source_cell/CMakeLists.txt b/source/source_cell/CMakeLists.txt index 50615128d8..3e03a33d9e 100644 --- a/source/source_cell/CMakeLists.txt +++ b/source/source_cell/CMakeLists.txt @@ -34,6 +34,8 @@ add_library( qlist.cpp qlist.h cal_nelec_nband.cpp + read_pseudo.cpp + cal_wfc.cpp ) if(ENABLE_COVERAGE) diff --git a/source/source_estate/cal_wfc.cpp b/source/source_cell/cal_wfc.cpp similarity index 99% rename from source/source_estate/cal_wfc.cpp rename to source/source_cell/cal_wfc.cpp index 370259a9a0..bbac017512 100644 --- a/source/source_estate/cal_wfc.cpp +++ b/source/source_cell/cal_wfc.cpp @@ -1,6 +1,6 @@ #include "read_pseudo.h" -namespace elecstate +namespace unitcell { void cal_nwfc(std::ofstream& log,UnitCell& ucell,Atom* atoms, const int nspin, const int nlocal, const int npol, const std::string& basis_type, const std::string& esolver_type, const std::string& init_wfc, const int nbands) diff --git a/source/source_estate/read_pseudo.cpp b/source/source_cell/read_pseudo.cpp similarity index 97% rename from source/source_estate/read_pseudo.cpp rename to source/source_cell/read_pseudo.cpp index ac91c2ac70..c4d59122e0 100644 --- a/source/source_estate/read_pseudo.cpp +++ b/source/source_cell/read_pseudo.cpp @@ -1,14 +1,14 @@ #include "read_pseudo.h" #include "source_base/global_file.h" -#include "source_cell/cal_atoms_info.h" -#include "source_cell/read_pp.h" -#include "source_cell/bcast_cell.h" +#include "cal_atoms_info.h" +#include "read_pp.h" +#include "bcast_cell.h" #include "source_base/element_elec_config.h" #include "source_base/parallel_common.h" -#include // Peize Lin fix bug about strcmp 2016-08-02 +#include -namespace elecstate { +namespace unitcell { AtomsInfoResult read_pseudo(std::ofstream& ofs, UnitCell& ucell, const std::string& pseudo_dir, const std::string& global_out_dir, @@ -132,7 +132,7 @@ AtomsInfoResult read_pseudo(std::ofstream& ofs, UnitCell& ucell, } #ifdef __MPI - unitcell::bcast_atoms_pseudo(ucell.atoms,ucell.ntype); + bcast_atoms_pseudo(ucell.atoms,ucell.ntype); #endif for (int it = 0; it < ucell.ntype; it++) { @@ -265,7 +265,7 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel const double pseudo_rcut, const double soc_lambda) { - ModuleBase::TITLE("Elecstate", "read_cell_pseudopots"); + ModuleBase::TITLE("UnitCell", "read_cell_pseudopots"); // setup reading log for pseudopot_upf const std::string global_out_dir_ = global_out_dir; const std::string dft_functional_ = dft_functional; @@ -386,7 +386,7 @@ void read_cell_pseudopots(const std::string& pp_dir, std::ofstream& log, UnitCel void print_unitcell_pseudo(const std::string& fn, UnitCell& ucell) { - ModuleBase::TITLE("elecstate", "print_unitcell_pseudo"); + ModuleBase::TITLE("unitcell", "print_unitcell_pseudo"); std::ofstream ofs(fn.c_str()); ucell.print_cell(ofs); diff --git a/source/source_estate/read_pseudo.h b/source/source_cell/read_pseudo.h similarity index 96% rename from source/source_estate/read_pseudo.h rename to source/source_cell/read_pseudo.h index d938ed9b8f..256e5da49f 100644 --- a/source/source_estate/read_pseudo.h +++ b/source/source_cell/read_pseudo.h @@ -1,10 +1,10 @@ #ifndef READ_PSEUDO_H #define READ_PSEUDO_H -#include "source_cell/unitcell.h" -#include "source_cell/cal_atoms_info.h" +#include "unitcell.h" +#include "cal_atoms_info.h" -namespace elecstate { +namespace unitcell { AtomsInfoResult read_pseudo(std::ofstream& ofs, UnitCell& ucell, const std::string& pseudo_dir, diff --git a/source/source_cell/test/CMakeLists.txt b/source/source_cell/test/CMakeLists.txt index 846128ff8a..d78ffb5117 100644 --- a/source/source_cell/test/CMakeLists.txt +++ b/source/source_cell/test/CMakeLists.txt @@ -40,8 +40,8 @@ list(APPEND cell_simple_srcs ../read_pp_vwr.cpp ../read_pp_blps.cpp ../check_atomic_stru.cpp - ../../source_estate/read_pseudo.cpp - ../../source_estate/cal_wfc.cpp + ../read_pseudo.cpp + ../cal_wfc.cpp ../cal_nelec_nband.cpp ../read_orb.cpp ../sep.cpp diff --git a/source/source_cell/test/unitcell_test.cpp b/source/source_cell/test/unitcell_test.cpp index 5f354d046d..55452fc47c 100644 --- a/source/source_cell/test/unitcell_test.cpp +++ b/source/source_cell/test/unitcell_test.cpp @@ -3,7 +3,7 @@ #include "source_estate/cal_ux.h" #include "source_cell/read_orb.h" -#include "source_estate/read_pseudo.h" +#include "read_pseudo.h" #include "source_cell/read_stru.h" #include "source_cell/print_cell.h" #include "memory" @@ -787,7 +787,7 @@ TEST_F(UcellTest, PrintUnitcellPseudo) UcellTestPrepare utp = UcellTestLib["C1H2-Index"]; ucell = utp.SetUcellInfo(); std::string fn = "printcell.log"; - elecstate::print_unitcell_pseudo(fn, *ucell); + unitcell::print_unitcell_pseudo(fn, *ucell); std::ifstream ifs; ifs.open("printcell.log"); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); diff --git a/source/source_cell/test/unitcell_test_para.cpp b/source/source_cell/test/unitcell_test_para.cpp index 32705d7ddd..3ae2fb2972 100644 --- a/source/source_cell/test/unitcell_test_para.cpp +++ b/source/source_cell/test/unitcell_test_para.cpp @@ -7,7 +7,7 @@ #include "source_base/global_variable.h" #include "source_base/mathzone.h" #include "source_cell/unitcell.h" -#include "source_estate/read_pseudo.h" +#include "read_pseudo.h" #include #include #ifdef __MPI @@ -226,7 +226,7 @@ TEST_F(UcellTest, ReadPseudo) const int bndpar = 1; const double nelec = 0.0; const double nupdown = 0.0; - auto atoms_info = elecstate::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); + auto atoms_info = unitcell::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); // check_structure will print some warning info // output nonlocal file if (GlobalV::MY_RANK == 0) diff --git a/source/source_cell/test/unitcell_test_readpp.cpp b/source/source_cell/test/unitcell_test_readpp.cpp index 3f1e003174..70955f19e8 100644 --- a/source/source_cell/test/unitcell_test_readpp.cpp +++ b/source/source_cell/test/unitcell_test_readpp.cpp @@ -6,7 +6,7 @@ #include "source_cell/check_atomic_stru.h" #include "source_cell/unitcell.h" #include "source_cell/cal_nelec_nband.h" -#include "source_estate/read_pseudo.h" +#include "read_pseudo.h" #include #include #include "string.h" @@ -111,7 +111,7 @@ TEST_F(UcellDeathTest, ReadCellPPWarning1) { const std::string global_out_dir = "./"; const std::string dft_functional = "default"; pp_dir = "./support/"; - EXPECT_EXIT(elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, + EXPECT_EXIT(unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda), ::testing::ExitedWithCode(1),""); output = testing::internal::GetCapturedStdout(); @@ -127,7 +127,7 @@ TEST_F(UcellDeathTest, ReadCellPPWarning2) { testing::internal::CaptureStdout(); const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - EXPECT_EXIT(elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, + EXPECT_EXIT(unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda), ::testing::ExitedWithCode(1), ""); output = testing::internal::GetCapturedStdout(); @@ -145,7 +145,7 @@ TEST_F(UcellDeathTest, ReadCellPPWarning3) { const std::string global_out_dir = "./"; const std::string dft_functional = "default"; pp_dir = "./support/"; - EXPECT_EXIT(elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, + EXPECT_EXIT(unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda), ::testing::ExitedWithCode(1),""); output = testing::internal::GetCapturedStdout(); @@ -160,7 +160,7 @@ TEST_F(UcellDeathTest, ReadCellPPWarning4) { const std::string dft_functional = "LDA"; testing::internal::CaptureStdout(); const std::string global_out_dir = "./"; - EXPECT_NO_THROW(elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda)); + EXPECT_NO_THROW(unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda)); output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("DFT FUNC. (PSEUDO) : PBE")); EXPECT_THAT(output, testing::HasSubstr("DFT FUNC. (SET TO) : LDA")); @@ -174,7 +174,7 @@ TEST_F(UcellDeathTest, ReadCellPPWarning5) { testing::internal::CaptureStdout(); const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - EXPECT_EXIT(elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda), + EXPECT_EXIT(unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda), ::testing::ExitedWithCode(1), ""); output = testing::internal::GetCapturedStdout(); @@ -188,7 +188,7 @@ TEST_F(UcellTest, ReadCellPP) { ucell->atoms[1].flag_empty_element = true; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_EQ(ucell->atoms[0].ncpp.pp_type, "NC"); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); // becomes false in average_p EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); @@ -216,8 +216,8 @@ TEST_F(UcellTest, CalMeshx) { const double soc_lambda = 0.0; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); - elecstate::cal_meshx(ucell->meshx,ucell->atoms,ucell->ntype); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::cal_meshx(ucell->meshx,ucell->atoms,ucell->ntype); EXPECT_EQ(ucell->atoms[0].ncpp.msh, 1247); EXPECT_EQ(ucell->atoms[1].ncpp.msh, 1165); EXPECT_EQ(ucell->meshx, 1247); @@ -230,10 +230,10 @@ TEST_F(UcellTest, CalNatomwfc1) { const std::string global_out_dir = "./"; const std::string dft_functional = "default"; const int nspin = 1; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); - elecstate::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); + unitcell::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); EXPECT_EQ(ucell->atoms[0].ncpp.nchi, 2); EXPECT_EQ(ucell->atoms[1].ncpp.nchi, 1); EXPECT_EQ(ucell->atoms[0].na, 1); @@ -248,10 +248,10 @@ TEST_F(UcellTest, CalNatomwfc2) { const int nspin = 4; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); - elecstate::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); + unitcell::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); EXPECT_EQ(ucell->atoms[0].ncpp.nchi, 2); EXPECT_EQ(ucell->atoms[1].ncpp.nchi, 1); EXPECT_EQ(ucell->atoms[0].na, 1); @@ -266,10 +266,10 @@ TEST_F(UcellTest, CalNatomwfc3) { const int nspin = 4; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_TRUE(ucell->atoms[0].ncpp.has_so); EXPECT_TRUE(ucell->atoms[1].ncpp.has_so); - elecstate::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); + unitcell::cal_natomwfc(ofs,ucell->natomwfc,ucell->ntype,ucell->atoms,nspin); EXPECT_EQ(ucell->atoms[0].ncpp.nchi, 3); EXPECT_EQ(ucell->atoms[1].ncpp.nchi, 1); EXPECT_EQ(ucell->atoms[0].na, 1); @@ -291,10 +291,10 @@ TEST_F(UcellTest, CalNwfc1) { const std::string esolver_type = "ksdft"; const std::string init_wfc = ""; const int nbands = 6; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); - elecstate::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands); + unitcell::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands); EXPECT_EQ(ucell->atoms[0].iw2l[8], 2); EXPECT_EQ(ucell->atoms[0].iw2n[8], 0); EXPECT_EQ(ucell->atoms[0].iw2m[8], 4); @@ -366,10 +366,10 @@ TEST_F(UcellTest, CalNwfc2) { const int nbands = 6; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); - EXPECT_NO_THROW(elecstate::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands)); + EXPECT_NO_THROW(unitcell::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands)); } TEST_F(UcellDeathTest, CheckStructure) { @@ -378,7 +378,7 @@ TEST_F(UcellDeathTest, CheckStructure) { const double soc_lambda = 0.0; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_FALSE(ucell->atoms[0].ncpp.has_so); EXPECT_FALSE(ucell->atoms[1].ncpp.has_so); // trial 1 @@ -446,7 +446,7 @@ TEST_F(UcellDeathTest, ReadPseudoWarning1) { testing::internal::CaptureStdout(); const double nelec = 0.0; const double nupdown = 0.0; - EXPECT_EXIT(elecstate::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown), ::testing::ExitedWithCode(1), ""); + EXPECT_EXIT(unitcell::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown), ::testing::ExitedWithCode(1), ""); output = testing::internal::GetCapturedStdout(); EXPECT_THAT(output, testing::HasSubstr("All DFT functional must consistent.")); @@ -478,7 +478,7 @@ TEST_F(UcellDeathTest, ReadPseudoWarning2) { ucell->pseudo_fn[0] = "Al_ONCV_PBE-1.0.upf"; testing::internal::CaptureStdout(); const double nelec = 0.0; - EXPECT_NO_THROW(elecstate::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec)); + EXPECT_NO_THROW(unitcell::read_pseudo(ofs, *ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec)); output = testing::internal::GetCapturedStdout(); EXPECT_THAT( output, @@ -493,7 +493,7 @@ TEST_F(UcellTest, CalNelec) { const double soc_lambda = 0.0; const std::string global_out_dir = "./"; const std::string dft_functional = "default"; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); EXPECT_EQ(4, ucell->atoms[0].ncpp.zv); EXPECT_EQ(1, ucell->atoms[1].ncpp.zv); EXPECT_EQ(1, ucell->atoms[0].na); diff --git a/source/source_esolver/esolver_dm2rho.cpp b/source/source_esolver/esolver_dm2rho.cpp index 017d190fe7..231a5f9a6e 100644 --- a/source/source_esolver/esolver_dm2rho.cpp +++ b/source/source_esolver/esolver_dm2rho.cpp @@ -3,7 +3,7 @@ #include "source_base/timer.h" #include "source_cell/module_neighbor/sltk_atom_arrange.h" #include "source_estate/elecstate_lcao.h" -#include "source_estate/read_pseudo.h" +#include "source_cell/read_pseudo.h" #include "source_lcao/LCAO_domain.h" #include "source_lcao/hamilt_lcao.h" #include "source_lcao/module_operator_lcao/operator_lcao.h" diff --git a/source/source_esolver/esolver_fp.cpp b/source/source_esolver/esolver_fp.cpp index 80e5bf1ab5..cc74a04230 100644 --- a/source/source_esolver/esolver_fp.cpp +++ b/source/source_esolver/esolver_fp.cpp @@ -2,7 +2,7 @@ #include "source_estate/cal_ux.h" #include "source_estate/module_charge/symmetry_rho.h" -#include "source_estate/read_pseudo.h" +#include "source_cell/read_pseudo.h" #include "source_estate/param_update.h" #include "source_hamilt/module_ewald/H_Ewald_pw.h" #include "source_hamilt/module_vdw/vdw.h" @@ -60,7 +60,7 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp) const int bndpar = PARAM.inp.bndpar; const double nelec = PARAM.inp.nelec; const double nupdown = PARAM.inp.nupdown; - auto atoms_info = elecstate::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); + auto atoms_info = unitcell::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); elecstate::ParamUpdater::update_from_atoms_info(atoms_info); //! 2) setup pw_rho, pw_rhod, pw_big, sf, and read_pseudopotentials diff --git a/source/source_esolver/esolver_gets.cpp b/source/source_esolver/esolver_gets.cpp index 44bbd83081..fd9f90ea18 100644 --- a/source/source_esolver/esolver_gets.cpp +++ b/source/source_esolver/esolver_gets.cpp @@ -3,7 +3,7 @@ #include "source_base/timer.h" #include "source_cell/module_neighbor/sltk_atom_arrange.h" #include "source_estate/elecstate_lcao.h" -#include "source_estate/read_pseudo.h" +#include "source_cell/read_pseudo.h" #include "source_estate/param_update.h" #include "source_lcao/LCAO_domain.h" #include "source_lcao/hamilt_lcao.h" @@ -52,7 +52,7 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp) const double nelec = PARAM.inp.nelec; const double nupdown = PARAM.inp.nupdown; // nlocal is calculated inside read_pseudo() via CalAtomsInfo::cal_atoms_info() - auto atoms_info = elecstate::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); + auto atoms_info = unitcell::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); elecstate::ParamUpdater::update_from_atoms_info(atoms_info); // 1.2) symmetrize things diff --git a/source/source_estate/CMakeLists.txt b/source/source_estate/CMakeLists.txt index 9a8475874f..2a68eea4a5 100644 --- a/source/source_estate/CMakeLists.txt +++ b/source/source_estate/CMakeLists.txt @@ -39,9 +39,7 @@ list(APPEND objects fp_energy.cpp occupy.cpp cal_ux.cpp - read_pseudo.cpp param_update.cpp - cal_wfc.cpp setup_estate_pw.cpp update_pot.cpp ) diff --git a/source/source_io/test/write_orb_info_test.cpp b/source/source_io/test/write_orb_info_test.cpp index b7c107451f..1504f5516b 100644 --- a/source/source_io/test/write_orb_info_test.cpp +++ b/source/source_io/test/write_orb_info_test.cpp @@ -6,7 +6,7 @@ #include "source_io/module_output/write_orb_info.h" #include "source_cell/unitcell.h" #include "prepare_unitcell.h" -#include "source_estate/read_pseudo.h" +#include "source_cell/read_pseudo.h" Magnetism::Magnetism() { @@ -48,8 +48,8 @@ TEST(OrbInfo,WriteOrbInfo) const std::string esolver_type = "ksdft"; const std::string init_wfc = ""; const int nbands = 6; - elecstate::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); - elecstate::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands); + unitcell::read_cell_pseudopots(pp_dir, ofs, *ucell, global_out_dir, dft_functional, lspinorb, pseudo_rcut, soc_lambda); + unitcell::cal_nwfc(ofs,*ucell,ucell->atoms, nspin, nlocal, npol, basis_type, esolver_type, init_wfc, nbands); ModuleIO::write_orb_info(ucell); ofs.close(); std::ifstream ifs("Orbital"); diff --git a/source/source_lcao/module_deepks/test/deepks_test_prep.cpp b/source/source_lcao/module_deepks/test/deepks_test_prep.cpp index 6e599d5397..de060a8ece 100644 --- a/source/source_lcao/module_deepks/test/deepks_test_prep.cpp +++ b/source/source_lcao/module_deepks/test/deepks_test_prep.cpp @@ -1,6 +1,6 @@ #include "deepks_test.h" #include "source_base/global_variable.h" -#include "source_estate/read_pseudo.h" +#include "source_cell/read_pseudo.h" #include "source_hamilt/module_xc/exx_info.h" #include "../../LCAO_nonlocal_info.h" #include "source_io/module_parameter/parameter.h" @@ -209,7 +209,7 @@ void test_deepks::setup_cell() const double nelec = 0.0; const double nupdown = 0.0; - auto atoms_info = elecstate::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); + auto atoms_info = unitcell::read_pseudo(GlobalV::ofs_running, ucell, pseudo_dir, global_out_dir, out_element_info, dft_functional, lspinorb, pseudo_rcut, soc_lambda, nspin, npol, basis_type, esolver_type, init_wfc, nbands, two_fermi, nelec_delta, smearing_method, ks_solver, bndpar, nelec, nupdown); this->nlocal = atoms_info.nlocal; this->nbands = atoms_info.nbands; From 270d5cffa17630e2bc08926284f236b0e5a51add Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Wed, 22 Jul 2026 18:01:08 +0800 Subject: [PATCH 2/4] update makefiles --- source/source_cell/test_pw/CMakeLists.txt | 4 ++-- source/source_lcao/module_deepks/test/CMakeLists.txt | 4 ++-- source/source_md/test/CMakeLists.txt | 4 ++-- source/source_pw/module_pwdft/test/CMakeLists.txt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/source_cell/test_pw/CMakeLists.txt b/source/source_cell/test_pw/CMakeLists.txt index beea3be431..b852cf2da3 100644 --- a/source/source_cell/test_pw/CMakeLists.txt +++ b/source/source_cell/test_pw/CMakeLists.txt @@ -16,9 +16,9 @@ AddTest( ../atom_pseudo.cpp ../pseudo.cpp ../read_pp.cpp ../read_pp_complete.cpp ../read_pp_upf201.cpp ../read_pp_upf100.cpp ../read_stru.cpp ../read_atom_species.cpp ../read_pp_vwr.cpp ../read_pp_blps.cpp - ../../source_estate/read_pseudo.cpp ../cal_nelec_nband.cpp + ../read_pseudo.cpp ../cal_nelec_nband.cpp ../../source_cell/read_orb.cpp ../print_cell.cpp - ../../source_estate/cal_wfc.cpp ../sep.cpp ../sep_cell.cpp + ../cal_wfc.cpp ../sep.cpp ../sep_cell.cpp ) find_program(BASH bash) diff --git a/source/source_lcao/module_deepks/test/CMakeLists.txt b/source/source_lcao/module_deepks/test/CMakeLists.txt index 9c474f4258..99389de9bd 100644 --- a/source/source_lcao/module_deepks/test/CMakeLists.txt +++ b/source/source_lcao/module_deepks/test/CMakeLists.txt @@ -39,9 +39,9 @@ set(DEEPKS_UNIT_COMMON_SOURCES ../../../source_cell/sep_cell.cpp ../../../source_pw/module_pwdft/soc.cpp ../../../source_io/module_output/sparse_matrix.cpp - ../../../source_estate/read_pseudo.cpp + ../../../source_cell/read_pseudo.cpp ../../../source_estate/param_update.cpp - ../../../source_estate/cal_wfc.cpp + ../../../source_cell/cal_wfc.cpp ../../../source_cell/read_orb.cpp ../../../source_cell/cal_nelec_nband.cpp ../../../source_estate/module_dm/density_matrix.cpp diff --git a/source/source_md/test/CMakeLists.txt b/source/source_md/test/CMakeLists.txt index f8420442a3..101b4da35a 100644 --- a/source/source_md/test/CMakeLists.txt +++ b/source/source_md/test/CMakeLists.txt @@ -57,8 +57,8 @@ list(APPEND depend_files ../../source_base/parallel_reduce.cpp ../../source_base/parallel_global.cpp ../../source_base/parallel_comm.cpp - ../../source_estate/read_pseudo.cpp - ../../source_estate/cal_wfc.cpp + ../../source_cell/read_pseudo.cpp + ../../source_cell/cal_wfc.cpp ../../source_cell/cal_nelec_nband.cpp ../../source_cell/read_orb.cpp ../../source_cell/sep.cpp diff --git a/source/source_pw/module_pwdft/test/CMakeLists.txt b/source/source_pw/module_pwdft/test/CMakeLists.txt index 16703c9100..08a5c9dd8e 100644 --- a/source/source_pw/module_pwdft/test/CMakeLists.txt +++ b/source/source_pw/module_pwdft/test/CMakeLists.txt @@ -52,8 +52,8 @@ AddTest( ../../../source_cell/read_pp_blps.cpp ../../../source_cell/sep.cpp ../../../source_cell/sep_cell.cpp - ../../../source_estate/read_pseudo.cpp - ../../../source_estate/cal_wfc.cpp + ../../../source_cell/read_pseudo.cpp + ../../../source_cell/cal_wfc.cpp ../../../source_cell/cal_nelec_nband.cpp ../../../source_cell/read_orb.cpp ) From ba57b7d15f49671a2ef4054d188e5aba70c1cb8e Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Wed, 22 Jul 2026 21:47:08 +0800 Subject: [PATCH 3/4] update --- source/source_cell/test/unitcell_test.cpp | 2 +- source/source_cell/test/unitcell_test_para.cpp | 2 +- source/source_cell/test/unitcell_test_readpp.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/source_cell/test/unitcell_test.cpp b/source/source_cell/test/unitcell_test.cpp index 55452fc47c..03df73c163 100644 --- a/source/source_cell/test/unitcell_test.cpp +++ b/source/source_cell/test/unitcell_test.cpp @@ -3,7 +3,7 @@ #include "source_estate/cal_ux.h" #include "source_cell/read_orb.h" -#include "read_pseudo.h" +#include "source_cell/read_pseudo.h" #include "source_cell/read_stru.h" #include "source_cell/print_cell.h" #include "memory" diff --git a/source/source_cell/test/unitcell_test_para.cpp b/source/source_cell/test/unitcell_test_para.cpp index 3ae2fb2972..9a40ceb853 100644 --- a/source/source_cell/test/unitcell_test_para.cpp +++ b/source/source_cell/test/unitcell_test_para.cpp @@ -7,7 +7,7 @@ #include "source_base/global_variable.h" #include "source_base/mathzone.h" #include "source_cell/unitcell.h" -#include "read_pseudo.h" +#include "source_cell/read_pseudo.h" #include #include #ifdef __MPI diff --git a/source/source_cell/test/unitcell_test_readpp.cpp b/source/source_cell/test/unitcell_test_readpp.cpp index 70955f19e8..d0045c3379 100644 --- a/source/source_cell/test/unitcell_test_readpp.cpp +++ b/source/source_cell/test/unitcell_test_readpp.cpp @@ -6,7 +6,7 @@ #include "source_cell/check_atomic_stru.h" #include "source_cell/unitcell.h" #include "source_cell/cal_nelec_nband.h" -#include "read_pseudo.h" +#include "source_cell/read_pseudo.h" #include #include #include "string.h" From 8292e86fca1bd66046e5ecf0dd315ea5e1f44fb6 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Thu, 23 Jul 2026 16:53:21 +0800 Subject: [PATCH 4/4] fix --- source/source_io/module_parameter/system_parameter.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/source_io/module_parameter/system_parameter.h b/source/source_io/module_parameter/system_parameter.h index 225596f476..438bd32c14 100644 --- a/source/source_io/module_parameter/system_parameter.h +++ b/source/source_io/module_parameter/system_parameter.h @@ -21,9 +21,7 @@ struct System_para // ------------ but decided by INPUT parameters ------------- // --------------------------------------------------------------- /** - * @brief Total number of local basis functions. - * - * Calculated by CalAtomsInfo::cal_atoms_info() during pseudopotential reading, + * Calculated in elecstate::ParamUpdater after pseudopotential reading, * based on atoms[it].nw * atoms[it].na for each atom type. * For nspin == 4 (non-collinear), each basis function has 2 polarizations, * so nlocal is doubled. @@ -77,4 +75,4 @@ struct System_para bool search_pbc = true; ///< whether to search for periodic boundary conditions, force set to true }; -#endif \ No newline at end of file +#endif