From f029be2ba8aaa983575f062f07aa01a42f4a0591 Mon Sep 17 00:00:00 2001 From: Critsium Date: Tue, 21 Apr 2026 16:27:58 +0800 Subject: [PATCH 1/2] Move abfs-vector3_order from source_base to module_ri --- source/Makefile.Objects | 6 +++--- source/source_base/CMakeLists.txt | 1 - source/source_base/test/CMakeLists.txt | 6 ------ source/source_io/module_hs/cal_r_overlap_R.h | 2 +- source/source_io/module_restart/restart.h | 2 +- source/source_io/module_restart/restart_exx_csr.h | 2 +- source/source_io/module_wannier/to_wannier90_lcao.h | 4 ++-- source/source_io/module_wannier/to_wannier90_lcao_in_pw.h | 2 +- source/source_lcao/CMakeLists.txt | 1 + source/source_lcao/LCAO_HS_arrays.hpp | 2 +- source/source_lcao/module_gint/gint_dvlocal.h | 2 +- source/source_lcao/module_ri/LRI_CV.h | 2 +- source/source_lcao/module_ri/LRI_CV_Tools.h | 2 +- .../module_ri}/abfs-vector3_order.cpp | 0 .../module_ri}/abfs-vector3_order.h | 0 .../module_ri/module_exx_symmetry/irreducible_sector.h | 2 +- source/source_lcao/module_ri/serialization_boost.h | 2 +- source/source_lcao/module_ri/serialization_cereal.h | 2 +- source/source_lcao/module_ri/test/CMakeLists.txt | 5 +++++ .../module_ri}/test/abfs-vector3_order_test.cpp | 2 +- source/source_lcao/module_rt/td_folding.h | 2 +- source/source_lcao/module_rt/td_info.h | 2 +- source/source_lcao/spar_exx.cpp | 2 +- source/source_lcao/spar_u.h | 2 +- 24 files changed, 27 insertions(+), 28 deletions(-) rename source/{source_base => source_lcao/module_ri}/abfs-vector3_order.cpp (100%) rename source/{source_base => source_lcao/module_ri}/abfs-vector3_order.h (100%) rename source/{source_base => source_lcao/module_ri}/test/abfs-vector3_order_test.cpp (93%) diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 9ad0ebe5094..efbe709d336 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -123,8 +123,7 @@ OBJS_MAIN=main.o\ driver_run.o\ parameter.o -OBJS_BASE=abfs-vector3_order.o\ - assoc_laguerre.o\ +OBJS_BASE=assoc_laguerre.o\ blas_connector_base.o\ blas_connector_vector.o\ blas_connector_matrix.o\ @@ -613,7 +612,8 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\ module_mulliken/output_dmk.o\ module_ml/io_npz.o\ -OBJS_LCAO=evolve_elec.o\ +OBJS_LCAO=abfs-vector3_order.o\ + evolve_elec.o\ evolve_psi.o\ band_energy.o\ middle_hamilt.o\ diff --git a/source/source_base/CMakeLists.txt b/source/source_base/CMakeLists.txt index 717ef9bf441..142269fe0b5 100644 --- a/source/source_base/CMakeLists.txt +++ b/source/source_base/CMakeLists.txt @@ -49,7 +49,6 @@ add_library( tool_quit.cpp tool_title.cpp ylm.cpp - abfs-vector3_order.cpp parallel_common.cpp parallel_global.cpp parallel_comm.cpp diff --git a/source/source_base/test/CMakeLists.txt b/source/source_base/test/CMakeLists.txt index 3481cba7804..1042569d57b 100644 --- a/source/source_base/test/CMakeLists.txt +++ b/source/source_base/test/CMakeLists.txt @@ -160,12 +160,6 @@ AddTest( SOURCES ylm_test.cpp ../ylm.cpp ../timer.cpp ../tool_quit.cpp ../global_variable.cpp ../global_file.cpp ../global_function.cpp ../memory.cpp ) -AddTest( - TARGET MODULE_BASE_abfs-vector3_order - LIBS parameter - SOURCES abfs-vector3_order_test.cpp ../abfs-vector3_order.cpp -) - AddTest( TARGET MODULE_BASE_global_file LIBS parameter diff --git a/source/source_io/module_hs/cal_r_overlap_R.h b/source/source_io/module_hs/cal_r_overlap_R.h index 81d093bfe09..9ae15c92768 100644 --- a/source/source_io/module_hs/cal_r_overlap_R.h +++ b/source/source_io/module_hs/cal_r_overlap_R.h @@ -1,7 +1,7 @@ #ifndef CAL_R_OVERLAP_R_H #define CAL_R_OVERLAP_R_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/sph_bessel_recursive.h" #include "source_base/vector3.h" #include "source_base/ylm.h" diff --git a/source/source_io/module_restart/restart.h b/source/source_io/module_restart/restart.h index 8908c9d8022..06dd5431726 100644 --- a/source/source_io/module_restart/restart.h +++ b/source/source_io/module_restart/restart.h @@ -3,7 +3,7 @@ #include #include "source_base/global_function.h" -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #ifdef __EXX #include #endif diff --git a/source/source_io/module_restart/restart_exx_csr.h b/source/source_io/module_restart/restart_exx_csr.h index 2900e9237e0..2a40192e142 100644 --- a/source/source_io/module_restart/restart_exx_csr.h +++ b/source/source_io/module_restart/restart_exx_csr.h @@ -1,5 +1,5 @@ #pragma once -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_cell/unitcell.h" #include "source_lcao/module_ri/serialization_cereal.h" #include diff --git a/source/source_io/module_wannier/to_wannier90_lcao.h b/source/source_io/module_wannier/to_wannier90_lcao.h index b50555c4265..e25610a1d41 100644 --- a/source/source_io/module_wannier/to_wannier90_lcao.h +++ b/source/source_io/module_wannier/to_wannier90_lcao.h @@ -1,7 +1,7 @@ #ifndef TOWannier90_LCAO_H #define TOWannier90_LCAO_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/complexmatrix.h" #include "source_base/global_function.h" #include "source_base/global_variable.h" @@ -36,7 +36,7 @@ #ifdef __LCAO #include "fR_overlap.h" -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/math_lebedev_laikov.h" #include "source_lcao/module_hcontainer/hcontainer.h" diff --git a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h index 04a2414e9fe..fbbdcc80758 100644 --- a/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h +++ b/source/source_io/module_wannier/to_wannier90_lcao_in_pw.h @@ -1,7 +1,7 @@ #ifndef TO_WANNIER90_LCAO_IN_PW_H #define TO_WANNIER90_LCAO_IN_PW_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/complexmatrix.h" #include "source_base/global_function.h" #include "source_base/global_variable.h" diff --git a/source/source_lcao/CMakeLists.txt b/source/source_lcao/CMakeLists.txt index a793f5d5d02..58133ddc0ce 100644 --- a/source/source_lcao/CMakeLists.txt +++ b/source/source_lcao/CMakeLists.txt @@ -53,6 +53,7 @@ if(ENABLE_LCAO) center2_orb-orb21.cpp center2_orb-orb22.cpp wavefunc_in_pw.cpp + module_ri/abfs-vector3_order.cpp ) add_library( diff --git a/source/source_lcao/LCAO_HS_arrays.hpp b/source/source_lcao/LCAO_HS_arrays.hpp index 5a306918ea5..d4c9d0df103 100644 --- a/source/source_lcao/LCAO_HS_arrays.hpp +++ b/source/source_lcao/LCAO_HS_arrays.hpp @@ -1,7 +1,7 @@ #ifndef LCAO_HS_ARRAYS_H #define LCAO_HS_ARRAYS_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include #include diff --git a/source/source_lcao/module_gint/gint_dvlocal.h b/source/source_lcao/module_gint/gint_dvlocal.h index dc48b102922..606efbac36e 100644 --- a/source/source_lcao/module_gint/gint_dvlocal.h +++ b/source/source_lcao/module_gint/gint_dvlocal.h @@ -3,7 +3,7 @@ #include #include "source_lcao/module_hcontainer/hcontainer.h" #include "source_lcao/LCAO_HS_arrays.hpp" -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "gint.h" #include "gint_info.h" diff --git a/source/source_lcao/module_ri/LRI_CV.h b/source/source_lcao/module_ri/LRI_CV.h index aaf00e8656c..fc17e4d2707 100644 --- a/source/source_lcao/module_ri/LRI_CV.h +++ b/source/source_lcao/module_ri/LRI_CV.h @@ -9,7 +9,7 @@ #include "Matrix_Orbs11.h" #include "Matrix_Orbs21.h" #include "source_basis/module_ao/ORB_atomic_lm.h" -#include "source_base/abfs-vector3_order.h" +#include "abfs-vector3_order.h" #include "source_base/element_basis_index.h" #include diff --git a/source/source_lcao/module_ri/LRI_CV_Tools.h b/source/source_lcao/module_ri/LRI_CV_Tools.h index a87320a2eaf..b3f60706cdf 100644 --- a/source/source_lcao/module_ri/LRI_CV_Tools.h +++ b/source/source_lcao/module_ri/LRI_CV_Tools.h @@ -7,7 +7,7 @@ #define LRI_CV_TOOLS_H #include "Inverse_Matrix.h" -#include "source_base/abfs-vector3_order.h" +#include "abfs-vector3_order.h" #include "source_lcao/module_ri/abfs.h" #include diff --git a/source/source_base/abfs-vector3_order.cpp b/source/source_lcao/module_ri/abfs-vector3_order.cpp similarity index 100% rename from source/source_base/abfs-vector3_order.cpp rename to source/source_lcao/module_ri/abfs-vector3_order.cpp diff --git a/source/source_base/abfs-vector3_order.h b/source/source_lcao/module_ri/abfs-vector3_order.h similarity index 100% rename from source/source_base/abfs-vector3_order.h rename to source/source_lcao/module_ri/abfs-vector3_order.h diff --git a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.h b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.h index 9252273bd5c..e2ff540d734 100644 --- a/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.h +++ b/source/source_lcao/module_ri/module_exx_symmetry/irreducible_sector.h @@ -2,7 +2,7 @@ #include #include #include -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/matrix3.h" #include "source_cell/unitcell.h" #include "source_cell/module_symmetry/symmetry.h" diff --git a/source/source_lcao/module_ri/serialization_boost.h b/source/source_lcao/module_ri/serialization_boost.h index baaa68a4236..6c08d6d5c07 100644 --- a/source/source_lcao/module_ri/serialization_boost.h +++ b/source/source_lcao/module_ri/serialization_boost.h @@ -12,7 +12,7 @@ #include #include "../../source_base/vector3.h" -#include "../../source_base/abfs-vector3_order.h" +#include "abfs-vector3_order.h" #include "../../source_base/matrix.h" #include "../../source_base/matrix_wrapper.h" diff --git a/source/source_lcao/module_ri/serialization_cereal.h b/source/source_lcao/module_ri/serialization_cereal.h index cc7101a88de..c6d1dcc614e 100644 --- a/source/source_lcao/module_ri/serialization_cereal.h +++ b/source/source_lcao/module_ri/serialization_cereal.h @@ -10,7 +10,7 @@ #include #include "../../source_base/vector3.h" -#include "../../source_base/abfs-vector3_order.h" +#include "abfs-vector3_order.h" #include "../../source_base/matrix.h" diff --git a/source/source_lcao/module_ri/test/CMakeLists.txt b/source/source_lcao/module_ri/test/CMakeLists.txt index 5ea386e2cc9..305f3b4d918 100644 --- a/source/source_lcao/module_ri/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/test/CMakeLists.txt @@ -11,4 +11,9 @@ AddTest( LIBS base ${math_libs} device parameter SOURCES ri_cv_io_test.cpp ) +AddTest( + TARGET MODULE_RI_abfs-vector3_order + LIBS parameter + SOURCES abfs-vector3_order_test.cpp ../abfs-vector3_order.cpp +) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file diff --git a/source/source_base/test/abfs-vector3_order_test.cpp b/source/source_lcao/module_ri/test/abfs-vector3_order_test.cpp similarity index 93% rename from source/source_base/test/abfs-vector3_order_test.cpp rename to source/source_lcao/module_ri/test/abfs-vector3_order_test.cpp index a73041921ef..a641d2a3ad1 100644 --- a/source/source_base/test/abfs-vector3_order_test.cpp +++ b/source/source_lcao/module_ri/test/abfs-vector3_order_test.cpp @@ -1,4 +1,4 @@ -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/vector3.h" #include "gtest/gtest.h" #include "source_lcao/module_ri/abfs.h" diff --git a/source/source_lcao/module_rt/td_folding.h b/source/source_lcao/module_rt/td_folding.h index dae13e21af5..a086c56f9a8 100644 --- a/source/source_lcao/module_rt/td_folding.h +++ b/source/source_lcao/module_rt/td_folding.h @@ -1,7 +1,7 @@ #ifndef TD_FOLDING_H #define TD_FOLDING_H #include "source_lcao/module_hcontainer/hcontainer.h" -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" namespace module_rt{ // folding HR to hk, for hybrid gauge diff --git a/source/source_lcao/module_rt/td_info.h b/source/source_lcao/module_rt/td_info.h index 78f0b1cc003..92f91ae638b 100644 --- a/source/source_lcao/module_rt/td_info.h +++ b/source/source_lcao/module_rt/td_info.h @@ -1,6 +1,6 @@ #ifndef TD_INFO_H #define TD_INFO_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/timer.h" #include "source_lcao/module_hcontainer/hcontainer.h" #include "source_io/module_hs/cal_r_overlap_R.h" diff --git a/source/source_lcao/spar_exx.cpp b/source/source_lcao/spar_exx.cpp index 4c45c3b1ac1..65efc194814 100644 --- a/source/source_lcao/spar_exx.cpp +++ b/source/source_lcao/spar_exx.cpp @@ -10,7 +10,7 @@ #include #include -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_base/global_variable.h" #include "source_base/timer.h" #include "source_hamilt/module_xc/exx_info.h" diff --git a/source/source_lcao/spar_u.h b/source/source_lcao/spar_u.h index 4940a3c5ff3..8e070334961 100644 --- a/source/source_lcao/spar_u.h +++ b/source/source_lcao/spar_u.h @@ -1,7 +1,7 @@ #ifndef SPARSE_FORMAT_U_H #define SPARSE_FORMAT_U_H -#include "source_base/abfs-vector3_order.h" +#include "source_lcao/module_ri/abfs-vector3_order.h" #include "source_cell/module_neighbor/sltk_atom_arrange.h" #include "source_cell/module_neighbor/sltk_grid_driver.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 20251107 From ae9109ee8a6a0c6b435fe4956967aaaa9471eb07 Mon Sep 17 00:00:00 2001 From: Critsium Date: Tue, 21 Apr 2026 17:01:08 +0800 Subject: [PATCH 2/2] Fix link problem --- source/Makefile.Objects | 3 +- source/source_lcao/CMakeLists.txt | 1 - .../module_ri/abfs-vector3_order.cpp | 36 ------------------- .../module_ri/abfs-vector3_order.h | 27 ++++++++++++++ .../source_lcao/module_ri/test/CMakeLists.txt | 2 +- 5 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 source/source_lcao/module_ri/abfs-vector3_order.cpp diff --git a/source/Makefile.Objects b/source/Makefile.Objects index efbe709d336..803cd04018f 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -612,8 +612,7 @@ OBJS_IO_LCAO=cal_r_overlap_R.o\ module_mulliken/output_dmk.o\ module_ml/io_npz.o\ -OBJS_LCAO=abfs-vector3_order.o\ - evolve_elec.o\ +OBJS_LCAO=evolve_elec.o\ evolve_psi.o\ band_energy.o\ middle_hamilt.o\ diff --git a/source/source_lcao/CMakeLists.txt b/source/source_lcao/CMakeLists.txt index 58133ddc0ce..a793f5d5d02 100644 --- a/source/source_lcao/CMakeLists.txt +++ b/source/source_lcao/CMakeLists.txt @@ -53,7 +53,6 @@ if(ENABLE_LCAO) center2_orb-orb21.cpp center2_orb-orb22.cpp wavefunc_in_pw.cpp - module_ri/abfs-vector3_order.cpp ) add_library( diff --git a/source/source_lcao/module_ri/abfs-vector3_order.cpp b/source/source_lcao/module_ri/abfs-vector3_order.cpp deleted file mode 100644 index f2307a46185..00000000000 --- a/source/source_lcao/module_ri/abfs-vector3_order.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "abfs-vector3_order.h" - -template<> -bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) -{ - // threshold is used when v1 and v2 are approximately equal with double numerical error, - // but a strange bug occurs at LRI_CV::dVws. - // Peize Lin change at 2023.04.29 - if ( v1.x < v2.x ) return true; - else if ( v1.x > v2.x ) return false; - if ( v1.y < v2.y ) return true; - else if ( v1.y > v2.y ) return false; - if ( v1.z < v2.z ) return true; - else if ( v1.z > v2.z ) return false; - return false; - //constexpr double threshold = 1E-8; - //if ( v1.x < v2.x - threshold ) return true; - //else if ( v1.x > v2.x + threshold ) return false; - //if ( v1.y < v2.y - threshold ) return true; - //else if ( v1.y > v2.y + threshold ) return false; - //if ( v1.z < v2.z - threshold ) return true; - //else if ( v1.z > v2.z + threshold ) return false; - //return false; -} - -template<> -bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) -{ - if ( v1.x < v2.x ) return true; - else if ( v1.x > v2.x ) return false; - if ( v1.y < v2.y ) return true; - else if ( v1.y > v2.y ) return false; - if ( v1.z < v2.z ) return true; - else if ( v1.z > v2.z ) return false; - return false; -} \ No newline at end of file diff --git a/source/source_lcao/module_ri/abfs-vector3_order.h b/source/source_lcao/module_ri/abfs-vector3_order.h index 3f675e4b57f..4857770ea0f 100644 --- a/source/source_lcao/module_ri/abfs-vector3_order.h +++ b/source/source_lcao/module_ri/abfs-vector3_order.h @@ -23,6 +23,33 @@ template class Abfs::Vector3_Order: public ModuleBase::Vector3 template bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ); +template<> +inline bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + // threshold is used when v1 and v2 are approximately equal with double numerical error, + // but a strange bug occurs at LRI_CV::dVws. + // Peize Lin change at 2023.04.29 + if ( v1.x < v2.x ) return true; + else if ( v1.x > v2.x ) return false; + if ( v1.y < v2.y ) return true; + else if ( v1.y > v2.y ) return false; + if ( v1.z < v2.z ) return true; + else if ( v1.z > v2.z ) return false; + return false; +} + +template<> +inline bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + if ( v1.x < v2.x ) return true; + else if ( v1.x > v2.x ) return false; + if ( v1.y < v2.y ) return true; + else if ( v1.y > v2.y ) return false; + if ( v1.z < v2.z ) return true; + else if ( v1.z > v2.z ) return false; + return false; +} + /* template bool operator> ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) diff --git a/source/source_lcao/module_ri/test/CMakeLists.txt b/source/source_lcao/module_ri/test/CMakeLists.txt index 305f3b4d918..b1a0f3f90e6 100644 --- a/source/source_lcao/module_ri/test/CMakeLists.txt +++ b/source/source_lcao/module_ri/test/CMakeLists.txt @@ -14,6 +14,6 @@ AddTest( AddTest( TARGET MODULE_RI_abfs-vector3_order LIBS parameter - SOURCES abfs-vector3_order_test.cpp ../abfs-vector3_order.cpp + SOURCES abfs-vector3_order_test.cpp ) install(DIRECTORY support DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) \ No newline at end of file