From b69c08538fa2cf11bb42b3d0e9a3c2b35fcae5af Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 23 Jan 2026 20:25:54 +0800 Subject: [PATCH 01/21] Refactor: Encapsulate timer functionality in timer_wrapper.h --- source/source_base/timer_wrapper.h | 56 +++++++++++++++++++ source/source_esolver/esolver_fp.h | 10 +--- source/source_esolver/esolver_ks.cpp | 15 +---- source/source_esolver/esolver_of.cpp | 14 ++--- source/source_esolver/esolver_of_tddft.cpp | 6 +- .../source_pw/module_ofdft/of_print_info.cpp | 32 +++-------- source/source_pw/module_ofdft/of_print_info.h | 20 +++---- 7 files changed, 84 insertions(+), 69 deletions(-) create mode 100644 source/source_base/timer_wrapper.h diff --git a/source/source_base/timer_wrapper.h b/source/source_base/timer_wrapper.h new file mode 100644 index 0000000000..6da3f391e3 --- /dev/null +++ b/source/source_base/timer_wrapper.h @@ -0,0 +1,56 @@ +#ifndef TIMER_WRAPPER_H +#define TIMER_WRAPPER_H + +#include + +#ifdef __MPI +#include +#endif + +namespace ModuleBase { + +/** + * @brief Time point type that works in both MPI and non-MPI environments + */ +typedef double TimePoint; + +/** + * @brief Get current time as a TimePoint + * + * @return TimePoint Current time + */ +inline TimePoint get_time() +{ +#ifdef __MPI + int is_initialized = 0; + MPI_Initialized(&is_initialized); + if (is_initialized) + { + return MPI_Wtime(); + } + else + { + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count() / 1e6; + } +#else + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count() / 1e6; +#endif +} + +/** + * @brief Calculate duration between two TimePoints in seconds + * + * @param start Start time point + * @param end End time point + * @return double Duration in seconds + */ +inline double get_duration(const TimePoint& start, const TimePoint& end) +{ + return end - start; +} + +} + +#endif // TIMER_WRAPPER_H \ No newline at end of file diff --git a/source/source_esolver/esolver_fp.h b/source/source_esolver/esolver_fp.h index b2bb8f065e..94faa31e74 100644 --- a/source/source_esolver/esolver_fp.h +++ b/source/source_esolver/esolver_fp.h @@ -3,9 +3,7 @@ #include "esolver.h" -#ifndef __MPI -#include -#endif +#include "source_base/timer_wrapper.h" #include "source_basis/module_pw/pw_basis.h" // plane wave basis #include "source_cell/module_symmetry/symmetry.h" // symmetry analysis @@ -83,11 +81,7 @@ class ESolver_FP: public ESolver bool pw_rho_flag = false; ///< flag for pw_rho, 0: not initialized, 1: initialized //! the start time of scf iteration - #ifdef __MPI - double iter_time; - #else - std::chrono::system_clock::time_point iter_time; - #endif + ModuleBase::TimePoint iter_time; }; } // namespace ModuleESolver diff --git a/source/source_esolver/esolver_ks.cpp b/source/source_esolver/esolver_ks.cpp index 166e7b3fb9..8c0c651172 100644 --- a/source/source_esolver/esolver_ks.cpp +++ b/source/source_esolver/esolver_ks.cpp @@ -1,4 +1,5 @@ #include "esolver_ks.h" +#include "source_base/timer_wrapper.h" // for jason output information #include "source_io/json_output/init_info.h" @@ -190,11 +191,7 @@ void ESolver_KS::iter_init(UnitCell& ucell, const int istep, const in ModuleIO::write_head(GlobalV::ofs_running, istep, iter, this->basisname); } -#ifdef __MPI - iter_time = MPI_Wtime(); -#else - iter_time = std::chrono::system_clock::now(); -#endif + iter_time = ModuleBase::get_time(); if (PARAM.inp.esolver_type == "ksdft") { @@ -281,13 +278,7 @@ void ESolver_KS::iter_finish(UnitCell& ucell, const int istep, int& i // the end, print time -#ifdef __MPI - double duration = (double)(MPI_Wtime() - iter_time); -#else - double duration - = (std::chrono::duration_cast(std::chrono::system_clock::now() - iter_time)).count() - / static_cast(1e6); -#endif + double duration = ModuleBase::get_duration(iter_time, ModuleBase::get_time()); // print energies elecstate::print_etot(ucell.magnet, *pelec, conv_esolver, iter, drho, diff --git a/source/source_esolver/esolver_of.cpp b/source/source_esolver/esolver_of.cpp index 4debfde4d5..b17cf6fb9d 100644 --- a/source/source_esolver/esolver_of.cpp +++ b/source/source_esolver/esolver_of.cpp @@ -27,10 +27,10 @@ ESolver_OF::ESolver_OF() ESolver_OF::~ESolver_OF() { - //**************************************************** - // do not add any codes in this deconstructor funcion - //**************************************************** - delete psi_; + //**************************************************** + // do not add any codes in this deconstructor funcion + //**************************************************** + delete psi_; delete[] this->pphi_; for (int i = 0; i < PARAM.inp.nspin; ++i) @@ -137,11 +137,7 @@ void ESolver_OF::runner(UnitCell& ucell, const int istep) this->iter_ = 0; bool conv_esolver = false; // this conv_esolver is added by mohan 20250302 -#ifdef __MPI - this->iter_time = MPI_Wtime(); -#else - this->iter_time = std::chrono::system_clock::now(); -#endif + this->iter_time = ModuleBase::get_time(); while (true) { diff --git a/source/source_esolver/esolver_of_tddft.cpp b/source/source_esolver/esolver_of_tddft.cpp index daeda628cb..12a398a2f7 100644 --- a/source/source_esolver/esolver_of_tddft.cpp +++ b/source/source_esolver/esolver_of_tddft.cpp @@ -41,11 +41,7 @@ void ESolver_OF_TDDFT::runner(UnitCell& ucell, const int istep) this->iter_ = 0; bool conv_esolver = false; // this conv_esolver is added by mohan 20250302 -#ifdef __MPI - this->iter_time = MPI_Wtime(); -#else - this->iter_time = std::chrono::system_clock::now(); -#endif + this->iter_time = ModuleBase::get_time(); if (this->phi_td.empty()) { diff --git a/source/source_pw/module_ofdft/of_print_info.cpp b/source/source_pw/module_ofdft/of_print_info.cpp index ea411bcb1b..fa19083dcd 100644 --- a/source/source_pw/module_ofdft/of_print_info.cpp +++ b/source/source_pw/module_ofdft/of_print_info.cpp @@ -8,17 +8,13 @@ * and write the components of the total energy into running_log. */ void OFDFT::print_info(const int iter, - #ifdef __MPI - double &iter_time, - #else - std::chrono::system_clock::time_point &iter_time, - #endif - const double &energy_current, - const double &energy_last, - const double &normdLdphi, - const elecstate::ElecState *pelec, - KEDF_Manager *kedf_manager, - const bool conv_esolver) + ModuleBase::TimePoint &iter_time, + const double &energy_current, + const double &energy_last, + const double &normdLdphi, + const elecstate::ElecState *pelec, + KEDF_Manager *kedf_manager, + const bool conv_esolver) { if (iter == 0) { @@ -35,13 +31,7 @@ void OFDFT::print_info(const int iter, {"tn", "TN"} }; std::string iteration = prefix_map[PARAM.inp.of_method] + std::to_string(iter); -#ifdef __MPI - double duration = (double)(MPI_Wtime() - iter_time); -#else - double duration - = (std::chrono::duration_cast(std::chrono::system_clock::now() - iter_time)).count() - / static_cast(1e6); -#endif + double duration = ModuleBase::get_duration(iter_time, ModuleBase::get_time()); std::cout << " " << std::setw(8) << iteration << std::setw(18) << std::scientific << std::setprecision(8) << energy_current * ModuleBase::Ry_to_eV << std::setw(18) << (energy_current - energy_last) * ModuleBase::Ry_to_eV @@ -141,9 +131,5 @@ void OFDFT::print_info(const int iter, GlobalV::ofs_running << table.str() << std::endl; // reset the iter_time for the next iteration -#ifdef __MPI - iter_time = MPI_Wtime(); -#else - iter_time = std::chrono::system_clock::now(); -#endif + iter_time = ModuleBase::get_time(); } diff --git a/source/source_pw/module_ofdft/of_print_info.h b/source/source_pw/module_ofdft/of_print_info.h index b60eeb69db..dd45e6bbc6 100644 --- a/source/source_pw/module_ofdft/of_print_info.h +++ b/source/source_pw/module_ofdft/of_print_info.h @@ -4,24 +4,20 @@ #include "source_estate/elecstate.h" // electronic states #include "source_pw/module_ofdft/kedf_manager.h" -#include +#include "source_base/timer_wrapper.h" namespace OFDFT { void print_info(const int iter, - #ifdef __MPI - double &iter_time, - #else - std::chrono::system_clock::time_point &iter_time, - #endif - const double &energy_current, - const double &energy_last, - const double &normdLdphi, - const elecstate::ElecState *pelec, - KEDF_Manager *kedf_manager, - const bool conv_esolver); + ModuleBase::TimePoint &iter_time, + const double &energy_current, + const double &energy_last, + const double &normdLdphi, + const elecstate::ElecState *pelec, + KEDF_Manager *kedf_manager, + const bool conv_esolver); } From 382926887a20b868df74a8eefef3b299c232fb1a Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Fri, 23 Jan 2026 20:54:14 +0800 Subject: [PATCH 02/21] Refactor timer code and clean_esolver function 1. Remove #ifdef __MPI from timer code, encapsulate in timer_wrapper.h 2. Move ESolver clean logic to after_all_runners method 3. Replace clean_esolver calls with direct delete p_esolver 4. Remove #ifdef __MPI from delete p_esolver 5. Add Cblacs_exit(1) in after_all_runners for LCAO calculations --- source/source_esolver/esolver.cpp | 51 ++++++++--------------- source/source_esolver/esolver.h | 2 +- source/source_esolver/esolver_ks_lcao.cpp | 28 ++++++++----- source/source_main/driver_run.cpp | 8 +--- 4 files changed, 39 insertions(+), 50 deletions(-) diff --git a/source/source_esolver/esolver.cpp b/source/source_esolver/esolver.cpp index 2d89673313..4809c6df77 100644 --- a/source/source_esolver/esolver.cpp +++ b/source/source_esolver/esolver.cpp @@ -311,23 +311,23 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) // of LR-TDDFT is implemented. std::cout << " PREPARING FOR EXCITED STATES." << std::endl; // initialize the 2nd ESolver_LR at the temporary pointer - ModuleESolver::ESolver* p_esolver_lr = nullptr; - if (PARAM.globalv.gamma_only_local) - { - p_esolver_lr = new LR::ESolver_LR( - std::move(*dynamic_cast*>(p_esolver)), - inp, - ucell); - } - else - { - p_esolver_lr = new LR::ESolver_LR, double>( - std::move(*dynamic_cast, double>*>(p_esolver)), - inp, - ucell); - } - // clean the 1st ESolver_KS and swap the pointer - ModuleESolver::clean_esolver(p_esolver, false); // do not call Cblacs_exit, remain it for the 2nd ESolver + ModuleESolver::ESolver* p_esolver_lr = nullptr; + if (PARAM.globalv.gamma_only_local) + { + p_esolver_lr = new LR::ESolver_LR( + std::move(*dynamic_cast*>(p_esolver)), + inp, + ucell); + } + else + { + p_esolver_lr = new LR::ESolver_LR, double>( + std::move(*dynamic_cast, double>*>(p_esolver)), + inp, + ucell); + } + // clean the 1st ESolver_KS and swap the pointer + delete p_esolver; return p_esolver_lr; } #endif @@ -355,20 +355,5 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) + " line " + std::to_string(__LINE__)); } -void clean_esolver(ESolver*& pesolver, const bool lcao_cblacs_exit) -{ -// Zhang Xiaoyang modified in 2024/7/6: -// Note: because of the init method of serial lcao hsolver -// it needs no release step for it, or this [delete] will cause Segmentation Fault -// Probably it will be modified later. -#ifdef __MPI - delete pesolver; -#ifdef __LCAO - if (lcao_cblacs_exit) - { - Cblacs_exit(1); - } -#endif -#endif -} + } // namespace ModuleESolver diff --git a/source/source_esolver/esolver.h b/source/source_esolver/esolver.h index 6716ea0c96..dd621cfe15 100644 --- a/source/source_esolver/esolver.h +++ b/source/source_esolver/esolver.h @@ -69,7 +69,7 @@ std::string determine_type(); */ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell); -void clean_esolver(ESolver*& pesolver, const bool lcao_cblacs_exit = false); + } // namespace ModuleESolver diff --git a/source/source_esolver/esolver_ks_lcao.cpp b/source/source_esolver/esolver_ks_lcao.cpp index 3a2fb57496..47b6648954 100644 --- a/source/source_esolver/esolver_ks_lcao.cpp +++ b/source/source_esolver/esolver_ks_lcao.cpp @@ -293,17 +293,25 @@ void ESolver_KS_LCAO::after_all_runners(UnitCell& ucell) ESolver_KS::after_all_runners(ucell); auto* hamilt_lcao = dynamic_cast*>(this->p_hamilt); - if(!hamilt_lcao) - { - ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","p_hamilt does not exist"); - } + if(!hamilt_lcao) + { + ModuleBase::WARNING_QUIT("ESolver_KS_LCAO::after_all_runners","p_hamilt does not exist"); + } - ModuleIO::ctrl_runner_lcao(ucell, - PARAM.inp, this->kv, this->pelec, this->dmat, this->pv, this->Pgrid, - this->gd, this->psi, this->chr, hamilt_lcao, - this->two_center_bundle_, - this->orb_, this->pw_rho, this->pw_rhod, - this->sf, this->locpp.vloc, this->exx_nao, this->solvent); + ModuleIO::ctrl_runner_lcao(ucell, + PARAM.inp, this->kv, this->pelec, this->dmat, this->pv, this->Pgrid, + this->gd, this->psi, this->chr, hamilt_lcao, + this->two_center_bundle_, + this->orb_, this->pw_rho, this->pw_rhod, + this->sf, this->locpp.vloc, this->exx_nao, this->solvent); + + +#ifdef __MPI +#ifdef __LCAO + // Exit BLACS environment for LCAO calculations + Cblacs_exit(1); +#endif +#endif ModuleBase::timer::tick("ESolver_KS_LCAO", "after_all_runners"); } diff --git a/source/source_main/driver_run.cpp b/source/source_main/driver_run.cpp index 990aa56751..895b06bf57 100644 --- a/source/source_main/driver_run.cpp +++ b/source/source_main/driver_run.cpp @@ -90,11 +90,6 @@ void Driver::driver_run() else if (cal == "get_pchg" || cal == "get_wf" || cal == "gen_bessel" || cal == "gen_opt_abfs" || cal == "test_memory" || cal == "test_neighbour") { - //! supported "other" functions: - //! get_pchg(LCAO), - //! test_memory(PW,LCAO), - //! test_neighbour(LCAO), - //! gen_bessel(PW), et al. const int istep = 0; p_esolver->others(ucell, istep); } @@ -106,7 +101,8 @@ void Driver::driver_run() //! 5: clean up esolver p_esolver->after_all_runners(ucell); - ModuleESolver::clean_esolver(p_esolver); + delete p_esolver; + this->finalize_hardware(); //! 6: output the json file From 1138023357a08128f64ee50bfba7967379e76e8d Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 17:56:24 +0800 Subject: [PATCH 03/21] Fix uninitialized variables in source_pw directory This commit fixes 37 uninitialized variables (19 int, 18 double) in 19 files within the source_pw directory. All variables are initialized to 0 or 0.0 to prevent undefined behavior and improve code safety. Affected files: - source_stodft/sto_wf.cpp - source_stodft/sto_tool.h - source_stodft/sto_iter.h - source_stodft/sto_iter.cpp - source_stodft/sto_forces.cpp - source_pwdft/stress_func_loc.cpp - source_pwdft/soc.cpp - source_pwdft/parallel_grid.cpp - source_pwdft/onsite_projector.cpp - source_pwdft/operator_pw/exx_pw_ace.cpp - source_pwdft/onsite_proj_tools.h - source_pwdft/nonlocal_maths.hpp - source_pwdft/fs_nonlocal_tools.h - source_pwdft/elecond.cpp - source_pwdft/forces_cc.cpp - source_pwdft/VNL_in_pw.cpp - source_pwdft/forces_scc.cpp - source_pwdft/forces.cpp - source_pwdft/VNL_grad_pw.cpp --- source/source_pw/module_pwdft/VNL_grad_pw.cpp | 2 +- source/source_pw/module_pwdft/VNL_in_pw.cpp | 4 ++-- source/source_pw/module_pwdft/elecond.cpp | 2 +- source/source_pw/module_pwdft/forces.cpp | 12 ++++++------ source/source_pw/module_pwdft/forces_cc.cpp | 2 +- source/source_pw/module_pwdft/forces_scc.cpp | 2 +- source/source_pw/module_pwdft/fs_nonlocal_tools.h | 8 ++++---- source/source_pw/module_pwdft/nonlocal_maths.hpp | 2 +- source/source_pw/module_pwdft/onsite_proj_tools.h | 8 ++++---- source/source_pw/module_pwdft/onsite_projector.cpp | 2 +- .../module_pwdft/operator_pw/exx_pw_ace.cpp | 2 +- source/source_pw/module_pwdft/parallel_grid.cpp | 2 +- source/source_pw/module_pwdft/soc.cpp | 2 +- source/source_pw/module_pwdft/stress_func_loc.cpp | 4 ++-- source/source_pw/module_stodft/sto_forces.cpp | 2 +- source/source_pw/module_stodft/sto_iter.cpp | 8 ++++---- source/source_pw/module_stodft/sto_iter.h | 4 ++-- source/source_pw/module_stodft/sto_tool.h | 4 ++-- source/source_pw/module_stodft/sto_wf.cpp | 4 ++-- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/source/source_pw/module_pwdft/VNL_grad_pw.cpp b/source/source_pw/module_pwdft/VNL_grad_pw.cpp index 0cc37eccdb..4a2ea47a46 100644 --- a/source/source_pw/module_pwdft/VNL_grad_pw.cpp +++ b/source/source_pw/module_pwdft/VNL_grad_pw.cpp @@ -47,7 +47,7 @@ void pseudopot_cell_vnl::initgradq_vnl(const UnitCell &cell) aux[ir] = cell.atoms[it].ncpp.betar(ib, ir) * djl[ir] * pow(cell.atoms[it].ncpp.r[ir],2); } - double vqint; + double vqint = 0.0; ModuleBase::Integral::Simpson_Integral(kkbeta, aux, cell.atoms[it].ncpp.rab.data(), vqint); this->tab_dq(it, ib, iq) = vqint * pref; } diff --git a/source/source_pw/module_pwdft/VNL_in_pw.cpp b/source/source_pw/module_pwdft/VNL_in_pw.cpp index 3b63c28f3d..68257770c9 100644 --- a/source/source_pw/module_pwdft/VNL_in_pw.cpp +++ b/source/source_pw/module_pwdft/VNL_in_pw.cpp @@ -825,7 +825,7 @@ void pseudopot_cell_vnl::compute_qrad(UnitCell& cell) aux[ir] = besr[ir] * upf->qfuncl(l, ijv, ir); } // then we integrate with all the Q functions - double vqint; + double vqint = 0.0; ModuleBase::Integral::Simpson_Integral(kkbeta, aux, upf->rab.data(), vqint); qrad(it, l, ijv, iq) = vqint * pref; } @@ -1234,7 +1234,7 @@ void pseudopot_cell_vnl::init_vnl_alpha(const UnitCell& ucell) // pengfei Li 201 aux[ir] = ucell.atoms[it].ncpp.betar(ib, ir) * jl[ir] * ucell.atoms[it].ncpp.r[ir] * ucell.atoms[it].ncpp.r[ir]; } - double vqint; + double vqint = 0.0; ModuleBase::Integral::Simpson_Integral(kkbeta, aux, ucell.atoms[it].ncpp.rab.data(), vqint); this->tab_alpha(it, ib, L, iq) = vqint * pref; } diff --git a/source/source_pw/module_pwdft/elecond.cpp b/source/source_pw/module_pwdft/elecond.cpp index 068ca01067..985f7f8717 100644 --- a/source/source_pw/module_pwdft/elecond.cpp +++ b/source/source_pw/module_pwdft/elecond.cpp @@ -61,7 +61,7 @@ void EleCond::KG(const int& smear_type, const double gamma = fwhmin / 2.0 / ModuleBase::Ry_to_eV; double dt = dt_in; // unit in a.u., 1 a.u. = 4.837771834548454e-17 s const double expfactor = 23; // exp(-23) = 1e-10 - int nt; // set nt empirically + int nt = 0; // set nt empirically if (smear_type == 1) { nt = ceil(sqrt(2 * expfactor) / sigma / dt); diff --git a/source/source_pw/module_pwdft/forces.cpp b/source/source_pw/module_pwdft/forces.cpp index 255b8e23a2..fbcebe6304 100644 --- a/source/source_pw/module_pwdft/forces.cpp +++ b/source/source_pw/module_pwdft/forces.cpp @@ -197,7 +197,7 @@ void Forces::cal_force(UnitCell& ucell, if (ModuleSymmetry::Symmetry::symm_flag == 1) { - double d1, d2, d3; + double d1 = 0.0, d2 = 0.0, d3 = 0.0; for (int iat = 0; iat < this->nat; iat++) { ModuleBase::Mathzone::Cartesian_to_Direct(force(iat, 0), @@ -449,7 +449,7 @@ void Forces::cal_force_loc(const UnitCell& ucell, for (int ig = 0; ig < rho_basis->npw; ig++) { const double phase = ModuleBase::TWO_PI * (rho_basis->gcar[ig] * ucell.atoms[it].tau[ia]); - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(phase, &sinp, &cosp); const double factor = vloc(it, rho_basis->ig2igg[ig]) * (cosp * aux[ig].imag() + sinp * aux[ig].real()); @@ -503,7 +503,7 @@ void Forces::cal_force_ew(const UnitCell& ucell, { if (ucell.atoms[it].na != 0) { - double dzv; + double dzv = 0.0; { dzv = ucell.atoms[it].ncpp.zv; } @@ -526,7 +526,7 @@ void Forces::cal_force_ew(const UnitCell& ucell, } double alpha = 1.1; - double upperbound; + double upperbound = 0.0; do { alpha -= 0.10; @@ -634,7 +634,7 @@ void Forces::cal_force_ew(const UnitCell& ucell, { const ModuleBase::Vector3 gcar = rho_basis->gcar[ig]; const double arg = ModuleBase::TWO_PI * (gcar * ucell.atoms[it].tau[ia]); - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); double sumnb = -cosp * aux[ig].imag() + sinp * aux[ig].real(); forceion(iat, 0) += gcar[0] * sumnb; @@ -686,7 +686,7 @@ void Forces::cal_force_ew(const UnitCell& ucell, { const double rr = sqrt(r2[n]) * ucell.lat0; - double factor; + double factor = 0.0; { factor = ucell.atoms[T1].ncpp.zv * ucell.atoms[T2].ncpp.zv * ModuleBase::e2 / (rr * rr) diff --git a/source/source_pw/module_pwdft/forces_cc.cpp b/source/source_pw/module_pwdft/forces_cc.cpp index a03d49964b..fd8b3ac20c 100644 --- a/source/source_pw/module_pwdft/forces_cc.cpp +++ b/source/source_pw/module_pwdft/forces_cc.cpp @@ -254,7 +254,7 @@ void Forces::deriv_drhoc const UnitCell& ucell_in ) { - int igl0; + int igl0 = 0; double gx = 0, rhocg1 = 0; //double *aux = new double[mesh]; std::vector aux(mesh); diff --git a/source/source_pw/module_pwdft/forces_scc.cpp b/source/source_pw/module_pwdft/forces_scc.cpp index 10681e5114..d77ee3bf2a 100644 --- a/source/source_pw/module_pwdft/forces_scc.cpp +++ b/source/source_pw/module_pwdft/forces_scc.cpp @@ -114,7 +114,7 @@ void Forces::cal_force_scc(ModuleBase::matrix& forcescc, const double rhocgntigg = rhocgnt[rho_basis->ig2igg[ig]]; const double arg = ModuleBase::TWO_PI * (gv * pos); - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); const std::complex cpm = std::complex(sinp, cosp) * conj(psic[ig]); diff --git a/source/source_pw/module_pwdft/fs_nonlocal_tools.h b/source/source_pw/module_pwdft/fs_nonlocal_tools.h index ffe745f07e..d424b7be1e 100644 --- a/source/source_pw/module_pwdft/fs_nonlocal_tools.h +++ b/source/source_pw/module_pwdft/fs_nonlocal_tools.h @@ -154,13 +154,13 @@ class FS_Nonlocal_tools Device* ctx = {}; base_device::DEVICE_CPU* cpu_ctx = {}; base_device::AbacusDevice_t device = {}; - int nkb; - int nbands; + int nkb = 0; + int nbands = 0; int max_nh = 0; int max_npw = 0; - int ntype; - bool nondiagonal; + int ntype = 0; + bool nondiagonal = false; int pre_ik_s = -1; int pre_ik_f = -1; diff --git a/source/source_pw/module_pwdft/nonlocal_maths.hpp b/source/source_pw/module_pwdft/nonlocal_maths.hpp index 07cd28de2d..dba911488d 100644 --- a/source/source_pw/module_pwdft/nonlocal_maths.hpp +++ b/source/source_pw/module_pwdft/nonlocal_maths.hpp @@ -33,7 +33,7 @@ class Nonlocal_maths private: ModuleBase::matrix nhtol_; - int lmax_; + int lmax_ = 0; const UnitCell* ucell_; Device* ctx = {}; diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.h b/source/source_pw/module_pwdft/onsite_proj_tools.h index a8b7a56b8e..82a24efadf 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.h +++ b/source/source_pw/module_pwdft/onsite_proj_tools.h @@ -104,8 +104,8 @@ class Onsite_Proj_tools Device* ctx = {}; base_device::DEVICE_CPU* cpu_ctx = {}; base_device::AbacusDevice_t device = {}; - int nkb; - int nbands; + int nkb = 0; + int nbands = 0; int deeq_dims[4] = {0, 0, 0, 0}; // deeq can be something other than that in pseudopotentials int deeq_nc_dims[4] = {0, 0, 0, 0}; @@ -113,8 +113,8 @@ class Onsite_Proj_tools int max_nh = 0; int max_npw = 0; - int ntype; - bool nondiagonal; + int ntype = 0; + bool nondiagonal = false; int pre_ik_s = -1; int pre_ik_f = -1; diff --git a/source/source_pw/module_pwdft/onsite_projector.cpp b/source/source_pw/module_pwdft/onsite_projector.cpp index 4c03ce9b74..f9b8ad7cbc 100644 --- a/source/source_pw/module_pwdft/onsite_projector.cpp +++ b/source/source_pw/module_pwdft/onsite_projector.cpp @@ -503,7 +503,7 @@ void projectors::OnsiteProjector::read_abacus_orb(std::ifstream& ifs, { if (rank == 0) { - int l, izeta; + int l = 0, izeta = 0; ifs >> tmp >> tmp >> tmp; ifs >> tmp >> l >> izeta; ichi = radial_map_[l][izeta]; diff --git a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp b/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp index 1e62477e5d..2e06904a3b 100644 --- a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp +++ b/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp @@ -148,7 +148,7 @@ void OperatorEXXPW::construct_ace() const for (int iq0 = 0; iq0 < nqs; iq0++) { // For nspin=2, iq should be in the same spin channel as ik - int iq; + int iq = 0; int nk = wfcpw->nks / 2; iq = iq0 + ispin * nk; // iq in the same spin channel diff --git a/source/source_pw/module_pwdft/parallel_grid.cpp b/source/source_pw/module_pwdft/parallel_grid.cpp index 73cbba225e..ff20f40d73 100644 --- a/source/source_pw/module_pwdft/parallel_grid.cpp +++ b/source/source_pw/module_pwdft/parallel_grid.cpp @@ -90,7 +90,7 @@ void Parallel_Grid::init(const int& ncx_in, assert(GlobalV::KPAR > 0); this->nproc_in_pool = new int[GlobalV::KPAR]; - int nprocgroup; + int nprocgroup = 0; if (PARAM.inp.esolver_type == "sdft") { nprocgroup = GlobalV::NPROC_IN_BNDGROUP; diff --git a/source/source_pw/module_pwdft/soc.cpp b/source/source_pw/module_pwdft/soc.cpp index d90b334a2f..a44a0b6a48 100644 --- a/source/source_pw/module_pwdft/soc.cpp +++ b/source/source_pw/module_pwdft/soc.cpp @@ -122,7 +122,7 @@ int Soc::sph_ind(const int l, const double j, const int m, const int spin) // in a spinor with orbital angular momentum l, total angular // momentum j, projection along z of the total angular momentum m+-1/2. // Spin selects the up (spin=1) or down (spin=2) coefficient. - int sph_ind0; + int sph_ind0 = 0; if (spin != 0 && spin != 1) { ModuleBase::WARNING_QUIT("sph_ind", "spin must be 0 1"); diff --git a/source/source_pw/module_pwdft/stress_func_loc.cpp b/source/source_pw/module_pwdft/stress_func_loc.cpp index 11c414f4dc..0b932afcdb 100644 --- a/source/source_pw/module_pwdft/stress_func_loc.cpp +++ b/source/source_pw/module_pwdft/stress_func_loc.cpp @@ -188,7 +188,7 @@ const UnitCell& ucell_in // - int igl0; + int igl0 = 0; this->device = base_device::get_device_type(this->ctx); std::vector gx_arr(rho_basis->ngg+1); @@ -276,7 +276,7 @@ void Stress_Func::dvloc_coulomb(const UnitCell& ucell, FPTYPE* dvloc, ModulePW::PW_Basis* rho_basis) { - int igl0; + int igl0 = 0; // start from |G|=0 or not. if (rho_basis->gg_uniq[0] < 1.0e-8) { diff --git a/source/source_pw/module_stodft/sto_forces.cpp b/source/source_pw/module_stodft/sto_forces.cpp index 3fb761d85c..47a91f3dde 100644 --- a/source/source_pw/module_stodft/sto_forces.cpp +++ b/source/source_pw/module_stodft/sto_forces.cpp @@ -108,7 +108,7 @@ void Sto_Forces::cal_stoforce(ModuleBase::matrix& force, if (ModuleSymmetry::Symmetry::symm_flag == 1) { - double d1, d2, d3; + double d1 = 0.0, d2 = 0.0, d3 = 0.0; for (int iat = 0; iat < ucell.nat; iat++) { ModuleBase::Mathzone::Cartesian_to_Direct(force(iat, 0), diff --git a/source/source_pw/module_stodft/sto_iter.cpp b/source/source_pw/module_stodft/sto_iter.cpp index cd00e2f6f2..99fd2ef2bb 100644 --- a/source/source_pw/module_stodft/sto_iter.cpp +++ b/source/source_pw/module_stodft/sto_iter.cpp @@ -273,7 +273,7 @@ void Stochastic_Iter::itermu(const int iter, elecstate::ElecState* pe { ModuleBase::TITLE("Stochastic_Iter", "itermu"); ModuleBase::timer::tick("Stochastic_Iter", "itermu"); - double dmu; + double dmu = 0.0; if (iter == 1) { dmu = 2; @@ -294,8 +294,8 @@ void Stochastic_Iter::itermu(const int iter, elecstate::ElecState* pe double ne2 = calne(pes); double mu2 = this->stofunc.mu; double Dne = th_ne + 1; - double ne3; - double mu3; + double ne3 = 0.0; + double mu3 = 0.0; while (ne1 > targetne) { @@ -440,7 +440,7 @@ double Stochastic_Iter::calne(elecstate::ElecState* pes) double totne = 0; KS_ne = 0; const int norder = p_che->norder; - double sto_ne; + double sto_ne = 0.0; if (this->method == 1) { // Note: spolyv contains kv.wk[ik] diff --git a/source/source_pw/module_stodft/sto_iter.h b/source/source_pw/module_stodft/sto_iter.h index 20837d708f..8a97796502 100644 --- a/source/source_pw/module_stodft/sto_iter.h +++ b/source/source_pw/module_stodft/sto_iter.h @@ -119,8 +119,8 @@ class Stochastic_Iter Sto_Func stofunc; hamilt::HamiltSdftPW* p_hamilt_sto = nullptr; - double mu0; // chemical potential; unit in Ry - bool change; + double mu0 = 0.0; // chemical potential; unit in Ry + bool change = false; double targetne=0.0; Real* spolyv = nullptr; //[Device] coefficients of Chebyshev expansion Real* spolyv_cpu = nullptr; //[CPU] coefficients of Chebyshev expansion diff --git a/source/source_pw/module_stodft/sto_tool.h b/source/source_pw/module_stodft/sto_tool.h index 65a8b792a0..6b0c9e2a59 100644 --- a/source/source_pw/module_stodft/sto_tool.h +++ b/source/source_pw/module_stodft/sto_tool.h @@ -53,8 +53,8 @@ struct parallel_distribution this->start = st_per; this->num_per = num_per; } - int start; - int num_per; + int start = 0; + int num_per = 0; }; #ifdef __MPI diff --git a/source/source_pw/module_stodft/sto_wf.cpp b/source/source_pw/module_stodft/sto_wf.cpp index de9a4559e1..2ba8db2908 100644 --- a/source/source_pw/module_stodft/sto_wf.cpp +++ b/source/source_pw/module_stodft/sto_wf.cpp @@ -166,7 +166,7 @@ void Stochastic_WF::init_com_orbitals() const bool firstrankmore = false; const int npwx = this->npwx; const int nks = this->nks; - int igroup; + int igroup = 0; // former processor calculate more bands if (firstrankmore) { @@ -219,7 +219,7 @@ void Stochastic_WF::init_com_orbitals() // give value to orbitals in one parallel group one by one. for (int ichi = 0; ichi < nchipk; ++ichi) { - int ig; + int ig = 0; if (igroup < re) { // It has more nchip. From 626595a180375b0b90eb15010ecc628aece8c9bb Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 21:02:26 +0800 Subject: [PATCH 04/21] Fix uninitialized variables in source_lcao directory This commit fixes uninitialized variables (int and double) in 18 files within the source_lcao directory. All variables are initialized to 0 or 0.0 to prevent undefined behavior and improve code safety. Affected files: - spar_hsr.cpp, spar_dh.cpp - wavefunc_in_pw.cpp - module_rt/velocity_op.cpp, module_rt/norm_psi.cpp, module_rt/propagator.cpp, module_rt/td_folding.cpp, module_rt/boundary_fix.cpp - module_ri/exx_abfs-io.cpp, module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp, module_ri/module_exx_symmetry/symmetry_rotation.cpp - module_lr/dm_trans/dmr_complex.cpp, module_lr/esolver_lrtd_lcao.cpp - module_operator_lcao/dspin_force_stress.hpp, module_operator_lcao/dftu_force_stress.hpp - module_hcontainer/func_folding.cpp, module_hcontainer/test/test_hcontainer.cpp - module_gint/set_ddphi.cpp --- source/source_lcao/module_gint/set_ddphi.cpp | 2 +- .../source_lcao/module_hcontainer/func_folding.cpp | 4 ++-- .../module_hcontainer/test/test_hcontainer.cpp | 4 ++-- .../source_lcao/module_lr/dm_trans/dmr_complex.cpp | 2 +- source/source_lcao/module_lr/esolver_lrtd_lcao.cpp | 2 +- .../module_operator_lcao/dftu_force_stress.hpp | 2 +- .../module_operator_lcao/dspin_force_stress.hpp | 2 +- source/source_lcao/module_ri/exx_abfs-io.cpp | 2 +- .../module_exx_symmetry/irreducible_sector_bvk.cpp | 8 ++++---- .../module_exx_symmetry/symmetry_rotation.cpp | 2 +- source/source_lcao/module_rt/boundary_fix.cpp | 2 +- source/source_lcao/module_rt/norm_psi.cpp | 2 +- source/source_lcao/module_rt/propagator.cpp | 4 ++-- source/source_lcao/module_rt/td_folding.cpp | 6 +++--- source/source_lcao/module_rt/velocity_op.cpp | 12 ++++++------ source/source_lcao/spar_dh.cpp | 4 ++-- source/source_lcao/spar_hsr.cpp | 2 +- source/source_lcao/wavefunc_in_pw.cpp | 8 ++++---- 18 files changed, 35 insertions(+), 35 deletions(-) diff --git a/source/source_lcao/module_gint/set_ddphi.cpp b/source/source_lcao/module_gint/set_ddphi.cpp index c84f087487..4e7d486fbc 100644 --- a/source/source_lcao/module_gint/set_ddphi.cpp +++ b/source/source_lcao/module_gint/set_ddphi.cpp @@ -72,7 +72,7 @@ void GintAtom::set_ddphi( const double x12 = x1 * x2 / 6; const double x03 = x0 * x3 / 2; - double tmp, dtmp; + double tmp = 0.0, dtmp = 0.0; for(int iw = 0; iw < atom_->nw; ++iw) { diff --git a/source/source_lcao/module_hcontainer/func_folding.cpp b/source/source_lcao/module_hcontainer/func_folding.cpp index 58ba3d267a..4b276846d6 100644 --- a/source/source_lcao/module_hcontainer/func_folding.cpp +++ b/source/source_lcao/module_hcontainer/func_folding.cpp @@ -40,7 +40,7 @@ void folding_HR(const hamilt::HContainer& hR, // if TK==std::complex, kphase is e^{ikR} const ModuleBase::Vector3 dR(r_index.x, r_index.y, r_index.z); const double arg = (kvec_d_in * dR) * ModuleBase::TWO_PI; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); std::complex kphase = std::complex(cosp, sinp); @@ -86,7 +86,7 @@ void folding_HR(const hamilt::HContainer& hR, // if TK==std::complex, kphase is e^{ikR} const ModuleBase::Vector3 dR(rx, ry, rz); const double arg = (kvec_d_in * dR) * ModuleBase::TWO_PI; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); std::complex kphase = std::complex(cosp, sinp); diff --git a/source/source_lcao/module_hcontainer/test/test_hcontainer.cpp b/source/source_lcao/module_hcontainer/test/test_hcontainer.cpp index 536eb8744e..ef948f87d8 100644 --- a/source/source_lcao/module_hcontainer/test/test_hcontainer.cpp +++ b/source/source_lcao/module_hcontainer/test/test_hcontainer.cpp @@ -542,8 +542,8 @@ TEST_F(HContainerTest, atompair_funcs) } HR.unfix_R(); // check hr_array and hr_array2 are correct - std::complex correct1; - double correct2; + std::complex correct1 = 0.0; + double correct2 = 0.0; double correct_array[16] = { 1, 2, 3, 4, 5, 6, 7, 8, diff --git a/source/source_lcao/module_lr/dm_trans/dmr_complex.cpp b/source/source_lcao/module_lr/dm_trans/dmr_complex.cpp index 3ed8ab69bf..4f62aa2a43 100644 --- a/source/source_lcao/module_lr/dm_trans/dmr_complex.cpp +++ b/source/source_lcao/module_lr/dm_trans/dmr_complex.cpp @@ -47,7 +47,7 @@ namespace elecstate // if TK==std::complex, kphase is e^{ikR} const ModuleBase::Vector3 dR(r_index[0], r_index[1], r_index[2]); const double arg = (this->_kvec_d[ik] * dR) * ModuleBase::TWO_PI; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); const std::complex kphase = std::complex(cosp, sinp); // set DMR element diff --git a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp index 16efc5f046..95b956b7fb 100644 --- a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp +++ b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp @@ -692,7 +692,7 @@ void LR::ESolver_LR::read_ks_chg(Charge& chg_gs) std::stringstream ssc; ssc << PARAM.globalv.global_readin_dir << "SPIN" << is + 1 << "_CHG.cube"; GlobalV::ofs_running << ssc.str() << std::endl; - double ef; + double ef = 0.0; if (ModuleIO::read_vdata_palgrid(Pgrid, GlobalV::MY_RANK, GlobalV::ofs_running, diff --git a/source/source_lcao/module_operator_lcao/dftu_force_stress.hpp b/source/source_lcao/module_operator_lcao/dftu_force_stress.hpp index 2ce46854a4..8175d1009f 100644 --- a/source/source_lcao/module_operator_lcao/dftu_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/dftu_force_stress.hpp @@ -324,7 +324,7 @@ void DFTU>::cal_force_IJR(const int& iat1, step_trace[3] = col_indexes.size() + 1; } - double tmp[3]; + double tmp[3] = {0.0}; // calculate the local matrix for (int is = 0; is < nspin; is++) { diff --git a/source/source_lcao/module_operator_lcao/dspin_force_stress.hpp b/source/source_lcao/module_operator_lcao/dspin_force_stress.hpp index ff14029e25..449d73c050 100644 --- a/source/source_lcao/module_operator_lcao/dspin_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/dspin_force_stress.hpp @@ -272,7 +272,7 @@ void DeltaSpin>::cal_force_IJR(const int& iat1, step_trace[2] = col_indexes.size(); step_trace[3] = col_indexes.size() + 1; } - double tmp[3]; + double tmp[3] = {0.0}; // calculate the local matrix for (int is = 1; is < nspin; is++) { diff --git a/source/source_lcao/module_ri/exx_abfs-io.cpp b/source/source_lcao/module_ri/exx_abfs-io.cpp index 0ed196335b..bbdda73897 100644 --- a/source/source_lcao/module_ri/exx_abfs-io.cpp +++ b/source/source_lcao/module_ri/exx_abfs-io.cpp @@ -62,7 +62,7 @@ std::vector> Exx_Abfs::IO::construct_abfs_T( size_t L_size; std::map N_size; size_t meshr; - double dr; + double dr = 0.0; std::map>> psis; /*---------------------- diff --git a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp index 50df31b360..8b8879ee1d 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector_bvk.cpp @@ -102,8 +102,8 @@ namespace ModuleSymmetry } // analyze bravis and generate optimized lattice for minimal BvK lattice - double cel_const[6]; - double pre_const[6]; + double cel_const[6] = {0.0}; + double pre_const[6] = {0.0}; int bvk_brav = 0; std::string bvk_latname=""; // bvk_brav = symm.standard_lat(s1, s2, s3, cel_const); //not enough, optimal lattice may change after cell-extension @@ -126,10 +126,10 @@ namespace ModuleSymmetry // generate symmetry operation of the BvK lattice using the original optlat-direct coordinates std::vector bvk_op(48); - int bvk_nop; + int bvk_nop = 0; symm.setgroup(bvk_op.data(), bvk_nop, bvk_brav); bvk_op.resize(bvk_nop); - int bvk_npg, bvk_nsg, bvk_pgnum, bvk_sgnum; + int bvk_npg = 0, bvk_nsg = 0, bvk_pgnum = 0, bvk_sgnum = 0; std::string bvk_pgname, bvk_sgname; std::vector bvk_gmatrix(48); std::vector> bvk_gtrans(48); diff --git a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp index e0b4d91b8b..27929737f6 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp @@ -203,7 +203,7 @@ namespace ModuleSymmetry TCdouble Symmetry_rotation::get_euler_angle(const ModuleBase::Matrix3& gmatc) const { double threshold = this->eps_; - double alpha, beta, gamma; + double alpha = 0.0, beta = 0.0, gamma = 0.0; if (std::fabs(gmatc.e32) > threshold || std::fabs(gmatc.e31) > threshold) // sin(beta) is not zero { // use the 2-angle elements to get alpha and gamma diff --git a/source/source_lcao/module_rt/boundary_fix.cpp b/source/source_lcao/module_rt/boundary_fix.cpp index 22e7324633..dcdb436153 100644 --- a/source/source_lcao/module_rt/boundary_fix.cpp +++ b/source/source_lcao/module_rt/boundary_fix.cpp @@ -33,7 +33,7 @@ void reset_matrix_boundary(const UnitCell& ucell, //skip unrelevent ik if(arg==0)continue; //calculate correction phase - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); const std::complex phase = std::complex(cosp, sinp); //phase correction for Hamiltionian, overlap matrix and c vec. diff --git a/source/source_lcao/module_rt/norm_psi.cpp b/source/source_lcao/module_rt/norm_psi.cpp index 307cef9f80..d29972dce3 100644 --- a/source/source_lcao/module_rt/norm_psi.cpp +++ b/source/source_lcao/module_rt/norm_psi.cpp @@ -16,7 +16,7 @@ namespace module_rt inline int globalIndex(int localindex, int nblk, int nprocs, int myproc) { - int iblock, gIndex; + int iblock = 0, gIndex = 0; iblock = localindex / nblk; gIndex = (iblock * nprocs + myproc) * nblk + localindex % nblk; return gIndex; diff --git a/source/source_lcao/module_rt/propagator.cpp b/source/source_lcao/module_rt/propagator.cpp index d9a37b8c8b..2854839066 100644 --- a/source/source_lcao/module_rt/propagator.cpp +++ b/source/source_lcao/module_rt/propagator.cpp @@ -24,7 +24,7 @@ void Propagator::compute_propagator(const int nlocal, std::ofstream& ofs_running, const int print_matrix) const { - int tag; + int tag = 0; switch (ptype) { case 0: @@ -56,7 +56,7 @@ void Propagator::compute_propagator_tensor(const int nlocal, const int print_matrix, const bool use_lapack) const { - int tag; + int tag = 0; switch (ptype) { case 0: diff --git a/source/source_lcao/module_rt/td_folding.cpp b/source/source_lcao/module_rt/td_folding.cpp index e0b34cd31f..ed42b7524e 100644 --- a/source/source_lcao/module_rt/td_folding.cpp +++ b/source/source_lcao/module_rt/td_folding.cpp @@ -32,7 +32,7 @@ void folding_HR_td(const UnitCell& ucell, // if TK==std::complex, kphase is e^{ikR} const ModuleBase::Vector3 dR(r_index.x, r_index.y, r_index.z); const double arg = (kvec_d_in * dR) * ModuleBase::TWO_PI + arg_td; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); std::complex kphase = std::complex(cosp, sinp); @@ -62,7 +62,7 @@ void folding_partial_HR(const UnitCell& ucell, const ModuleBase::Vector3 r_index = tmp.get_R_index(ir); const ModuleBase::Vector3 dR(r_index.x, r_index.y, r_index.z); const double arg = (kvec_d_in * dR) * ModuleBase::TWO_PI; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); std::complex kphase = std::complex(cosp, sinp); const ModuleBase::Vector3 dR_car = dR * ucell.latvec * ucell.lat0; @@ -105,7 +105,7 @@ void folding_partial_HR_td(const UnitCell& ucell, // if TK==std::complex, kphase is e^{ikR} const ModuleBase::Vector3 dR(r_index.x, r_index.y, r_index.z); const double arg = (kvec_d_in * dR) * ModuleBase::TWO_PI + arg_td; - double sinp, cosp; + double sinp = 0.0, cosp = 0.0; ModuleBase::libm::sincos(arg, &sinp, &cosp); std::complex kphase = std::complex(cosp, sinp); const ModuleBase::Vector3 dR_car = dR * ucell.latvec * ucell.lat0; diff --git a/source/source_lcao/module_rt/velocity_op.cpp b/source/source_lcao/module_rt/velocity_op.cpp index ceec0b1b65..7114fb2495 100644 --- a/source/source_lcao/module_rt/velocity_op.cpp +++ b/source/source_lcao/module_rt/velocity_op.cpp @@ -54,7 +54,7 @@ void Velocity_op::initialize_vcomm_r(const Grid_Driver* GridD, const Paralle for (int iat0 = 0; iat0 < ucell->nat; iat0++) { auto tau0 = ucell->get_tau(iat0); - int T0, I0; + int T0 = 0, I0 = 0; ucell->iat2iait(iat0, &I0, &T0); AdjacentAtomInfo adjs; GridD->Find_atom(*ucell, tau0, T0, I0, &adjs); @@ -129,7 +129,7 @@ void Velocity_op::initialize_grad_term(const Grid_Driver* GridD, const Paral for (int iat1 = 0; iat1 < ucell->nat; iat1++) { auto tau1 = ucell->get_tau(iat1); - int T1, I1; + int T1 = 0, I1 = 0; ucell->iat2iait(iat1, &I1, &T1); AdjacentAtomInfo adjs; GridD->Find_atom(*ucell, tau1, T1, I1, &adjs); @@ -190,7 +190,7 @@ void Velocity_op::calculate_vcomm_r() for (int iat0 = 0; iat0 < this->ucell->nat; iat0++) { auto tau0 = ucell->get_tau(iat0); - int T0, I0; + int T0 = 0, I0 = 0; ucell->iat2iait(iat0, &I0, &T0); AdjacentAtomInfo& adjs = this->adjs_vcommr[iat0]; std::vector>>> nlm_tot; @@ -422,7 +422,7 @@ void Velocity_op::calculate_grad_term() for (int iat1 = 0; iat1 < this->ucell->nat; iat1++) { auto tau1 = ucell->get_tau(iat1); - int T1, I1; + int T1 = 0, I1 = 0; ucell->iat2iait(iat1, &I1, &T1); AdjacentAtomInfo& adjs = this->adjs_grad[iat1]; for (int ad = 0; ad < adjs.adj_num + 1; ++ad) @@ -464,9 +464,9 @@ void Velocity_op::cal_grad_IJR(const int& iat1, // --------------------------------------------- // get info of orbitals of atom1 and atom2 from ucell // --------------------------------------------- - int T1, I1; + int T1 = 0, I1 = 0; this->ucell->iat2iait(iat1, &I1, &T1); - int T2, I2; + int T2 = 0, I2 = 0; this->ucell->iat2iait(iat2, &I2, &T2); Atom& atom1 = this->ucell->atoms[T1]; Atom& atom2 = this->ucell->atoms[T2]; diff --git a/source/source_lcao/spar_dh.cpp b/source/source_lcao/spar_dh.cpp index 7d5d485d56..1848901eea 100644 --- a/source/source_lcao/spar_dh.cpp +++ b/source/source_lcao/spar_dh.cpp @@ -160,8 +160,8 @@ void sparse_format::cal_dSTN_R(const UnitCell& ucell, ModuleBase::Vector3 dtau, tau1, tau2; ModuleBase::Vector3 dtau1, dtau2, tau0; - double temp_value_double; - std::complex temp_value_complex; + double temp_value_double = 0.0; + std::complex temp_value_complex = 0.0; for (int T1 = 0; T1 < ucell.ntype; ++T1) { diff --git a/source/source_lcao/spar_hsr.cpp b/source/source_lcao/spar_hsr.cpp index b0c1ce2139..22cb11bba3 100644 --- a/source/source_lcao/spar_hsr.cpp +++ b/source/source_lcao/spar_hsr.cpp @@ -10,7 +10,7 @@ #ifdef __MPI void sparse_format::sync_all_R_coor(std::set>& all_R_coor, MPI_Comm comm) { - int my_rank, nproc; + int my_rank = 0, nproc = 0; MPI_Comm_rank(comm, &my_rank); MPI_Comm_size(comm, &nproc); diff --git a/source/source_lcao/wavefunc_in_pw.cpp b/source/source_lcao/wavefunc_in_pw.cpp index 701f0f42a4..3bc3711e14 100644 --- a/source/source_lcao/wavefunc_in_pw.cpp +++ b/source/source_lcao/wavefunc_in_pw.cpp @@ -125,7 +125,7 @@ void Wavefunc_in_pw::make_table_q( } else { - double no_use; + double no_use = 0.0; for(int ir=0; ir> no_use; @@ -327,7 +327,7 @@ void Wavefunc_in_pw::produce_local_basis_in_pw(const UnitCell& ucell, }//if else {//atomic_wfc_so_mag - double alpha, gamma; + double alpha = 0.0, gamma = 0.0; std::complex fup,fdown; //int nc; //This routine creates two functions only in the case j=l+1/2 or exit in the other case @@ -402,8 +402,8 @@ void Wavefunc_in_pw::produce_local_basis_in_pw(const UnitCell& ucell, } // end if ucell.atoms[it].has_so else {//atomic_wfc_nc - double alpha, gamman; - std::complex fup, fdown; + double alpha = 0.0, gamman = 0.0; + std::complex fup = 0.0, fdown = 0.0; //alpha = ucell.magnet.angle1_[it]; //gamman = -ucell.magnet.angle2_[it] + 0.5*ModuleBase::PI; alpha = ucell.atoms[it].angle1[ia]; From 3b5c3876a0269a7049b3bea8f3b80345877758e8 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 21:47:00 +0800 Subject: [PATCH 05/21] fix: initialize all uninitialized variables in source_relax and source_md --- source/source_md/msst.cpp | 2 +- source/source_md/nhchain.cpp | 12 ++++++------ source/source_md/verlet.cpp | 2 +- source/source_relax/ions_move_bfgs.cpp | 2 +- source/source_relax/relax_sync.cpp | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/source_md/msst.cpp b/source/source_md/msst.cpp index 0a9024cdfe..cadea1a8f1 100644 --- a/source/source_md/msst.cpp +++ b/source/source_md/msst.cpp @@ -83,7 +83,7 @@ void MSST::first_half(std::ofstream& ofs) const int sd = mdp.msst_direction; const double dthalf = 0.5 * md_dt; - double vol; + double vol = 0.0; energy_ = potential + kinetic; /// propagate the time derivative of volume 1/2 step diff --git a/source/source_md/nhchain.cpp b/source/source_md/nhchain.cpp index dfe086490a..ac1e23570c 100644 --- a/source/source_md/nhchain.cpp +++ b/source/source_md/nhchain.cpp @@ -390,7 +390,7 @@ void Nose_Hoover::restart(const std::string& global_readin_dir) if (ok) { - double Mnum; + double Mnum = 0.0; file >> step_rst_ >> md_tfirst >> Mnum; if (Mnum != mdp.md_tchain) @@ -494,7 +494,7 @@ void Nose_Hoover::particle_thermo() } /// integrate loop - double factor; + double factor = 0.0; double scale = 1.0; double KE = kinetic; for (int i = 0; i < nc_tchain; ++i) @@ -583,7 +583,7 @@ void Nose_Hoover::baro_thermo() g_peta[0] = (ke_omega - lkt_press) / mass_peta[0]; /// integrate loop - double factor; + double factor = 0.0; double scale = 1.0; double kecurrent = ke_omega; for (int i = 0; i < nc_pchain; ++i) @@ -662,7 +662,7 @@ void Nose_Hoover::update_baro() } term_one /= pdim * ucell.nat; - double g_omega; + double g_omega = 0.0; double term_two = 0; for (int i = 0; i < 3; ++i) { @@ -689,7 +689,7 @@ void Nose_Hoover::update_baro() void Nose_Hoover::vel_baro() { - double factor[3]; + double factor[3] = {0.0}; for (int i = 0; i < 3; ++i) { factor[i] = exp(-(v_omega[i] + mtk_term) * md_dt / 4); @@ -721,7 +721,7 @@ void Nose_Hoover::vel_baro() void Nose_Hoover::update_volume(std::ofstream& ofs) { - double factor; + double factor = 0.0; /// tri mode, off-diagonal components, first half if (pflag[4]) diff --git a/source/source_md/verlet.cpp b/source/source_md/verlet.cpp index 3eafb181e1..66871f8970 100644 --- a/source/source_md/verlet.cpp +++ b/source/source_md/verlet.cpp @@ -75,7 +75,7 @@ void Verlet::apply_thermostat(void) { if (my_rank == 0) { - double deviation; + double deviation = 0.0; for (int i = 0; i < ucell.nat; ++i) { if (static_cast(std::rand()) / RAND_MAX <= 1.0 / mdp.md_nraise) diff --git a/source/source_relax/ions_move_bfgs.cpp b/source/source_relax/ions_move_bfgs.cpp index 9c52010862..ee8a9d97e9 100644 --- a/source/source_relax/ions_move_bfgs.cpp +++ b/source/source_relax/ions_move_bfgs.cpp @@ -144,7 +144,7 @@ void Ions_Move_BFGS::restart_bfgs(const double& lat0) std::ifstream hess_file("hess_in"); if(hess_file) { - int rank1,rank2; + int rank1 = 0, rank2 = 0; hess_file >> rank1 >> rank2; if(rank1 == dim && rank2 == dim) { diff --git a/source/source_relax/relax_sync.cpp b/source/source_relax/relax_sync.cpp index 47f3e3b333..06fd91dc83 100644 --- a/source/source_relax/relax_sync.cpp +++ b/source/source_relax/relax_sync.cpp @@ -383,7 +383,7 @@ void Relax::perform_line_search() // perform line search bool restart_brent = false; double x = dmovel, y = etot; - double xnew, yd; + double xnew = 0.0, yd = 0.0; brent_done = this->ls.line_search(restart_brent, x, y, f, xnew, force_thr_eva); dmove = xnew; @@ -497,7 +497,7 @@ void Relax::move_cell_ions(UnitCell& ucell, const bool is_new_dir) // or a line search step, the treatment is slightly different // and the input variable is_new_dir is used to make the distinction - double fac; // fac1 for force, fac2 for stress + double fac = 0.0; // fac1 for force, fac2 for stress if (is_new_dir) { fac = 1.0; @@ -594,7 +594,7 @@ void Relax::move_cell_ions(UnitCell& ucell, const bool is_new_dir) // ================================================================= // Calculating displacement in Cartesian coordinate (in Angstrom) - double move_ion[nat * 3]; + double move_ion[nat * 3] = {0.0}; ModuleBase::zeros(move_ion, nat * 3); for (int iat = 0; iat < nat; iat++) From f9edda41dc9e6aae44d983420c6d94dfb2100cea Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 21:51:09 +0800 Subject: [PATCH 06/21] fix: initialize all uninitialized variables in source_base --- source/source_base/math_chebyshev.cpp | 6 +++--- source/source_base/math_erf_complex.cpp | 4 ++-- source/source_base/math_ylmreal.cpp | 2 +- source/source_base/tool_check.cpp | 2 +- source/source_base/tool_quit.cpp | 2 +- source/source_base/ylm.cpp | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/source_base/math_chebyshev.cpp b/source/source_base/math_chebyshev.cpp index aaa0e82b74..8a84686ea5 100644 --- a/source/source_base/math_chebyshev.cpp +++ b/source/source_base/math_chebyshev.cpp @@ -417,7 +417,7 @@ void Chebyshev::calfinalvec_real( std::complex* arrayn = nullptr; std::complex* arrayn_1 = nullptr; assert(N >= 0 && LDA >= N); - int ndmxt; + int ndmxt = 0; if (m == 1) { ndmxt = N * m; @@ -486,7 +486,7 @@ void Chebyshev::calfinalvec_complex( std::complex* arrayn = nullptr; std::complex* arrayn_1 = nullptr; assert(N >= 0 && LDA >= N); - int ndmxt; + int ndmxt = 0; if (m == 1) { ndmxt = N * m; @@ -585,7 +585,7 @@ void Chebyshev::tracepolyA( std::complex* arrayn = nullptr; std::complex* arrayn_1 = nullptr; assert(N >= 0 && LDA >= N); - int ndmxt; + int ndmxt = 0; if (m == 1) { ndmxt = N * m; diff --git a/source/source_base/math_erf_complex.cpp b/source/source_base/math_erf_complex.cpp index 18709c4866..4c7385245a 100644 --- a/source/source_base/math_erf_complex.cpp +++ b/source/source_base/math_erf_complex.cpp @@ -106,7 +106,7 @@ std::complex ErrorFunc::scaled_w(std::complex z, double relerr) else if (x < 10) { double prod2ax = 1, prodm2ax = 1; - double expx2; + double expx2 = 0.0; if (std::isnan(y)) return std::complex(y, y); @@ -235,7 +235,7 @@ std::complex ErrorFunc::scaled_w(std::complex z, double relerr) sum3 = std::exp(-dx * dx) / (a2 * (n0 * n0) + y * y); sum5 = a * n0 * sum3; double exp1 = std::exp(4 * a * dx), exp1dn = 1; - int dn; + int dn = 0; for (dn = 1; n0 - dn > 0; ++dn) { // loop over n0-dn and n0+dn terms double np = n0 + dn, nm = n0 - dn; diff --git a/source/source_base/math_ylmreal.cpp b/source/source_base/math_ylmreal.cpp index 3a11f95438..e94b027bb3 100644 --- a/source/source_base/math_ylmreal.cpp +++ b/source/source_base/math_ylmreal.cpp @@ -179,7 +179,7 @@ void YlmReal::rlylm { int twok = 2 * ik; - double gamma; + double gamma = 0.0; double aux0, aux1, aux2, aux3; aux0 = pow(-1.0, ik) * pow(2.0, -il); diff --git a/source/source_base/tool_check.cpp b/source/source_base/tool_check.cpp index a9450b4fcb..dab7dd5f21 100644 --- a/source/source_base/tool_check.cpp +++ b/source/source_base/tool_check.cpp @@ -49,7 +49,7 @@ void CHECK_INT(std::ifstream &ifs,const int &v,bool quit) void CHECK_DOUBLE(std::ifstream &ifs,const double &v,bool quit) { const double tiny = 1.0e-5; - double v_in; + double v_in = 0.0; ifs >> v_in; if( fabs(v - v_in) > tiny ) { diff --git a/source/source_base/tool_quit.cpp b/source/source_base/tool_quit.cpp index 77c855c7a0..efd72278cc 100644 --- a/source/source_base/tool_quit.cpp +++ b/source/source_base/tool_quit.cpp @@ -65,7 +65,7 @@ void WARNING_QUIT(const std::string &file,const std::string &description) #ifdef __MPI /* if it is MPI run, finalize first, then exit */ std::cout << "Detecting if MPI has been initialized..." << std::endl; - int is_initialized; + int is_initialized = 0; MPI_Initialized(&is_initialized); if (is_initialized) { std::cout << "Terminating ABACUS with multiprocessing environment." << std::endl; diff --git a/source/source_base/ylm.cpp b/source/source_base/ylm.cpp index cd7336718d..b055ed37ad 100644 --- a/source/source_base/ylm.cpp +++ b/source/source_base/ylm.cpp @@ -474,7 +474,7 @@ void Ylm::rlylm { int twok = 2 * ik; - double gamma; + double gamma = 0.0; double aux0, aux1, aux2, aux3; aux0 = pow(-1.0, ik) * pow(2.0, -il); @@ -1107,7 +1107,7 @@ void Ylm::hes_rl_sph_harm hrly.resize( (Lmax+1)*(Lmax+1), std::vector(6) ); double radius2 = x*x+y*y+z*z; - double coeff; + double coeff = 0.0; //begin calculation /*************************** @@ -1867,7 +1867,7 @@ void Ylm::rlylm { int twok = 2 * ik; - double gamma; + double gamma = 0.0; double aux0, aux1, aux2, aux3; aux0 = pow(-1.0, ik) * pow(2.0, -il); From 2ccadc5173bcb223c5c409e04ad58d8812ad0ddc Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 21:53:27 +0800 Subject: [PATCH 07/21] fix: initialize all uninitialized variables in source_cell and source_estate --- source/source_cell/klist.cpp | 2 +- source/source_cell/read_pp_blps.cpp | 4 ++-- source/source_cell/read_pp_upf100.cpp | 2 +- source/source_cell/read_pp_upf201.cpp | 2 +- source/source_cell/setup_nonlocal.cpp | 2 +- source/source_estate/cal_ux.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/source_cell/klist.cpp b/source/source_cell/klist.cpp index b9ee8c4eba..1bba575528 100644 --- a/source/source_cell/klist.cpp +++ b/source/source_cell/klist.cpp @@ -466,7 +466,7 @@ void K_Vectors::interpolate_k_between(std::ifstream& ifk, std::vector> zatom >> zion; pp.zv = zion; ifs.ignore(300, '\n'); diff --git a/source/source_cell/read_pp_upf100.cpp b/source/source_cell/read_pp_upf100.cpp index 0e91dffccc..9327ebe712 100644 --- a/source/source_cell/read_pp_upf100.cpp +++ b/source/source_cell/read_pp_upf100.cpp @@ -326,7 +326,7 @@ void Pseudopot_upf::read_pseudo_nl(std::ifstream& ifs, Atom_pseudo& pp) ModuleBase::GlobalFunc::READ_VALUE(ifs, this->nd); // nl_4 for (int i = 0; i < this->nd; i++) { - double swap; + double swap = 0.0; ifs >> nb >> mb >> swap; nb--; mb--; diff --git a/source/source_cell/read_pp_upf201.cpp b/source/source_cell/read_pp_upf201.cpp index e0941664bf..d02bb8e6d5 100644 --- a/source/source_cell/read_pp_upf201.cpp +++ b/source/source_cell/read_pp_upf201.cpp @@ -807,7 +807,7 @@ void Pseudopot_upf::read_pseudo_upf201_fullwfc(std::ifstream& ifs) std::string word; std::string name[50]; std::string val[50]; - int nparameter; + int nparameter = 0; this->aewfc.create(this->nbeta, this->mesh); this->pswfc.create(this->nbeta, this->mesh); ModuleBase::GlobalFunc::SCAN_BEGIN(ifs, "", false)) { - int iproj; + int iproj = 0; ModuleBase::GlobalFunc::READ_VALUE(ifs, iproj); if (iproj != p1) { diff --git a/source/source_estate/cal_ux.cpp b/source/source_estate/cal_ux.cpp index 5175e48d5a..f7ea856386 100644 --- a/source/source_estate/cal_ux.cpp +++ b/source/source_estate/cal_ux.cpp @@ -93,7 +93,7 @@ void cal_ux(UnitCell& ucell) { bool judge_parallel(double a[3], ModuleBase::Vector3 b) { bool jp = false; - double cross; + double cross = 0.0; cross = pow((a[1] * b.z - a[2] * b.y), 2) + pow((a[2] * b.x - a[0] * b.z), 2) + pow((a[0] * b.y - a[1] * b.x), 2); From c4f18fcd2b80cadb2501ec25628df446dd28f3d3 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 22:01:09 +0800 Subject: [PATCH 08/21] fix: initialize all uninitialized variables in source_hsolver and source_io --- source/source_hsolver/diago_elpa_native.cpp | 2 +- source/source_hsolver/hsolver_pw.cpp | 4 ++-- source/source_io/bessel_basis.cpp | 8 ++++---- source/source_io/cif_io.cpp | 12 ++++++------ source/source_io/csr_reader.cpp | 2 +- source/source_io/get_pchg_lcao.cpp | 2 +- source/source_io/get_wf_lcao.cpp | 2 +- source/source_io/read_input.cpp | 6 +++--- source/source_io/to_qo_kernel.cpp | 2 +- source/source_io/to_qo_mpi.cpp | 4 ++-- source/source_io/to_qo_structures.cpp | 4 ++-- source/source_io/to_wannier90.cpp | 4 ++-- source/source_io/unk_overlap_lcao.cpp | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/source/source_hsolver/diago_elpa_native.cpp b/source/source_hsolver/diago_elpa_native.cpp index f320191d28..dc4bf2b6d7 100644 --- a/source/source_hsolver/diago_elpa_native.cpp +++ b/source/source_hsolver/diago_elpa_native.cpp @@ -77,7 +77,7 @@ void DiagoElpaNative::diag_pool(hamilt::MatrixBlock& h_mat, } // elpa_init(20210430); - int success; + int success = 0; elpa_t handle = elpa_allocate(&success); #ifdef _OPENMP int num_threads = omp_get_max_threads(); diff --git a/source/source_hsolver/hsolver_pw.cpp b/source/source_hsolver/hsolver_pw.cpp index 7d178f699b..2ea7b92a2b 100644 --- a/source/source_hsolver/hsolver_pw.cpp +++ b/source/source_hsolver/hsolver_pw.cpp @@ -544,8 +544,8 @@ void HSolverPW::build_k_neighbors() { // Store k-points and corresponding indices struct KPoint { ModuleBase::Vector3 kvec; - int index; - double norm; + int index = 0; + double norm = 0.0; KPoint(const ModuleBase::Vector3& v, int i) : kvec(v), index(i), norm(v.norm()) {} diff --git a/source/source_io/bessel_basis.cpp b/source/source_io/bessel_basis.cpp index 5768f411e0..2795fefa25 100644 --- a/source/source_io/bessel_basis.cpp +++ b/source/source_io/bessel_basis.cpp @@ -392,10 +392,10 @@ void Bessel_Basis::readin_C4( if(ModuleBase::GlobalFunc::SCAN_BEGIN(inc4, "")) { - double tmp_ecut; - double tmp_rcut; - double tmp_enumber; - double tmp_tolerence; + double tmp_ecut = 0.0; + double tmp_rcut = 0.0; + double tmp_enumber = 0.0; + double tmp_tolerence = 0.0; ModuleBase::GlobalFunc::READ_VALUE( inc4, tmp_ecut); ModuleBase::GlobalFunc::READ_VALUE( inc4, tmp_rcut); ModuleBase::GlobalFunc::READ_VALUE( inc4, tmp_enumber); diff --git a/source/source_io/cif_io.cpp b/source/source_io/cif_io.cpp index c06ecb7033..a03cd0d15c 100644 --- a/source/source_io/cif_io.cpp +++ b/source/source_io/cif_io.cpp @@ -238,7 +238,7 @@ void bcast_cifmap(std::map>& map, // the m const int rank = 0) // source rank: from which rank to broadcast { #ifdef __MPI - int myrank; + int myrank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); // use Parallel_Common namespace bcast_int and bcast_string to broadcast the size of map and key, value pairs int size = map.size(); @@ -328,7 +328,7 @@ void ModuleIO::CifParser::write(const std::string& fcif, const std::string& cell_formula_units_z) { #ifdef __MPI // well...very simple... - int myrank; + int myrank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); if (myrank != rank) // if present rank is not the rank assigned to write the cif file, then return { @@ -402,7 +402,7 @@ void ModuleIO::CifParser::write(const std::string& fcif, const std::string& cell_formula_units_z) { #ifdef __MPI - int myrank; + int myrank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); if (myrank != rank) // if present rank is not the rank assigned to write the cif file, then return { @@ -429,7 +429,7 @@ void ModuleIO::CifParser::write(const std::string& fcif, const int rank) { #ifdef __MPI - int myrank; + int myrank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); if (myrank != rank) // if present rank is not the rank assigned to write the cif file, then return { @@ -437,7 +437,7 @@ void ModuleIO::CifParser::write(const std::string& fcif, } #endif std::vector veca, vecb, vecc; - int natom; + int natom = 0; std::vector atom_site_labels; std::vector atom_site_fract_coords; _unpack_ucell(ucell, veca, vecb, vecc, natom, atom_site_labels, atom_site_fract_coords); @@ -468,7 +468,7 @@ void ModuleIO::CifParser::read(const std::string& fcif, // okey for read, cannot just use if rank != 0 then return, because need to broadcast the map out.clear(); #ifdef __MPI - int myrank; + int myrank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myrank); if (myrank == rank) // only the rank assigned to read the cif file will read the file { diff --git a/source/source_io/csr_reader.cpp b/source/source_io/csr_reader.cpp index 160cb78a61..7e85c137b6 100644 --- a/source/source_io/csr_reader.cpp +++ b/source/source_io/csr_reader.cpp @@ -40,7 +40,7 @@ void csrFileReader::parseFile() for (int i = 0; i < numberOfR; i++) { std::vector RCoord(3); - int nonZero; + int nonZero = 0; readLine(); ss >> RCoord[0] >> RCoord[1] >> RCoord[2] >> nonZero; diff --git a/source/source_io/get_pchg_lcao.cpp b/source/source_io/get_pchg_lcao.cpp index 346b56f12a..82de5db224 100644 --- a/source/source_io/get_pchg_lcao.cpp +++ b/source/source_io/get_pchg_lcao.cpp @@ -408,7 +408,7 @@ void Get_pchg_lcao::idmatrix(const int& ib, if (ib_local >= 0) { - double wg_value; + double wg_value = 0.0; if (if_separate_k) { wg_value = (ib < fermi_band) ? wg_sum_k : wg_sum_k_homo; diff --git a/source/source_io/get_wf_lcao.cpp b/source/source_io/get_wf_lcao.cpp index 6cafa72d60..91d2c0b514 100644 --- a/source/source_io/get_wf_lcao.cpp +++ b/source/source_io/get_wf_lcao.cpp @@ -513,7 +513,7 @@ void Get_wf_lcao::wfc_2d_to_grid(const T* lowf_2d, MPI_Comm_rank(pv.comm(), &rank); // calculate the maximum number of nlocal over all processes in pv.comm() range - long buf_size; + long buf_size = 0; mpi_info = MPI_Reduce(&pv.nloc_wfc, &buf_size, 1, MPI_LONG, MPI_MAX, 0, pv.comm()); mpi_info = MPI_Bcast(&buf_size, 1, MPI_LONG, 0, pv.comm()); // get and then broadcast std::vector lowf_block(buf_size); diff --git a/source/source_io/read_input.cpp b/source/source_io/read_input.cpp index a23bcd0da9..c08c63acc7 100644 --- a/source/source_io/read_input.cpp +++ b/source/source_io/read_input.cpp @@ -104,13 +104,13 @@ bool filter_nonascii_and_comment(std::ifstream& ifs, ifs.clear(); ifs.seekg(0, std::ios::beg); - char c; + char c = '\0'; while (ifs.get(c)) { // If comment start, skip until end of line (but keep the newline) if (c == '#') { - char d; + char d = '\0'; bool newline_found = false; while (ifs.get(d)) { @@ -562,7 +562,7 @@ int ReadInput::current_md_step(const std::string& file_dir) ModuleBase::WARNING_QUIT("current_md_step", "no Restart_md.txt"); } - int md_step; + int md_step = 0; file >> md_step; file.close(); diff --git a/source/source_io/to_qo_kernel.cpp b/source/source_io/to_qo_kernel.cpp index b16917259a..8ce94520a1 100644 --- a/source/source_io/to_qo_kernel.cpp +++ b/source/source_io/to_qo_kernel.cpp @@ -598,7 +598,7 @@ void toQO::read_ovlp(const std::string& dir, const int& nrows, const int& ncols, { if (is_R) { - double val; + double val = 0.0; ifs >> val; inum++; if (inum <= nchi_ * nphi_) { diff --git a/source/source_io/to_qo_mpi.cpp b/source/source_io/to_qo_mpi.cpp index e8823a3ee5..c4a01cc693 100644 --- a/source/source_io/to_qo_mpi.cpp +++ b/source/source_io/to_qo_mpi.cpp @@ -7,7 +7,7 @@ void toQO::bcast_stdvector_ofvector3int(std::vector>& v const int rank) { #ifdef __MPI - int dim; + int dim = 0; std::vector vec_1d; if(rank == 0) { @@ -37,7 +37,7 @@ void toQO::bcast_stdvector_ofvector3double(std::vector vec_1d; if(rank == 0) { diff --git a/source/source_io/to_qo_structures.cpp b/source/source_io/to_qo_structures.cpp index 28679baf58..91f4cf4092 100644 --- a/source/source_io/to_qo_structures.cpp +++ b/source/source_io/to_qo_structures.cpp @@ -60,7 +60,7 @@ void toQO::read_structures(const UnitCell* p_ucell, } for(int i = 0; i < nranks; i++) { - int nks_dim; + int nks_dim = 0; if(iproc_ == 0) nks_dim = nks_divided[i].size(); Parallel_Common::bcast_int(nks_dim); if(iproc_ != 0) nks_divided[i].resize(nks_dim); @@ -244,7 +244,7 @@ void toQO::scan_supercell(const int& rank, const int& nranks) } for(int i = 0; i < nranks; i++) { - int nR_dim; + int nR_dim = 0; if(rank == 0) nR_dim = nR_divided[i].size(); Parallel_Common::bcast_int(nR_dim); if(rank != 0) nR_divided[i].resize(nR_dim); diff --git a/source/source_io/to_wannier90.cpp b/source/source_io/to_wannier90.cpp index a3b814ed82..e7a291dcfc 100644 --- a/source/source_io/to_wannier90.cpp +++ b/source/source_io/to_wannier90.cpp @@ -202,7 +202,7 @@ bool toWannier90::try_read_nnkp(const UnitCell& ucell, const K_Vectors& kv) cal_num_kpts = num_kpts / 2; } - int numkpt_nnkp; + int numkpt_nnkp = 0; ModuleBase::GlobalFunc::READ_VALUE(nnkp_read, numkpt_nnkp); if ((PARAM.inp.nspin == 1 || PARAM.inp.nspin == 4) && numkpt_nnkp != num_kpts) { @@ -433,7 +433,7 @@ bool toWannier90::try_read_nnkp(const UnitCell& ucell, const K_Vectors& kv) { for (int ib = 0; ib < nntot; ib++) { - int ik_nnkp; + int ik_nnkp = 0; nnkp_read >> ik_nnkp; if (ik_nnkp != (ik + 1)) { diff --git a/source/source_io/unk_overlap_lcao.cpp b/source/source_io/unk_overlap_lcao.cpp index eaab367041..99726117ff 100644 --- a/source/source_io/unk_overlap_lcao.cpp +++ b/source/source_io/unk_overlap_lcao.cpp @@ -96,7 +96,7 @@ void unkOverlap_lcao::init(const UnitCell& ucell, { local_term++; } - int start; + int start = 0; for (int rank = 0; rank < nproc; rank++) { if (rank == myrank) From 493d6e2e59a019a52d75dba7e8d81033b1303bc0 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 22:05:31 +0800 Subject: [PATCH 09/21] fix: initialize all uninitialized variables in source_lcao and source_psi --- source/source_lcao/module_deepks/deepks_orbital.cpp | 2 +- source/source_lcao/module_deepks/deepks_pdm.cpp | 4 ++-- source/source_lcao/module_deepks/deepks_vdelta.cpp | 2 +- source/source_lcao/module_deltaspin/lambda_loop.cpp | 4 +--- source/source_lcao/module_dftu/dftu_folding.cpp | 2 +- source/source_lcao/module_dftu/dftu_io.cpp | 2 +- source/source_lcao/module_gint/gint_common.cpp | 2 +- source/source_lcao/module_gint/gint_dvlocal.cpp | 2 +- source/source_lcao/module_hcontainer/func_transfer.cpp | 2 +- source/source_psi/psi_initializer_nao.cpp | 6 +++--- 10 files changed, 13 insertions(+), 15 deletions(-) diff --git a/source/source_lcao/module_deepks/deepks_orbital.cpp b/source/source_lcao/module_deepks/deepks_orbital.cpp index 1a0d91cafe..7f16b6fec1 100644 --- a/source/source_lcao/module_deepks/deepks_orbital.cpp +++ b/source/source_lcao/module_deepks/deepks_orbital.cpp @@ -29,7 +29,7 @@ void DeePKS_domain::cal_o_delta(const std::vector& dm_hl, if (mu >= 0 && nu >= 0) { - int iic; + int iic = 0; if (PARAM.inp.ks_solver == "genelpa" || PARAM.inp.ks_solver == "scalapack_gvx" || PARAM.inp.ks_solver == "pexsi") // save the matrix as column major format { diff --git a/source/source_lcao/module_deepks/deepks_pdm.cpp b/source/source_lcao/module_deepks/deepks_pdm.cpp index edbfec8ef8..fdc838f45a 100644 --- a/source/source_lcao/module_deepks/deepks_pdm.cpp +++ b/source/source_lcao/module_deepks/deepks_pdm.cpp @@ -53,7 +53,7 @@ void DeePKS_domain::read_pdm(bool read_pdm_file, { for (int m2 = 0; m2 < nm; m2++) { - double c; + double c = 0.0; ifs >> c; accessor[m1][m2] = c; } @@ -74,7 +74,7 @@ void DeePKS_domain::read_pdm(bool read_pdm_file, auto accessor = pdm[iat].accessor(); for (int ind = 0; ind < pdm_size; ind++) { - double c; + double c = 0.0; ifs >> c; accessor[ind] = c; } diff --git a/source/source_lcao/module_deepks/deepks_vdelta.cpp b/source/source_lcao/module_deepks/deepks_vdelta.cpp index ba9f35f9fc..ab0f94c3a4 100644 --- a/source/source_lcao/module_deepks/deepks_vdelta.cpp +++ b/source/source_lcao/module_deepks/deepks_vdelta.cpp @@ -38,7 +38,7 @@ void DeePKS_domain::cal_e_delta_band(const std::vector>& dm, if (mu >= 0 && nu >= 0) { - int iic; + int iic = 0; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER(PARAM.inp.ks_solver)) { iic = mu + nu * pv->nrow; diff --git a/source/source_lcao/module_deltaspin/lambda_loop.cpp b/source/source_lcao/module_deltaspin/lambda_loop.cpp index 8b87f7eedd..5d38c5d261 100644 --- a/source/source_lcao/module_deltaspin/lambda_loop.cpp +++ b/source/source_lcao/module_deltaspin/lambda_loop.cpp @@ -117,9 +117,7 @@ void spinconstrain::SpinConstrain>::run_lambda_loop( std::vector> new_spin(nat, 0.0), spin_plus(nat, 0.0); double alpha_opt, alpha_plus; - double beta; - double mean_error, mean_error_old, rms_error; - double g; + double beta = 0.0, g = 0.0, mean_error = 0.0, mean_error_old = 0.0, rms_error = 0.0; double alpha_trial = this->alpha_trial_; diff --git a/source/source_lcao/module_dftu/dftu_folding.cpp b/source/source_lcao/module_dftu/dftu_folding.cpp index b67db9fcb4..cba6b33991 100644 --- a/source/source_lcao/module_dftu/dftu_folding.cpp +++ b/source/source_lcao/module_dftu/dftu_folding.cpp @@ -246,7 +246,7 @@ void Plus_U::folding_matrix_k(const UnitCell& ucell, continue; } - int iic; + int iic = 0; if (ModuleBase::GlobalFunc::IS_COLUMN_MAJOR_KS_SOLVER(PARAM.inp.ks_solver)) { iic = mu + nu * pv.nrow; diff --git a/source/source_lcao/module_dftu/dftu_io.cpp b/source/source_lcao/module_dftu/dftu_io.cpp index f75bc408c6..737c1c590a 100644 --- a/source/source_lcao/module_dftu/dftu_io.cpp +++ b/source/source_lcao/module_dftu/dftu_io.cpp @@ -487,7 +487,7 @@ inline void JacobiRotate(std::vector>& A, int p, int q, int if (std::abs(A[p][q]) > 1e-10) { double r = (A[q][q] - A[p][p]) / (2.0 * A[p][q]); - double t; + double t = 0.0; if (r >= 0) { t = 1.0 / (r + sqrt(1.0 + r * r)); } else { diff --git a/source/source_lcao/module_gint/gint_common.cpp b/source/source_lcao/module_gint/gint_common.cpp index 69957f0b38..3588604f59 100644 --- a/source/source_lcao/module_gint/gint_common.cpp +++ b/source/source_lcao/module_gint/gint_common.cpp @@ -316,7 +316,7 @@ void wfc_2d_to_gint(const T* wfc_2d, MPI_Comm_rank(pv.comm(), &rank); // calculate the maximum number of nlocal over all processes in pv.comm() range - long buf_size; + long buf_size = 0; mpi_info = MPI_Reduce(&pv.nloc_wfc, &buf_size, 1, MPI_LONG, MPI_MAX, 0, pv.comm()); mpi_info = MPI_Bcast(&buf_size, 1, MPI_LONG, 0, pv.comm()); // get and then broadcast std::vector wfc_block(buf_size); diff --git a/source/source_lcao/module_gint/gint_dvlocal.cpp b/source/source_lcao/module_gint/gint_dvlocal.cpp index 3d3888a0b9..7910649b71 100644 --- a/source/source_lcao/module_gint/gint_dvlocal.cpp +++ b/source/source_lcao/module_gint/gint_dvlocal.cpp @@ -72,7 +72,7 @@ void Gint_dvlocal::cal_dvlocal_R_sparseMatrix( std::map, std::map>> pvdpRy_sparseMatrix; std::map, std::map>> pvdpRz_sparseMatrix; - double temp_value_double; + double temp_value_double = 0.0; Vec3d tau1, dtau; for (int iap = 0; iap < pvdpRx.size_atom_pairs(); iap++) diff --git a/source/source_lcao/module_hcontainer/func_transfer.cpp b/source/source_lcao/module_hcontainer/func_transfer.cpp index 1da0c524a1..14566ac01d 100644 --- a/source/source_lcao/module_hcontainer/func_transfer.cpp +++ b/source/source_lcao/module_hcontainer/func_transfer.cpp @@ -169,7 +169,7 @@ void transferParallels2Serial(const hamilt::HContainer& hR_p, hamilt::HConta // send data std::vector receive_values; - long max_size; + long max_size = 0; if (my_rank == serial_rank) { max_size = trans_s->get_max_size(); diff --git a/source/source_psi/psi_initializer_nao.cpp b/source/source_psi/psi_initializer_nao.cpp index 7f74b40c44..bd0a29e7d1 100644 --- a/source/source_psi/psi_initializer_nao.cpp +++ b/source/source_psi/psi_initializer_nao.cpp @@ -85,9 +85,9 @@ void psi_initializer_nao::read_external_orbs(const std::string* orbital_files << this->orbital_files_[it] << std::endl; } std::string elem; // garbage value, will discard - double ecut; // garbage value, will discard - int nr; - double dr; + double ecut = 0.0; // garbage value, will discard + int nr = 0; + double dr = 0.0; std::vector nzeta; std::vector> radials; ModuleIO::read_abacus_orb(ifs_it, elem, ecut, nr, dr, nzeta, radials, rank); From 60aede4cc0a3338cf29bc1f3294daf79132d4d5f Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Sun, 25 Jan 2026 22:38:08 +0800 Subject: [PATCH 10/21] fix some uninitalized variables --- .../module_vdw/vdwd2_parameters.cpp | 4 +-- source/source_hamilt/module_vdw/vdwd3.cpp | 8 +++--- .../module_xc/xc_funct_corr_gga.cpp | 2 +- .../module_xc/xc_funct_corr_lda.cpp | 2 +- .../module_xc/xc_functional_gradcorr.cpp | 4 +-- .../module_xc/xc_functional_wrapper_gcxc.cpp | 4 +-- .../module_xc/xc_functional_wrapper_xc.cpp | 2 +- .../module_genelpa/elpa_new.cpp | 10 +++---- .../module_genelpa/elpa_new_complex.cpp | 12 ++++----- .../module_genelpa/elpa_new_real.cpp | 8 +++--- .../source_hsolver/module_genelpa/utils.cpp | 4 +-- .../module_pexsi/dist_bcd_matrix.cpp | 2 +- .../module_pexsi/dist_ccs_matrix.cpp | 2 +- .../module_pexsi/dist_matrix_transformer.cpp | 8 +++--- .../module_pexsi/simple_pexsi.cpp | 26 +++++++++---------- .../source_lcao/module_lr/utils/lr_util.cpp | 4 +-- .../irreducible_sector.cpp | 2 +- .../module_exx_symmetry/symmetry_rotation.cpp | 2 +- 18 files changed, 53 insertions(+), 53 deletions(-) diff --git a/source/source_hamilt/module_vdw/vdwd2_parameters.cpp b/source/source_hamilt/module_vdw/vdwd2_parameters.cpp index a562244be3..3ac48e1819 100644 --- a/source/source_hamilt/module_vdw/vdwd2_parameters.cpp +++ b/source/source_hamilt/module_vdw/vdwd2_parameters.cpp @@ -50,7 +50,7 @@ void Vdwd2Parameters::C6_input(const std::string &file, const std::string &unit) ModuleBase::WARNING_QUIT("Vdwd2::C6_input", "Can not find the file " + ModuleBase::GlobalFunc::TO_STRING(file)); std::string element; - double value; + double value = 0.0; while (ifs >> element >> value) C6_[element] = value; ifs.close(); @@ -77,7 +77,7 @@ void Vdwd2Parameters::R0_input(const std::string &file, const std::string &unit) ModuleBase::WARNING_QUIT("Vdwd2::R0_input", "Can not find the file " + ModuleBase::GlobalFunc::TO_STRING(file)); std::string element; - double value; + double value = 0.0; while (ifs >> element >> value) R0_[element] = value; ifs.close(); diff --git a/source/source_hamilt/module_vdw/vdwd3.cpp b/source/source_hamilt/module_vdw/vdwd3.cpp index 95aeac8226..66245e0f09 100644 --- a/source/source_hamilt/module_vdw/vdwd3.cpp +++ b/source/source_hamilt/module_vdw/vdwd3.cpp @@ -88,7 +88,7 @@ void Vdwd3::cal_energy() ModuleBase::timer::tick("Vdwd3", "cal_energy"); init(); - int ij; + int ij = 0; double c6 = 0.0, c8 = 0.0, r2 = 0.0, r6 = 0.0, r8 = 0.0, rr = 0.0, damp6 = 0.0, damp8 = 0.0; double e6 = 0.0, e8 = 0.0, eabc = 0.0; std::vector cc6ab(ucell_.nat * ucell_.nat), cn(ucell_.nat); @@ -96,7 +96,7 @@ void Vdwd3::cal_energy() ModuleBase::Vector3 tau; if (para_.version() == "d3_0") // DFT-D3(zero-damping) { - double tmp; + double tmp = 0.0; for (int iat = 0; iat != ucell_.nat - 1; iat++) { for (int jat = iat + 1; jat != ucell_.nat; jat++) { @@ -178,7 +178,7 @@ void Vdwd3::cal_energy() } // end d3_0 else if (para_.version() == "d3_bj") // DFT-D3(BJ-damping) { - double r42; + double r42 = 0.0; for (int iat = 0; iat != ucell_.nat; iat++) { for (int jat = iat + 1; jat != ucell_.nat; jat++) @@ -860,7 +860,7 @@ void Vdwd3::pbc_gdisp(std::vector> &g, ModuleBase::m } // end d3_0 else if (para_.version() == "d3_bj") { - double r4; + double r4 = 0.0; for (int iat = 0; iat != ucell_.nat; iat++) { get_dc6_dcnij(para_.mxc()[iz_[iat]], para_.mxc()[iz_[iat]], cn[iat], cn[iat], diff --git a/source/source_hamilt/module_xc/xc_funct_corr_gga.cpp b/source/source_hamilt/module_xc/xc_funct_corr_gga.cpp index 2c94989482..3c88eb653c 100644 --- a/source/source_hamilt/module_xc/xc_funct_corr_gga.cpp +++ b/source/source_hamilt/module_xc/xc_funct_corr_gga.cpp @@ -104,7 +104,7 @@ void XC_Functional::ggac(const double &rho,const double &grho, double &sc, doubl y = af * t * t; xy = (1.0 + y) / (1.0 + y + y * y); - double x; + double x = 0.0; x = 1.0 + y + y * y; qy = y * y * (2.0 + y) / (x * x); s1 = 1.0 + 2.0 * al / be * t * t * xy; diff --git a/source/source_hamilt/module_xc/xc_funct_corr_lda.cpp b/source/source_hamilt/module_xc/xc_funct_corr_lda.cpp index 4a749320b8..5b6ff5367b 100644 --- a/source/source_hamilt/module_xc/xc_funct_corr_lda.cpp +++ b/source/source_hamilt/module_xc/xc_funct_corr_lda.cpp @@ -138,7 +138,7 @@ void XC_Functional::vwn(const double &rs, double &ec, double &vc) fx = rs + b * rs12 + c; qx = atan(q / (2.0 * rs12 + b)); - double x; + double x = 0.0; x = (rs12 - x0); ec = a * (log(rs / fx) + f1 * qx - f2 * (log((x * x) / fx) + f3 * qx)); diff --git a/source/source_hamilt/module_xc/xc_functional_gradcorr.cpp b/source/source_hamilt/module_xc/xc_functional_gradcorr.cpp index 66b0a4a0d6..008109377c 100644 --- a/source/source_hamilt/module_xc/xc_functional_gradcorr.cpp +++ b/source/source_hamilt/module_xc/xc_functional_gradcorr.cpp @@ -226,7 +226,7 @@ void XC_Functional::gradcorr(double &etxc, double &vtxc, ModuleBase::matrix &v, if(nspin0==1) { - double segno; + double segno = 0.0; #ifdef _OPENMP #pragma omp for #endif @@ -249,7 +249,7 @@ void XC_Functional::gradcorr(double &etxc, double &vtxc, ModuleBase::matrix &v, #ifdef USE_LIBXC if(func_type == 3 || func_type == 5) //the gradcorr part to stress of mGGA { - double v3xc; + double v3xc = 0.0; double atau = chr->kin_r[0][ir]/2.0; XC_Functional_Libxc::tau_xc( func_id, arho, grho2a, atau, sxc, v1xc, v2xc, v3xc); } diff --git a/source/source_hamilt/module_xc/xc_functional_wrapper_gcxc.cpp b/source/source_hamilt/module_xc/xc_functional_wrapper_gcxc.cpp index ea6a5a3e1e..3956d29702 100644 --- a/source/source_hamilt/module_xc/xc_functional_wrapper_gcxc.cpp +++ b/source/source_hamilt/module_xc/xc_functional_wrapper_gcxc.cpp @@ -128,7 +128,7 @@ void XC_Functional::gcx_spin(double rhoup, double rhodw, double grhoup2, double // parameter : double small = 1.e-10; double sxup, sxdw; - int iflag; + int iflag = 0; // exchange double rho = rhoup + rhodw; @@ -247,7 +247,7 @@ void XC_Functional::gcc_spin(double rho, double &zeta, double grho, double &sc, double small = 1.0e-10; double epsr = 1.0e-6; - double x; + double x = 0.0; sc = 0.00; v1cup = 0.00; v1cdw = 0.00; diff --git a/source/source_hamilt/module_xc/xc_functional_wrapper_xc.cpp b/source/source_hamilt/module_xc/xc_functional_wrapper_xc.cpp index d13eb0d129..0a9bffbc42 100644 --- a/source/source_hamilt/module_xc/xc_functional_wrapper_xc.cpp +++ b/source/source_hamilt/module_xc/xc_functional_wrapper_xc.cpp @@ -17,7 +17,7 @@ void XC_Functional::xc(const double &rho, double &exc, double &vxc) double third = 1.0 / 3.0; double pi34 = 0.6203504908994e0 ; // pi34=(3/4pi)^(1/3) - double rs; + double rs = 0.0; double e,v; exc = vxc = 0.00; diff --git a/source/source_hsolver/module_genelpa/elpa_new.cpp b/source/source_hsolver/module_genelpa/elpa_new.cpp index 3d214d20fd..d045482190 100644 --- a/source/source_hsolver/module_genelpa/elpa_new.cpp +++ b/source/source_hsolver/module_genelpa/elpa_new.cpp @@ -57,7 +57,7 @@ ELPA_Solver::ELPA_Solver(const bool isReal, else kernel_id = read_complex_kernel(); // cout<<"kernel id is inited as "< NEW_ELPA_HANDLE_POOL; - static int total_handle; + static int total_handle = 0; #ifdef _OPENMP int num_threads = omp_get_max_threads(); @@ -270,7 +270,7 @@ int ELPA_Solver::read_cpuflag() int ELPA_Solver::read_real_kernel() { - int kernel_id; + int kernel_id = 0; if (const char* env = getenv("ELPA_DEFAULT_real_kernel")) { @@ -454,7 +454,7 @@ int ELPA_Solver::read_complex_kernel() int ELPA_Solver::allocate_work() { unsigned long nloc = static_cast(narows) * nacols; // local size - unsigned long maxloc; // maximum local size + unsigned long maxloc = 0; // maximum local size MPI_Allreduce(&nloc, &maxloc, 1, MPI_UNSIGNED_LONG, MPI_MAX, comm); maxloc = nloc; @@ -467,7 +467,7 @@ int ELPA_Solver::allocate_work() void ELPA_Solver::timer(int myid, const char function[], const char step[], double& t0) { - double t1; + double t1 = 0.0; if (t0 < 0) // t0 < 0 means this is the init call before the function { t0 = MPI_Wtime(); diff --git a/source/source_hsolver/module_genelpa/elpa_new_complex.cpp b/source/source_hsolver/module_genelpa/elpa_new_complex.cpp index 0c78009522..cf28835942 100644 --- a/source/source_hsolver/module_genelpa/elpa_new_complex.cpp +++ b/source/source_hsolver/module_genelpa/elpa_new_complex.cpp @@ -19,9 +19,9 @@ extern std::map NEW_ELPA_HANDLE_POOL; int ELPA_Solver::eigenvector(std::complex* A, double* EigenValue, std::complex* EigenVector) { - int info; - int allinfo; - double t; + int info = 0; + int allinfo = 0; + double t = 0.0; if((loglevel>0 && myid==0) || loglevel>1) { @@ -42,7 +42,7 @@ int ELPA_Solver::generalized_eigenvector(std::complex* A, std::complex* EigenVector) { int info, allinfo; - double t; + double t = 0.0; if((loglevel>0 && myid==0) || loglevel>1) { @@ -164,7 +164,7 @@ int ELPA_Solver::decomposeRightMatrix(std::complex* B, double* EigenValu { int info=0; int allinfo=0; - double t; + double t = 0.0; // first try cholesky decomposing if(nFull* B, double* EigenValu int ELPA_Solver::composeEigenVector(int DecomposedState, std::complex* B, std::complex* EigenVector) { - double t; + double t = 0.0; if(DecomposedState==1 || DecomposedState==2) { // transform the eigenvectors to original general equation, let U^-1*q, and put to q diff --git a/source/source_hsolver/module_genelpa/elpa_new_real.cpp b/source/source_hsolver/module_genelpa/elpa_new_real.cpp index a780c89f55..cc6d0242bd 100644 --- a/source/source_hsolver/module_genelpa/elpa_new_real.cpp +++ b/source/source_hsolver/module_genelpa/elpa_new_real.cpp @@ -18,8 +18,8 @@ extern std::map NEW_ELPA_HANDLE_POOL; int ELPA_Solver::eigenvector(double* A, double* EigenValue, double* EigenVector) { - int info; - double t; + int info = 0; + double t = 0.0; if (loglevel > 0 && myid == 0) { @@ -41,7 +41,7 @@ int ELPA_Solver::generalized_eigenvector(double* A, double* EigenVector) { int info, allinfo; - double t; + double t = 0.0; if (loglevel > 0 && myid == 0) { @@ -407,7 +407,7 @@ void ELPA_Solver::verify(double* A, double* EigenValue, double* EigenVector, dou maxError = 0; for (int i = 1; i <= nev; ++i) { - double E; + double E = 0.0; ScalapackConnector::dot(nFull, E, R, 1, i, 1, R, 1, i, 1, desc); // printf("myid: %d, i: %d, E: %lf\n", myid, i, E); sumError += E; diff --git a/source/source_hsolver/module_genelpa/utils.cpp b/source/source_hsolver/module_genelpa/utils.cpp index d9e6e74c59..6654c33b9e 100644 --- a/source/source_hsolver/module_genelpa/utils.cpp +++ b/source/source_hsolver/module_genelpa/utils.cpp @@ -25,7 +25,7 @@ void initBlacsGrid(int loglevel, int nprows, npcols; int myprow, mypcol; int nprocs, myid; - int info; + int info = 0; MPI_Comm_size(comm, &nprocs); MPI_Comm_rank(comm, &myid); // set blacs parameters @@ -137,7 +137,7 @@ void loadMatrix(const char FileName[], int nFull, double* a, int* desca, int bla void saveLocalMatrix(const char filePrefix[], int narows, int nacols, double* a) { char FileName[80]; - int myid; + int myid = 0; std::ofstream matrixFile; #ifdef __MPI MPI_Comm_rank(MPI_COMM_WORLD, &myid); diff --git a/source/source_hsolver/module_pexsi/dist_bcd_matrix.cpp b/source/source_hsolver/module_pexsi/dist_bcd_matrix.cpp index ff3f85f32b..93a6dcb5b0 100644 --- a/source/source_hsolver/module_pexsi/dist_bcd_matrix.cpp +++ b/source/source_hsolver/module_pexsi/dist_bcd_matrix.cpp @@ -48,7 +48,7 @@ DistBCDMatrix::DistBCDMatrix(MPI_Comm comm, } // synchronize matrix parameters to all processes, including those are not in bcd group - int myid_in_comm_world; + int myid_in_comm_world = 0; MPI_Comm_rank(MPI_COMM_WORLD, &myid_in_comm_world); if (myid_in_comm_world == 0) { diff --git a/source/source_hsolver/module_pexsi/dist_ccs_matrix.cpp b/source/source_hsolver/module_pexsi/dist_ccs_matrix.cpp index 74391f2fbe..0a73653c8e 100644 --- a/source/source_hsolver/module_pexsi/dist_ccs_matrix.cpp +++ b/source/source_hsolver/module_pexsi/dist_ccs_matrix.cpp @@ -55,7 +55,7 @@ DistCCSMatrix::DistCCSMatrix(MPI_Comm comm_in, int nproc_data_in, int size_in) this->size = size_in; this->nnz = 0; this->nnzLocal = 0; - int myproc; + int myproc = 0; if (comm != MPI_COMM_NULL) { MPI_Comm_size(comm, &nprocs); diff --git a/source/source_hsolver/module_pexsi/dist_matrix_transformer.cpp b/source/source_hsolver/module_pexsi/dist_matrix_transformer.cpp index 313a840e68..7a4ecec6b1 100644 --- a/source/source_hsolver/module_pexsi/dist_matrix_transformer.cpp +++ b/source/source_hsolver/module_pexsi/dist_matrix_transformer.cpp @@ -28,8 +28,8 @@ inline int DistMatrixTransformer::MinimumIndexPosition(const bool isFirst, { // usually the minimum index is continuous, so it will be a good idea to // check the one next to the previous index first. - static int pre_position; // previous position in index array of minimum index, - static int pre_process; // the process contains previous index + static int pre_position = 0; // previous position in index array of minimum index, + static int pre_process = 0; // the process contains previous index int minimum_index = INT_MAX; // the minimum index, initial value is a large number which is larger than any other index; @@ -110,7 +110,7 @@ inline void DistMatrixTransformer::buildCCSParameter(const int size, int pre_col = -1; int nnz_now = 0; - int p_mini; + int p_mini = 0; p_mini = MinimumIndexPosition(true, nprocs, &size_process[0], &displacement_process[0], position_index); while (p_mini >= 0) { @@ -146,7 +146,7 @@ inline void DistMatrixTransformer::countMatrixDistribution(int N, double* A, std { for (int i = 0; i < N; ++i) { - int key; + int key = 0; if (fabs(A[i] < 1e-31)) key = -100; else diff --git a/source/source_hsolver/module_pexsi/simple_pexsi.cpp b/source/source_hsolver/module_pexsi/simple_pexsi.cpp index edf000ecae..255b1019b3 100644 --- a/source/source_hsolver/module_pexsi/simple_pexsi.cpp +++ b/source/source_hsolver/module_pexsi/simple_pexsi.cpp @@ -27,7 +27,7 @@ namespace pexsi { inline void strtolower(char* sa, char* sb) { - char c; + char c = '\0'; int len = strlen(sa); for (int i = 0; i < len; i++) { @@ -172,8 +172,8 @@ void splitNProc2NProwNPcol(const int NPROC, int& nprow, int& npcol) } else { - int flag; - int i; + int flag = 0; + int i = 0; int low = pow(integral_part, 2); int high = pow(integral_part + 1, 2); if ((NPROC - low) >= (high - NPROC)) @@ -218,7 +218,7 @@ int simplePEXSI(MPI_Comm comm_PEXSI, if (comm_2D == MPI_COMM_NULL && comm_PEXSI == MPI_COMM_NULL) return 0; - int myid; + int myid = 0; std::ofstream f_log; if (comm_PEXSI != MPI_COMM_NULL) { @@ -228,15 +228,15 @@ int simplePEXSI(MPI_Comm comm_PEXSI, // set up PEXSI parameter PPEXSIOptions options; PPEXSISetDefaultOptions(&options); - int numProcessPerPole; - double ZERO_Limit; + int numProcessPerPole = 0; + double ZERO_Limit = 0.0; loadPEXSIOption(comm_PEXSI, PexsiOptionFile, options, numProcessPerPole, ZERO_Limit); options.mu0 = mu0; ModuleBase::timer::tick("Diago_LCAO_Matrix", "setup_PEXSI_plan"); PPEXSIPlan plan; - int info; - int outputFileIndex; + int info = 0; + int outputFileIndex = 0; int pexsi_prow, pexsi_pcol; ModuleBase::timer::tick("Diago_LCAO_Matrix", "splitNProc2NProwNPcol"); splitNProc2NProwNPcol(numProcessPerPole, pexsi_prow, pexsi_pcol); @@ -292,11 +292,11 @@ int simplePEXSI(MPI_Comm comm_PEXSI, SnzvalLocal, &info); - double nelec; - double muMinInertia; - double muMaxInertia; - int numTotalPEXSIIter; - int numTotalInertiaIter; // Number of total inertia[out] + double nelec = 0.0; + double muMinInertia = 0.0; + double muMaxInertia = 0.0; + int numTotalPEXSIIter = 0; + int numTotalInertiaIter = 0; // Number of total inertia[out] // LiuXh modify 2021-04-29, add DONE(ofs_running,"xx") for test ModuleBase::timer::tick("Diago_LCAO_Matrix", "PEXSIDFT"); PPEXSIDFTDriver2(plan, // PEXSI plan[in] diff --git a/source/source_lcao/module_lr/utils/lr_util.cpp b/source/source_lcao/module_lr/utils/lr_util.cpp index ae2f00ffa3..f720012413 100644 --- a/source/source_lcao/module_lr/utils/lr_util.cpp +++ b/source/source_lcao/module_lr/utils/lr_util.cpp @@ -120,7 +120,7 @@ namespace LR_Util ModuleBase::TITLE("LR_Util", "diag_lapack"); int info = 0; char jobz = 'V', uplo = 'U'; - double work_tmp; + double work_tmp = 0.0; const int minus_one = -1; dsyev_(&jobz, &uplo, &n, mat, &n, eig, &work_tmp, &minus_one, &info); // get best lwork const int lwork = work_tmp; @@ -149,7 +149,7 @@ namespace LR_Util ModuleBase::TITLE("LR_Util", "diag_lapack_nh"); int info = 0; char jobvl = 'N', jobvr = 'V'; //calculate right eigenvectors - double work_tmp; + double work_tmp = 0.0; const int minus_one = -1; std::vector eig_real(n); std::vector eig_imag(n); diff --git a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp index b79bfcfc20..8347624797 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp @@ -64,7 +64,7 @@ namespace ModuleSymmetry // }; auto restrict_center = [&symm](const TCdouble& v) -> TCdouble { // in [0,1) - TCdouble vr; + TCdouble vr = 0.0; vr.x = fmod(v.x + 100 + symm.epsilon, 1) - symm.epsilon; vr.y = fmod(v.y + 100 + symm.epsilon, 1) - symm.epsilon; vr.z = fmod(v.z + 100 + symm.epsilon, 1) - symm.epsilon; diff --git a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp index 27929737f6..aeb118155d 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp @@ -38,7 +38,7 @@ namespace ModuleSymmetry // 2. calculate the rotation matrix in AO-representation for each ibz_kpoint and symmetry operation: M(k, isym) auto restrict_kpt = [](const TCdouble& kvec, const double& symm_prec) -> TCdouble {// in (-0.5, 0.5] - TCdouble kvec_res; + TCdouble kvec_res = 0.0; kvec_res.x = fmod(kvec.x + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; kvec_res.y = fmod(kvec.y + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; kvec_res.z = fmod(kvec.z + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; From f19b85ef7de09ee7c3d3291ae583955d3bb13672 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:03:46 +0800 Subject: [PATCH 11/21] move exx_helper to module_pwdft --- source/source_esolver/CMakeLists.txt | 4 ++-- source/source_esolver/esolver_ks_pw.h | 2 +- .../{module_exx_helper => }/exx_helper.cpp | 0 .../{module_exx_helper => }/exx_helper.h | 3 --- source/source_pw/module_pwdft/hamilt_pw.h | 2 +- .../module_pwdft/operator_pw/ekinetic_pw.cpp | 16 +++------------- 6 files changed, 7 insertions(+), 20 deletions(-) rename source/source_pw/module_pwdft/{module_exx_helper => }/exx_helper.cpp (100%) rename source/source_pw/module_pwdft/{module_exx_helper => }/exx_helper.h (97%) diff --git a/source/source_esolver/CMakeLists.txt b/source/source_esolver/CMakeLists.txt index 787982d555..4a83a9e9a1 100644 --- a/source/source_esolver/CMakeLists.txt +++ b/source/source_esolver/CMakeLists.txt @@ -29,8 +29,8 @@ add_library( esolver OBJECT ${objects} - ../source_pw/module_pwdft/module_exx_helper/exx_helper.cpp - ../source_pw/module_pwdft/module_exx_helper/exx_helper.h + ../source_pw/module_pwdft/exx_helper.cpp + ../source_pw/module_pwdft/exx_helper.h ) if(ENABLE_COVERAGE) diff --git a/source/source_esolver/esolver_ks_pw.h b/source/source_esolver/esolver_ks_pw.h index b6f48e18cd..d2df594260 100644 --- a/source/source_esolver/esolver_ks_pw.h +++ b/source/source_esolver/esolver_ks_pw.h @@ -3,7 +3,7 @@ #include "./esolver_ks.h" #include "source_psi/setup_psi_pw.h" // mohan add 20251012 #include "source_pw/module_pwdft/VSep_in_pw.h" -#include "source_pw/module_pwdft/module_exx_helper/exx_helper.h" +#include "source_pw/module_pwdft/exx_helper.h" #include "source_pw/module_pwdft/operator_pw/velocity_pw.h" #include diff --git a/source/source_pw/module_pwdft/module_exx_helper/exx_helper.cpp b/source/source_pw/module_pwdft/exx_helper.cpp similarity index 100% rename from source/source_pw/module_pwdft/module_exx_helper/exx_helper.cpp rename to source/source_pw/module_pwdft/exx_helper.cpp diff --git a/source/source_pw/module_pwdft/module_exx_helper/exx_helper.h b/source/source_pw/module_pwdft/exx_helper.h similarity index 97% rename from source/source_pw/module_pwdft/module_exx_helper/exx_helper.h rename to source/source_pw/module_pwdft/exx_helper.h index 010d9c7176..9ab8eab12d 100644 --- a/source/source_pw/module_pwdft/module_exx_helper/exx_helper.h +++ b/source/source_pw/module_pwdft/exx_helper.h @@ -1,6 +1,3 @@ -// -// For EXX in PW. -// #include "source_psi/psi.h" #include "source_base/matrix.h" #include "source_pw/module_pwdft/operator_pw/op_exx_pw.h" diff --git a/source/source_pw/module_pwdft/hamilt_pw.h b/source/source_pw/module_pwdft/hamilt_pw.h index ca67b6f424..e57f0df4c4 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.h +++ b/source/source_pw/module_pwdft/hamilt_pw.h @@ -8,7 +8,7 @@ #include "source_hamilt/hamilt.h" #include "source_pw/module_pwdft/VNL_in_pw.h" #include "source_base/kernels/math_kernel_op.h" -#include "source_pw/module_pwdft/module_exx_helper/exx_helper.h" +#include "source_pw/module_pwdft/exx_helper.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06 namespace hamilt diff --git a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp b/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp index c776863089..f225863080 100644 --- a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp +++ b/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp @@ -1,11 +1,8 @@ #include "ekinetic_pw.h" - #include "source_base/timer.h" #include "source_base/tool_quit.h" - #include "source_base/module_device/device.h" - namespace hamilt { template @@ -22,7 +19,8 @@ Ekinetic>::Ekinetic( this->gk2_row = gk2_row; this->gk2_col = gk2_col; this->device = base_device::get_device_type(this->ctx); - if( this->tpiba2 < 1e-10 || this->gk2 == nullptr) { + if( this->tpiba2 < 1e-10 || this->gk2 == nullptr) + { ModuleBase::WARNING_QUIT("EkineticPW", "Constuctor of Operator::EkineticPW is failed, please check your code!"); } } @@ -77,16 +75,8 @@ hamilt::Ekinetic>::Ekinetic(const Ekinetic, base_device::DEVICE_CPU>>; template class Ekinetic, base_device::DEVICE_CPU>>; -// template Ekinetic, base_device::DEVICE_CPU>>::Ekinetic(const -// Ekinetic, base_device::DEVICE_CPU>> *ekinetic); #if ((defined __CUDA) || (defined __ROCM)) template class Ekinetic, base_device::DEVICE_GPU>>; template class Ekinetic, base_device::DEVICE_GPU>>; -// template Ekinetic, base_device::DEVICE_CPU>>::Ekinetic(const -// Ekinetic, base_device::DEVICE_GPU>> *ekinetic); template -// Ekinetic, base_device::DEVICE_GPU>>::Ekinetic(const -// Ekinetic, base_device::DEVICE_CPU>> *ekinetic); template -// Ekinetic, base_device::DEVICE_GPU>>::Ekinetic(const -// Ekinetic, base_device::DEVICE_GPU>> *ekinetic); #endif -} // namespace hamilt \ No newline at end of file +} // namespace hamilt From b7c1ebd7762a733374e19e7ef6609a6d24fc5597 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:09:44 +0800 Subject: [PATCH 12/21] rename pw files --- source/Makefile.Objects | 2 +- source/source_pw/module_pwdft/CMakeLists.txt | 2 +- source/source_pw/module_pwdft/hamilt_pw.cpp | 2 +- .../{operator_pw/ekinetic_pw.cpp => op_pw_ekin.cpp} | 2 +- .../module_pwdft/{operator_pw/ekinetic_pw.h => op_pw_ekin.h} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename source/source_pw/module_pwdft/{operator_pw/ekinetic_pw.cpp => op_pw_ekin.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/ekinetic_pw.h => op_pw_ekin.h} (98%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 11d4b65a2f..3ee2922d0c 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -310,7 +310,7 @@ OBJS_HAMILT=hamilt_pw.o\ operator.o\ operator_pw.o\ op_exx_pw.o\ - ekinetic_pw.o\ + op_pw_ekin.o\ ekinetic_op.o\ exx_pw_ace.o\ exx_pw_pot.o\ diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 66354adb9a..76bc864feb 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -2,7 +2,7 @@ add_subdirectory(operator_pw) list(APPEND objects hamilt_pw.cpp - operator_pw/ekinetic_pw.cpp + op_pw_ekin.cpp operator_pw/veff_pw.cpp operator_pw/nonlocal_pw.cpp operator_pw/meta_pw.cpp diff --git a/source/source_pw/module_pwdft/hamilt_pw.cpp b/source/source_pw/module_pwdft/hamilt_pw.cpp index 6ba4df4318..48491a4e29 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.cpp +++ b/source/source_pw/module_pwdft/hamilt_pw.cpp @@ -5,7 +5,7 @@ #include "source_base/global_variable.h" #include "operator_pw/veff_pw.h" -#include "operator_pw/ekinetic_pw.h" +#include "op_pw_ekin.h" #include "operator_pw/meta_pw.h" #include "operator_pw/nonlocal_pw.h" #include "operator_pw/onsite_proj_pw.h" diff --git a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp b/source/source_pw/module_pwdft/op_pw_ekin.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp rename to source/source_pw/module_pwdft/op_pw_ekin.cpp index f225863080..05d28266fd 100644 --- a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_ekin.cpp @@ -1,4 +1,4 @@ -#include "ekinetic_pw.h" +#include "op_pw_ekin.h" #include "source_base/timer.h" #include "source_base/tool_quit.h" #include "source_base/module_device/device.h" diff --git a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.h b/source/source_pw/module_pwdft/op_pw_ekin.h similarity index 98% rename from source/source_pw/module_pwdft/operator_pw/ekinetic_pw.h rename to source/source_pw/module_pwdft/op_pw_ekin.h index e5b6281fa9..91adbc31be 100644 --- a/source/source_pw/module_pwdft/operator_pw/ekinetic_pw.h +++ b/source/source_pw/module_pwdft/op_pw_ekin.h @@ -1,7 +1,7 @@ #ifndef EKINETICPW_H #define EKINETICPW_H -#include "operator_pw.h" +#include "operator_pw/operator_pw.h" #include "source_pw/module_pwdft/kernels/ekinetic_op.h" #include From 573dd784fc7c3000f2de1c340d2805feb92cf292 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:15:17 +0800 Subject: [PATCH 13/21] Refactor: Move and rename nonlocal_pw files to module_pwdft directory --- source/Makefile.Objects | 2 +- source/source_pw/module_pwdft/CMakeLists.txt | 2 +- source/source_pw/module_pwdft/hamilt_pw.cpp | 2 +- .../module_pwdft/{operator_pw/nonlocal_pw.cpp => op_pw_nl.cpp} | 2 +- .../module_pwdft/{operator_pw/nonlocal_pw.h => op_pw_nl.h} | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) rename source/source_pw/module_pwdft/{operator_pw/nonlocal_pw.cpp => op_pw_nl.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/nonlocal_pw.h => op_pw_nl.h} (98%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 3ee2922d0c..74bc60dd8c 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -317,7 +317,7 @@ OBJS_HAMILT=hamilt_pw.o\ hpsi_norm_op.o\ veff_pw.o\ veff_op.o\ - nonlocal_pw.o\ + op_pw_nl.o\ nonlocal_op.o\ meta_pw.o\ meta_op.o\ diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 76bc864feb..0914f019fb 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -4,7 +4,7 @@ list(APPEND objects hamilt_pw.cpp op_pw_ekin.cpp operator_pw/veff_pw.cpp - operator_pw/nonlocal_pw.cpp + op_pw_nl.cpp operator_pw/meta_pw.cpp operator_pw/velocity_pw.cpp operator_pw/operator_pw.cpp diff --git a/source/source_pw/module_pwdft/hamilt_pw.cpp b/source/source_pw/module_pwdft/hamilt_pw.cpp index 48491a4e29..011e54bf64 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.cpp +++ b/source/source_pw/module_pwdft/hamilt_pw.cpp @@ -7,7 +7,7 @@ #include "operator_pw/veff_pw.h" #include "op_pw_ekin.h" #include "operator_pw/meta_pw.h" -#include "operator_pw/nonlocal_pw.h" +#include "op_pw_nl.h" #include "operator_pw/onsite_proj_pw.h" #include "operator_pw/op_exx_pw.h" #include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info diff --git a/source/source_pw/module_pwdft/operator_pw/nonlocal_pw.cpp b/source/source_pw/module_pwdft/op_pw_nl.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/nonlocal_pw.cpp rename to source/source_pw/module_pwdft/op_pw_nl.cpp index 2a87f3c1a7..c757c4f7a2 100644 --- a/source/source_pw/module_pwdft/operator_pw/nonlocal_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_nl.cpp @@ -1,4 +1,4 @@ -#include "nonlocal_pw.h" +#include "op_pw_nl.h" #include "source_io/module_parameter/parameter.h" #include "source_base/timer.h" diff --git a/source/source_pw/module_pwdft/operator_pw/nonlocal_pw.h b/source/source_pw/module_pwdft/op_pw_nl.h similarity index 98% rename from source/source_pw/module_pwdft/operator_pw/nonlocal_pw.h rename to source/source_pw/module_pwdft/op_pw_nl.h index 6a2bf6a954..4a7eab8c97 100644 --- a/source/source_pw/module_pwdft/operator_pw/nonlocal_pw.h +++ b/source/source_pw/module_pwdft/op_pw_nl.h @@ -1,7 +1,7 @@ #ifndef NONLOCALPW_H #define NONLOCALPW_H -#include "operator_pw.h" +#include "operator_pw/operator_pw.h" #include "source_cell/unitcell.h" #include "source_pw/module_pwdft/kernels/nonlocal_op.h" From 93f54cc4044f3f55c09a7a83ca24fa35014c7a0e Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:20:40 +0800 Subject: [PATCH 14/21] Refactor: Move and rename velocity_pw, veff_pw, and meta_pw files to module_pwdft directory --- source/Makefile.Objects | 6 +++--- source/source_esolver/esolver_ks_pw.h | 2 +- source/source_io/write_vxc_lip.hpp | 2 +- source/source_pw/module_pwdft/CMakeLists.txt | 6 +++--- source/source_pw/module_pwdft/elecond.h | 2 +- source/source_pw/module_pwdft/hamilt_pw.cpp | 4 ++-- .../{operator_pw/meta_pw.cpp => op_pw_meta.cpp} | 2 +- .../module_pwdft/{operator_pw/meta_pw.h => op_pw_meta.h} | 2 +- .../{operator_pw/veff_pw.cpp => op_pw_veff.cpp} | 2 +- .../module_pwdft/{operator_pw/veff_pw.h => op_pw_veff.h} | 2 +- .../{operator_pw/velocity_pw.cpp => op_pw_vel.cpp} | 2 +- .../module_pwdft/{operator_pw/velocity_pw.h => op_pw_vel.h} | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) rename source/source_pw/module_pwdft/{operator_pw/meta_pw.cpp => op_pw_meta.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/meta_pw.h => op_pw_meta.h} (98%) rename source/source_pw/module_pwdft/{operator_pw/veff_pw.cpp => op_pw_veff.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/veff_pw.h => op_pw_veff.h} (98%) rename source/source_pw/module_pwdft/{operator_pw/velocity_pw.cpp => op_pw_vel.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/velocity_pw.h => op_pw_vel.h} (98%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 74bc60dd8c..98d21a084f 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -315,13 +315,13 @@ OBJS_HAMILT=hamilt_pw.o\ exx_pw_ace.o\ exx_pw_pot.o\ hpsi_norm_op.o\ - veff_pw.o\ + op_pw_veff.o\ veff_op.o\ op_pw_nl.o\ nonlocal_op.o\ - meta_pw.o\ + op_pw_meta.o\ meta_op.o\ - velocity_pw.o\ + op_pw_vel.o\ radial_proj.o\ exx_helper.o\ vec_mul_vec_complex_op.o\ diff --git a/source/source_esolver/esolver_ks_pw.h b/source/source_esolver/esolver_ks_pw.h index d2df594260..be90caa973 100644 --- a/source/source_esolver/esolver_ks_pw.h +++ b/source/source_esolver/esolver_ks_pw.h @@ -4,7 +4,7 @@ #include "source_psi/setup_psi_pw.h" // mohan add 20251012 #include "source_pw/module_pwdft/VSep_in_pw.h" #include "source_pw/module_pwdft/exx_helper.h" -#include "source_pw/module_pwdft/operator_pw/velocity_pw.h" +#include "source_pw/module_pwdft/op_pw_vel.h" #include #include diff --git a/source/source_io/write_vxc_lip.hpp b/source/source_io/write_vxc_lip.hpp index 3705993022..84a2aeefbf 100644 --- a/source/source_io/write_vxc_lip.hpp +++ b/source/source_io/write_vxc_lip.hpp @@ -3,7 +3,7 @@ #include "source_io/module_parameter/parameter.h" #include "source_base/parallel_reduce.h" #include "source_base/module_container/base/third_party/blas.h" -#include "source_pw/module_pwdft/operator_pw/veff_pw.h" +#include "source_pw/module_pwdft/op_pw_veff.h" #include "source_psi/psi.h" #include "source_cell/unitcell.h" #include "source_cell/klist.h" diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 0914f019fb..b5fa43a741 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -3,10 +3,10 @@ add_subdirectory(operator_pw) list(APPEND objects hamilt_pw.cpp op_pw_ekin.cpp - operator_pw/veff_pw.cpp + op_pw_veff.cpp op_pw_nl.cpp - operator_pw/meta_pw.cpp - operator_pw/velocity_pw.cpp + op_pw_meta.cpp + op_pw_vel.cpp operator_pw/operator_pw.cpp operator_pw/onsite_proj_pw.cpp operator_pw/op_exx_pw.cpp diff --git a/source/source_pw/module_pwdft/elecond.h b/source/source_pw/module_pwdft/elecond.h index 13bc48bea3..c48f843dd2 100644 --- a/source/source_pw/module_pwdft/elecond.h +++ b/source/source_pw/module_pwdft/elecond.h @@ -7,7 +7,7 @@ #include "source_cell/unitcell.h" #include "source_estate/elecstate.h" #include "source_pw/module_pwdft/VNL_in_pw.h" -#include "source_pw/module_pwdft/operator_pw/velocity_pw.h" +#include "source_pw/module_pwdft/op_pw_vel.h" template class EleCond diff --git a/source/source_pw/module_pwdft/hamilt_pw.cpp b/source/source_pw/module_pwdft/hamilt_pw.cpp index 011e54bf64..a3f7a8e9e7 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.cpp +++ b/source/source_pw/module_pwdft/hamilt_pw.cpp @@ -4,9 +4,9 @@ #include "source_base/global_function.h" #include "source_base/global_variable.h" -#include "operator_pw/veff_pw.h" +#include "op_pw_veff.h" #include "op_pw_ekin.h" -#include "operator_pw/meta_pw.h" +#include "op_pw_meta.h" #include "op_pw_nl.h" #include "operator_pw/onsite_proj_pw.h" #include "operator_pw/op_exx_pw.h" diff --git a/source/source_pw/module_pwdft/operator_pw/meta_pw.cpp b/source/source_pw/module_pwdft/op_pw_meta.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/meta_pw.cpp rename to source/source_pw/module_pwdft/op_pw_meta.cpp index 70926e0830..e0140b8641 100644 --- a/source/source_pw/module_pwdft/operator_pw/meta_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_meta.cpp @@ -1,4 +1,4 @@ -#include "meta_pw.h" +#include "op_pw_meta.h" #include "source_base/timer.h" #include "source_hamilt/module_xc/xc_functional.h" diff --git a/source/source_pw/module_pwdft/operator_pw/meta_pw.h b/source/source_pw/module_pwdft/op_pw_meta.h similarity index 98% rename from source/source_pw/module_pwdft/operator_pw/meta_pw.h rename to source/source_pw/module_pwdft/op_pw_meta.h index 8534170079..cc54aa16ba 100644 --- a/source/source_pw/module_pwdft/operator_pw/meta_pw.h +++ b/source/source_pw/module_pwdft/op_pw_meta.h @@ -1,7 +1,7 @@ #ifndef METAPW_H #define METAPW_H -#include "operator_pw.h" +#include "operator_pw/operator_pw.h" #include "source_base/matrix.h" #include "source_basis/module_pw/pw_basis_k.h" #include "source_pw/module_pwdft/kernels/meta_op.h" diff --git a/source/source_pw/module_pwdft/operator_pw/veff_pw.cpp b/source/source_pw/module_pwdft/op_pw_veff.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/veff_pw.cpp rename to source/source_pw/module_pwdft/op_pw_veff.cpp index 6406b9267a..bd5fa7f4e8 100644 --- a/source/source_pw/module_pwdft/operator_pw/veff_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_veff.cpp @@ -1,4 +1,4 @@ -#include "veff_pw.h" +#include "op_pw_veff.h" #include "source_base/timer.h" #include "source_base/tool_quit.h" diff --git a/source/source_pw/module_pwdft/operator_pw/veff_pw.h b/source/source_pw/module_pwdft/op_pw_veff.h similarity index 98% rename from source/source_pw/module_pwdft/operator_pw/veff_pw.h rename to source/source_pw/module_pwdft/op_pw_veff.h index 3c2024edc5..59a8aac39c 100644 --- a/source/source_pw/module_pwdft/operator_pw/veff_pw.h +++ b/source/source_pw/module_pwdft/op_pw_veff.h @@ -1,7 +1,7 @@ #ifndef VEFFPW_H #define VEFFPW_H -#include "operator_pw.h" +#include "operator_pw/operator_pw.h" #include "source_base/matrix.h" #include "source_basis/module_pw/pw_basis_k.h" #include "source_pw/module_pwdft/kernels/veff_op.h" diff --git a/source/source_pw/module_pwdft/operator_pw/velocity_pw.cpp b/source/source_pw/module_pwdft/op_pw_vel.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/velocity_pw.cpp rename to source/source_pw/module_pwdft/op_pw_vel.cpp index f9a7aa6333..b4f0127586 100644 --- a/source/source_pw/module_pwdft/operator_pw/velocity_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_vel.cpp @@ -1,4 +1,4 @@ -#include "velocity_pw.h" +#include "op_pw_vel.h" #include "source_base/kernels/math_kernel_op.h" #include "source_base/parallel_reduce.h" diff --git a/source/source_pw/module_pwdft/operator_pw/velocity_pw.h b/source/source_pw/module_pwdft/op_pw_vel.h similarity index 98% rename from source/source_pw/module_pwdft/operator_pw/velocity_pw.h rename to source/source_pw/module_pwdft/op_pw_vel.h index 191e07fde3..16967e3ddf 100644 --- a/source/source_pw/module_pwdft/operator_pw/velocity_pw.h +++ b/source/source_pw/module_pwdft/op_pw_vel.h @@ -1,6 +1,6 @@ #ifndef VELOCITY_PW_H #define VELOCITY_PW_H -#include "operator_pw.h" +#include "operator_pw/operator_pw.h" #include "source_cell/unitcell.h" #include "source_pw/module_pwdft/VNL_in_pw.h" #include "source_basis/module_pw/pw_basis_k.h" From 98e429b28bdd306a14e18cb4acf176560748abfd Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:29:16 +0800 Subject: [PATCH 15/21] Refactor: Move and rename all operator_pw files to module_pwdft directory and clean up --- source/Makefile.Objects | 11 +++++---- source/source_pw/module_pwdft/CMakeLists.txt | 12 +++++----- source/source_pw/module_pwdft/exx_helper.h | 2 +- source/source_pw/module_pwdft/hamilt_pw.cpp | 4 ++-- .../operator_pw.cpp => op_pw.cpp} | 2 +- .../{operator_pw/operator_pw.h => op_pw.h} | 0 source/source_pw/module_pwdft/op_pw_ekin.h | 2 +- .../op_exx_pw.cpp => op_pw_exx.cpp} | 2 +- .../{operator_pw/op_exx_pw.h => op_pw_exx.h} | 2 +- .../exx_pw_ace.cpp => op_pw_exx_ace.cpp} | 2 +- .../exx_pw_pot.cpp => op_pw_exx_pot.cpp} | 2 +- source/source_pw/module_pwdft/op_pw_meta.h | 2 +- source/source_pw/module_pwdft/op_pw_nl.h | 2 +- .../onsite_proj_pw.cpp => op_pw_proj.cpp} | 2 +- .../onsite_proj_pw.h => op_pw_proj.h} | 2 +- source/source_pw/module_pwdft/op_pw_veff.h | 2 +- source/source_pw/module_pwdft/op_pw_vel.h | 2 +- .../module_pwdft/operator_pw/CMakeLists.txt | 23 ------------------- .../module_pwdft/stress_func_exx.cpp | 2 +- 19 files changed, 28 insertions(+), 50 deletions(-) rename source/source_pw/module_pwdft/{operator_pw/operator_pw.cpp => op_pw.cpp} (89%) rename source/source_pw/module_pwdft/{operator_pw/operator_pw.h => op_pw.h} (100%) rename source/source_pw/module_pwdft/{operator_pw/op_exx_pw.cpp => op_pw_exx.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/op_exx_pw.h => op_pw_exx.h} (99%) rename source/source_pw/module_pwdft/{operator_pw/exx_pw_ace.cpp => op_pw_exx_ace.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/exx_pw_pot.cpp => op_pw_exx_pot.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/onsite_proj_pw.cpp => op_pw_proj.cpp} (99%) rename source/source_pw/module_pwdft/{operator_pw/onsite_proj_pw.h => op_pw_proj.h} (99%) delete mode 100644 source/source_pw/module_pwdft/operator_pw/CMakeLists.txt diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 98d21a084f..6b8d1a8f39 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -50,7 +50,7 @@ VPATH=./src_global:\ ./source_pw/module_pwdft:\ ./source_pw/module_ofdft:\ ./source_pw/module_stodft:\ -./source_pw/module_pwdft/operator_pw:\ + ./source_pw/module_pwdft/kernels:\ ./source_pw/module_pwdft/module_exx_helper:\ ./source_pw/module_stodft/kernels:\ @@ -308,12 +308,12 @@ OBJS_GINT=batch_biggrid.o\ OBJS_HAMILT=hamilt_pw.o\ hamilt_sdft_pw.o\ operator.o\ - operator_pw.o\ - op_exx_pw.o\ + op_pw.o\ + op_pw_exx.o\ op_pw_ekin.o\ ekinetic_op.o\ - exx_pw_ace.o\ - exx_pw_pot.o\ + op_pw_exx_ace.o\ + op_pw_exx_pot.o\ hpsi_norm_op.o\ op_pw_veff.o\ veff_op.o\ @@ -322,6 +322,7 @@ OBJS_HAMILT=hamilt_pw.o\ op_pw_meta.o\ meta_op.o\ op_pw_vel.o\ + op_pw_proj.o\ radial_proj.o\ exx_helper.o\ vec_mul_vec_complex_op.o\ diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index b5fa43a741..6e7c7be7e3 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -1,4 +1,4 @@ -add_subdirectory(operator_pw) + list(APPEND objects hamilt_pw.cpp @@ -7,11 +7,11 @@ list(APPEND objects op_pw_nl.cpp op_pw_meta.cpp op_pw_vel.cpp - operator_pw/operator_pw.cpp - operator_pw/onsite_proj_pw.cpp - operator_pw/op_exx_pw.cpp - operator_pw/exx_pw_ace.cpp - operator_pw/exx_pw_pot.cpp + op_pw.cpp + op_pw_proj.cpp + op_pw_exx.cpp + op_pw_exx_ace.cpp + op_pw_exx_pot.cpp setup_pot.cpp setup_pwrho.cpp setup_pwwfc.cpp diff --git a/source/source_pw/module_pwdft/exx_helper.h b/source/source_pw/module_pwdft/exx_helper.h index 9ab8eab12d..283b035760 100644 --- a/source/source_pw/module_pwdft/exx_helper.h +++ b/source/source_pw/module_pwdft/exx_helper.h @@ -1,6 +1,6 @@ #include "source_psi/psi.h" #include "source_base/matrix.h" -#include "source_pw/module_pwdft/operator_pw/op_exx_pw.h" +#include "source_pw/module_pwdft/op_pw_exx.h" #ifndef EXX_HELPER_H #define EXX_HELPER_H diff --git a/source/source_pw/module_pwdft/hamilt_pw.cpp b/source/source_pw/module_pwdft/hamilt_pw.cpp index a3f7a8e9e7..27a56cbe11 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.cpp +++ b/source/source_pw/module_pwdft/hamilt_pw.cpp @@ -8,8 +8,8 @@ #include "op_pw_ekin.h" #include "op_pw_meta.h" #include "op_pw_nl.h" -#include "operator_pw/onsite_proj_pw.h" -#include "operator_pw/op_exx_pw.h" +#include "op_pw_proj.h" +#include "op_pw_exx.h" #include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info namespace hamilt diff --git a/source/source_pw/module_pwdft/operator_pw/operator_pw.cpp b/source/source_pw/module_pwdft/op_pw.cpp similarity index 89% rename from source/source_pw/module_pwdft/operator_pw/operator_pw.cpp rename to source/source_pw/module_pwdft/op_pw.cpp index 331545a3a3..b4289bc023 100644 --- a/source/source_pw/module_pwdft/operator_pw/operator_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw.cpp @@ -1,6 +1,6 @@ #include "source_base/timer.h" #include "source_hamilt/operator.h" -#include "source_pw/module_pwdft/operator_pw/operator_pw.h" +#include "op_pw.h" using namespace hamilt; diff --git a/source/source_pw/module_pwdft/operator_pw/operator_pw.h b/source/source_pw/module_pwdft/op_pw.h similarity index 100% rename from source/source_pw/module_pwdft/operator_pw/operator_pw.h rename to source/source_pw/module_pwdft/op_pw.h diff --git a/source/source_pw/module_pwdft/op_pw_ekin.h b/source/source_pw/module_pwdft/op_pw_ekin.h index 91adbc31be..adfb67eb7e 100644 --- a/source/source_pw/module_pwdft/op_pw_ekin.h +++ b/source/source_pw/module_pwdft/op_pw_ekin.h @@ -1,7 +1,7 @@ #ifndef EKINETICPW_H #define EKINETICPW_H -#include "operator_pw/operator_pw.h" +#include "op_pw.h" #include "source_pw/module_pwdft/kernels/ekinetic_op.h" #include diff --git a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp b/source/source_pw/module_pwdft/op_pw_exx.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp rename to source/source_pw/module_pwdft/op_pw_exx.cpp index a949a806c7..be29938057 100644 --- a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_exx.cpp @@ -1,4 +1,4 @@ -#include "op_exx_pw.h" +#include "op_pw_exx.h" #include "source_base/constants.h" #include "source_base/global_variable.h" diff --git a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.h b/source/source_pw/module_pwdft/op_pw_exx.h similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/op_exx_pw.h rename to source/source_pw/module_pwdft/op_pw_exx.h index 4e9d953afc..0329de8477 100644 --- a/source/source_pw/module_pwdft/operator_pw/op_exx_pw.h +++ b/source/source_pw/module_pwdft/op_pw_exx.h @@ -1,7 +1,7 @@ #ifndef OPEXXPW_H #define OPEXXPW_H -#include "operator_pw.h" +#include "op_pw.h" #include "source_base/kernels/math_kernel_op.h" #include "source_base/macros.h" #include "source_base/matrix.h" diff --git a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp b/source/source_pw/module_pwdft/op_pw_exx_ace.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp rename to source/source_pw/module_pwdft/op_pw_exx_ace.cpp index 0812a31bf2..d6c7f6517d 100644 --- a/source/source_pw/module_pwdft/operator_pw/exx_pw_ace.cpp +++ b/source/source_pw/module_pwdft/op_pw_exx_ace.cpp @@ -1,4 +1,4 @@ -#include "op_exx_pw.h" +#include "op_pw_exx.h" #include "source_base/parallel_comm.h" #include "source_io/module_parameter/parameter.h" #include "source_hamilt/module_xc/exx_info.h" diff --git a/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp b/source/source_pw/module_pwdft/op_pw_exx_pot.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp rename to source/source_pw/module_pwdft/op_pw_exx_pot.cpp index e353e5ee60..042276cd28 100644 --- a/source/source_pw/module_pwdft/operator_pw/exx_pw_pot.cpp +++ b/source/source_pw/module_pwdft/op_pw_exx_pot.cpp @@ -1,4 +1,4 @@ -#include "op_exx_pw.h" +#include "op_pw_exx.h" #include "source_io/module_parameter/parameter.h" #include "source_hamilt/module_xc/exx_info.h" // use GlobalC::exx_info diff --git a/source/source_pw/module_pwdft/op_pw_meta.h b/source/source_pw/module_pwdft/op_pw_meta.h index cc54aa16ba..84a8f322a7 100644 --- a/source/source_pw/module_pwdft/op_pw_meta.h +++ b/source/source_pw/module_pwdft/op_pw_meta.h @@ -1,7 +1,7 @@ #ifndef METAPW_H #define METAPW_H -#include "operator_pw/operator_pw.h" +#include "op_pw.h" #include "source_base/matrix.h" #include "source_basis/module_pw/pw_basis_k.h" #include "source_pw/module_pwdft/kernels/meta_op.h" diff --git a/source/source_pw/module_pwdft/op_pw_nl.h b/source/source_pw/module_pwdft/op_pw_nl.h index 4a7eab8c97..e5cc203721 100644 --- a/source/source_pw/module_pwdft/op_pw_nl.h +++ b/source/source_pw/module_pwdft/op_pw_nl.h @@ -1,7 +1,7 @@ #ifndef NONLOCALPW_H #define NONLOCALPW_H -#include "operator_pw/operator_pw.h" +#include "op_pw.h" #include "source_cell/unitcell.h" #include "source_pw/module_pwdft/kernels/nonlocal_op.h" diff --git a/source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.cpp b/source/source_pw/module_pwdft/op_pw_proj.cpp similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.cpp rename to source/source_pw/module_pwdft/op_pw_proj.cpp index 249f78e4a7..d28bce4165 100644 --- a/source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.cpp +++ b/source/source_pw/module_pwdft/op_pw_proj.cpp @@ -1,4 +1,4 @@ -#include "onsite_proj_pw.h" +#include "op_pw_proj.h" #include "source_base/timer.h" #include "source_base/parallel_reduce.h" diff --git a/source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.h b/source/source_pw/module_pwdft/op_pw_proj.h similarity index 99% rename from source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.h rename to source/source_pw/module_pwdft/op_pw_proj.h index 3eca4d99d4..50207cc7b7 100644 --- a/source/source_pw/module_pwdft/operator_pw/onsite_proj_pw.h +++ b/source/source_pw/module_pwdft/op_pw_proj.h @@ -1,7 +1,7 @@ #ifndef MODULEHAMILTPW_ONSITE_PROJ_PW_H #define MODULEHAMILTPW_ONSITE_PROJ_PW_H -#include "operator_pw.h" +#include "op_pw.h" #include "source_cell/unitcell.h" #include "source_base/kernels/math_kernel_op.h" diff --git a/source/source_pw/module_pwdft/op_pw_veff.h b/source/source_pw/module_pwdft/op_pw_veff.h index 59a8aac39c..fa7fe40872 100644 --- a/source/source_pw/module_pwdft/op_pw_veff.h +++ b/source/source_pw/module_pwdft/op_pw_veff.h @@ -1,7 +1,7 @@ #ifndef VEFFPW_H #define VEFFPW_H -#include "operator_pw/operator_pw.h" +#include "op_pw.h" #include "source_base/matrix.h" #include "source_basis/module_pw/pw_basis_k.h" #include "source_pw/module_pwdft/kernels/veff_op.h" diff --git a/source/source_pw/module_pwdft/op_pw_vel.h b/source/source_pw/module_pwdft/op_pw_vel.h index 16967e3ddf..8315eb7041 100644 --- a/source/source_pw/module_pwdft/op_pw_vel.h +++ b/source/source_pw/module_pwdft/op_pw_vel.h @@ -1,6 +1,6 @@ #ifndef VELOCITY_PW_H #define VELOCITY_PW_H -#include "operator_pw/operator_pw.h" +#include "op_pw.h" #include "source_cell/unitcell.h" #include "source_pw/module_pwdft/VNL_in_pw.h" #include "source_basis/module_pw/pw_basis_k.h" diff --git a/source/source_pw/module_pwdft/operator_pw/CMakeLists.txt b/source/source_pw/module_pwdft/operator_pw/CMakeLists.txt deleted file mode 100644 index 0a0e923ee0..0000000000 --- a/source/source_pw/module_pwdft/operator_pw/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -list(APPEND operator_ks_pw_srcs - operator_pw.cpp - ekinetic_pw.cpp - veff_pw.cpp - nonlocal_pw.cpp - meta_pw.cpp - velocity_pw.cpp - onsite_proj_pw.cpp - op_exx_pw.cpp - exx_pw_ace.cpp - exx_pw_pot.cpp -) - -# this library is included in module_pwdft now -#add_library( -# operator_ks_pw -# OBJECT -# ${operator_ks_pw_srcs} -#) - -#if(ENABLE_COVERAGE) -# add_coverage(operator_ks_pw) -#endif() diff --git a/source/source_pw/module_pwdft/stress_func_exx.cpp b/source/source_pw/module_pwdft/stress_func_exx.cpp index cf0bf2af88..73e7f7e214 100644 --- a/source/source_pw/module_pwdft/stress_func_exx.cpp +++ b/source/source_pw/module_pwdft/stress_func_exx.cpp @@ -1,5 +1,5 @@ #include "source_hamilt/module_xc/exx_info.h" -#include "operator_pw/op_exx_pw.h" +#include "op_pw_exx.h" #include "source_base/parallel_common.h" #include "stress_pw.h" From 1158a0e70d3929672bd6c0e5a3557b802aad5e6b Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:32:47 +0800 Subject: [PATCH 16/21] Refactor: Rename stress_func_xxx files to stress_xxx by removing _func suffix --- source/Makefile.Objects | 22 +++++++++---------- source/source_pw/module_pwdft/CMakeLists.txt | 22 +++++++++---------- .../{stress_func_cc.cpp => stress_cc.cpp} | 0 .../{stress_func_ewa.cpp => stress_ewa.cpp} | 0 .../{stress_func_exx.cpp => stress_exx.cpp} | 0 .../{stress_func_gga.cpp => stress_gga.cpp} | 0 .../{stress_func_har.cpp => stress_har.cpp} | 0 .../{stress_func_kin.cpp => stress_kin.cpp} | 0 .../{stress_func_loc.cpp => stress_loc.cpp} | 0 .../{stress_func_mgga.cpp => stress_mgga.cpp} | 0 .../{stress_func_nl.cpp => stress_nl.cpp} | 0 ...ress_func_onsite.cpp => stress_onsite.cpp} | 0 .../{stress_func_us.cpp => stress_us.cpp} | 0 13 files changed, 22 insertions(+), 22 deletions(-) rename source/source_pw/module_pwdft/{stress_func_cc.cpp => stress_cc.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_ewa.cpp => stress_ewa.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_exx.cpp => stress_exx.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_gga.cpp => stress_gga.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_har.cpp => stress_har.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_kin.cpp => stress_kin.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_loc.cpp => stress_loc.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_mgga.cpp => stress_mgga.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_nl.cpp => stress_nl.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_onsite.cpp => stress_onsite.cpp} (100%) rename source/source_pw/module_pwdft/{stress_func_us.cpp => stress_us.cpp} (100%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 6b8d1a8f39..88ded0411d 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -729,17 +729,17 @@ OBJS_SRCPW=H_Ewald_pw.o\ sto_func.o\ sto_forces.o\ sto_stress_pw.o\ - stress_func_cc.o\ - stress_func_ewa.o\ - stress_func_exx.o\ - stress_func_gga.o\ - stress_func_mgga.o\ - stress_func_har.o\ - stress_func_kin.o\ - stress_func_loc.o\ - stress_func_nl.o\ - stress_func_us.o\ - stress_func_onsite.o\ + stress_cc.o\ + stress_ewa.o\ + stress_exx.o\ + stress_gga.o\ + stress_mgga.o\ + stress_har.o\ + stress_kin.o\ + stress_loc.o\ + stress_nl.o\ + stress_us.o\ + stress_onsite.o\ stress_pw.o\ of_stress_pw.o\ of_print_info.o\ diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 6e7c7be7e3..29ccf26b0a 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -21,17 +21,17 @@ list(APPEND objects forces.cpp forces_us.cpp forces_onsite.cpp - stress_func_cc.cpp - stress_func_ewa.cpp - stress_func_gga.cpp - stress_func_mgga.cpp - stress_func_har.cpp - stress_func_kin.cpp - stress_func_loc.cpp - stress_func_nl.cpp - stress_func_us.cpp - stress_func_onsite.cpp - stress_func_exx.cpp + stress_cc.cpp + stress_ewa.cpp + stress_gga.cpp + stress_mgga.cpp + stress_har.cpp + stress_kin.cpp + stress_loc.cpp + stress_nl.cpp + stress_us.cpp + stress_onsite.cpp + stress_exx.cpp stress_pw.cpp VL_in_pw.cpp VNL_in_pw.cpp diff --git a/source/source_pw/module_pwdft/stress_func_cc.cpp b/source/source_pw/module_pwdft/stress_cc.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_cc.cpp rename to source/source_pw/module_pwdft/stress_cc.cpp diff --git a/source/source_pw/module_pwdft/stress_func_ewa.cpp b/source/source_pw/module_pwdft/stress_ewa.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_ewa.cpp rename to source/source_pw/module_pwdft/stress_ewa.cpp diff --git a/source/source_pw/module_pwdft/stress_func_exx.cpp b/source/source_pw/module_pwdft/stress_exx.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_exx.cpp rename to source/source_pw/module_pwdft/stress_exx.cpp diff --git a/source/source_pw/module_pwdft/stress_func_gga.cpp b/source/source_pw/module_pwdft/stress_gga.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_gga.cpp rename to source/source_pw/module_pwdft/stress_gga.cpp diff --git a/source/source_pw/module_pwdft/stress_func_har.cpp b/source/source_pw/module_pwdft/stress_har.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_har.cpp rename to source/source_pw/module_pwdft/stress_har.cpp diff --git a/source/source_pw/module_pwdft/stress_func_kin.cpp b/source/source_pw/module_pwdft/stress_kin.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_kin.cpp rename to source/source_pw/module_pwdft/stress_kin.cpp diff --git a/source/source_pw/module_pwdft/stress_func_loc.cpp b/source/source_pw/module_pwdft/stress_loc.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_loc.cpp rename to source/source_pw/module_pwdft/stress_loc.cpp diff --git a/source/source_pw/module_pwdft/stress_func_mgga.cpp b/source/source_pw/module_pwdft/stress_mgga.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_mgga.cpp rename to source/source_pw/module_pwdft/stress_mgga.cpp diff --git a/source/source_pw/module_pwdft/stress_func_nl.cpp b/source/source_pw/module_pwdft/stress_nl.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_nl.cpp rename to source/source_pw/module_pwdft/stress_nl.cpp diff --git a/source/source_pw/module_pwdft/stress_func_onsite.cpp b/source/source_pw/module_pwdft/stress_onsite.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_onsite.cpp rename to source/source_pw/module_pwdft/stress_onsite.cpp diff --git a/source/source_pw/module_pwdft/stress_func_us.cpp b/source/source_pw/module_pwdft/stress_us.cpp similarity index 100% rename from source/source_pw/module_pwdft/stress_func_us.cpp rename to source/source_pw/module_pwdft/stress_us.cpp From 6dac2a71c9087b37198dbc5bf605817b28f4a41e Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:44:08 +0800 Subject: [PATCH 17/21] Rename V*_in_pw files to more concise names and update references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit includes: 1. Renamed files in module_pwdft directory: - VL_in_pw.cpp/h → vl_pw.cpp/h - VNL_in_pw.cpp/h → vnl_pw.cpp/h - VNL_grad_pw.cpp → vnl_pw_grad.cpp - VSep_in_pw.cpp/h → vsep_pw.cpp/h 2. Updated CMakeLists.txt and Makefile.Objects to use new filenames 3. Updated include paths in 41 files across the codebase: - source_cell/test/klist_test.cpp and klist_test_para.cpp - source_esolver/esolver_fp.h, esolver_ks_pw.cpp, esolver_ks_pw.h - source_estate/module_pot/pot_sep.h, potential_new.h, setup_estate_pw.h - source_estate/test/elecstate_pw_test.cpp - source_io/test/for_testing_input_conv.h, for_testing_klist.h - source_lcao/LCAO_set.h - source_psi/psi_initializer.h and related files - source_pw/module_ofdft/of_stress_pw.h - source_pw/module_pwdft/* (multiple files) - source_pw/module_stodft/sto_stress_pw.h 4. Verified compilation success with make -j30 The renaming follows consistent naming conventions and makes filenames more concise. --- source/Makefile.Objects | 8 ++++---- source/source_cell/test/klist_test.cpp | 4 ++-- source/source_cell/test/klist_test_para.cpp | 4 ++-- source/source_esolver/esolver_fp.h | 2 +- source/source_esolver/esolver_ks_pw.cpp | 2 +- source/source_esolver/esolver_ks_pw.h | 2 +- source/source_estate/module_pot/pot_sep.h | 2 +- source/source_estate/module_pot/potential_new.h | 4 ++-- source/source_estate/setup_estate_pw.h | 4 ++-- source/source_estate/test/elecstate_pw_test.cpp | 2 +- source/source_io/test/for_testing_input_conv.h | 2 +- source/source_io/test/for_testing_klist.h | 4 ++-- source/source_lcao/LCAO_set.h | 2 +- source/source_psi/psi_initializer.h | 2 +- source/source_psi/psi_initializer_atomic_random.h | 2 +- source/source_psi/psi_initializer_nao_random.h | 2 +- source/source_psi/psi_initializer_random.h | 2 +- source/source_psi/setup_psi_pw.h | 2 +- source/source_psi/test/psi_initializer_unit_test.cpp | 2 +- source/source_pw/module_ofdft/of_stress_pw.h | 2 +- source/source_pw/module_pwdft/CMakeLists.txt | 8 ++++---- source/source_pw/module_pwdft/elecond.h | 2 +- source/source_pw/module_pwdft/forces.h | 2 +- source/source_pw/module_pwdft/fs_nonlocal_tools.h | 2 +- source/source_pw/module_pwdft/hamilt_pw.h | 2 +- source/source_pw/module_pwdft/nonlocal_maths.hpp | 2 +- source/source_pw/module_pwdft/onsite_proj_tools.h | 2 +- source/source_pw/module_pwdft/op_pw_nl.h | 2 +- source/source_pw/module_pwdft/op_pw_vel.h | 2 +- source/source_pw/module_pwdft/setup_pot.cpp | 2 +- source/source_pw/module_pwdft/setup_pot.h | 2 +- source/source_pw/module_pwdft/stress_func.h | 2 +- source/source_pw/module_pwdft/stress_pw.h | 2 +- source/source_pw/module_pwdft/{VL_in_pw.cpp => vl_pw.cpp} | 2 +- source/source_pw/module_pwdft/{VL_in_pw.h => vl_pw.h} | 0 .../source_pw/module_pwdft/{VNL_in_pw.cpp => vnl_pw.cpp} | 2 +- source/source_pw/module_pwdft/{VNL_in_pw.h => vnl_pw.h} | 0 .../module_pwdft/{VNL_grad_pw.cpp => vnl_pw_grad.cpp} | 2 +- .../module_pwdft/{VSep_in_pw.cpp => vsep_pw.cpp} | 2 +- source/source_pw/module_pwdft/{VSep_in_pw.h => vsep_pw.h} | 0 source/source_pw/module_stodft/sto_stress_pw.h | 2 +- 41 files changed, 49 insertions(+), 49 deletions(-) rename source/source_pw/module_pwdft/{VL_in_pw.cpp => vl_pw.cpp} (99%) rename source/source_pw/module_pwdft/{VL_in_pw.h => vl_pw.h} (100%) rename source/source_pw/module_pwdft/{VNL_in_pw.cpp => vnl_pw.cpp} (99%) rename source/source_pw/module_pwdft/{VNL_in_pw.h => vnl_pw.h} (100%) rename source/source_pw/module_pwdft/{VNL_grad_pw.cpp => vnl_pw_grad.cpp} (99%) rename source/source_pw/module_pwdft/{VSep_in_pw.cpp => vsep_pw.cpp} (99%) rename source/source_pw/module_pwdft/{VSep_in_pw.h => vsep_pw.h} (100%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 88ded0411d..3f8c5bcea8 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -686,9 +686,9 @@ OBJS_PARALLEL=parallel_common.o\ OBJS_SRCPW=H_Ewald_pw.o\ dnrm2.o\ - VL_in_pw.o\ - VNL_in_pw.o\ - VNL_grad_pw.o\ + vl_pw.o\ + vnl_pw.o\ + vnl_pw_grad.o\ chgmixing.o\ charge.o\ charge_init.o\ @@ -754,7 +754,7 @@ OBJS_SRCPW=H_Ewald_pw.o\ sto_dos.o\ onsite_projector.o\ onsite_proj_tools.o\ - VSep_in_pw.o + vsep_pw.o OBJS_VDW=vdw.o\ vdwd2_parameters.o\ diff --git a/source/source_cell/test/klist_test.cpp b/source/source_cell/test/klist_test.cpp index 4d351af719..f14071f0f4 100644 --- a/source/source_cell/test/klist_test.cpp +++ b/source/source_cell/test/klist_test.cpp @@ -12,8 +12,8 @@ #include "source_cell/setup_nonlocal.h" #include "source_cell/unitcell.h" #include "source_estate/magnetism.h" -#include "source_pw/module_pwdft/VL_in_pw.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" #include "source_io/berryphase.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_cell/test/klist_test_para.cpp b/source/source_cell/test/klist_test_para.cpp index 789e58e8e5..032372e5a3 100644 --- a/source/source_cell/test/klist_test_para.cpp +++ b/source/source_cell/test/klist_test_para.cpp @@ -19,8 +19,8 @@ #include "source_cell/setup_nonlocal.h" #include "source_cell/unitcell.h" #include "source_estate/magnetism.h" -#include "source_pw/module_pwdft/VL_in_pw.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" #include "source_io/berryphase.h" #undef private diff --git a/source/source_esolver/esolver_fp.h b/source/source_esolver/esolver_fp.h index 94faa31e74..9edf4f3367 100644 --- a/source/source_esolver/esolver_fp.h +++ b/source/source_esolver/esolver_fp.h @@ -10,7 +10,7 @@ #include "source_estate/elecstate.h" // electronic states #include "source_estate/module_charge/charge_extra.h" // charge extrapolation #include "source_hamilt/module_surchem/surchem.h" // solvation model -#include "source_pw/module_pwdft/VL_in_pw.h" // local pseudopotential +#include "source_pw/module_pwdft/vl_pw.h" // local pseudopotential #include "source_pw/module_pwdft/structure_factor.h" // structure factor #include diff --git a/source/source_esolver/esolver_ks_pw.cpp b/source/source_esolver/esolver_ks_pw.cpp index 11088a6daf..511ccf3b5f 100644 --- a/source/source_esolver/esolver_ks_pw.cpp +++ b/source/source_esolver/esolver_ks_pw.cpp @@ -12,7 +12,7 @@ #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_pw/module_pwdft/onsite_projector.h" #include "source_lcao/module_dftu/dftu.h" -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" #include "source_pw/module_pwdft/hamilt_pw.h" #include "source_pw/module_pwdft/forces.h" diff --git a/source/source_esolver/esolver_ks_pw.h b/source/source_esolver/esolver_ks_pw.h index be90caa973..01e1027d79 100644 --- a/source/source_esolver/esolver_ks_pw.h +++ b/source/source_esolver/esolver_ks_pw.h @@ -2,7 +2,7 @@ #define ESOLVER_KS_PW_H #include "./esolver_ks.h" #include "source_psi/setup_psi_pw.h" // mohan add 20251012 -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" #include "source_pw/module_pwdft/exx_helper.h" #include "source_pw/module_pwdft/op_pw_vel.h" diff --git a/source/source_estate/module_pot/pot_sep.h b/source/source_estate/module_pot/pot_sep.h index fce110cb40..cb4368030d 100644 --- a/source/source_estate/module_pot/pot_sep.h +++ b/source/source_estate/module_pot/pot_sep.h @@ -3,7 +3,7 @@ #include "pot_base.h" #include "source_base/matrix.h" -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" namespace elecstate { diff --git a/source/source_estate/module_pot/potential_new.h b/source/source_estate/module_pot/potential_new.h index 0d7e2b2be4..5b888e7d8b 100644 --- a/source/source_estate/module_pot/potential_new.h +++ b/source/source_estate/module_pot/potential_new.h @@ -3,8 +3,8 @@ #include "source_base/complexmatrix.h" #include "source_hamilt/module_surchem/surchem.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" #include "source_pw/module_pwdft/structure_factor.h" #include "pot_base.h" diff --git a/source/source_estate/setup_estate_pw.h b/source/source_estate/setup_estate_pw.h index 44864ad588..81a2261f6d 100644 --- a/source/source_estate/setup_estate_pw.h +++ b/source/source_estate/setup_estate_pw.h @@ -6,8 +6,8 @@ #include "source_cell/klist.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" namespace elecstate { diff --git a/source/source_estate/test/elecstate_pw_test.cpp b/source/source_estate/test/elecstate_pw_test.cpp index 27b9bea73a..c71a38002e 100644 --- a/source/source_estate/test/elecstate_pw_test.cpp +++ b/source/source_estate/test/elecstate_pw_test.cpp @@ -6,7 +6,7 @@ #define protected public #include "source_estate/elecstate_pw.h" #include "source_hamilt/module_xc/xc_functional.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_io/module_parameter/parameter.h" // mock functions for testing int XC_Functional::func_type = 1; diff --git a/source/source_io/test/for_testing_input_conv.h b/source/source_io/test/for_testing_input_conv.h index d9cd4d053d..6fe441c20e 100644 --- a/source/source_io/test/for_testing_input_conv.h +++ b/source/source_io/test/for_testing_input_conv.h @@ -14,7 +14,7 @@ #include "source_lcao/module_dftu/dftu.h" #include "source_lcao/module_rt/evolve_elec.h" #include "source_lcao/module_rt/td_velocity.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_hsolver/hsolver_lcao.h" #include "source_io/berryphase.h" diff --git a/source/source_io/test/for_testing_klist.h b/source/source_io/test/for_testing_klist.h index e8d518fa49..675c3de3c4 100644 --- a/source/source_io/test/for_testing_klist.h +++ b/source/source_io/test/for_testing_klist.h @@ -11,8 +11,8 @@ #include "source_cell/setup_nonlocal.h" #include "source_cell/unitcell.h" #include "source_estate/magnetism.h" -#include "source_pw/module_pwdft/VL_in_pw.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" #include "source_io/berryphase.h" diff --git a/source/source_lcao/LCAO_set.h b/source/source_lcao/LCAO_set.h index 1e1aa6e5a3..fc7d807a37 100644 --- a/source/source_lcao/LCAO_set.h +++ b/source/source_lcao/LCAO_set.h @@ -9,7 +9,7 @@ #include "source_pw/module_pwdft/structure_factor.h" #include "source_basis/module_pw/pw_basis.h" #include "source_hamilt/module_surchem/surchem.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_lcao/module_deepks/LCAO_deepks.h" #include "source_lcao/module_dftu/dftu.h" #include "source_lcao/setup_exx.h" diff --git a/source/source_psi/psi_initializer.h b/source/source_psi/psi_initializer.h index 7f48fc7d58..a812656209 100644 --- a/source/source_psi/psi_initializer.h +++ b/source/source_psi/psi_initializer.h @@ -2,7 +2,7 @@ #define PSI_INITIALIZER_H // data structure support #include "source_basis/module_pw/pw_basis_k.h" // for kpoint related data structure -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_psi/psi.h" // for psi data structure // smart pointer for auto-memory management diff --git a/source/source_psi/psi_initializer_atomic_random.h b/source/source_psi/psi_initializer_atomic_random.h index e37adc4c23..2137527c4a 100644 --- a/source/source_psi/psi_initializer_atomic_random.h +++ b/source/source_psi/psi_initializer_atomic_random.h @@ -1,7 +1,7 @@ #ifndef PSI_INITIALIZER_ATOMIC_RANDOM_H #define PSI_INITIALIZER_ATOMIC_RANDOM_H #include "source_cell/parallel_kpoints.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "psi_initializer_atomic.h" /* diff --git a/source/source_psi/psi_initializer_nao_random.h b/source/source_psi/psi_initializer_nao_random.h index 0dd1853a13..10613039ee 100644 --- a/source/source_psi/psi_initializer_nao_random.h +++ b/source/source_psi/psi_initializer_nao_random.h @@ -1,7 +1,7 @@ #ifndef PSI_INITIALIZER_NAO_RANDOM_H #define PSI_INITIALIZER_NAO_RANDOM_H #include "source_cell/parallel_kpoints.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "psi_initializer_nao.h" /* diff --git a/source/source_psi/psi_initializer_random.h b/source/source_psi/psi_initializer_random.h index 2c9ab4a5c4..cffa907e98 100644 --- a/source/source_psi/psi_initializer_random.h +++ b/source/source_psi/psi_initializer_random.h @@ -1,7 +1,7 @@ #ifndef PSI_INITIALIZER_RANDOM_H #define PSI_INITIALIZER_RANDOM_H -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "psi_initializer.h" /* diff --git a/source/source_psi/setup_psi_pw.h b/source/source_psi/setup_psi_pw.h index 99407f67e1..7930baed5f 100644 --- a/source/source_psi/setup_psi_pw.h +++ b/source/source_psi/setup_psi_pw.h @@ -6,7 +6,7 @@ #include "source_cell/klist.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_basis/module_pw/pw_basis_k.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_io/module_parameter/input_parameter.h" #include "source_base/module_device/device.h" #include "source_hamilt/hamilt.h" diff --git a/source/source_psi/test/psi_initializer_unit_test.cpp b/source/source_psi/test/psi_initializer_unit_test.cpp index 0bfad3d371..cc702d5697 100644 --- a/source/source_psi/test/psi_initializer_unit_test.cpp +++ b/source/source_psi/test/psi_initializer_unit_test.cpp @@ -8,7 +8,7 @@ #include "../psi_initializer_nao.h" #include "../psi_initializer_nao_random.h" #include "../psi_initializer_random.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_cell/klist.h" /* diff --git a/source/source_pw/module_ofdft/of_stress_pw.h b/source/source_pw/module_ofdft/of_stress_pw.h index e6efdca212..d5d5d5feb1 100644 --- a/source/source_pw/module_ofdft/of_stress_pw.h +++ b/source/source_pw/module_ofdft/of_stress_pw.h @@ -2,7 +2,7 @@ #define OF_STRESS_PW_H #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/stress_func.h" class OF_Stress_PW : public Stress_Func diff --git a/source/source_pw/module_pwdft/CMakeLists.txt b/source/source_pw/module_pwdft/CMakeLists.txt index 29ccf26b0a..3c525240ea 100644 --- a/source/source_pw/module_pwdft/CMakeLists.txt +++ b/source/source_pw/module_pwdft/CMakeLists.txt @@ -33,9 +33,9 @@ list(APPEND objects stress_onsite.cpp stress_exx.cpp stress_pw.cpp - VL_in_pw.cpp - VNL_in_pw.cpp - VNL_grad_pw.cpp + vl_pw.cpp + vnl_pw.cpp + vnl_pw_grad.cpp structure_factor.cpp structure_factor_k.cpp soc.cpp @@ -46,7 +46,7 @@ list(APPEND objects radial_proj.cpp onsite_projector.cpp onsite_proj_tools.cpp - VSep_in_pw.cpp + vsep_pw.cpp ) add_library( diff --git a/source/source_pw/module_pwdft/elecond.h b/source/source_pw/module_pwdft/elecond.h index c48f843dd2..83a4a85d25 100644 --- a/source/source_pw/module_pwdft/elecond.h +++ b/source/source_pw/module_pwdft/elecond.h @@ -6,7 +6,7 @@ #include "source_cell/klist.h" #include "source_cell/unitcell.h" #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/op_pw_vel.h" template diff --git a/source/source_pw/module_pwdft/forces.h b/source/source_pw/module_pwdft/forces.h index 61466fcdd6..9730109071 100644 --- a/source/source_pw/module_pwdft/forces.h +++ b/source/source_pw/module_pwdft/forces.h @@ -9,7 +9,7 @@ #include "source_cell/klist.h" #include "source_cell/module_symmetry/symmetry.h" #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/kernels/force_op.h" #include "source_base/kernels/math_kernel_op.h" #include "source_psi/psi.h" diff --git a/source/source_pw/module_pwdft/fs_nonlocal_tools.h b/source/source_pw/module_pwdft/fs_nonlocal_tools.h index ffe745f07e..5a96f71fb9 100644 --- a/source/source_pw/module_pwdft/fs_nonlocal_tools.h +++ b/source/source_pw/module_pwdft/fs_nonlocal_tools.h @@ -5,7 +5,7 @@ #include "source_basis/module_pw/pw_basis_k.h" #include "source_cell/klist.h" #include "source_cell/unitcell.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/kernels/stress_op.h" #include "source_base/kernels/math_kernel_op.h" #include "source_psi/psi.h" diff --git a/source/source_pw/module_pwdft/hamilt_pw.h b/source/source_pw/module_pwdft/hamilt_pw.h index e57f0df4c4..d3411c54f4 100644 --- a/source/source_pw/module_pwdft/hamilt_pw.h +++ b/source/source_pw/module_pwdft/hamilt_pw.h @@ -6,7 +6,7 @@ #include "source_estate/module_pot/potential_new.h" #include "source_esolver/esolver_ks_pw.h" #include "source_hamilt/hamilt.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_base/kernels/math_kernel_op.h" #include "source_pw/module_pwdft/exx_helper.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06 diff --git a/source/source_pw/module_pwdft/nonlocal_maths.hpp b/source/source_pw/module_pwdft/nonlocal_maths.hpp index 07cd28de2d..70d812e7c9 100644 --- a/source/source_pw/module_pwdft/nonlocal_maths.hpp +++ b/source/source_pw/module_pwdft/nonlocal_maths.hpp @@ -5,7 +5,7 @@ #include "source_basis/module_pw/pw_basis_k.h" #include "source_cell/klist.h" #include "source_cell/unitcell.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/kernels/stress_op.h" #include "source_base/kernels/math_kernel_op.h" diff --git a/source/source_pw/module_pwdft/onsite_proj_tools.h b/source/source_pw/module_pwdft/onsite_proj_tools.h index a8b7a56b8e..2bfa5ebb44 100644 --- a/source/source_pw/module_pwdft/onsite_proj_tools.h +++ b/source/source_pw/module_pwdft/onsite_proj_tools.h @@ -5,7 +5,7 @@ #include "source_basis/module_pw/pw_basis_k.h" #include "source_cell/klist.h" #include "source_cell/unitcell.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/kernels/stress_op.h" #include "source_base/kernels/math_kernel_op.h" #include "source_psi/psi.h" diff --git a/source/source_pw/module_pwdft/op_pw_nl.h b/source/source_pw/module_pwdft/op_pw_nl.h index e5cc203721..829bb31e93 100644 --- a/source/source_pw/module_pwdft/op_pw_nl.h +++ b/source/source_pw/module_pwdft/op_pw_nl.h @@ -7,7 +7,7 @@ #include "source_pw/module_pwdft/kernels/nonlocal_op.h" #include "source_base/kernels/math_kernel_op.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" namespace hamilt { diff --git a/source/source_pw/module_pwdft/op_pw_vel.h b/source/source_pw/module_pwdft/op_pw_vel.h index 8315eb7041..211ce4007e 100644 --- a/source/source_pw/module_pwdft/op_pw_vel.h +++ b/source/source_pw/module_pwdft/op_pw_vel.h @@ -2,7 +2,7 @@ #define VELOCITY_PW_H #include "op_pw.h" #include "source_cell/unitcell.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_basis/module_pw/pw_basis_k.h" namespace hamilt { diff --git a/source/source_pw/module_pwdft/setup_pot.cpp b/source/source_pw/module_pwdft/setup_pot.cpp index 5080e265f7..d8a340535c 100644 --- a/source/source_pw/module_pwdft/setup_pot.cpp +++ b/source/source_pw/module_pwdft/setup_pot.cpp @@ -4,7 +4,7 @@ #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_pw/module_pwdft/onsite_projector.h" #include "source_lcao/module_dftu/dftu.h" -#include "source_pw/module_pwdft/VSep_in_pw.h" +#include "source_pw/module_pwdft/vsep_pw.h" template void pw::setup_pot(const int istep, diff --git a/source/source_pw/module_pwdft/setup_pot.h b/source/source_pw/module_pwdft/setup_pot.h index 3849ee5087..0f691bbfc7 100644 --- a/source/source_pw/module_pwdft/setup_pot.h +++ b/source/source_pw/module_pwdft/setup_pot.h @@ -6,7 +6,7 @@ #include "source_cell/klist.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_hamilt/hamilt.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06 diff --git a/source/source_pw/module_pwdft/stress_func.h b/source/source_pw/module_pwdft/stress_func.h index 3f0a79b6d3..815298aa9d 100644 --- a/source/source_pw/module_pwdft/stress_func.h +++ b/source/source_pw/module_pwdft/stress_func.h @@ -11,7 +11,7 @@ #include "source_basis/module_pw/pw_basis_k.h" #include "source_cell/klist.h" #include "source_estate/module_charge/charge.h" -#include "source_pw/module_pwdft/VNL_in_pw.h" +#include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/kernels/stress_op.h" #include "source_pw/module_pwdft/structure_factor.h" #include "source_base/kernels/math_kernel_op.h" diff --git a/source/source_pw/module_pwdft/stress_pw.h b/source/source_pw/module_pwdft/stress_pw.h index 0fb31fecaa..dde4688681 100644 --- a/source/source_pw/module_pwdft/stress_pw.h +++ b/source/source_pw/module_pwdft/stress_pw.h @@ -2,7 +2,7 @@ #define STRESS_PW_H #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "stress_func.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-07 diff --git a/source/source_pw/module_pwdft/VL_in_pw.cpp b/source/source_pw/module_pwdft/vl_pw.cpp similarity index 99% rename from source/source_pw/module_pwdft/VL_in_pw.cpp rename to source/source_pw/module_pwdft/vl_pw.cpp index 66c0b595bb..672fbd6185 100644 --- a/source/source_pw/module_pwdft/VL_in_pw.cpp +++ b/source/source_pw/module_pwdft/vl_pw.cpp @@ -1,4 +1,4 @@ -#include "VL_in_pw.h" +#include "vl_pw.h" #include "source_io/module_parameter/parameter.h" #include "source_base/libm/libm.h" #include "source_base/math_integral.h" diff --git a/source/source_pw/module_pwdft/VL_in_pw.h b/source/source_pw/module_pwdft/vl_pw.h similarity index 100% rename from source/source_pw/module_pwdft/VL_in_pw.h rename to source/source_pw/module_pwdft/vl_pw.h diff --git a/source/source_pw/module_pwdft/VNL_in_pw.cpp b/source/source_pw/module_pwdft/vnl_pw.cpp similarity index 99% rename from source/source_pw/module_pwdft/VNL_in_pw.cpp rename to source/source_pw/module_pwdft/vnl_pw.cpp index 3b63c28f3d..52d3d447da 100644 --- a/source/source_pw/module_pwdft/VNL_in_pw.cpp +++ b/source/source_pw/module_pwdft/vnl_pw.cpp @@ -1,4 +1,4 @@ -#include "VNL_in_pw.h" +#include "vnl_pw.h" #include "source_io/module_parameter/parameter.h" #include "source_base/clebsch_gordan_coeff.h" diff --git a/source/source_pw/module_pwdft/VNL_in_pw.h b/source/source_pw/module_pwdft/vnl_pw.h similarity index 100% rename from source/source_pw/module_pwdft/VNL_in_pw.h rename to source/source_pw/module_pwdft/vnl_pw.h diff --git a/source/source_pw/module_pwdft/VNL_grad_pw.cpp b/source/source_pw/module_pwdft/vnl_pw_grad.cpp similarity index 99% rename from source/source_pw/module_pwdft/VNL_grad_pw.cpp rename to source/source_pw/module_pwdft/vnl_pw_grad.cpp index 0cc37eccdb..eb70520f25 100644 --- a/source/source_pw/module_pwdft/VNL_grad_pw.cpp +++ b/source/source_pw/module_pwdft/vnl_pw_grad.cpp @@ -1,4 +1,4 @@ -#include "VNL_in_pw.h" +#include "vnl_pw.h" #include "source_base/math_sphbes.h" #include "source_io/module_parameter/parameter.h" #include "source_base/timer.h" diff --git a/source/source_pw/module_pwdft/VSep_in_pw.cpp b/source/source_pw/module_pwdft/vsep_pw.cpp similarity index 99% rename from source/source_pw/module_pwdft/VSep_in_pw.cpp rename to source/source_pw/module_pwdft/vsep_pw.cpp index ee49a839a0..569ae0131c 100644 --- a/source/source_pw/module_pwdft/VSep_in_pw.cpp +++ b/source/source_pw/module_pwdft/vsep_pw.cpp @@ -1,4 +1,4 @@ -#include "VSep_in_pw.h" +#include "vsep_pw.h" #include "source_base/constants.h" #include "source_base/libm/libm.h" diff --git a/source/source_pw/module_pwdft/VSep_in_pw.h b/source/source_pw/module_pwdft/vsep_pw.h similarity index 100% rename from source/source_pw/module_pwdft/VSep_in_pw.h rename to source/source_pw/module_pwdft/vsep_pw.h diff --git a/source/source_pw/module_stodft/sto_stress_pw.h b/source/source_pw/module_stodft/sto_stress_pw.h index 8dbbc08804..fd47037249 100644 --- a/source/source_pw/module_stodft/sto_stress_pw.h +++ b/source/source_pw/module_stodft/sto_stress_pw.h @@ -3,7 +3,7 @@ #include "source_basis/module_pw/pw_basis_k.h" #include "source_estate/elecstate.h" -#include "source_pw/module_pwdft/VL_in_pw.h" +#include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/stress_func.h" #include "sto_wf.h" From e57560ccc163d816f2ebe1e86e540ba4145de7ef Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:49:38 +0800 Subject: [PATCH 18/21] fix Makefile.Objects --- source/Makefile.Objects | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 3f8c5bcea8..8f88d002ec 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -50,7 +50,6 @@ VPATH=./src_global:\ ./source_pw/module_pwdft:\ ./source_pw/module_ofdft:\ ./source_pw/module_stodft:\ - ./source_pw/module_pwdft/kernels:\ ./source_pw/module_pwdft/module_exx_helper:\ ./source_pw/module_stodft/kernels:\ @@ -168,8 +167,8 @@ OBJS_BASE=abfs-vector3_order.o\ ylm.o\ opt_CG.o\ opt_DCsrch.o\ - cubic_spline.o\ - spherical_bessel_transformer.o\ + cubic_spline.o\ + spherical_bessel_transformer.o\ mixing_data.o\ mixing.o\ plain_mixing.o\ @@ -418,18 +417,18 @@ OBJS_ORBITAL=ORB_atomic.o\ ORB_nonlocal_lm.o\ ORB_read.o\ parallel_orbitals.o\ - atomic_radials.o\ + atomic_radials.o\ hydrogen_radials.o\ pswfc_radials.o\ - beta_radials.o\ - sphbes_radials.o\ - numerical_radial.o\ - radial_collection.o\ - radial_set.o\ - real_gaunt_table.o\ - two_center_bundle.o\ - two_center_integrator.o\ - two_center_table.o\ + beta_radials.o\ + sphbes_radials.o\ + numerical_radial.o\ + radial_collection.o\ + radial_set.o\ + real_gaunt_table.o\ + two_center_bundle.o\ + two_center_integrator.o\ + two_center_table.o\ projgen.o\ OBJS_PSI=psi.o\ @@ -629,8 +628,8 @@ OBJS_LCAO=evolve_elec.o\ boundary_fix.o\ upsi.o\ FORCE_STRESS.o\ - FORCE_gamma.o\ - FORCE_k.o\ + FORCE_gamma.o\ + FORCE_k.o\ stress_tools.o\ edm.o\ pulay_fs_center2.o\ From 123478aa2f5433539d24001b5cb81c9dc9e53196 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Tue, 27 Jan 2026 13:56:51 +0800 Subject: [PATCH 19/21] Fix CI/CD error: Update operator_pw paths to new op_pw locations This commit fixes the CI/CD build error by updating references to the old operator_pw directory structure: 1. Updated source/source_hsolver/test/CMakeLists.txt: - Changed all 7 references from '../../source_pw/module_pwdft/operator_pw/operator_pw.cpp' to '../../source_pw/module_pwdft/op_pw.cpp' 2. Updated source/source_hsolver/test/diago_mock.h: - Changed '#include "source_pw/module_pwdft/operator_pw/operator_pw.h"' to '#include "source_pw/module_pwdft/op_pw.h"' The operator_pw directory has been renamed and its files moved to the module_pwdft root directory with op_pw_ prefixes, so these path updates are necessary to ensure CI/CD builds succeed. --- source/source_hsolver/test/CMakeLists.txt | 14 +++++++------- source/source_hsolver/test/diago_mock.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/source_hsolver/test/CMakeLists.txt b/source/source_hsolver/test/CMakeLists.txt index 217f8251b3..d074ddd8be 100644 --- a/source/source_hsolver/test/CMakeLists.txt +++ b/source/source_hsolver/test/CMakeLists.txt @@ -14,7 +14,7 @@ if (ENABLE_MPI) SOURCES diago_bpcg_test.cpp ../diago_bpcg.cpp ../para_linear_transform.cpp ../diago_iter_assist.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) AddTest( TARGET MODULE_HSOLVER_cg @@ -22,7 +22,7 @@ if (ENABLE_MPI) SOURCES diago_cg_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) AddTest( TARGET MODULE_HSOLVER_cg_float @@ -30,7 +30,7 @@ if (ENABLE_MPI) SOURCES diago_cg_float_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) AddTest( TARGET MODULE_HSOLVER_dav @@ -38,7 +38,7 @@ if (ENABLE_MPI) SOURCES diago_david_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) AddTest( TARGET MODULE_HSOLVER_dav_float @@ -46,7 +46,7 @@ if (ENABLE_MPI) SOURCES diago_david_float_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) if(ENABLE_LCAO) AddTest( @@ -55,7 +55,7 @@ if (ENABLE_MPI) SOURCES diago_cg_float_test.cpp ../diago_cg.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) AddTest( TARGET MODULE_HSOLVER_dav_real @@ -63,7 +63,7 @@ if (ENABLE_MPI) SOURCES diago_david_real_test.cpp ../diago_david.cpp ../diago_iter_assist.cpp ../diag_const_nums.cpp ../../source_basis/module_pw/test/test_tool.cpp ../../source_hamilt/operator.cpp - ../../source_pw/module_pwdft/operator_pw/operator_pw.cpp + ../../source_pw/module_pwdft/op_pw.cpp ) endif() diff --git a/source/source_hsolver/test/diago_mock.h b/source/source_hsolver/test/diago_mock.h index 16e1359cae..75cced8409 100644 --- a/source/source_hsolver/test/diago_mock.h +++ b/source/source_hsolver/test/diago_mock.h @@ -443,7 +443,7 @@ void hamilt::HamiltPW, base_device::DEVICE_CPU>::sPsi(const } //Mock function h_psi -#include "source_pw/module_pwdft/operator_pw/operator_pw.h" +#include "source_pw/module_pwdft/op_pw.h" template class OperatorMock : public hamilt::Operator { From 0ae466ecbcb02dafeb05c8580d4bc68eea854ac4 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Wed, 28 Jan 2026 10:22:02 +0800 Subject: [PATCH 20/21] fix --- .../module_ri/module_exx_symmetry/irreducible_sector.cpp | 4 ++-- .../module_ri/module_exx_symmetry/symmetry_rotation.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp index 8347624797..f93b8aa040 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.cpp @@ -64,7 +64,7 @@ namespace ModuleSymmetry // }; auto restrict_center = [&symm](const TCdouble& v) -> TCdouble { // in [0,1) - TCdouble vr = 0.0; + TCdouble vr; vr.x = fmod(v.x + 100 + symm.epsilon, 1) - symm.epsilon; vr.y = fmod(v.y + 100 + symm.epsilon, 1) - symm.epsilon; vr.z = fmod(v.z + 100 + symm.epsilon, 1) - symm.epsilon; @@ -235,4 +235,4 @@ namespace ModuleSymmetry // this->output_sector_star(); this->write_irreducible_sector(); } -} \ No newline at end of file +} diff --git a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp index aeb118155d..27929737f6 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp +++ b/source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation.cpp @@ -38,7 +38,7 @@ namespace ModuleSymmetry // 2. calculate the rotation matrix in AO-representation for each ibz_kpoint and symmetry operation: M(k, isym) auto restrict_kpt = [](const TCdouble& kvec, const double& symm_prec) -> TCdouble {// in (-0.5, 0.5] - TCdouble kvec_res = 0.0; + TCdouble kvec_res; kvec_res.x = fmod(kvec.x + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; kvec_res.y = fmod(kvec.y + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; kvec_res.z = fmod(kvec.z + 100.5 - 0.5 * symm_prec, 1) - 0.5 + 0.5 * symm_prec; From 216fb982b51099036171a4dca3cefe830e781cf9 Mon Sep 17 00:00:00 2001 From: abacus_fixer Date: Wed, 28 Jan 2026 13:47:10 +0800 Subject: [PATCH 21/21] fix relax_sync.cpp --- source/source_relax/relax_sync.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/source_relax/relax_sync.cpp b/source/source_relax/relax_sync.cpp index 06fd91dc83..492feaea49 100644 --- a/source/source_relax/relax_sync.cpp +++ b/source/source_relax/relax_sync.cpp @@ -594,8 +594,7 @@ void Relax::move_cell_ions(UnitCell& ucell, const bool is_new_dir) // ================================================================= // Calculating displacement in Cartesian coordinate (in Angstrom) - double move_ion[nat * 3] = {0.0}; - ModuleBase::zeros(move_ion, nat * 3); + std::vector move_ion(nat * 3, 0.0); for (int iat = 0; iat < nat; iat++) { @@ -630,10 +629,10 @@ void Relax::move_cell_ions(UnitCell& ucell, const bool is_new_dir) if (ModuleSymmetry::Symmetry::symm_flag && ucell.symm.all_mbl && ucell.symm.nrotk > 0) { - ucell.symm.symmetrize_vec3_nat(move_ion); + ucell.symm.symmetrize_vec3_nat(move_ion.data()); } - unitcell::update_pos_taud(ucell.lat,move_ion,ucell.ntype,ucell.nat,ucell.atoms); + unitcell::update_pos_taud(ucell.lat,move_ion.data(),ucell.ntype,ucell.nat,ucell.atoms); // Print the structure file. unitcell::print_tau(ucell.atoms,ucell.Coordinate,ucell.ntype,ucell.lat0,GlobalV::ofs_running);