From 6f7e1bab1e2aa6122b57795b9877b150e83b70cb Mon Sep 17 00:00:00 2001 From: dyzheng Date: Tue, 27 Jan 2026 22:57:46 +0800 Subject: [PATCH 1/3] Refactor: rename to delete new from names of operators in source_lcao --- docs/advanced/output_files/running_scf.log.md | 18 ++--- .../AFM/reference/running_scf.log.ref | 18 ++--- .../AFM/reference/scf.output.ref | 18 ++--- .../ATOM/reference/running_scf.log.ref | 18 ++--- .../ATOM/reference/scf.output.ref | 18 ++--- .../FM/reference/running_scf.log.ref | 18 ++--- .../FM/reference/scf.output.ref | 18 ++--- .../reference/scf.output.ref | 18 ++--- source/Makefile.Objects | 6 +- source/source_io/ctrl_scf_lcao.cpp | 4 +- source/source_io/write_eband_terms.hpp | 8 +- source/source_lcao/CMakeLists.txt | 6 +- source/source_lcao/FORCE_STRESS.cpp | 18 ++--- source/source_lcao/hamilt_lcao.cpp | 20 ++--- .../module_operator_lcao/CMakeLists.txt | 6 +- .../{ekinetic_new.cpp => ekinetic.cpp} | 42 +++++----- .../{ekinetic_new.h => ekinetic.h} | 24 +++--- .../ekinetic_force_stress.hpp | 14 ++-- .../{nonlocal_new.cpp => nonlocal.cpp} | 40 +++++----- .../{nonlocal_new.h => nonlocal.h} | 12 +-- .../nonlocal_force_stress.hpp | 78 +++++-------------- .../operator_force_stress_utils.hpp | 2 +- .../{overlap_new.cpp => overlap.cpp} | 48 ++++++------ .../{overlap_new.h => overlap.h} | 18 ++--- .../overlap_force_stress.hpp | 14 ++-- .../module_operator_lcao/td_pot_hybrid.h | 14 ++-- .../module_operator_lcao/test/CMakeLists.txt | 18 ++--- .../test/test_T_NL_cd.cpp | 14 ++-- ...test_ekineticnew.cpp => test_ekinetic.cpp} | 20 ++--- ...ew_serial.cpp => test_ekinetic_serial.cpp} | 66 ++++++++-------- ...test_nonlocalnew.cpp => test_nonlocal.cpp} | 20 ++--- .../{test_overlapnew.cpp => test_overlap.cpp} | 20 ++--- ..._overlapnew_cd.cpp => test_overlap_cd.cpp} | 14 ++-- ...new_serial.cpp => test_overlap_serial.cpp} | 70 ++++++++--------- source/source_lcao/module_rdmft/rdmft_pot.cpp | 8 +- 35 files changed, 362 insertions(+), 406 deletions(-) rename source/source_lcao/module_operator_lcao/{ekinetic_new.cpp => ekinetic.cpp} (85%) rename source/source_lcao/module_operator_lcao/{ekinetic_new.h => ekinetic.h} (89%) rename source/source_lcao/module_operator_lcao/{nonlocal_new.cpp => nonlocal.cpp} (89%) rename source/source_lcao/module_operator_lcao/{nonlocal_new.h => nonlocal.h} (93%) rename source/source_lcao/module_operator_lcao/{overlap_new.cpp => overlap.cpp} (85%) rename source/source_lcao/module_operator_lcao/{overlap_new.h => overlap.h} (91%) rename source/source_lcao/module_operator_lcao/test/{test_ekineticnew.cpp => test_ekinetic.cpp} (92%) rename source/source_lcao/module_operator_lcao/test/{test_ekineticnew_serial.cpp => test_ekinetic_serial.cpp} (93%) rename source/source_lcao/module_operator_lcao/test/{test_nonlocalnew.cpp => test_nonlocal.cpp} (94%) rename source/source_lcao/module_operator_lcao/test/{test_overlapnew.cpp => test_overlap.cpp} (91%) rename source/source_lcao/module_operator_lcao/test/{test_overlapnew_cd.cpp => test_overlap_cd.cpp} (93%) rename source/source_lcao/module_operator_lcao/test/{test_overlapnew_serial.cpp => test_overlap_serial.cpp} (92%) diff --git a/docs/advanced/output_files/running_scf.log.md b/docs/advanced/output_files/running_scf.log.md index 64c2ed401f..07d16a4f54 100644 --- a/docs/advanced/output_files/running_scf.log.md +++ b/docs/advanced/output_files/running_scf.log.md @@ -1249,9 +1249,9 @@ TIME STATISTICS Grid_Driver Find_atom 0.03 792 0.00 0.01 LCAO_domain grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 - OverlapNew initialize_SR 0.00 1 0.00 0.00 - EkineticNew initialize_HR 0.00 1 0.00 0.00 - NonlocalNew initialize_HR 0.00 1 0.00 0.00 + Overlap initialize_SR 0.00 1 0.00 0.00 + Ekinetic initialize_HR 0.00 1 0.00 0.00 + Nonlocal initialize_HR 0.00 1 0.00 0.00 Charge set_rho_core 0.14 1 0.14 0.03 PW_Basis_Sup recip2real 3.44 122 0.03 0.69 PW_Basis_Sup gathers_scatterp 1.72 122 0.01 0.34 @@ -1279,12 +1279,12 @@ TIME STATISTICS Gint_interface cal_gint_vlocal 114.33 17 6.73 22.83 Gint_Tools cal_psir_ylm 82.79 272000 0.00 16.53 Gint_k transfer_pvpR 3.98 17 0.23 0.79 - OverlapNew calculate_SR 0.67 1 0.67 0.13 - OverlapNew contributeHk 0.06 17 0.00 0.01 - EkineticNew contributeHR 0.67 17 0.04 0.13 - EkineticNew calculate_HR 0.67 1 0.67 0.13 - NonlocalNew contributeHR 0.49 17 0.03 0.10 - NonlocalNew calculate_HR 0.45 1 0.45 0.09 + Overlap calculate_SR 0.67 1 0.67 0.13 + Overlap contributeHk 0.06 17 0.00 0.01 + Ekinetic contributeHR 0.67 17 0.04 0.13 + Ekinetic calculate_HR 0.67 1 0.67 0.13 + Nonlocal contributeHR 0.49 17 0.03 0.10 + Nonlocal calculate_HR 0.45 1 0.45 0.09 OperatorLCAO contributeHk 0.09 17 0.01 0.02 HSolverLCAO hamiltSolvePsiK 90.50 17 5.32 18.07 ElecStateLCAO psiToRho 132.45 17 7.79 26.45 diff --git a/examples/03_spin_polarized/AFM/reference/running_scf.log.ref b/examples/03_spin_polarized/AFM/reference/running_scf.log.ref index 03045b0f05..0125faebfc 100644 --- a/examples/03_spin_polarized/AFM/reference/running_scf.log.ref +++ b/examples/03_spin_polarized/AFM/reference/running_scf.log.ref @@ -4811,9 +4811,9 @@ Record_adj for_2d 0.00 1 0.00 0. Grid_Driver Find_atom 0.00 112 0.00 0.01 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.00 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.00 Charge set_rho_core 0.00 1 0.00 0.00 Charge atomic_rho 0.00 1 0.00 0.01 PW_Basis_Sup recip2real 0.03 219 0.00 0.07 @@ -4838,12 +4838,12 @@ Gint_interface cal_gint 27.76 69 0.40 70. Gint_interface cal_gint_vlocal 15.79 46 0.34 40.29 Gint_Tools cal_psir_ylm 2.18 9936 0.00 5.56 Gint_k transfer_pvpR 0.75 46 0.02 1.92 -OverlapNew calculate_SR 0.09 1 0.09 0.24 -OverlapNew contributeHk 0.86 2898 0.00 2.21 -EkineticNew contributeHR 0.09 46 0.00 0.24 -EkineticNew calculate_HR 0.09 1 0.09 0.24 -NonlocalNew contributeHR 0.08 46 0.00 0.20 -NonlocalNew calculate_HR 0.07 1 0.07 0.18 +Overlap calculate_SR 0.09 1 0.09 0.24 +Overlap contributeHk 0.86 2898 0.00 2.21 +Ekinetic contributeHR 0.09 46 0.00 0.24 +Ekinetic calculate_HR 0.09 1 0.09 0.24 +Nonlocal contributeHR 0.08 46 0.00 0.20 +Nonlocal calculate_HR 0.07 1 0.07 0.18 OperatorLCAO contributeHk 0.98 2898 0.00 2.49 HSolverLCAO hamiltSolvePsiK 6.35 2898 0.00 16.19 DiagoElpa elpa_solve 5.46 2898 0.00 13.93 diff --git a/examples/03_spin_polarized/AFM/reference/scf.output.ref b/examples/03_spin_polarized/AFM/reference/scf.output.ref index 5a76fc513f..d34ff54d90 100644 --- a/examples/03_spin_polarized/AFM/reference/scf.output.ref +++ b/examples/03_spin_polarized/AFM/reference/scf.output.ref @@ -101,9 +101,9 @@ Record_adj for_2d 0.00 1 0.00 0. Grid_Driver Find_atom 0.00 112 0.00 0.01 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.00 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.00 Charge set_rho_core 0.00 1 0.00 0.00 Charge atomic_rho 0.00 1 0.00 0.01 PW_Basis_Sup recip2real 0.03 219 0.00 0.07 @@ -128,12 +128,12 @@ Gint_interface cal_gint 27.76 69 0.40 70. Gint_interface cal_gint_vlocal 15.79 46 0.34 40.29 Gint_Tools cal_psir_ylm 2.18 9936 0.00 5.56 Gint_k transfer_pvpR 0.75 46 0.02 1.92 -OverlapNew calculate_SR 0.09 1 0.09 0.24 -OverlapNew contributeHk 0.86 2898 0.00 2.21 -EkineticNew contributeHR 0.09 46 0.00 0.24 -EkineticNew calculate_HR 0.09 1 0.09 0.24 -NonlocalNew contributeHR 0.08 46 0.00 0.20 -NonlocalNew calculate_HR 0.07 1 0.07 0.18 +Overlap calculate_SR 0.09 1 0.09 0.24 +Overlap contributeHk 0.86 2898 0.00 2.21 +Ekinetic contributeHR 0.09 46 0.00 0.24 +Ekinetic calculate_HR 0.09 1 0.09 0.24 +Nonlocal contributeHR 0.08 46 0.00 0.20 +Nonlocal calculate_HR 0.07 1 0.07 0.18 OperatorLCAO contributeHk 0.98 2898 0.00 2.49 HSolverLCAO hamiltSolvePsiK 6.35 2898 0.00 16.19 DiagoElpa elpa_solve 5.46 2898 0.00 13.93 diff --git a/examples/03_spin_polarized/ATOM/reference/running_scf.log.ref b/examples/03_spin_polarized/ATOM/reference/running_scf.log.ref index 74008dd00f..68f568f337 100644 --- a/examples/03_spin_polarized/ATOM/reference/running_scf.log.ref +++ b/examples/03_spin_polarized/ATOM/reference/running_scf.log.ref @@ -597,9 +597,9 @@ Grid_BigCell grid_expansion_index 0.01 2 0.01 0. Record_adj for_2d 0.00 1 0.00 0.00 Grid_Driver Find_atom 0.00 7 0.00 0.00 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.00 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 LOC Alltoall 0.00 1 0.00 0.00 Charge set_rho_core 0.01 1 0.01 0.03 @@ -621,12 +621,12 @@ H_Ewald_pw compute_ewald 0.05 1 0.05 0. HSolverLCAO solve 0.46 7 0.07 2.81 HamiltLCAO updateHk 0.11 14 0.01 0.68 OperatorLCAO init 0.11 42 0.00 0.68 -OverlapNew calculate_SR 0.00 1 0.00 0.00 -OverlapNew contributeHk 0.00 1 0.00 0.00 -EkineticNew contributeHR 0.00 14 0.00 0.00 -EkineticNew calculate_HR 0.00 1 0.00 0.00 -NonlocalNew contributeHR 0.00 14 0.00 0.00 -NonlocalNew calculate_HR 0.00 1 0.00 0.00 +Overlap calculate_SR 0.00 1 0.00 0.00 +Overlap contributeHk 0.00 1 0.00 0.00 +Ekinetic contributeHR 0.00 14 0.00 0.00 +Ekinetic calculate_HR 0.00 1 0.00 0.00 +Nonlocal contributeHR 0.00 14 0.00 0.00 +Nonlocal calculate_HR 0.00 1 0.00 0.00 Veff contributeHR 0.06 7 0.01 0.39 Gint_interface cal_gint 0.27 23 0.01 1.62 Gint_interface cal_gint_vlocal 0.11 14 0.01 0.66 diff --git a/examples/03_spin_polarized/ATOM/reference/scf.output.ref b/examples/03_spin_polarized/ATOM/reference/scf.output.ref index ba20a7423f..41fe4824a0 100644 --- a/examples/03_spin_polarized/ATOM/reference/scf.output.ref +++ b/examples/03_spin_polarized/ATOM/reference/scf.output.ref @@ -84,9 +84,9 @@ Grid_BigCell grid_expansion_index 0.01 2 0.01 0. Record_adj for_2d 0.00 1 0.00 0.00 Grid_Driver Find_atom 0.00 7 0.00 0.00 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.00 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 LOC Alltoall 0.00 1 0.00 0.00 Charge set_rho_core 0.01 1 0.01 0.03 @@ -108,12 +108,12 @@ H_Ewald_pw compute_ewald 0.05 1 0.05 0. HSolverLCAO solve 0.46 7 0.07 2.81 HamiltLCAO updateHk 0.11 14 0.01 0.68 OperatorLCAO init 0.11 42 0.00 0.68 -OverlapNew calculate_SR 0.00 1 0.00 0.00 -OverlapNew contributeHk 0.00 1 0.00 0.00 -EkineticNew contributeHR 0.00 14 0.00 0.00 -EkineticNew calculate_HR 0.00 1 0.00 0.00 -NonlocalNew contributeHR 0.00 14 0.00 0.00 -NonlocalNew calculate_HR 0.00 1 0.00 0.00 +Overlap calculate_SR 0.00 1 0.00 0.00 +Overlap contributeHk 0.00 1 0.00 0.00 +Ekinetic contributeHR 0.00 14 0.00 0.00 +Ekinetic calculate_HR 0.00 1 0.00 0.00 +Nonlocal contributeHR 0.00 14 0.00 0.00 +Nonlocal calculate_HR 0.00 1 0.00 0.00 Veff contributeHR 0.06 7 0.01 0.39 Gint_interface cal_gint 0.27 23 0.01 1.62 Gint_interface cal_gint_vlocal 0.11 14 0.01 0.66 diff --git a/examples/03_spin_polarized/FM/reference/running_scf.log.ref b/examples/03_spin_polarized/FM/reference/running_scf.log.ref index e72057936e..a2b17a38ac 100644 --- a/examples/03_spin_polarized/FM/reference/running_scf.log.ref +++ b/examples/03_spin_polarized/FM/reference/running_scf.log.ref @@ -5305,9 +5305,9 @@ Record_adj for_2d 0.00 1 0.00 0. Grid_Driver Find_atom 0.00 76 0.00 0.01 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.01 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.01 Charge set_rho_core 0.00 1 0.00 0.00 Charge atomic_rho 0.00 1 0.00 0.01 PW_Basis_Sup recip2real 0.02 138 0.00 0.07 @@ -5332,12 +5332,12 @@ Gint_interface cal_gint 16.57 42 0.39 68. Gint_interface cal_gint_vlocal 9.47 28 0.34 39.40 Gint_Tools cal_psir_ylm 1.26 6048 0.00 5.23 Gint_k transfer_pvpR 0.56 28 0.02 2.32 -OverlapNew calculate_SR 0.09 1 0.09 0.39 -OverlapNew contributeHk 0.52 1764 0.00 2.18 -EkineticNew contributeHR 0.09 28 0.00 0.40 -EkineticNew calculate_HR 0.09 1 0.09 0.39 -NonlocalNew contributeHR 0.08 28 0.00 0.31 -NonlocalNew calculate_HR 0.07 1 0.07 0.29 +Overlap calculate_SR 0.09 1 0.09 0.39 +Overlap contributeHk 0.52 1764 0.00 2.18 +Ekinetic contributeHR 0.09 28 0.00 0.40 +Ekinetic calculate_HR 0.09 1 0.09 0.39 +Nonlocal contributeHR 0.08 28 0.00 0.31 +Nonlocal calculate_HR 0.07 1 0.07 0.29 OperatorLCAO contributeHk 0.59 1764 0.00 2.46 HSolverLCAO hamiltSolvePsiK 3.90 1764 0.00 16.25 DiagoElpa elpa_solve 3.33 1764 0.00 13.86 diff --git a/examples/03_spin_polarized/FM/reference/scf.output.ref b/examples/03_spin_polarized/FM/reference/scf.output.ref index f2b2d9578e..77aa7a6488 100644 --- a/examples/03_spin_polarized/FM/reference/scf.output.ref +++ b/examples/03_spin_polarized/FM/reference/scf.output.ref @@ -92,9 +92,9 @@ Record_adj for_2d 0.00 1 0.00 0. Grid_Driver Find_atom 0.00 76 0.00 0.01 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.01 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.01 Charge set_rho_core 0.00 1 0.00 0.00 Charge atomic_rho 0.00 1 0.00 0.01 PW_Basis_Sup recip2real 0.02 138 0.00 0.07 @@ -119,12 +119,12 @@ Gint_interface cal_gint 16.57 42 0.39 68. Gint_interface cal_gint_vlocal 9.47 28 0.34 39.40 Gint_Tools cal_psir_ylm 1.26 6048 0.00 5.23 Gint_k transfer_pvpR 0.56 28 0.02 2.32 -OverlapNew calculate_SR 0.09 1 0.09 0.39 -OverlapNew contributeHk 0.52 1764 0.00 2.18 -EkineticNew contributeHR 0.09 28 0.00 0.40 -EkineticNew calculate_HR 0.09 1 0.09 0.39 -NonlocalNew contributeHR 0.08 28 0.00 0.31 -NonlocalNew calculate_HR 0.07 1 0.07 0.29 +Overlap calculate_SR 0.09 1 0.09 0.39 +Overlap contributeHk 0.52 1764 0.00 2.18 +Ekinetic contributeHR 0.09 28 0.00 0.40 +Ekinetic calculate_HR 0.09 1 0.09 0.39 +Nonlocal contributeHR 0.08 28 0.00 0.31 +Nonlocal calculate_HR 0.07 1 0.07 0.29 OperatorLCAO contributeHk 0.59 1764 0.00 2.46 HSolverLCAO hamiltSolvePsiK 3.90 1764 0.00 16.25 DiagoElpa elpa_solve 3.33 1764 0.00 13.86 diff --git a/examples/04_noncollinear/BCC_Fe_NC_ground_state/reference/scf.output.ref b/examples/04_noncollinear/BCC_Fe_NC_ground_state/reference/scf.output.ref index f9f0970f67..7882dc68ff 100644 --- a/examples/04_noncollinear/BCC_Fe_NC_ground_state/reference/scf.output.ref +++ b/examples/04_noncollinear/BCC_Fe_NC_ground_state/reference/scf.output.ref @@ -102,9 +102,9 @@ Record_adj for_2d 0.00 1 0.00 0. Grid_Driver Find_atom 0.00 68 0.00 0.00 LCAO_Hamilt grid_prepare 0.00 1 0.00 0.00 Veff initialize_HR 0.00 1 0.00 0.00 -OverlapNew initialize_SR 0.00 1 0.00 0.00 -EkineticNew initialize_HR 0.00 1 0.00 0.00 -NonlocalNew initialize_HR 0.00 1 0.00 0.00 +Overlap initialize_SR 0.00 1 0.00 0.00 +Ekinetic initialize_HR 0.00 1 0.00 0.00 +Nonlocal initialize_HR 0.00 1 0.00 0.00 Charge set_rho_core 0.01 1 0.01 0.00 PW_Basis recip2real 0.04 306 0.00 0.03 PW_Basis gathers_scatterp 0.01 306 0.00 0.01 @@ -129,12 +129,12 @@ Gint_interface cal_gint 103.55 120 0.86 90. Gint_interface cal_gint_vlocal 58.66 96 0.61 51.50 Gint_Tools cal_psir_ylm 5.41 17280 0.00 4.75 Gint_k transfer_pvpR 4.83 24 0.20 4.24 -OverlapNew calculate_SR 0.13 1 0.13 0.11 -OverlapNew contributeHk 0.12 192 0.00 0.11 -EkineticNew contributeHR 0.13 24 0.01 0.11 -EkineticNew calculate_HR 0.13 1 0.13 0.11 -NonlocalNew contributeHR 0.79 24 0.03 0.70 -NonlocalNew calculate_HR 0.77 1 0.77 0.68 +Overlap calculate_SR 0.13 1 0.13 0.11 +Overlap contributeHk 0.12 192 0.00 0.11 +Ekinetic contributeHR 0.13 24 0.01 0.11 +Ekinetic calculate_HR 0.13 1 0.13 0.11 +Nonlocal contributeHR 0.79 24 0.03 0.70 +Nonlocal calculate_HR 0.77 1 0.77 0.68 OperatorLCAO contributeHk 0.10 192 0.00 0.09 HSolverLCAO hamiltSolvePsiK 1.08 192 0.01 0.95 DiagoElpa elpa_solve 0.90 192 0.00 0.79 diff --git a/source/Makefile.Objects b/source/Makefile.Objects index 11d4b65a2f..778c8b556c 100644 --- a/source/Makefile.Objects +++ b/source/Makefile.Objects @@ -339,9 +339,9 @@ OBJS_HAMILT_OF=kedf_tf.o\ OBJS_HAMILT_LCAO=hamilt_lcao.o\ operator_lcao.o\ - ekinetic_new.o\ - nonlocal_new.o\ - overlap_new.o\ + ekinetic.o\ + nonlocal.o\ + overlap.o\ td_ekinetic_lcao.o\ td_nonlocal_lcao.o\ td_pot_hybrid.o\ diff --git a/source/source_io/ctrl_scf_lcao.cpp b/source/source_io/ctrl_scf_lcao.cpp index e2e5588289..7c60dbb44c 100644 --- a/source/source_io/ctrl_scf_lcao.cpp +++ b/source/source_io/ctrl_scf_lcao.cpp @@ -19,7 +19,7 @@ #include "source_io/write_dos_lcao.h" // use ModuleIO::write_dos_lcao() #include "source_io/write_wfc_nao.h" // use ModuleIO::write_wfc_nao() #include "source_lcao/module_deltaspin/spin_constrain.h" // use spinconstrain::SpinConstrain -#include "source_lcao/module_operator_lcao/ekinetic_new.h" // use hamilt::EkineticNew +#include "source_lcao/module_operator_lcao/ekinetic.h" // use hamilt::EKinetic #ifdef __MLALGO #include "source_lcao/module_deepks/LCAO_deepks.h" #include "source_lcao/module_deepks/LCAO_deepks_interface.h" @@ -240,7 +240,7 @@ void ModuleIO::ctrl_scf_lcao(UnitCell& ucell, hamilt::HS_Matrix_K hsk(&pv, true); hamilt::HContainer hR(&pv); hamilt::Operator* ekinetic - = new hamilt::EkineticNew>(&hsk, + = new hamilt::EKinetic>(&hsk, kv.kvec_d, &hR, &ucell, diff --git a/source/source_io/write_eband_terms.hpp b/source/source_io/write_eband_terms.hpp index 701b097b25..16e5988144 100644 --- a/source/source_io/write_eband_terms.hpp +++ b/source/source_io/write_eband_terms.hpp @@ -2,8 +2,8 @@ #define WRITE_EBAND_TERMS_HPP #include "source_io/write_vxc.hpp" -#include "source_lcao/module_operator_lcao/ekinetic_new.h" -#include "source_lcao/module_operator_lcao/nonlocal_new.h" +#include "source_lcao/module_operator_lcao/ekinetic.h" +#include "source_lcao/module_operator_lcao/nonlocal.h" #include "source_basis/module_nao/two_center_bundle.h" namespace ModuleIO @@ -75,7 +75,7 @@ void write_eband_terms(const int nspin, hamilt::HContainer kinetic_R_ao(pv); if_gamma_fix(kinetic_R_ao); - hamilt::EkineticNew> kinetic_op(&kinetic_k_ao, kv.kvec_d, + hamilt::EKinetic> kinetic_op(&kinetic_k_ao, kv.kvec_d, &kinetic_R_ao, &ucell, orb_cutoff, &gd, two_center_bundle.kinetic_orb.get()); kinetic_op.contributeHR(); @@ -132,7 +132,7 @@ void write_eband_terms(const int nspin, hamilt::HContainer v_pp_nonlocal_R_ao(pv); if_gamma_fix(v_pp_nonlocal_R_ao); std::vector> e_orb_pp_nonlocal; - hamilt::NonlocalNew> v_pp_nonlocal_op(&v_pp_nonlocal_k_ao, kv.kvec_d, + hamilt::Nonlocal> v_pp_nonlocal_op(&v_pp_nonlocal_k_ao, kv.kvec_d, &v_pp_nonlocal_R_ao, &ucell, orb_cutoff, &gd, two_center_bundle.overlap_orb_beta.get()); v_pp_nonlocal_op.contributeHR(); for (int ik = 0;ik < kv.get_nks();++ik) diff --git a/source/source_lcao/CMakeLists.txt b/source/source_lcao/CMakeLists.txt index 25b2d2f374..2bdbfc0b45 100644 --- a/source/source_lcao/CMakeLists.txt +++ b/source/source_lcao/CMakeLists.txt @@ -14,9 +14,9 @@ if(ENABLE_LCAO) module_operator_lcao/op_dftu_lcao.cpp module_operator_lcao/deepks_lcao.cpp module_operator_lcao/op_exx_lcao.cpp - module_operator_lcao/overlap_new.cpp - module_operator_lcao/ekinetic_new.cpp - module_operator_lcao/nonlocal_new.cpp + module_operator_lcao/overlap.cpp + module_operator_lcao/ekinetic.cpp + module_operator_lcao/nonlocal.cpp module_operator_lcao/td_ekinetic_lcao.cpp module_operator_lcao/td_nonlocal_lcao.cpp module_operator_lcao/td_pot_hybrid.cpp diff --git a/source/source_lcao/FORCE_STRESS.cpp b/source/source_lcao/FORCE_STRESS.cpp index 9b129793df..9988e677a8 100644 --- a/source/source_lcao/FORCE_STRESS.cpp +++ b/source/source_lcao/FORCE_STRESS.cpp @@ -19,9 +19,9 @@ #endif #include "source_lcao/module_operator_lcao/dftu_lcao.h" #include "source_lcao/module_operator_lcao/dspin_lcao.h" -#include "source_lcao/module_operator_lcao/nonlocal_new.h" -#include "source_lcao/module_operator_lcao/ekinetic_new.h" -#include "source_lcao/module_operator_lcao/overlap_new.h" +#include "source_lcao/module_operator_lcao/nonlocal.h" +#include "source_lcao/module_operator_lcao/ekinetic.h" +#include "source_lcao/module_operator_lcao/overlap.h" #include "source_lcao/pulay_fs.h" @@ -187,20 +187,20 @@ void Force_Stress_LCAO::getForceStress(UnitCell& ucell, // Calculate kinetic force/stress (uses DM) if (PARAM.inp.t_in_h) { - hamilt::EkineticNew> tmp_ekinetic( + hamilt::EKinetic> tmp_ekinetic( nullptr, kv.kvec_d, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.kinetic_orb.get()); tmp_ekinetic.cal_force_stress(isforce, isstress, dmR, ftvnl_dphi, stvnl_dphi); } // Calculate overlap force/stress (uses EDM) - hamilt::OverlapNew> tmp_overlap( + hamilt::Overlap> tmp_overlap( nullptr, kv.kvec_d, nullptr, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.overlap_orb.get()); tmp_overlap.cal_force_stress(isforce, isstress, edmR, foverlap, soverlap); // Calculate nonlocal force/stress (uses DM) - hamilt::NonlocalNew> tmp_nonlocal( + hamilt::Nonlocal> tmp_nonlocal( nullptr, kv.kvec_d, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.overlap_orb_beta.get()); tmp_nonlocal.cal_force_stress(isforce, isstress, dmR, fvnl_dbeta, svnl_dbeta); @@ -224,14 +224,14 @@ void Force_Stress_LCAO::getForceStress(UnitCell& ucell, // Calculate kinetic force/stress (uses DM) if (PARAM.inp.t_in_h) { - hamilt::EkineticNew, std::complex>> tmp_ekinetic( + hamilt::EKinetic, std::complex>> tmp_ekinetic( nullptr, kv.kvec_d, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.kinetic_orb.get()); tmp_ekinetic.cal_force_stress(isforce, isstress, dmat.dm->get_DMR_pointer(1), ftvnl_dphi, stvnl_dphi); } // Calculate overlap force/stress (uses EDM) - hamilt::OverlapNew, std::complex>> tmp_overlap( + hamilt::Overlap, std::complex>> tmp_overlap( nullptr, kv.kvec_d, nullptr, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.overlap_orb.get()); tmp_overlap.cal_force_stress(isforce, isstress, edm.get_DMR_pointer(1), foverlap, soverlap); @@ -244,7 +244,7 @@ void Force_Stress_LCAO::getForceStress(UnitCell& ucell, tmp_dmr.allocate(); dmat.dm->cal_DMR_full(&tmp_dmr); // Calculate nonlocal force/stress (uses DM) - hamilt::NonlocalNew, std::complex>> tmp_nonlocal( + hamilt::Nonlocal, std::complex>> tmp_nonlocal( nullptr, kv.kvec_d, nullptr, &ucell, orb.cutoffs(), &gd, two_center_bundle.overlap_orb_beta.get()); tmp_nonlocal.cal_force_stress(isforce, isstress, &tmp_dmr, fvnl_dbeta, svnl_dbeta); diff --git a/source/source_lcao/hamilt_lcao.cpp b/source/source_lcao/hamilt_lcao.cpp index d0a5cb62fd..1b3d7195a6 100644 --- a/source/source_lcao/hamilt_lcao.cpp +++ b/source/source_lcao/hamilt_lcao.cpp @@ -29,12 +29,12 @@ #include "source_hsolver/hsolver_lcao.h" #include "module_operator_lcao/dftu_lcao.h" #include "module_operator_lcao/dspin_lcao.h" -#include "module_operator_lcao/ekinetic_new.h" +#include "module_operator_lcao/ekinetic.h" #include "module_operator_lcao/meta_lcao.h" -#include "module_operator_lcao/nonlocal_new.h" +#include "module_operator_lcao/nonlocal.h" #include "module_operator_lcao/op_dftu_lcao.h" #include "module_operator_lcao/op_exx_lcao.h" -#include "module_operator_lcao/overlap_new.h" +#include "module_operator_lcao/overlap.h" #include "module_operator_lcao/td_ekinetic_lcao.h" #include "module_operator_lcao/td_nonlocal_lcao.h" #include "module_operator_lcao/td_pot_hybrid.h" @@ -59,7 +59,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // initialize the overlap matrix this->sR = new HContainer(paraV); - this->getOperator() = new OverlapNew>(this->hsk, + this->getOperator() = new Overlap>(this->hsk, this->kv->kvec_d, this->hR, this->sR, @@ -137,7 +137,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // initial operator for Gamma_only case // overlap term () is indispensable // in Gamma_only case, target SK is this->hsk->get_sk(), the target SR is this->sR - this->getOperator() = new OverlapNew>(this->hsk, + this->getOperator() = new Overlap>(this->hsk, this->kv->kvec_d, this->hR, this->sR, @@ -149,7 +149,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // kinetic term () if (PARAM.inp.t_in_h) { - Operator* ekinetic = new EkineticNew>(this->hsk, + Operator* ekinetic = new EKinetic>(this->hsk, this->kv->kvec_d, this->hR, &ucell, @@ -163,7 +163,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // in general case, target HR is this->hR, while target HK is this->hsk->get_hk() if (PARAM.inp.vnl_in_h) { - Operator* nonlocal = new NonlocalNew>(this->hsk, + Operator* nonlocal = new Nonlocal>(this->hsk, this->kv->kvec_d, this->hR, &ucell, @@ -266,7 +266,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // initial operator for multi-k case // overlap term is indispensable - Operator* overlap = new OverlapNew>(this->hsk, + Operator* overlap = new Overlap>(this->hsk, this->kv->kvec_d, this->hR, this->sR, @@ -287,7 +287,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // in general case, target HR is this->hR, while target HK is this->hsk->get_hk() if (PARAM.inp.t_in_h) { - Operator* ekinetic = new EkineticNew>(this->hsk, + Operator* ekinetic = new EKinetic>(this->hsk, this->kv->kvec_d, this->hR, &ucell, @@ -301,7 +301,7 @@ HamiltLCAO::HamiltLCAO(const UnitCell& ucell, // in general case, target HR is this->hR, while target HK is this->hsk->get_hk() if (PARAM.inp.vnl_in_h) { - Operator* nonlocal = new NonlocalNew>(this->hsk, + Operator* nonlocal = new Nonlocal>(this->hsk, this->kv->kvec_d, this->hR, &ucell, diff --git a/source/source_lcao/module_operator_lcao/CMakeLists.txt b/source/source_lcao/module_operator_lcao/CMakeLists.txt index 275f313383..e9dbbe381b 100644 --- a/source/source_lcao/module_operator_lcao/CMakeLists.txt +++ b/source/source_lcao/module_operator_lcao/CMakeLists.txt @@ -6,9 +6,9 @@ add_library( meta_lcao.cpp veff_lcao.cpp deepks_lcao.cpp - overlap_new.cpp - ekinetic_new.cpp - nonlocal_new.cpp + overlap.cpp + ekinetic.cpp + nonlocal.cpp td_ekinetic_lcao.cpp td_nonlocal_lcao.cpp td_pot_hybrid.cpp diff --git a/source/source_lcao/module_operator_lcao/ekinetic_new.cpp b/source/source_lcao/module_operator_lcao/ekinetic.cpp similarity index 85% rename from source/source_lcao/module_operator_lcao/ekinetic_new.cpp rename to source/source_lcao/module_operator_lcao/ekinetic.cpp index 17456579e3..77d751cb67 100644 --- a/source/source_lcao/module_operator_lcao/ekinetic_new.cpp +++ b/source/source_lcao/module_operator_lcao/ekinetic.cpp @@ -1,4 +1,4 @@ -#include "ekinetic_new.h" +#include "ekinetic.h" #include "source_base/timer.h" #include "source_base/tool_title.h" @@ -8,7 +8,7 @@ // Constructor template -hamilt::EkineticNew>::EkineticNew( +hamilt::EKinetic>::EKinetic( HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, hamilt::HContainer* hR_in, @@ -34,7 +34,7 @@ hamilt::EkineticNew>::EkineticNew( // destructor template -hamilt::EkineticNew>::~EkineticNew() +hamilt::EKinetic>::~EKinetic() { if (this->allocated) { @@ -44,10 +44,10 @@ hamilt::EkineticNew>::~EkineticNew() // initialize_HR() template -void hamilt::EkineticNew>::initialize_HR(const Grid_Driver* GridD) +void hamilt::EKinetic>::initialize_HR(const Grid_Driver* GridD) { - ModuleBase::TITLE("EkineticNew", "initialize_HR"); - ModuleBase::timer::tick("EkineticNew", "initialize_HR"); + ModuleBase::TITLE("EKinetic", "initialize_HR"); + ModuleBase::timer::tick("EKinetic", "initialize_HR"); auto* paraV = this->hR->get_paraV();// get parallel orbitals from HR // TODO: if paraV is nullptr, AtomPair can not use paraV for constructor, I will repair it in the future. @@ -96,20 +96,20 @@ void hamilt::EkineticNew>::initialize_HR(const Grid // allocate the memory of BaseMatrix in HR, and set the new values to zero this->hR->allocate(nullptr, true); - ModuleBase::timer::tick("EkineticNew", "initialize_HR"); + ModuleBase::timer::tick("EKinetic", "initialize_HR"); } template -void hamilt::EkineticNew>::calculate_HR() +void hamilt::EKinetic>::calculate_HR() { - ModuleBase::TITLE("EkineticNew", "calculate_HR"); + ModuleBase::TITLE("EKinetic", "calculate_HR"); if (this->HR_fixed == nullptr || this->HR_fixed->size_atom_pairs() <= 0) { // Skip calculation if HR_fixed is empty (e.g., zero cutoff case) // This is not an error, just means there are no atom pairs to calculate return; } - ModuleBase::timer::tick("EkineticNew", "calculate_HR"); + ModuleBase::timer::tick("EKinetic", "calculate_HR"); const Parallel_Orbitals* paraV = this->HR_fixed->get_atom_pair(0).get_paraV(); #ifdef _OPENMP @@ -137,17 +137,17 @@ void hamilt::EkineticNew>::calculate_HR() } else { - ModuleBase::WARNING_QUIT("hamilt::EkineticNew::calculate_HR", "R_index not found in HR"); + ModuleBase::WARNING_QUIT("hamilt::EKinetic::calculate_HR", "R_index not found in HR"); } } } - ModuleBase::timer::tick("EkineticNew", "calculate_HR"); + ModuleBase::timer::tick("EKinetic", "calculate_HR"); } // cal_HR_IJR() template -void hamilt::EkineticNew>::cal_HR_IJR(const int& iat1, +void hamilt::EKinetic>::cal_HR_IJR(const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, const ModuleBase::Vector3& dtau, @@ -216,7 +216,7 @@ void hamilt::EkineticNew>::cal_HR_IJR(const int& ia // set_HR_fixed() template -void hamilt::EkineticNew>::set_HR_fixed(void* HR_fixed_in) +void hamilt::EKinetic>::set_HR_fixed(void* HR_fixed_in) { this->HR_fixed = static_cast*>(HR_fixed_in); this->allocated = false; @@ -224,10 +224,10 @@ void hamilt::EkineticNew>::set_HR_fixed(void* HR_fi // contributeHR() template -void hamilt::EkineticNew>::contributeHR() +void hamilt::EKinetic>::contributeHR() { - ModuleBase::TITLE("EkineticNew", "contributeHR"); - ModuleBase::timer::tick("EkineticNew", "contributeHR"); + ModuleBase::TITLE("EKinetic", "contributeHR"); + ModuleBase::timer::tick("EKinetic", "contributeHR"); if (!this->HR_fixed_done) { @@ -254,13 +254,13 @@ void hamilt::EkineticNew>::contributeHR() this->hR->add(*(this->HR_fixed)); } - ModuleBase::timer::tick("EkineticNew", "contributeHR"); + ModuleBase::timer::tick("EKinetic", "contributeHR"); return; } // Include force/stress implementation #include "ekinetic_force_stress.hpp" -template class hamilt::EkineticNew>; -template class hamilt::EkineticNew, double>>; -template class hamilt::EkineticNew, std::complex>>; +template class hamilt::EKinetic>; +template class hamilt::EKinetic, double>>; +template class hamilt::EKinetic, std::complex>>; diff --git a/source/source_lcao/module_operator_lcao/ekinetic_new.h b/source/source_lcao/module_operator_lcao/ekinetic.h similarity index 89% rename from source/source_lcao/module_operator_lcao/ekinetic_new.h rename to source/source_lcao/module_operator_lcao/ekinetic.h index b1feb27c32..916c384a09 100644 --- a/source/source_lcao/module_operator_lcao/ekinetic_new.h +++ b/source/source_lcao/module_operator_lcao/ekinetic.h @@ -1,5 +1,5 @@ -#ifndef EKINETICNEW_H -#define EKINETICNEW_H +#ifndef EKINETIC_H +#define EKINETIC_H #include "source_basis/module_ao/parallel_orbitals.h" #include "source_basis/module_nao/two_center_integrator.h" #include "source_cell/module_neighbor/sltk_grid_driver.h" @@ -11,22 +11,22 @@ namespace hamilt { -#ifndef __EKINETICNEWTEMPLATE -#define __EKINETICNEWTEMPLATE +#ifndef __EKINETICTEMPLATE +#define __EKINETICTEMPLATE -/// The EkineticNew class template inherits from class T +/// The EKinetic class template inherits from class T /// it is used to calculate the electronic kinetic /// Template parameters: /// - T: base class, it would be OperatorLCAO or OperatorPW /// - TR: data type of real space Hamiltonian, it would be double or std::complex template -class EkineticNew : public T +class EKinetic : public T { }; #endif -/// EkineticNew class template specialization for OperatorLCAO base class +/// EKinetic class template specialization for OperatorLCAO base class /// It is used to calculate the electronic kinetic matrix in real space and fold it to k-space /// HR = /// HK = = \sum_{R} e^{ikR} HR @@ -34,13 +34,13 @@ class EkineticNew : public T /// - TK: data type of k-space Hamiltonian /// - TR: data type of real space Hamiltonian template -class EkineticNew> : public OperatorLCAO +class EKinetic> : public OperatorLCAO { public: /** - * @brief Construct a new EkineticNew object + * @brief Construct a new EKinetic object */ - EkineticNew>(HS_Matrix_K* hsk_in, + EKinetic>(HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, HContainer* hR_in, const UnitCell* ucell_in, @@ -49,9 +49,9 @@ class EkineticNew> : public OperatorLCAO const TwoCenterIntegrator* intor); /** - * @brief Destroy the EkineticNew object + * @brief Destroy the EKinetic object */ - ~EkineticNew>(); + ~EKinetic>(); /** * @brief contributeHR() is used to calculate the HR matrix diff --git a/source/source_lcao/module_operator_lcao/ekinetic_force_stress.hpp b/source/source_lcao/module_operator_lcao/ekinetic_force_stress.hpp index 17a8dbdaab..b7427f69c1 100644 --- a/source/source_lcao/module_operator_lcao/ekinetic_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/ekinetic_force_stress.hpp @@ -1,5 +1,5 @@ #pragma once -#include "ekinetic_new.h" +#include "ekinetic.h" #include "operator_force_stress_utils.hpp" #include "source_base/timer.h" @@ -7,14 +7,14 @@ namespace hamilt { template -void EkineticNew>::cal_force_stress(const bool cal_force, +void EKinetic>::cal_force_stress(const bool cal_force, const bool cal_stress, const HContainer* dmR, ModuleBase::matrix& force, ModuleBase::matrix& stress) { - ModuleBase::TITLE("EkineticNew", "cal_force_stress"); - ModuleBase::timer::tick("EkineticNew", "cal_force_stress"); + ModuleBase::TITLE("EKinetic", "cal_force_stress"); + ModuleBase::timer::tick("EKinetic", "cal_force_stress"); // Lambda function to calculate kinetic integral and its gradient auto integral_calc = [this](int T1, int L1, int N1, int M1, @@ -30,13 +30,13 @@ void EkineticNew>::cal_force_stress(const bool cal_force, cal_force, cal_stress, dmR, this->ucell, this->gridD, this->orb_cutoff_, dmR->get_paraV(), integral_calc, force, stress); - ModuleBase::timer::tick("EkineticNew", "cal_force_stress"); + ModuleBase::timer::tick("EKinetic", "cal_force_stress"); } // Dummy implementations for cal_force_IJR and cal_stress_IJR // These are not used in the simplified approach above template -void EkineticNew>::cal_force_IJR( +void EKinetic>::cal_force_IJR( const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, @@ -50,7 +50,7 @@ void EkineticNew>::cal_force_IJR( } template -void EkineticNew>::cal_stress_IJR( +void EKinetic>::cal_stress_IJR( const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, diff --git a/source/source_lcao/module_operator_lcao/nonlocal_new.cpp b/source/source_lcao/module_operator_lcao/nonlocal.cpp similarity index 89% rename from source/source_lcao/module_operator_lcao/nonlocal_new.cpp rename to source/source_lcao/module_operator_lcao/nonlocal.cpp index c4161114db..bf7a5ccd99 100644 --- a/source/source_lcao/module_operator_lcao/nonlocal_new.cpp +++ b/source/source_lcao/module_operator_lcao/nonlocal.cpp @@ -1,4 +1,4 @@ -#include "nonlocal_new.h" +#include "nonlocal.h" #include "source_base/timer.h" #include "source_base/tool_title.h" @@ -10,7 +10,7 @@ #endif template -hamilt::NonlocalNew>::NonlocalNew( +hamilt::Nonlocal>::Nonlocal( HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, hamilt::HContainer* hR_in, @@ -35,7 +35,7 @@ hamilt::NonlocalNew>::NonlocalNew( // destructor template -hamilt::NonlocalNew>::~NonlocalNew() +hamilt::Nonlocal>::~Nonlocal() { if (this->allocated) { @@ -45,10 +45,10 @@ hamilt::NonlocalNew>::~NonlocalNew() // initialize_HR() template -void hamilt::NonlocalNew>::initialize_HR(const Grid_Driver* GridD) +void hamilt::Nonlocal>::initialize_HR(const Grid_Driver* GridD) { - ModuleBase::TITLE("NonlocalNew", "initialize_HR"); - ModuleBase::timer::tick("NonlocalNew", "initialize_HR"); + ModuleBase::TITLE("Nonlocal", "initialize_HR"); + ModuleBase::timer::tick("Nonlocal", "initialize_HR"); auto* paraV = this->hR->get_paraV();// get parallel orbitals from HR // TODO: if paraV is nullptr, AtomPair can not use paraV for constructor, I will repair it in the future. @@ -111,14 +111,14 @@ void hamilt::NonlocalNew>::initialize_HR(const Grid // allocate the memory of BaseMatrix in HR, and set the new values to zero this->hR->allocate(nullptr, true); - ModuleBase::timer::tick("NonlocalNew", "initialize_HR"); + ModuleBase::timer::tick("Nonlocal", "initialize_HR"); } template -void hamilt::NonlocalNew>::calculate_HR() +void hamilt::Nonlocal>::calculate_HR() { - ModuleBase::TITLE("NonlocalNew", "calculate_HR"); - ModuleBase::timer::tick("NonlocalNew", "calculate_HR"); + ModuleBase::TITLE("Nonlocal", "calculate_HR"); + ModuleBase::timer::tick("Nonlocal", "calculate_HR"); const Parallel_Orbitals* paraV = this->HR_fixed->get_atom_pair(0).get_paraV(); const int npol = this->ucell->get_npol(); @@ -219,12 +219,12 @@ void hamilt::NonlocalNew>::calculate_HR() } #endif - ModuleBase::timer::tick("NonlocalNew", "calculate_HR"); + ModuleBase::timer::tick("Nonlocal", "calculate_HR"); } // cal_HR_IJR() template -void hamilt::NonlocalNew>::cal_HR_IJR( +void hamilt::Nonlocal>::cal_HR_IJR( const int& iat1, const int& iat2, const int& T0, @@ -284,7 +284,7 @@ void hamilt::NonlocalNew>::cal_HR_IJR( // set_HR_fixed() template -void hamilt::NonlocalNew>::set_HR_fixed(void* HR_fixed_in) +void hamilt::Nonlocal>::set_HR_fixed(void* HR_fixed_in) { this->HR_fixed = static_cast*>(HR_fixed_in); this->allocated = false; @@ -292,10 +292,10 @@ void hamilt::NonlocalNew>::set_HR_fixed(void* HR_fi // contributeHR() template -void hamilt::NonlocalNew>::contributeHR() +void hamilt::Nonlocal>::contributeHR() { - ModuleBase::TITLE("NonlocalNew", "contributeHR"); - ModuleBase::timer::tick("NonlocalNew", "contributeHR"); + ModuleBase::TITLE("Nonlocal", "contributeHR"); + ModuleBase::timer::tick("Nonlocal", "contributeHR"); if (!this->HR_fixed_done) { // if this Operator is the first node of the sub_chain, then HR_fixed is nullptr @@ -319,12 +319,12 @@ void hamilt::NonlocalNew>::contributeHR() { this->hR->add(*(this->HR_fixed)); } - ModuleBase::timer::tick("NonlocalNew", "contributeHR"); + ModuleBase::timer::tick("Nonlocal", "contributeHR"); return; } #include "nonlocal_force_stress.hpp" -template class hamilt::NonlocalNew>; -template class hamilt::NonlocalNew, double>>; -template class hamilt::NonlocalNew, std::complex>>; +template class hamilt::Nonlocal>; +template class hamilt::Nonlocal, double>>; +template class hamilt::Nonlocal, std::complex>>; diff --git a/source/source_lcao/module_operator_lcao/nonlocal_new.h b/source/source_lcao/module_operator_lcao/nonlocal.h similarity index 93% rename from source/source_lcao/module_operator_lcao/nonlocal_new.h rename to source/source_lcao/module_operator_lcao/nonlocal.h index 9bc19aa348..9da556b8e3 100644 --- a/source/source_lcao/module_operator_lcao/nonlocal_new.h +++ b/source/source_lcao/module_operator_lcao/nonlocal.h @@ -16,19 +16,19 @@ namespace hamilt #ifndef __NONLOCALNEWTEMPLATE #define __NONLOCALNEWTEMPLATE -/// The NonlocalNew class template inherits from class T +/// The Nonlocal class template inherits from class T /// it is used to calculate the non-local pseudopotential of wavefunction basis /// Template parameters: /// - T: base class, it would be OperatorLCAO or OperatorPW /// - TR: data type of real space Hamiltonian, it would be double or std::complex template -class NonlocalNew : public T +class Nonlocal : public T { }; #endif -/// NonlocalNew class template specialization for OperatorLCAO base class +/// Nonlocal class template specialization for OperatorLCAO base class /// It is used to calculate the non-local pseudopotential matrix in real space and fold it to k-space /// HR = D_{p1, p2} /// HK = D_{p1, p2} = \sum_{R} e^{ikR} HR @@ -36,17 +36,17 @@ class NonlocalNew : public T /// - TK: data type of k-space Hamiltonian /// - TR: data type of real space Hamiltonian template -class NonlocalNew> : public OperatorLCAO +class Nonlocal> : public OperatorLCAO { public: - NonlocalNew>(HS_Matrix_K* hsk_in, + Nonlocal>(HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, hamilt::HContainer* hR_in, const UnitCell* ucell_in, const std::vector& orb_cutoff, const Grid_Driver* GridD_in, const TwoCenterIntegrator* intor); - ~NonlocalNew>(); + ~Nonlocal>(); /** * @brief contributeHR() is used to calculate the HR matrix diff --git a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp index 284842ae4d..3b796cb347 100644 --- a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp @@ -1,22 +1,22 @@ #pragma once -#include "nonlocal_new.h" -#include "source_base/parallel_reduce.h" +#include "nonlocal.h" +#include "operator_force_stress_utils.h" #include "source_base/timer.h" namespace hamilt { template -void NonlocalNew>::cal_force_stress(const bool cal_force, +void Nonlocal>::cal_force_stress(const bool cal_force, const bool cal_stress, const HContainer* dmR, ModuleBase::matrix& force, ModuleBase::matrix& stress) { - ModuleBase::TITLE("NonlocalNew", "cal_force_stress"); + ModuleBase::TITLE("Nonlocal", "cal_force_stress"); // begin the calculation of force and stress - ModuleBase::timer::tick("NonlocalNew", "cal_force_stress"); + ModuleBase::timer::tick("Nonlocal", "cal_force_stress"); const Parallel_Orbitals* paraV = dmR->get_paraV(); const int npol = this->ucell->get_npol(); @@ -86,15 +86,10 @@ void NonlocalNew>::cal_force_stress(const bool cal_force, // If we are calculating force, we need also to store the gradient // and size of outer vector is then 4 // inner loop : all projectors (L0,M0) - int L1 = atom1->iw2l[iw1]; - int N1 = atom1->iw2n[iw1]; - int m1 = atom1->iw2m[iw1]; - - // convert m (0,1,...2l) to M (-l, -l+1, ..., l-1, l) - int M1 = (m1 % 2 == 0) ? -m1 / 2 : (m1 + 1) / 2; + auto qn1 = OperatorForceStress::get_orbital_qn(*atom1, iw1); ModuleBase::Vector3 dtau = tau0 - tau1; - intor_->snap(T1, L1, N1, M1, T0, dtau * this->ucell->lat0, true /*cal_deri*/, nlm); + intor_->snap(T1, qn1.L, qn1.N, qn1.M, T0, dtau * this->ucell->lat0, true /*cal_deri*/, nlm); // select the elements of nlm with target_L const int length = nlm[0].size(); std::vector nlm_target(length * 4); @@ -187,43 +182,14 @@ void NonlocalNew>::cal_force_stress(const bool cal_force, } } - if (cal_force) - { -#ifdef __MPI - // sum up the occupation matrix - Parallel_Reduce::reduce_all(force.c, force.nr * force.nc); -#endif - for (int i = 0; i < force.nr * force.nc; i++) - { - force.c[i] *= 2.0; - } - } + // Finalize with MPI reduction and post-processing + OperatorForceStress::finalize_force_stress(cal_force, cal_stress, this->ucell, stress_tmp, force, stress, 2.0, 2.0); - // stress renormalization - if (cal_stress) - { -#ifdef __MPI - // sum up the occupation matrix - Parallel_Reduce::reduce_all(stress_tmp.data(), 6); -#endif - const double weight = this->ucell->lat0 / this->ucell->omega; - for (int i = 0; i < 6; i++) - { - stress.c[i] = stress_tmp[i] * weight; - } - stress.c[8] = stress.c[5]; // stress(2,2) - stress.c[7] = stress.c[4]; // stress(2,1) - stress.c[6] = stress.c[2]; // stress(2,0) - stress.c[5] = stress.c[4]; // stress(1,2) - stress.c[4] = stress.c[3]; // stress(1,1) - stress.c[3] = stress.c[1]; // stress(1,0) - } - - ModuleBase::timer::tick("NonlocalNew", "cal_force_stress"); + ModuleBase::timer::tick("Nonlocal", "cal_force_stress"); } template <> -void NonlocalNew, std::complex>>::cal_force_IJR(const int& iat1, +void Nonlocal, std::complex>>::cal_force_IJR(const int& iat1, const int& iat2, const int& T0, const Parallel_Orbitals* paraV, @@ -243,12 +209,8 @@ void NonlocalNew, std::complex>>::cal_ auto row_indexes = paraV->get_indexes_row(iat1); auto col_indexes = paraV->get_indexes_col(iat2); // step_trace = 0 for NSPIN=2; ={0, 1, local_col, local_col+1} for NSPIN=4 - std::vector step_trace(npol * npol, 0); - if (npol == 2) { - step_trace[1] = 1; - step_trace[2] = col_indexes.size(); - step_trace[3] = col_indexes.size() + 1; - } + std::vector step_trace; + OperatorForceStress::setup_step_trace(npol, col_indexes.size(), step_trace); // calculate the local matrix const std::complex* tmp_d = nullptr; const std::complex* dm_pointer = dmR_pointer->get_pointer(); @@ -292,7 +254,7 @@ void NonlocalNew, std::complex>>::cal_ } template <> -void NonlocalNew, std::complex>>::cal_stress_IJR(const int& iat1, +void Nonlocal, std::complex>>::cal_stress_IJR(const int& iat1, const int& iat2, const int& T0, const Parallel_Orbitals* paraV, @@ -314,12 +276,8 @@ void NonlocalNew, std::complex>>::cal_ auto row_indexes = paraV->get_indexes_row(iat1); auto col_indexes = paraV->get_indexes_col(iat2); // step_trace = 0 for NSPIN=2; ={0, 1, local_col, local_col+1} for NSPIN=4 - std::vector step_trace(npol2, 0); - if (npol == 2) { - step_trace[1] = 1; - step_trace[2] = col_indexes.size(); - step_trace[3] = col_indexes.size() + 1; - } + std::vector step_trace; + OperatorForceStress::setup_step_trace(npol, col_indexes.size(), step_trace); // calculate the local matrix const std::complex* tmp_d = nullptr; const std::complex* dm_pointer = dmR_pointer->get_pointer(); @@ -364,7 +322,7 @@ void NonlocalNew, std::complex>>::cal_ } template -void NonlocalNew>::cal_force_IJR(const int& iat1, +void Nonlocal>::cal_force_IJR(const int& iat1, const int& iat2, const int& T0, const Parallel_Orbitals* paraV, @@ -414,7 +372,7 @@ void NonlocalNew>::cal_force_IJR(const int& iat1, } template -void NonlocalNew>::cal_stress_IJR(const int& iat1, +void Nonlocal>::cal_stress_IJR(const int& iat1, const int& iat2, const int& T0, const Parallel_Orbitals* paraV, diff --git a/source/source_lcao/module_operator_lcao/operator_force_stress_utils.hpp b/source/source_lcao/module_operator_lcao/operator_force_stress_utils.hpp index 29e42ff0e7..572d117a7e 100644 --- a/source/source_lcao/module_operator_lcao/operator_force_stress_utils.hpp +++ b/source/source_lcao/module_operator_lcao/operator_force_stress_utils.hpp @@ -140,7 +140,7 @@ void cal_force_stress_2center( integral_calculator(T1, L1, N1, M1, T2, L2, N2, M2, dtau, olm); // only charge should be considered - double dm_current = get_real_part(dm_pointer[0]); + const double dm_current = dm_pointer[0]; // Calculate force contribution with compile-time sign if (cal_force) diff --git a/source/source_lcao/module_operator_lcao/overlap_new.cpp b/source/source_lcao/module_operator_lcao/overlap.cpp similarity index 85% rename from source/source_lcao/module_operator_lcao/overlap_new.cpp rename to source/source_lcao/module_operator_lcao/overlap.cpp index 09c2b07a34..f7a9199f19 100644 --- a/source/source_lcao/module_operator_lcao/overlap_new.cpp +++ b/source/source_lcao/module_operator_lcao/overlap.cpp @@ -1,4 +1,4 @@ -#include "overlap_new.h" +#include "overlap.h" #include "source_io/module_parameter/parameter.h" #include "source_base/timer.h" @@ -11,7 +11,7 @@ #include "source_lcao/module_rt/td_folding.h" template -hamilt::OverlapNew>::OverlapNew(HS_Matrix_K* hsk_in, +hamilt::Overlap>::Overlap(HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, hamilt::HContainer* hR_in, hamilt::HContainer* SR_in, @@ -38,10 +38,10 @@ hamilt::OverlapNew>::OverlapNew(HS_Matrix_K* hs // initialize_SR() template -void hamilt::OverlapNew>::initialize_SR(const Grid_Driver* GridD) +void hamilt::Overlap>::initialize_SR(const Grid_Driver* GridD) { - ModuleBase::TITLE("OverlapNew", "initialize_SR"); - ModuleBase::timer::tick("OverlapNew", "initialize_SR"); + ModuleBase::TITLE("Overlap", "initialize_SR"); + ModuleBase::timer::tick("Overlap", "initialize_SR"); auto* paraV = this->SR->get_paraV(); // get parallel orbitals from HR // TODO: if paraV is nullptr, AtomPair can not use paraV for constructor, I will repair it in the future. for (int iat1 = 0; iat1 < ucell->nat; iat1++) @@ -77,14 +77,14 @@ void hamilt::OverlapNew>::initialize_SR(const Grid_ } // allocate the memory of BaseMatrix in SR, and set the new values to zero SR->allocate(nullptr, true); - ModuleBase::timer::tick("OverlapNew", "initialize_SR"); + ModuleBase::timer::tick("Overlap", "initialize_SR"); } template -void hamilt::OverlapNew>::calculate_SR() +void hamilt::Overlap>::calculate_SR() { - ModuleBase::TITLE("OverlapNew", "calculate_SR"); - ModuleBase::timer::tick("OverlapNew", "calculate_SR"); + ModuleBase::TITLE("Overlap", "calculate_SR"); + ModuleBase::timer::tick("Overlap", "calculate_SR"); #ifdef _OPENMP #pragma omp parallel for #endif @@ -109,12 +109,12 @@ void hamilt::OverlapNew>::calculate_SR() { this->SR->fix_gamma(); } - ModuleBase::timer::tick("OverlapNew", "calculate_SR"); + ModuleBase::timer::tick("Overlap", "calculate_SR"); } // cal_SR_IJR() template -void hamilt::OverlapNew>::cal_SR_IJR(const int& iat1, +void hamilt::Overlap>::cal_SR_IJR(const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, const ModuleBase::Vector3& dtau, @@ -183,7 +183,7 @@ void hamilt::OverlapNew>::cal_SR_IJR(const int& iat // contributeHR() template -void hamilt::OverlapNew>::contributeHR() +void hamilt::Overlap>::contributeHR() { if (this->SR_fixed_done) { @@ -195,15 +195,15 @@ void hamilt::OverlapNew>::contributeHR() // contributeHk() template <> -void hamilt::OverlapNew>::contributeHk(int ik) +void hamilt::Overlap>::contributeHk(int ik) { //! if k vector is not changed, then do nothing and return, only for gamma_only case if (this->kvec_d[ik] == this->kvec_d_old) { return; } - ModuleBase::TITLE("OverlapNew", "contributeHk"); - ModuleBase::timer::tick("OverlapNew", "contributeHk"); + ModuleBase::TITLE("Overlap", "contributeHk"); + ModuleBase::timer::tick("Overlap", "contributeHk"); //! set SK to zero and then calculate SK for each k vector this->hsk->set_zero_sk(); @@ -221,13 +221,13 @@ void hamilt::OverlapNew>::contributeHk(int // update kvec_d_old this->kvec_d_old = this->kvec_d[ik]; - ModuleBase::timer::tick("OverlapNew", "contributeHk"); + ModuleBase::timer::tick("Overlap", "contributeHk"); } template -void hamilt::OverlapNew>::contributeHk(int ik) +void hamilt::Overlap>::contributeHk(int ik) { - ModuleBase::TITLE("OverlapNew", "contributeHk"); - ModuleBase::timer::tick("OverlapNew", "contributeHk"); + ModuleBase::TITLE("Overlap", "contributeHk"); + ModuleBase::timer::tick("Overlap", "contributeHk"); //! set SK to zero and then calculate SK for each k vector this->hsk->set_zero_sk(); @@ -259,10 +259,10 @@ void hamilt::OverlapNew>::contributeHk(int ik) // update kvec_d_old this->kvec_d_old = this->kvec_d[ik]; - ModuleBase::timer::tick("OverlapNew", "contributeHk"); + ModuleBase::timer::tick("Overlap", "contributeHk"); } template -TK* hamilt::OverlapNew>::getSk() +TK* hamilt::Overlap>::getSk() { if (this->hsk != nullptr) { @@ -274,6 +274,6 @@ TK* hamilt::OverlapNew>::getSk() // Include force/stress implementation #include "overlap_force_stress.hpp" -template class hamilt::OverlapNew>; -template class hamilt::OverlapNew, double>>; -template class hamilt::OverlapNew, std::complex>>; +template class hamilt::Overlap>; +template class hamilt::Overlap, double>>; +template class hamilt::Overlap, std::complex>>; diff --git a/source/source_lcao/module_operator_lcao/overlap_new.h b/source/source_lcao/module_operator_lcao/overlap.h similarity index 91% rename from source/source_lcao/module_operator_lcao/overlap_new.h rename to source/source_lcao/module_operator_lcao/overlap.h index b561671a32..cb5034840d 100644 --- a/source/source_lcao/module_operator_lcao/overlap_new.h +++ b/source/source_lcao/module_operator_lcao/overlap.h @@ -1,5 +1,5 @@ -#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_OPERATOR_LCAO_OVERLAP_NEW_H -#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_OPERATOR_LCAO_OVERLAP_NEW_H +#ifndef W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_OPERATOR_LCAO_OVERLAP_H +#define W_ABACUS_DEVELOP_ABACUS_DEVELOP_SOURCE_MODULE_HAMILT_LCAO_HAMILT_LCAODFT_OPERATOR_LCAO_OVERLAP_H #include "source_basis/module_ao/parallel_orbitals.h" #include "source_basis/module_nao/two_center_integrator.h" #include "source_cell/module_neighbor/sltk_grid_driver.h" @@ -11,22 +11,22 @@ namespace hamilt { -#ifndef __OVERLAPNEWTEMPLATE -#define __OVERLAPNEWTEMPLATE +#ifndef __OVERLAPTEMPLATE +#define __OVERLAPTEMPLATE -/// The OverlapNew class template inherits from class T +/// The Overlap class template inherits from class T /// it is used to calculate the overlap of wavefunction basis /// Template parameters: /// - T: base class, it would be OperatorLCAO or OperatorPW /// - TR: data type of real space Hamiltonian, it would be double or std::complex template -class OverlapNew : public T +class Overlap : public T { }; #endif -/// OverlapNew class template specialization for OperatorLCAO base class +/// Overlap class template specialization for OperatorLCAO base class /// It is used to calculate the overlap matrix in real space and fold it to k-space /// SR = /// SK = = \sum_{R} e^{ikR} SR @@ -34,10 +34,10 @@ class OverlapNew : public T /// - TK: data type of k-space Hamiltonian /// - TR: data type of real space Hamiltonian template -class OverlapNew> : public OperatorLCAO +class Overlap> : public OperatorLCAO { public: - OverlapNew>(HS_Matrix_K* hsk_in, + Overlap>(HS_Matrix_K* hsk_in, const std::vector>& kvec_d_in, hamilt::HContainer* hR_in, hamilt::HContainer* SR_in, diff --git a/source/source_lcao/module_operator_lcao/overlap_force_stress.hpp b/source/source_lcao/module_operator_lcao/overlap_force_stress.hpp index 988a752937..679ebb544b 100644 --- a/source/source_lcao/module_operator_lcao/overlap_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/overlap_force_stress.hpp @@ -1,5 +1,5 @@ #pragma once -#include "overlap_new.h" +#include "overlap.h" #include "operator_force_stress_utils.hpp" #include "source_base/timer.h" @@ -7,14 +7,14 @@ namespace hamilt { template -void OverlapNew>::cal_force_stress(const bool cal_force, +void Overlap>::cal_force_stress(const bool cal_force, const bool cal_stress, const HContainer* dmR, ModuleBase::matrix& force, ModuleBase::matrix& stress) { - ModuleBase::TITLE("OverlapNew", "cal_force_stress"); - ModuleBase::timer::tick("OverlapNew", "cal_force_stress"); + ModuleBase::TITLE("Overlap", "cal_force_stress"); + ModuleBase::timer::tick("Overlap", "cal_force_stress"); // Lambda function to calculate overlap integral and its gradient auto integral_calc = [this](int T1, int L1, int N1, int M1, @@ -30,13 +30,13 @@ void OverlapNew>::cal_force_stress(const bool cal_force, cal_force, cal_stress, dmR, this->ucell, this->gridD, this->orb_cutoff_, dmR->get_paraV(), integral_calc, force, stress); - ModuleBase::timer::tick("OverlapNew", "cal_force_stress"); + ModuleBase::timer::tick("Overlap", "cal_force_stress"); } // Dummy implementations for cal_force_IJR and cal_stress_IJR // These are not used in the simplified approach above template -void OverlapNew>::cal_force_IJR( +void Overlap>::cal_force_IJR( const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, @@ -50,7 +50,7 @@ void OverlapNew>::cal_force_IJR( } template -void OverlapNew>::cal_stress_IJR( +void Overlap>::cal_stress_IJR( const int& iat1, const int& iat2, const Parallel_Orbitals* paraV, diff --git a/source/source_lcao/module_operator_lcao/td_pot_hybrid.h b/source/source_lcao/module_operator_lcao/td_pot_hybrid.h index 5790dd53a4..265d3b1576 100644 --- a/source/source_lcao/module_operator_lcao/td_pot_hybrid.h +++ b/source/source_lcao/module_operator_lcao/td_pot_hybrid.h @@ -18,8 +18,8 @@ namespace hamilt #ifndef __TD_POT_HYBRIDTEMPLATE #define __TD_POT_HYBRIDTEMPLATE -/// The EkineticNew class template inherits from class T -/// it is used to calculate the electronic kinetic +/// The TD_pot_hybrid class template inherits from class T +/// it is used to calculate the time-dependent hybrid potential /// Template parameters: /// - T: base class, it would be OperatorLCAO or OperatorPW /// - TR: data type of real space Hamiltonian, it would be double or std::complex @@ -30,10 +30,8 @@ class TD_pot_hybrid : public T #endif -/// EkineticNew class template specialization for OperatorLCAO base class -/// It is used to calculate the electronic kinetic matrix in real space and fold it to k-space -/// HR = -/// HK = = \sum_{R} e^{ikR} HR +/// TD_pot_hybrid class template specialization for OperatorLCAO base class +/// It is used to calculate the time-dependent hybrid potential matrix in real space and fold it to k-space /// Template parameters: /// - TK: data type of k-space Hamiltonian /// - TR: data type of real space Hamiltonian @@ -42,7 +40,7 @@ class TD_pot_hybrid> : public OperatorLCAO { public: /** - * @brief Construct a new EkineticNew object + * @brief Construct a new TD_pot_hybrid object */ TD_pot_hybrid>(HS_Matrix_K* hsk_in, const K_Vectors* kv_in, @@ -55,7 +53,7 @@ class TD_pot_hybrid> : public OperatorLCAO const TwoCenterIntegrator* intor); /** - * @brief Destroy the EkineticNew object + * @brief Destroy the TD_pot_hybrid object */ ~TD_pot_hybrid>(); diff --git a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt index 8ea1c83079..d78f94d181 100644 --- a/source/source_lcao/module_operator_lcao/test/CMakeLists.txt +++ b/source/source_lcao/module_operator_lcao/test/CMakeLists.txt @@ -4,7 +4,7 @@ remove_definitions(-DUSE_NEW_TWO_CENTER) AddTest( TARGET operator_overlap_test LIBS parameter ${math_libs} psi base device container - SOURCES test_overlapnew.cpp ../overlap_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_overlap.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp @@ -15,7 +15,7 @@ AddTest( AddTest( TARGET operator_overlap_serial_test LIBS parameter ${math_libs} psi base device container - SOURCES test_overlapnew_serial.cpp ../overlap_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_overlap_serial.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp @@ -26,7 +26,7 @@ AddTest( AddTest( TARGET operator_overlap_cd_test LIBS parameter ${math_libs} psi base device container - SOURCES test_overlapnew_cd.cpp ../overlap_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_overlap_cd.cpp ../overlap.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp @@ -37,7 +37,7 @@ AddTest( AddTest( TARGET operator_ekinetic_test LIBS parameter ${math_libs} psi base device container - SOURCES test_ekineticnew.cpp ../ekinetic_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_ekinetic.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp @@ -47,7 +47,7 @@ AddTest( AddTest( TARGET operator_ekinetic_serial_test LIBS parameter ${math_libs} psi base device container - SOURCES test_ekineticnew_serial.cpp ../ekinetic_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_ekinetic_serial.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp @@ -57,9 +57,9 @@ AddTest( AddTest( TARGET operator_nonlocal_test LIBS parameter ${math_libs} psi base device container - SOURCES test_nonlocalnew.cpp ../nonlocal_new.cpp ../../module_hcontainer/func_folding.cpp - ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp - ../../../source_basis/module_ao/parallel_orbitals.cpp + SOURCES test_nonlocal.cpp ../nonlocal.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp + ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp tmp_mocks.cpp ../../../source_hamilt/operator.cpp ) @@ -67,7 +67,7 @@ AddTest( AddTest( TARGET operator_T_NL_cd_test LIBS parameter ${math_libs} psi base device container - SOURCES test_T_NL_cd.cpp ../nonlocal_new.cpp ../ekinetic_new.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp + SOURCES test_T_NL_cd.cpp ../nonlocal.cpp ../ekinetic.cpp ../operator_force_stress_utils.cpp ../../module_hcontainer/func_folding.cpp ../../module_hcontainer/base_matrix.cpp ../../module_hcontainer/hcontainer.cpp ../../module_hcontainer/atom_pair.cpp ../../../source_basis/module_ao/parallel_orbitals.cpp ../../../source_basis/module_ao/ORB_atomic_lm.cpp diff --git a/source/source_lcao/module_operator_lcao/test/test_T_NL_cd.cpp b/source/source_lcao/module_operator_lcao/test/test_T_NL_cd.cpp index 5f3aa117ec..7ab72fa2c8 100644 --- a/source/source_lcao/module_operator_lcao/test/test_T_NL_cd.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_T_NL_cd.cpp @@ -1,12 +1,12 @@ -#include "../ekinetic_new.h" -#include "../nonlocal_new.h" +#include "../ekinetic.h" +#include "../nonlocal.h" #include "gtest/gtest.h" #include //--------------------------------------- -// Unit test of EkineticNew + NonlocalNew class -// EkineticNew and NonlocalNew are derivative classes of Operator, used to calculate the T+VNL matrix +// Unit test of EKinetic + Nonlocal class +// EKinetic and Nonlocal are derivative classes of Operator, used to calculate the T+VNL matrix // It use HContainer to store the real space HR matrix // In this test, we test the correctness and time consuming of 6 functions in T+VNL class // - initialize_HR() called in two constructors @@ -57,7 +57,7 @@ class TNLTest : public ::testing::Test ucell.atoms[0].iw2n[iw] = 0; } ucell.set_iat2iwt(2); - // for NonlocalNew + // for Nonlocal ucell.infoNL.Beta = new Numerical_Nonlocal[ucell.ntype]; ucell.atoms[0].ncpp.d_real.create(5, 5); ucell.atoms[0].ncpp.d_real.zero_out(); @@ -131,7 +131,7 @@ TEST_F(TNLTest, testTVNLcd2cd) Grid_Driver gd(0, 0); std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now(); hamilt::Operator>* op - = new hamilt::EkineticNew, std::complex>>(&hsk, + = new hamilt::EKinetic, std::complex>>(&hsk, kvec_d_in, HR, &ucell, @@ -139,7 +139,7 @@ TEST_F(TNLTest, testTVNLcd2cd) &gd, &intor_); hamilt::Operator>* op1 - = new hamilt::NonlocalNew, std::complex>>(&hsk, + = new hamilt::Nonlocal, std::complex>>(&hsk, kvec_d_in, HR, &ucell, diff --git a/source/source_lcao/module_operator_lcao/test/test_ekineticnew.cpp b/source/source_lcao/module_operator_lcao/test/test_ekinetic.cpp similarity index 92% rename from source/source_lcao/module_operator_lcao/test/test_ekineticnew.cpp rename to source/source_lcao/module_operator_lcao/test/test_ekinetic.cpp index dd81b95464..9edc265ccb 100644 --- a/source/source_lcao/module_operator_lcao/test/test_ekineticnew.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_ekinetic.cpp @@ -1,12 +1,12 @@ -#include "../ekinetic_new.h" +#include "../ekinetic.h" #include "gtest/gtest.h" //--------------------------------------- -// Unit test of EkineticNew class -// EkineticNew is a derivative class of Operator, it is used to calculate the kinetic matrix +// Unit test of EKinetic class +// EKinetic is a derivative class of Operator, it is used to calculate the kinetic matrix // It use HContainer to store the real space HR matrix -// In this test, we test the correctness and time consuming of 3 functions in EkineticNew class +// In this test, we test the correctness and time consuming of 3 functions in EKinetic class // - initialize_HR() called in constructor // - contributeHR() // - contributeHk() @@ -18,7 +18,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class EkineticNewTest : public ::testing::Test +class EKineticTest : public ::testing::Test { protected: void SetUp() override @@ -94,14 +94,14 @@ class EkineticNewTest : public ::testing::Test int my_rank = 0; }; -// using TEST_F to test EkineticNew -TEST_F(EkineticNewTest, constructHRd2d) +// using TEST_F to test EKinetic +TEST_F(EKineticTest, constructHRd2d) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of HR @@ -144,14 +144,14 @@ TEST_F(EkineticNewTest, constructHRd2d) } } -TEST_F(EkineticNewTest, constructHRd2cd) +TEST_F(EKineticTest, constructHRd2cd) { std::vector> kvec_d_in(2, ModuleBase::Vector3(0.0, 0.0, 0.0)); kvec_d_in[1] = ModuleBase::Vector3(0.1, 0.2, 0.3); hamilt::HS_Matrix_K> hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew, double>> + hamilt::EKinetic, double>> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of HR diff --git a/source/source_lcao/module_operator_lcao/test/test_ekineticnew_serial.cpp b/source/source_lcao/module_operator_lcao/test/test_ekinetic_serial.cpp similarity index 93% rename from source/source_lcao/module_operator_lcao/test/test_ekineticnew_serial.cpp rename to source/source_lcao/module_operator_lcao/test/test_ekinetic_serial.cpp index a1a498194f..87ce65d434 100644 --- a/source/source_lcao/module_operator_lcao/test/test_ekineticnew_serial.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_ekinetic_serial.cpp @@ -1,12 +1,12 @@ -#include "../ekinetic_new.h" +#include "../ekinetic.h" #include "gtest/gtest.h" //--------------------------------------- -// Unit test of EkineticNew class -// EkineticNew is a derivative class of Operator, it is used to calculate the kinetic matrix +// Unit test of EKinetic class +// EKinetic is a derivative class of Operator, it is used to calculate the kinetic matrix // It use HContainer to store the real space HR matrix -// In this test, we test the correctness and time consuming of 3 functions in EkineticNew class +// In this test, we test the correctness and time consuming of 3 functions in EKinetic class // - initialize_HR() called in constructor // - contributeHR() // - contributeHk() @@ -18,7 +18,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class EkineticNewTest : public ::testing::Test +class EKineticTest : public ::testing::Test { protected: void SetUp() override @@ -94,7 +94,7 @@ class EkineticNewTest : public ::testing::Test int my_rank = 0; }; // Test complex to complex template specialization -TEST_F(EkineticNewTest, constructHRcd2cd) +TEST_F(EKineticTest, constructHRcd2cd) { // Create complex HR container hamilt::HContainer>* HR_complex = new hamilt::HContainer>(paraV); @@ -104,7 +104,7 @@ TEST_F(EkineticNewTest, constructHRcd2cd) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew, std::complex>> + hamilt::EKinetic, std::complex>> op(&hsk, kvec_d_in, HR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -135,14 +135,14 @@ TEST_F(EkineticNewTest, constructHRcd2cd) } // Test set_HR_fixed method -TEST_F(EkineticNewTest, setHRFixed) +TEST_F(EKineticTest, setHRFixed) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); // First contributeHR - this creates and calculates HR_fixed internally @@ -184,7 +184,7 @@ TEST_F(EkineticNewTest, setHRFixed) } // Test with single atom system -TEST_F(EkineticNewTest, singleAtom) +TEST_F(EKineticTest, singleAtom) { // Create a single atom unit cell UnitCell ucell_single; @@ -227,7 +227,7 @@ TEST_F(EkineticNewTest, singleAtom) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR_single, &ucell_single, {1.0}, &gd, &intor_); op.contributeHR(); @@ -249,7 +249,7 @@ TEST_F(EkineticNewTest, singleAtom) } // Test with different orbital quantum numbers (L, N, M) -TEST_F(EkineticNewTest, differentOrbitals) +TEST_F(EKineticTest, differentOrbitals) { // Modify orbital quantum numbers to test different L, N, M values ucell.atoms[0].iw2l[0] = 0; // s orbital @@ -275,7 +275,7 @@ TEST_F(EkineticNewTest, differentOrbitals) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -291,14 +291,14 @@ TEST_F(EkineticNewTest, differentOrbitals) } // Test force calculation -TEST_F(EkineticNewTest, forceCalculation) +TEST_F(EKineticTest, forceCalculation) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -359,7 +359,7 @@ TEST_F(EkineticNewTest, forceCalculation) } // Test stress calculation -TEST_F(EkineticNewTest, stressCalculation) +TEST_F(EKineticTest, stressCalculation) { // Initialize unit cell parameters for stress calculation ucell.lat0 = 1.0; @@ -373,7 +373,7 @@ TEST_F(EkineticNewTest, stressCalculation) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -425,7 +425,7 @@ TEST_F(EkineticNewTest, stressCalculation) } // Test force and stress together -TEST_F(EkineticNewTest, forceStressTogether) +TEST_F(EKineticTest, forceStressTogether) { // Initialize unit cell parameters for stress calculation ucell.lat0 = 1.0; @@ -439,7 +439,7 @@ TEST_F(EkineticNewTest, forceStressTogether) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -494,14 +494,14 @@ TEST_F(EkineticNewTest, forceStressTogether) } // Test with null density matrix pointer -TEST_F(EkineticNewTest, nullDensityMatrix) +TEST_F(EKineticTest, nullDensityMatrix) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -520,7 +520,7 @@ TEST_F(EkineticNewTest, nullDensityMatrix) } // Test with zero orbital cutoff -TEST_F(EkineticNewTest, zeroOrbitalCutoff) +TEST_F(EKineticTest, zeroOrbitalCutoff) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); @@ -528,7 +528,7 @@ TEST_F(EkineticNewTest, zeroOrbitalCutoff) Grid_Driver gd(0, 0); // Use zero cutoff - should result in no atom pairs (except possibly self-interaction) - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {0.0}, &gd, &intor_); op.contributeHR(); @@ -539,7 +539,7 @@ TEST_F(EkineticNewTest, zeroOrbitalCutoff) } // Test with large orbital cutoff -TEST_F(EkineticNewTest, largeOrbitalCutoff) +TEST_F(EKineticTest, largeOrbitalCutoff) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); @@ -547,7 +547,7 @@ TEST_F(EkineticNewTest, largeOrbitalCutoff) Grid_Driver gd(0, 0); // Use very large cutoff - should include all atoms - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1000.0}, &gd, &intor_); op.contributeHR(); @@ -563,7 +563,7 @@ TEST_F(EkineticNewTest, largeOrbitalCutoff) } // Test with atoms at cutoff boundary -TEST_F(EkineticNewTest, cutoffBoundary) +TEST_F(EKineticTest, cutoffBoundary) { // Set up atoms at specific distances to test cutoff boundary ucell.lat0 = 1.0; @@ -581,7 +581,7 @@ TEST_F(EkineticNewTest, cutoffBoundary) Grid_Driver gd(0, 0); // Use cutoff of 5.0 - atoms at exactly this distance should be excluded - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {2.5}, &gd, &intor_); op.contributeHR(); @@ -591,14 +591,14 @@ TEST_F(EkineticNewTest, cutoffBoundary) } // Test multiple contributeHR calls for accumulation -TEST_F(EkineticNewTest, multipleContributeHRAccumulation) +TEST_F(EKineticTest, multipleContributeHRAccumulation) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew> + hamilt::EKinetic> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); // First call @@ -657,7 +657,7 @@ TEST_F(EkineticNewTest, multipleContributeHRAccumulation) } // Test force calculation with npol=2 (nspin=4, spin-orbit coupling) -TEST_F(EkineticNewTest, forceCalculationNpol2) +TEST_F(EKineticTest, forceCalculationNpol2) { // Set up unit cell with npol=2 ucell.set_iat2iwt(2); // npol=2 @@ -682,7 +682,7 @@ TEST_F(EkineticNewTest, forceCalculationNpol2) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew, std::complex>> + hamilt::EKinetic, std::complex>> op(&hsk, kvec_d_in, HR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -743,7 +743,7 @@ TEST_F(EkineticNewTest, forceCalculationNpol2) } // Test stress calculation with npol=2 (nspin=4, spin-orbit coupling) -TEST_F(EkineticNewTest, stressCalculationNpol2) +TEST_F(EKineticTest, stressCalculationNpol2) { // Set up unit cell with npol=2 ucell.set_iat2iwt(2); // npol=2 @@ -775,7 +775,7 @@ TEST_F(EkineticNewTest, stressCalculationNpol2) hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::EkineticNew, std::complex>> + hamilt::EKinetic, std::complex>> op(&hsk, kvec_d_in, HR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); diff --git a/source/source_lcao/module_operator_lcao/test/test_nonlocalnew.cpp b/source/source_lcao/module_operator_lcao/test/test_nonlocal.cpp similarity index 94% rename from source/source_lcao/module_operator_lcao/test/test_nonlocalnew.cpp rename to source/source_lcao/module_operator_lcao/test/test_nonlocal.cpp index e137f7ac73..1aef3dede1 100644 --- a/source/source_lcao/module_operator_lcao/test/test_nonlocalnew.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_nonlocal.cpp @@ -1,13 +1,13 @@ -#include "../nonlocal_new.h" +#include "../nonlocal.h" #include "gtest/gtest.h" #include //--------------------------------------- -// Unit test of NonlocalNew class -// NonlocalNew is a derivative class of Operator, it is used to calculate the kinetic matrix +// Unit test of Nonlocal class +// Nonlocal is a derivative class of Operator, it is used to calculate the kinetic matrix // It use HContainer to store the real space HR matrix -// In this test, we test the correctness and time consuming of 3 functions in NonlocalNew class +// In this test, we test the correctness and time consuming of 3 functions in Nonlocal class // - initialize_HR() called in constructor // - contributeHR() // - contributeHk() @@ -19,7 +19,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class NonlocalNewTest : public ::testing::Test +class NonlocalTest : public ::testing::Test { protected: void SetUp() override @@ -119,8 +119,8 @@ class NonlocalNewTest : public ::testing::Test int my_rank = 0; }; -// using TEST_F to test NonlocalNew -TEST_F(NonlocalNewTest, constructHRd2d) +// using TEST_F to test Nonlocal +TEST_F(NonlocalTest, constructHRd2d) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV, true); @@ -129,7 +129,7 @@ TEST_F(NonlocalNewTest, constructHRd2d) // check some input values EXPECT_EQ(ucell.infoNL.Beta[0].get_rcut_max(), 1.0); std::chrono::high_resolution_clock::time_point start_time = std::chrono::high_resolution_clock::now(); - hamilt::NonlocalNew> + hamilt::Nonlocal> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); std::chrono::high_resolution_clock::time_point end_time = std::chrono::high_resolution_clock::now(); std::chrono::duration elapsed_time @@ -192,14 +192,14 @@ TEST_F(NonlocalNewTest, constructHRd2d) << std::endl; } -TEST_F(NonlocalNewTest, constructHRd2cd) +TEST_F(NonlocalTest, constructHRd2cd) { std::vector> kvec_d_in(2, ModuleBase::Vector3(0.0, 0.0, 0.0)); kvec_d_in[1] = ModuleBase::Vector3(0.1, 0.2, 0.3); hamilt::HS_Matrix_K> hsk(paraV); hsk.set_zero_hk(); Grid_Driver gd(0, 0); - hamilt::NonlocalNew, double>> + hamilt::Nonlocal, double>> op(&hsk, kvec_d_in, HR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of HR diff --git a/source/source_lcao/module_operator_lcao/test/test_overlapnew.cpp b/source/source_lcao/module_operator_lcao/test/test_overlap.cpp similarity index 91% rename from source/source_lcao/module_operator_lcao/test/test_overlapnew.cpp rename to source/source_lcao/module_operator_lcao/test/test_overlap.cpp index 19d5e57737..e3c017857b 100644 --- a/source/source_lcao/module_operator_lcao/test/test_overlapnew.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_overlap.cpp @@ -1,12 +1,12 @@ -#include "../overlap_new.h" +#include "../overlap.h" #include "gtest/gtest.h" //--------------------------------------- -// Unit test of OverlapNew class -// OverlapNew is a derivative class of Operator, it is used to calculate the overlap matrix +// Unit test of Overlap class +// Overlap is a derivative class of Operator, it is used to calculate the overlap matrix // It use HContainer to store the real space SR matrix -// In this test, we test the correctness and time consuming of 3 functions in OverlapNew class +// In this test, we test the correctness and time consuming of 3 functions in Overlap class // - initialize_SR() called in constructor // - contributeHR() // - contributeHk() @@ -18,7 +18,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class OverlapNewTest : public ::testing::Test +class OverlapTest : public ::testing::Test { protected: void SetUp() override @@ -94,14 +94,14 @@ class OverlapNewTest : public ::testing::Test int my_rank = 0; }; -// using TEST_F to test OverlapNew -TEST_F(OverlapNewTest, constructHRd2d) +// using TEST_F to test Overlap +TEST_F(OverlapTest, constructHRd2d) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of SR @@ -128,14 +128,14 @@ TEST_F(OverlapNewTest, constructHRd2d) } } -TEST_F(OverlapNewTest, constructHRd2cd) +TEST_F(OverlapTest, constructHRd2cd) { std::vector> kvec_d_in(2, ModuleBase::Vector3(0.0, 0.0, 0.0)); kvec_d_in[1] = ModuleBase::Vector3(0.1, 0.2, 0.3); hamilt::HS_Matrix_K> hsk(paraV); hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, double>> + hamilt::Overlap, double>> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of SR diff --git a/source/source_lcao/module_operator_lcao/test/test_overlapnew_cd.cpp b/source/source_lcao/module_operator_lcao/test/test_overlap_cd.cpp similarity index 93% rename from source/source_lcao/module_operator_lcao/test/test_overlapnew_cd.cpp rename to source/source_lcao/module_operator_lcao/test/test_overlap_cd.cpp index d29c0cd840..ad2e8daf7e 100644 --- a/source/source_lcao/module_operator_lcao/test/test_overlapnew_cd.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_overlap_cd.cpp @@ -1,12 +1,12 @@ -#include "../overlap_new.h" +#include "../overlap.h" #include "gtest/gtest.h" //--------------------------------------- -// Unit test of OverlapNew class -// OverlapNew is a derivative class of Operator, it is used to calculate the overlap matrix +// Unit test of Overlap class +// Overlap is a derivative class of Operator, it is used to calculate the overlap matrix // It use HContainer to store the real space SR matrix -// In this test, we test the correctness and time consuming of 3 functions in OverlapNew class +// In this test, we test the correctness and time consuming of 3 functions in Overlap class // - initialize_SR() called in constructor // - contributeHR() // - contributeHk() @@ -17,7 +17,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class OverlapNewTest : public ::testing::Test +class OverlapTest : public ::testing::Test { protected: void SetUp() override @@ -93,7 +93,7 @@ class OverlapNewTest : public ::testing::Test int my_rank = 0; }; -TEST_F(OverlapNewTest, constructHRcd2cd) +TEST_F(OverlapTest, constructHRcd2cd) { int npol = ucell.get_npol(); std::vector> kvec_d_in(2, ModuleBase::Vector3(0.0, 0.0, 0.0)); @@ -101,7 +101,7 @@ TEST_F(OverlapNewTest, constructHRcd2cd) hamilt::HS_Matrix_K> hsk(paraV); hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, std::complex>> + hamilt::Overlap, std::complex>> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); // check the value of SR diff --git a/source/source_lcao/module_operator_lcao/test/test_overlapnew_serial.cpp b/source/source_lcao/module_operator_lcao/test/test_overlap_serial.cpp similarity index 92% rename from source/source_lcao/module_operator_lcao/test/test_overlapnew_serial.cpp rename to source/source_lcao/module_operator_lcao/test/test_overlap_serial.cpp index a0653a8953..98b8e4d741 100644 --- a/source/source_lcao/module_operator_lcao/test/test_overlapnew_serial.cpp +++ b/source/source_lcao/module_operator_lcao/test/test_overlap_serial.cpp @@ -1,12 +1,12 @@ -#include "../overlap_new.h" +#include "../overlap.h" #include "gtest/gtest.h" //--------------------------------------- -// Unit test of OverlapNew class -// OverlapNew is a derivative class of Operator, it is used to calculate the overlap matrix +// Unit test of Overlap class +// Overlap is a derivative class of Operator, it is used to calculate the overlap matrix // It use HContainer to store the real space SR matrix -// In this test, we test the correctness and time consuming of 3 functions in OverlapNew class +// In this test, we test the correctness and time consuming of 3 functions in Overlap class // - initialize_SR() called in constructor // - contributeHR() // - contributeHk() @@ -18,7 +18,7 @@ // modify test_size to test different size of unitcell int test_size = 10; int test_nw = 10; -class OverlapNewTest : public ::testing::Test +class OverlapTest : public ::testing::Test { protected: void SetUp() override @@ -93,7 +93,7 @@ class OverlapNewTest : public ::testing::Test int dsize; int my_rank = 0; }; -TEST_F(OverlapNewTest, constructHRcd2cd) +TEST_F(OverlapTest, constructHRcd2cd) { // Create complex SR container hamilt::HContainer>* SR_complex = new hamilt::HContainer>(paraV); @@ -103,7 +103,7 @@ TEST_F(OverlapNewTest, constructHRcd2cd) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, std::complex>> + hamilt::Overlap, std::complex>> op(&hsk, kvec_d_in, nullptr, SR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -134,14 +134,14 @@ TEST_F(OverlapNewTest, constructHRcd2cd) } // Test getSk method -TEST_F(OverlapNewTest, getSk) +TEST_F(OverlapTest, getSk) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -162,7 +162,7 @@ TEST_F(OverlapNewTest, getSk) } // Test k-vector caching optimization -TEST_F(OverlapNewTest, kVectorCaching) +TEST_F(OverlapTest, kVectorCaching) { std::vector> kvec_d_in(2, ModuleBase::Vector3(0.1, 0.2, 0.3)); kvec_d_in[1] = ModuleBase::Vector3(0.1, 0.2, 0.3); // Same k-vector @@ -170,7 +170,7 @@ TEST_F(OverlapNewTest, kVectorCaching) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, double>> + hamilt::Overlap, double>> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -191,7 +191,7 @@ TEST_F(OverlapNewTest, kVectorCaching) } // Test with single atom system -TEST_F(OverlapNewTest, singleAtom) +TEST_F(OverlapTest, singleAtom) { // Create a single atom unit cell UnitCell ucell_single; @@ -234,7 +234,7 @@ TEST_F(OverlapNewTest, singleAtom) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR_single, &ucell_single, {1.0}, &gd, &intor_); op.contributeHR(); @@ -255,7 +255,7 @@ TEST_F(OverlapNewTest, singleAtom) } // Test with different orbital quantum numbers (L, N, M) -TEST_F(OverlapNewTest, differentOrbitals) +TEST_F(OverlapTest, differentOrbitals) { // Modify orbital quantum numbers to test different L, N, M values ucell.atoms[0].iw2l[0] = 0; // s orbital @@ -281,7 +281,7 @@ TEST_F(OverlapNewTest, differentOrbitals) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -297,14 +297,14 @@ TEST_F(OverlapNewTest, differentOrbitals) } // Test force calculation -TEST_F(OverlapNewTest, forceCalculation) +TEST_F(OverlapTest, forceCalculation) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -352,7 +352,7 @@ TEST_F(OverlapNewTest, forceCalculation) } // Test stress calculation -TEST_F(OverlapNewTest, stressCalculation) +TEST_F(OverlapTest, stressCalculation) { // Initialize unit cell parameters for stress calculation ucell.lat0 = 1.0; @@ -366,7 +366,7 @@ TEST_F(OverlapNewTest, stressCalculation) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -418,7 +418,7 @@ TEST_F(OverlapNewTest, stressCalculation) } // Test force and stress together -TEST_F(OverlapNewTest, forceStressTogether) +TEST_F(OverlapTest, forceStressTogether) { // Initialize unit cell parameters for stress calculation ucell.lat0 = 1.0; @@ -432,7 +432,7 @@ TEST_F(OverlapNewTest, forceStressTogether) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -487,7 +487,7 @@ TEST_F(OverlapNewTest, forceStressTogether) } // Test with zero orbital cutoff -TEST_F(OverlapNewTest, zeroOrbitalCutoff) +TEST_F(OverlapTest, zeroOrbitalCutoff) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); @@ -495,7 +495,7 @@ TEST_F(OverlapNewTest, zeroOrbitalCutoff) Grid_Driver gd(0, 0); // Use zero cutoff - should result in no atom pairs (except possibly self-interaction) - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {0.0}, &gd, &intor_); op.contributeHR(); @@ -506,7 +506,7 @@ TEST_F(OverlapNewTest, zeroOrbitalCutoff) } // Test with large orbital cutoff -TEST_F(OverlapNewTest, largeOrbitalCutoff) +TEST_F(OverlapTest, largeOrbitalCutoff) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); @@ -514,7 +514,7 @@ TEST_F(OverlapNewTest, largeOrbitalCutoff) Grid_Driver gd(0, 0); // Use very large cutoff - should include all atoms - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1000.0}, &gd, &intor_); op.contributeHR(); @@ -530,7 +530,7 @@ TEST_F(OverlapNewTest, largeOrbitalCutoff) } // Test with atoms at cutoff boundary -TEST_F(OverlapNewTest, cutoffBoundary) +TEST_F(OverlapTest, cutoffBoundary) { // Set up atoms at specific distances to test cutoff boundary ucell.lat0 = 1.0; @@ -548,7 +548,7 @@ TEST_F(OverlapNewTest, cutoffBoundary) Grid_Driver gd(0, 0); // Use cutoff of 5.0 - atoms at exactly this distance should be excluded - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {2.5}, &gd, &intor_); op.contributeHR(); @@ -558,7 +558,7 @@ TEST_F(OverlapNewTest, cutoffBoundary) } // Test Hermitian property of SK matrix -TEST_F(OverlapNewTest, hermitianProperty) +TEST_F(OverlapTest, hermitianProperty) { // Use gamma point to test that diagonal elements are real std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); @@ -566,7 +566,7 @@ TEST_F(OverlapNewTest, hermitianProperty) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, double>> + hamilt::Overlap, double>> op(&hsk, kvec_d_in, nullptr, SR, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -592,7 +592,7 @@ TEST_F(OverlapNewTest, hermitianProperty) } // Test with null SR pointer (should skip initialization) -TEST_F(OverlapNewTest, nullSRPointer) +TEST_F(OverlapTest, nullSRPointer) { std::vector> kvec_d_in(1, ModuleBase::Vector3(0.0, 0.0, 0.0)); hamilt::HS_Matrix_K hsk(paraV); @@ -600,7 +600,7 @@ TEST_F(OverlapNewTest, nullSRPointer) Grid_Driver gd(0, 0); // Pass nullptr for SR - should not crash during construction - hamilt::OverlapNew> + hamilt::Overlap> op(&hsk, kvec_d_in, nullptr, nullptr, &ucell, {1.0}, &gd, &intor_); // Test passes if no crash occurs during construction @@ -608,7 +608,7 @@ TEST_F(OverlapNewTest, nullSRPointer) } // Test force calculation with npol=2 (nspin=4, spin-orbit coupling) -TEST_F(OverlapNewTest, forceCalculationNpol2) +TEST_F(OverlapTest, forceCalculationNpol2) { // Set up unit cell with npol=2 ucell.set_iat2iwt(2); // npol=2 @@ -633,7 +633,7 @@ TEST_F(OverlapNewTest, forceCalculationNpol2) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, std::complex>> + hamilt::Overlap, std::complex>> op(&hsk, kvec_d_in, nullptr, SR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); @@ -694,7 +694,7 @@ TEST_F(OverlapNewTest, forceCalculationNpol2) } // Test stress calculation with npol=2 (nspin=4, spin-orbit coupling) -TEST_F(OverlapNewTest, stressCalculationNpol2) +TEST_F(OverlapTest, stressCalculationNpol2) { // Set up unit cell with npol=2 ucell.set_iat2iwt(2); // npol=2 @@ -726,7 +726,7 @@ TEST_F(OverlapNewTest, stressCalculationNpol2) hsk.set_zero_sk(); Grid_Driver gd(0, 0); - hamilt::OverlapNew, std::complex>> + hamilt::Overlap, std::complex>> op(&hsk, kvec_d_in, nullptr, SR_complex, &ucell, {1.0}, &gd, &intor_); op.contributeHR(); diff --git a/source/source_lcao/module_rdmft/rdmft_pot.cpp b/source/source_lcao/module_rdmft/rdmft_pot.cpp index a962c2cac1..9c3d708fa1 100644 --- a/source/source_lcao/module_rdmft/rdmft_pot.cpp +++ b/source/source_lcao/module_rdmft/rdmft_pot.cpp @@ -12,8 +12,8 @@ #include "source_lcao/module_ri/RI_2D_Comm.h" #include "source_lcao/module_operator_lcao/op_exx_lcao.h" #endif -#include "source_lcao/module_operator_lcao/ekinetic_new.h" -#include "source_lcao/module_operator_lcao/nonlocal_new.h" +#include "source_lcao/module_operator_lcao/ekinetic.h" +#include "source_lcao/module_operator_lcao/nonlocal.h" #include "source_lcao/module_operator_lcao/veff_lcao.h" namespace rdmft @@ -51,7 +51,7 @@ void RDMFT::cal_V_TV() { HR_TV->set_zero(); - V_ekinetic_potential = new hamilt::EkineticNew>(hsk_TV, + V_ekinetic_potential = new hamilt::EKinetic>(hsk_TV, kv->kvec_d, HR_TV, this->ucell, @@ -59,7 +59,7 @@ void RDMFT::cal_V_TV() this->gd, two_center_bundle->kinetic_orb.get()); - V_nonlocal = new hamilt::NonlocalNew>(hsk_TV, + V_nonlocal = new hamilt::Nonlocal>(hsk_TV, kv->kvec_d, HR_TV, this->ucell, From 7fc141984e98475c6ba21bc75211bf15067869bc Mon Sep 17 00:00:00 2001 From: dyzheng Date: Wed, 28 Jan 2026 15:06:51 +0800 Subject: [PATCH 2/3] Fix: stress of nonlocal --- .../nonlocal_force_stress.hpp | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp index 3b796cb347..46add42fa7 100644 --- a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp @@ -182,8 +182,37 @@ void Nonlocal>::cal_force_stress(const bool cal_force, } } - // Finalize with MPI reduction and post-processing - OperatorForceStress::finalize_force_stress(cal_force, cal_stress, this->ucell, stress_tmp, force, stress, 2.0, 2.0); + if (cal_force) + { +#ifdef __MPI + // sum up the occupation matrix + Parallel_Reduce::reduce_all(force.c, force.nr * force.nc); +#endif + for (int i = 0; i < force.nr * force.nc; i++) + { + force.c[i] *= 2.0; + } + } + + // stress renormalization + if (cal_stress) + { +#ifdef __MPI + // sum up the occupation matrix + Parallel_Reduce::reduce_all(stress_tmp.data(), 6); +#endif + const double weight = this->ucell->lat0 / this->ucell->omega; + for (int i = 0; i < 6; i++) + { + stress.c[i] = stress_tmp[i] * weight; + } + stress.c[8] = stress.c[5]; // stress(2,2) + stress.c[7] = stress.c[4]; // stress(2,1) + stress.c[6] = stress.c[2]; // stress(2,0) + stress.c[5] = stress.c[4]; // stress(1,2) + stress.c[4] = stress.c[3]; // stress(1,1) + stress.c[3] = stress.c[1]; // stress(1,0) + } ModuleBase::timer::tick("Nonlocal", "cal_force_stress"); } From 7f4e9b8ca34aef408cef54bb3e138e72922c2d4a Mon Sep 17 00:00:00 2001 From: dyzheng Date: Thu, 29 Jan 2026 13:16:55 +0800 Subject: [PATCH 3/3] Fix: complining error --- .../source_lcao/module_operator_lcao/nonlocal_force_stress.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp index 46add42fa7..55c9ec6b42 100644 --- a/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp +++ b/source/source_lcao/module_operator_lcao/nonlocal_force_stress.hpp @@ -1,6 +1,7 @@ #pragma once #include "nonlocal.h" #include "operator_force_stress_utils.h" +#include "source_base/parallel_reduce.h" #include "source_base/timer.h" namespace hamilt