Docs: suggesting smaller mixing parameters for spin-polarized calculations#374
Closed
Cstandardlib wants to merge 532 commits into
Closed
Docs: suggesting smaller mixing parameters for spin-polarized calculations#374Cstandardlib wants to merge 532 commits into
Cstandardlib wants to merge 532 commits into
Conversation
* Docs: update the documentation of abacuslite * update the online documentation
* Fix formatting issue for input-main and update type info - Update the type field of parameter item field where multiple values are expected. - Fixed formatting issue in input-main.md where > and < are not escaped correctly. * Fix more formating issues Fixed some LaTeX issue and unify the description of types. * Add automatic escaping for < and > Escaping is performed when the md file is generated. * Minor wording updates
* fix: nspin = 2 for init_chg=dm * Fix: findmkl.cmake error * Fix: init_chg hr support nspin=2 * Fix: refactor for short esolver_ks_lcao.cpp * Fix: rewrite init_dm_from_file_test to match new CSR format, add init_chg=hr tests The CSR file format was updated (commit 9c1a061) with spin info, ucell data, and CSR comment block headers, but the unit test still wrote the old format, causing parse failures. Rewrote write_test_csr to use write_dmr_csr so the test always produces the current format. Added HR read tests for nspin=1 and nspin=2 covering the init_chg=hr code path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix: replace system() calls with POSIX mkdir in init_dm_from_file test Use POSIX mkdir() from <sys/stat.h> instead of system("mkdir -p") for C++11 compatibility, and remove system("rm -rf") cleanup calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: dyzheng <zhengdy@bjaisi.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* Update test for MODULE_HAMILT and MODULE_ESTATE * Update tests for MODULE_LCAO and MODULE_PW * Complete All * Update github workflow * Fix MODULE_LR
Co-authored-by: linpz <linpz@mail.ustc.edu.cn>
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [crazy-max/ghaction-github-pages](https://github.com/crazy-max/ghaction-github-pages) from 4 to 5. - [Release notes](https://github.com/crazy-max/ghaction-github-pages/releases) - [Commits](crazy-max/ghaction-github-pages@v4...v5) --- updated-dependencies: - dependency-name: crazy-max/ghaction-github-pages dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6 to 7. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](actions/upload-artifact@v6...v7) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…e GPU calculations (#6995) * Optimize memory management of RT-TDDFT to enable larger scale calculation * Fixed a bug where calculation results were incorrect due to not allocating H matrix on device
* Refactor cg interface from Tensor to T * * Remove redundant code * Remove redundant code
* fix some small places in source_base * refactor(cell_index): replace std::out_of_range with WARNING_QUIT Replace standard exception handling with project-specific error handling in cell_index.cpp to comply with ABACUS code style guidelines. Changes: - Replace 3 instances of 'throw std::out_of_range' with ModuleBase::WARNING_QUIT in functions: iw2l(), iw2z(), iw2m() - Remove unnecessary #include <stdexcept> - Fix incorrect error message strings in iw2z() and iw2m() (was 'iw2l') This change follows the cpp-code-style skill rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions for error handling in the ABACUS project. * refactor(cell_index): add const qualifier to member functions Add const qualifier to all getter and helper member functions in CellIndex class to improve const-correctness according to cpp-code-style skill guidelines. Changes in cell_index.h: - Add const to all public getter functions: get_nat(), get_ntype(), get_nw(), get_iwt(), get_maxL(), get_nchi(), get_atom_label() - Add const to write_orb_info() and change parameter to const reference - Add const to private helper functions: iat2it(), iat2ia(), iw2l(), iw2z(), iw2m() Changes in cell_index.cpp: - Update all function definitions to match header declarations - Change write_orb_info parameter from std::string to const std::string& This follows the ABACUS code style rule that getter functions and functions that do not modify member state should be marked const. * fix(density_matrix): 使用WARNING_QUIT替代throw语句 - 在density_matrix.cpp中添加了tool_quit.h头文件 - 将第616行的throw std::string替换为ModuleBase::WARNING_QUIT - 统一了项目的错误处理方式,符合ABACUS代码规范 修改文件: - source/source_estate/module_dm/density_matrix.cpp 影响范围:错误处理流程 * fix(symmetry_rotation): 修复C++14泛型lambda语法,改为C++11兼容写法 - 将泛型lambda [](auto x) 改为 [](double x) - 符合ABACUS项目只支持C++11标准的要求 - Matrix3的元素类型为double,无需泛型 修改文件: - source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp * refactor(restart): replace std::runtime_error with WARNING_QUIT Replace standard exception handling with project-specific error handling in restart.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 4 instances of 'throw std::runtime_error' with ModuleBase::WARNING_QUIT in functions: write_file2() and read_file2() - Remove unnecessary #include <stdexcept> - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. * refactor(write_libxc_r): replace std::exception with WARNING_QUIT Replace standard exception handling with project-specific error handling in write_libxc_r.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 9 instances of throw with ModuleBase::WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - Remove #include <stdexcept> - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. * style: unify code indentation to 4-space in source_md files - Replace tabs with 4 spaces in md_func.cpp (lines 198-209) - Replace tabs with 4 spaces in md_base.cpp (line 65) - Replace tabs with 4 spaces in run_md.cpp (lines 59-61) * refactor(source_io): replace std::exception with WARNING_QUIT Replace standard exception handling with project-specific error handling in source_io directory to comply with cpp-code-style skill guidelines. Changes: - Replace all instances of throw with ModuleBase::WARNING_QUIT - throw std::runtime_error -> WARNING_QUIT - throw std::logic_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - Remove unnecessary #include <stdexcept> - Add #include "source_base/tool_quit.h" where needed Files modified: - module_restart/restart.cpp (4 instances) - module_chgpot/write_libxc_r.cpp (9 instances) - module_wannier/to_wannier90_lcao.h (1 instance) - module_wannier/to_wannier90_lcao_in_pw.h (1 instance) - module_wannier/to_wannier90_pw.h (1 instance) - module_wannier/to_wannier90.cpp (1 instance) - module_unk/berryphase.h (1 instance) - module_parameter/read_input_tool.h (1 instance) - module_parameter/input_conv.cpp (1 instance) This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions. * revert(vector3): 撤销operator==的eps精度比较修改 - 恢复Vector3的operator==为直接比较 - 移除之前添加的eps精度比较逻辑 修改文件: - source/source_base/vector3.h * Revert "refactor(source_io): replace std::exception with WARNING_QUIT" This reverts commit 39811c4. * Revert "refactor(write_libxc_r): replace std::exception with WARNING_QUIT" This reverts commit f0558c5. * Revert "refactor(restart): replace std::runtime_error with WARNING_QUIT" This reverts commit 5682e00. --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3 to 4. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](docker/setup-buildx-action@v3...v4) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](docker/login-action@v3...v4) --- updated-dependencies: - dependency-name: docker/login-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5 to 6. - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](docker/metadata-action@v5...v6) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6 to 7. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](docker/build-push-action@v6...v7) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* refactor(esolver): extract update_cell_pw function from esolver_ks_pw - Create new files update_cell_pw.h and update_cell_pw.cpp in source_pw/module_pwdft - Extract cell parameter update logic from ESolver_KS_PW::before_scf() - The new function handles: 1. Rescaling non-local pseudopotential (ppcell.rescale_vnl) 2. Reinitializing plane wave basis grids (pw_wfc->initgrids/initparameters/collect_local_pw) - Keep psi initialization (p_psi_init->prepare_init) in esolver to avoid template dependency - Update CMakeLists.txt and Makefile.Objects for new source files This refactoring improves code organization by moving PW-specific cell update logic out of the esolver, making the esolver code cleaner and more focused on high-level workflow control. * refactor(esolver): extract EXX initialization into Exx_Helper::init - Add init() function to Exx_Helper class for EXX initialization - The init function handles: 1. Check if calculation type is scf/relax/cell-relax/md 2. Check if cal_exx is enabled 3. Set XC first loop if separate_loop is true 4. Set wg pointer for EXX calculation - Simplify ESolver_KS_PW::before_all_runners() by calling exx_helper.init() - Move EXX-specific logic out of esolver, improving code organization This refactoring makes the esolver code cleaner and more focused on high-level workflow control. * refactor(esolver): extract DFT+U initialization into pw::iter_init_dftu_pw - Create new files dftu_pw.h and dftu_pw.cpp in source_pw/module_pwdft - Extract DFT+U occupation update logic from ESolver_KS_PW::iter_init() - The new function handles: 1. Check if DFT+U is enabled 2. Check iteration and step conditions 3. Call cal_occ_pw for occupation calculation 4. Output DFT+U results - Use void* for psi parameter to avoid template dependency - Update CMakeLists.txt and Makefile.Objects for new source files This refactoring improves code organization by moving DFT+U specific logic out of the esolver, making the esolver code cleaner and more focused on high-level workflow control. * refactor(esolver): extract DeltaSpin lambda loop into pw::run_deltaspin_lambda_loop - Create new files deltaspin_pw.h and deltaspin_pw.cpp in source_pw/module_pwdft - Extract DeltaSpin lambda loop logic from ESolver_KS_PW::hamilt2rho_single() - The new function handles: 1. Check if DeltaSpin (sc_mag_switch) is enabled 2. Get SpinConstrain singleton instance 3. Run lambda loop to constrain atomic magnetic moments 4. Return skip_solve flag to control solver execution - Add Doxygen-style comments in English - Update CMakeLists.txt and Makefile.Objects for new source files This refactoring improves code organization by moving DeltaSpin-specific logic out of the esolver, making the esolver code cleaner and more focused on high-level workflow control. * refactor(esolver): extract DeltaSpin oscillation check into pw::check_deltaspin_oscillation - Add check_deltaspin_oscillation() function to deltaspin_pw.h/cpp - Extract DeltaSpin SCF oscillation check logic from ESolver_KS_PW::iter_finish() - The new function handles: 1. Check if DeltaSpin (sc_mag_switch) is enabled 2. Get SpinConstrain singleton instance 3. Detect SCF oscillation using if_scf_oscillate() 4. Set mixing_restart_step if oscillation detected - Add Doxygen-style comments in English This refactoring consolidates all DeltaSpin-related functions in one place, making the code more modular and easier to maintain. * refactor(esolver): extract EXX before_scf setup into Exx_Helper::before_scf - Add before_scf() function to Exx_Helper class - Extract EXX setup logic from ESolver_KS_PW::before_scf() - The new function handles: 1. Check if calculation type is valid (scf/relax/cell-relax/md) 2. Check if EXX is enabled and basis type is PW 3. Set EXX helper to Hamiltonian 4. Set psi for EXX calculation - Use void* for p_hamilt parameter to avoid circular dependency - Add Doxygen-style comments in English This refactoring consolidates EXX-related setup logic in the Exx_Helper class, making the code more modular and easier to maintain. * refactor(esolver): extract EXX iter_finish logic into Exx_Helper::iter_finish - Add iter_finish() function to Exx_Helper class - Extract EXX convergence handling logic from ESolver_KS_PW::iter_finish() - The new function handles: 1. Check if EXX is enabled 2. Handle separate_loop mode for EXX convergence 3. Calculate EXX energy difference for energy threshold 4. Update potential if SCF not converged 5. Increment EXX iteration counter - Use Charge* and void* parameters to avoid circular dependency - Add Doxygen-style comments in English This refactoring consolidates all EXX-related functions in the Exx_Helper class, making the code more modular and easier to maintain. --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* Allow compile LCAO version on DSP * Nooo, I shouldn't have modified the INPUT file
* small format changes * refactor(esolver): extract charge density symmetrization to Symmetry_rho::symmetrize_rho - Add static method symmetrize_rho() in Symmetry_rho class - Replace 7 duplicate code blocks with single function call - Simplify code from 35 lines to 7 lines (80% reduction) - Improve code readability and maintainability Modified files: - source_estate/module_charge/symmetry_rho.h: add static method declaration - source_estate/module_charge/symmetry_rho.cpp: implement static method - source_esolver/esolver_ks_lcao.cpp: 2 calls updated - source_esolver/esolver_ks_pw.cpp: 1 call updated - source_esolver/esolver_ks_lcao_tddft.cpp: 1 call updated - source_esolver/esolver_ks_lcaopw.cpp: 1 call updated - source_esolver/esolver_of.cpp: 1 call updated - source_esolver/esolver_sdft_pw.cpp: 1 call updated This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DeltaSpin lambda loop to deltaspin_lcao module - Create new files deltaspin_lcao.h/cpp in module_deltaspin - Extract DeltaSpin lambda loop logic from ESolver_KS_LCAO - Simplify code from 18 lines to 1 line in hamilt2rho_single - Separate LCAO and PW implementations for DeltaSpin Modified files: - source_esolver/esolver_ks_lcao.cpp: replace inline code with function call - source_lcao/module_deltaspin/CMakeLists.txt: add new source file New files: - source_lcao/module_deltaspin/deltaspin_lcao.h: function declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: function implementation This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): complete DeltaSpin refactoring in LCAO - Add init_deltaspin_lcao() function for DeltaSpin initialization - Add cal_mi_lcao_wrapper() function for magnetic moment calculation - Refactor all DeltaSpin-related code in esolver_ks_lcao.cpp - Simplify code from 29 lines to 3 lines (90% reduction) Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 3 code blocks with function calls - source_lcao/module_deltaspin/deltaspin_lcao.h: add 2 new function declarations - source_lcao/module_deltaspin/deltaspin_lcao.cpp: implement 2 new functions This completes the DeltaSpin refactoring for LCAO method: 1. init_deltaspin_lcao() - initialize DeltaSpin calculation 2. cal_mi_lcao_wrapper() - calculate magnetic moments 3. run_deltaspin_lambda_loop_lcao() - run lambda loop optimization All functions follow the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DFT+U code to dftu_lcao module - Create new files dftu_lcao.h/cpp in source_lcao directory - Add init_dftu_lcao() function for DFT+U initialization - Add finish_dftu_lcao() function for DFT+U finalization - Simplify code from 32 lines to 2 lines in esolver_ks_lcao.cpp - Remove conditional checks from ESolver, move them to functions Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 2 code blocks with function calls - source_lcao/CMakeLists.txt: add new source file New files: - source_lcao/dftu_lcao.h: function declarations - source_lcao/dftu_lcao.cpp: function implementations This refactoring prepares for unifying old and new DFT+U implementations: - Old DFT+U: source_lcao/module_dftu/ - New DFT+U: source_lcao/module_operator_lcao/op_dftu_lcao.cpp All functions follow ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract diagonalization parameters setup to hsolver module - Create new files diago_params.h/cpp in source_hsolver directory - Add setup_diago_params_pw() function for PW diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_ks_pw.cpp - Encapsulate diagonalization parameter setup logic Modified files: - source_esolver/esolver_ks_pw.cpp: replace inline code with function call - source_hsolver/CMakeLists.txt: add new source file New files: - source_hsolver/diago_params.h: function declaration - source_hsolver/diago_params.cpp: function implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. * fix(deltaspin): add sc_mag_switch check in cal_mi_lcao_wrapper - Add Input_para parameter to cal_mi_lcao_wrapper function - Add sc_mag_switch check to avoid calling cal_mi_lcao when DeltaSpin is disabled - Fix 'atomCounts is not set' error in non-DeltaSpin calculations - Update function call in esolver_ks_lcao.cpp This fix resolves the CI/CD failure caused by commit 2a520e3. The root cause was that cal_mi_lcao_wrapper was called without checking sc_mag_switch, leading to uninitialized atomCounts error. Modified files: - source_esolver/esolver_ks_lcao.cpp: update function call - source_lcao/module_deltaspin/deltaspin_lcao.h: add parameter - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add check This follows the refactoring principle: preserve original condition checks when extracting code to wrapper functions. * fix(deltaspin): add #ifdef __LCAO for conditional compilation - Add #ifdef __LCAO conditional compilation in init_deltaspin_lcao and cal_mi_lcao_wrapper - Fix parameter order in init_sc call for LCAO and non-LCAO builds - Fix undefined reference to cal_mi_lcao in non-LCAO build This fix resolves CI/CD compilation errors in both build_5pt (with __LCAO) and build_1p (without __LCAO) environments. The The root cause was 1. init_sc has different parameter order in LCAO vs non-LCAO builds - LCAO: psi, dm, pelec - non-LCAO: psi, pelec 2. cal_mi_lcao is only defined in LCAO build Modified files: - source_hsolver/diago_params.h: add setup_diago_params_sdft declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add conditional compilation This follows the refactoring principle: handle conditional compilation properly when code has different implementations for different build configurations. * refactor(esolver): extract SDFT diagonalization parameters setup - Add setup_diago_params_sdft() function for SDFT diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_sdft_pw.cpp - Encapsulate diagonalization parameter setup logic for SDFT Modified files: - source_esolver/esolver_sdft_pw.cpp: replace inline code with function call - source_hsolver/diago_params.cpp: add setup_diago_params_sdft implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. Note: SDFT has different parameter setup logic compared to PW: - Different need_subspace condition - No SCF_ITER setting - Always set PW_DIAG_NMAX (no nscf check) --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* small format changes * refactor(esolver): extract charge density symmetrization to Symmetry_rho::symmetrize_rho - Add static method symmetrize_rho() in Symmetry_rho class - Replace 7 duplicate code blocks with single function call - Simplify code from 35 lines to 7 lines (80% reduction) - Improve code readability and maintainability Modified files: - source_estate/module_charge/symmetry_rho.h: add static method declaration - source_estate/module_charge/symmetry_rho.cpp: implement static method - source_esolver/esolver_ks_lcao.cpp: 2 calls updated - source_esolver/esolver_ks_pw.cpp: 1 call updated - source_esolver/esolver_ks_lcao_tddft.cpp: 1 call updated - source_esolver/esolver_ks_lcaopw.cpp: 1 call updated - source_esolver/esolver_of.cpp: 1 call updated - source_esolver/esolver_sdft_pw.cpp: 1 call updated This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DeltaSpin lambda loop to deltaspin_lcao module - Create new files deltaspin_lcao.h/cpp in module_deltaspin - Extract DeltaSpin lambda loop logic from ESolver_KS_LCAO - Simplify code from 18 lines to 1 line in hamilt2rho_single - Separate LCAO and PW implementations for DeltaSpin Modified files: - source_esolver/esolver_ks_lcao.cpp: replace inline code with function call - source_lcao/module_deltaspin/CMakeLists.txt: add new source file New files: - source_lcao/module_deltaspin/deltaspin_lcao.h: function declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: function implementation This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): complete DeltaSpin refactoring in LCAO - Add init_deltaspin_lcao() function for DeltaSpin initialization - Add cal_mi_lcao_wrapper() function for magnetic moment calculation - Refactor all DeltaSpin-related code in esolver_ks_lcao.cpp - Simplify code from 29 lines to 3 lines (90% reduction) Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 3 code blocks with function calls - source_lcao/module_deltaspin/deltaspin_lcao.h: add 2 new function declarations - source_lcao/module_deltaspin/deltaspin_lcao.cpp: implement 2 new functions This completes the DeltaSpin refactoring for LCAO method: 1. init_deltaspin_lcao() - initialize DeltaSpin calculation 2. cal_mi_lcao_wrapper() - calculate magnetic moments 3. run_deltaspin_lambda_loop_lcao() - run lambda loop optimization All functions follow the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DFT+U code to dftu_lcao module - Create new files dftu_lcao.h/cpp in source_lcao directory - Add init_dftu_lcao() function for DFT+U initialization - Add finish_dftu_lcao() function for DFT+U finalization - Simplify code from 32 lines to 2 lines in esolver_ks_lcao.cpp - Remove conditional checks from ESolver, move them to functions Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 2 code blocks with function calls - source_lcao/CMakeLists.txt: add new source file New files: - source_lcao/dftu_lcao.h: function declarations - source_lcao/dftu_lcao.cpp: function implementations This refactoring prepares for unifying old and new DFT+U implementations: - Old DFT+U: source_lcao/module_dftu/ - New DFT+U: source_lcao/module_operator_lcao/op_dftu_lcao.cpp All functions follow ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract diagonalization parameters setup to hsolver module - Create new files diago_params.h/cpp in source_hsolver directory - Add setup_diago_params_pw() function for PW diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_ks_pw.cpp - Encapsulate diagonalization parameter setup logic Modified files: - source_esolver/esolver_ks_pw.cpp: replace inline code with function call - source_hsolver/CMakeLists.txt: add new source file New files: - source_hsolver/diago_params.h: function declaration - source_hsolver/diago_params.cpp: function implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. * fix(deltaspin): add sc_mag_switch check in cal_mi_lcao_wrapper - Add Input_para parameter to cal_mi_lcao_wrapper function - Add sc_mag_switch check to avoid calling cal_mi_lcao when DeltaSpin is disabled - Fix 'atomCounts is not set' error in non-DeltaSpin calculations - Update function call in esolver_ks_lcao.cpp This fix resolves the CI/CD failure caused by commit 2a520e3. The root cause was that cal_mi_lcao_wrapper was called without checking sc_mag_switch, leading to uninitialized atomCounts error. Modified files: - source_esolver/esolver_ks_lcao.cpp: update function call - source_lcao/module_deltaspin/deltaspin_lcao.h: add parameter - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add check This follows the refactoring principle: preserve original condition checks when extracting code to wrapper functions. * fix(deltaspin): add #ifdef __LCAO for conditional compilation - Add #ifdef __LCAO conditional compilation in init_deltaspin_lcao and cal_mi_lcao_wrapper - Fix parameter order in init_sc call for LCAO and non-LCAO builds - Fix undefined reference to cal_mi_lcao in non-LCAO build This fix resolves CI/CD compilation errors in both build_5pt (with __LCAO) and build_1p (without __LCAO) environments. The The root cause was 1. init_sc has different parameter order in LCAO vs non-LCAO builds - LCAO: psi, dm, pelec - non-LCAO: psi, pelec 2. cal_mi_lcao is only defined in LCAO build Modified files: - source_hsolver/diago_params.h: add setup_diago_params_sdft declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add conditional compilation This follows the refactoring principle: handle conditional compilation properly when code has different implementations for different build configurations. * refactor(esolver): extract SDFT diagonalization parameters setup - Add setup_diago_params_sdft() function for SDFT diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_sdft_pw.cpp - Encapsulate diagonalization parameter setup logic for SDFT Modified files: - source_esolver/esolver_sdft_pw.cpp: replace inline code with function call - source_hsolver/diago_params.cpp: add setup_diago_params_sdft implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. Note: SDFT has different parameter setup logic compared to PW: - Different need_subspace condition - No SCF_ITER setting - Always set PW_DIAG_NMAX (no nscf check) * refactor(hamilt): introduce HamiltBase non-template base class - Create HamiltBase as a non-template base class for Hamilt<T, Device> - Modify Hamilt<T, Device> to inherit from HamiltBase - Change ESolver_KS::p_hamilt type from Hamilt<T, Device>* to HamiltBase* - Add static_cast where needed when passing p_hamilt to functions expecting Hamilt<T, Device>* This is the first step towards removing template parameters from ESolver. Modified files: - source/source_esolver/esolver_ks.h - source/source_esolver/esolver_ks_lcaopw.cpp - source/source_esolver/esolver_ks_pw.cpp - source/source_esolver/esolver_sdft_pw.cpp - source/source_hamilt/hamilt.h New files: - source/source_hamilt/hamilt_base.h * refactor(esolver): add static_cast for p_hamilt in esolver files - Add static_cast<hamilt::Hamilt<T>*> when passing p_hamilt to functions expecting Hamilt<T, Device>* type - Split long cast statements into multiple lines for better readability - Files modified: - esolver_ks_pw.cpp: setup_pot, stp.init calls - esolver_ks_lcao.cpp: init_chg_hr, hsolver_lcao_obj.solve calls - esolver_ks_lcao_tddft.cpp: solve_psi, cal_edm_tddft, matrix calls - esolver_gets.cpp: ops access, output_SR call This follows the HamiltBase refactoring strategy where p_hamilt is stored as HamiltBase* and cast to Hamilt<T, Device>* when needed. --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* small format changes * refactor(esolver): extract charge density symmetrization to Symmetry_rho::symmetrize_rho - Add static method symmetrize_rho() in Symmetry_rho class - Replace 7 duplicate code blocks with single function call - Simplify code from 35 lines to 7 lines (80% reduction) - Improve code readability and maintainability Modified files: - source_estate/module_charge/symmetry_rho.h: add static method declaration - source_estate/module_charge/symmetry_rho.cpp: implement static method - source_esolver/esolver_ks_lcao.cpp: 2 calls updated - source_esolver/esolver_ks_pw.cpp: 1 call updated - source_esolver/esolver_ks_lcao_tddft.cpp: 1 call updated - source_esolver/esolver_ks_lcaopw.cpp: 1 call updated - source_esolver/esolver_of.cpp: 1 call updated - source_esolver/esolver_sdft_pw.cpp: 1 call updated This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DeltaSpin lambda loop to deltaspin_lcao module - Create new files deltaspin_lcao.h/cpp in module_deltaspin - Extract DeltaSpin lambda loop logic from ESolver_KS_LCAO - Simplify code from 18 lines to 1 line in hamilt2rho_single - Separate LCAO and PW implementations for DeltaSpin Modified files: - source_esolver/esolver_ks_lcao.cpp: replace inline code with function call - source_lcao/module_deltaspin/CMakeLists.txt: add new source file New files: - source_lcao/module_deltaspin/deltaspin_lcao.h: function declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: function implementation This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): complete DeltaSpin refactoring in LCAO - Add init_deltaspin_lcao() function for DeltaSpin initialization - Add cal_mi_lcao_wrapper() function for magnetic moment calculation - Refactor all DeltaSpin-related code in esolver_ks_lcao.cpp - Simplify code from 29 lines to 3 lines (90% reduction) Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 3 code blocks with function calls - source_lcao/module_deltaspin/deltaspin_lcao.h: add 2 new function declarations - source_lcao/module_deltaspin/deltaspin_lcao.cpp: implement 2 new functions This completes the DeltaSpin refactoring for LCAO method: 1. init_deltaspin_lcao() - initialize DeltaSpin calculation 2. cal_mi_lcao_wrapper() - calculate magnetic moments 3. run_deltaspin_lambda_loop_lcao() - run lambda loop optimization All functions follow the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DFT+U code to dftu_lcao module - Create new files dftu_lcao.h/cpp in source_lcao directory - Add init_dftu_lcao() function for DFT+U initialization - Add finish_dftu_lcao() function for DFT+U finalization - Simplify code from 32 lines to 2 lines in esolver_ks_lcao.cpp - Remove conditional checks from ESolver, move them to functions Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 2 code blocks with function calls - source_lcao/CMakeLists.txt: add new source file New files: - source_lcao/dftu_lcao.h: function declarations - source_lcao/dftu_lcao.cpp: function implementations This refactoring prepares for unifying old and new DFT+U implementations: - Old DFT+U: source_lcao/module_dftu/ - New DFT+U: source_lcao/module_operator_lcao/op_dftu_lcao.cpp All functions follow ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract diagonalization parameters setup to hsolver module - Create new files diago_params.h/cpp in source_hsolver directory - Add setup_diago_params_pw() function for PW diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_ks_pw.cpp - Encapsulate diagonalization parameter setup logic Modified files: - source_esolver/esolver_ks_pw.cpp: replace inline code with function call - source_hsolver/CMakeLists.txt: add new source file New files: - source_hsolver/diago_params.h: function declaration - source_hsolver/diago_params.cpp: function implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. * fix(deltaspin): add sc_mag_switch check in cal_mi_lcao_wrapper - Add Input_para parameter to cal_mi_lcao_wrapper function - Add sc_mag_switch check to avoid calling cal_mi_lcao when DeltaSpin is disabled - Fix 'atomCounts is not set' error in non-DeltaSpin calculations - Update function call in esolver_ks_lcao.cpp This fix resolves the CI/CD failure caused by commit 2a520e3. The root cause was that cal_mi_lcao_wrapper was called without checking sc_mag_switch, leading to uninitialized atomCounts error. Modified files: - source_esolver/esolver_ks_lcao.cpp: update function call - source_lcao/module_deltaspin/deltaspin_lcao.h: add parameter - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add check This follows the refactoring principle: preserve original condition checks when extracting code to wrapper functions. * fix(deltaspin): add #ifdef __LCAO for conditional compilation - Add #ifdef __LCAO conditional compilation in init_deltaspin_lcao and cal_mi_lcao_wrapper - Fix parameter order in init_sc call for LCAO and non-LCAO builds - Fix undefined reference to cal_mi_lcao in non-LCAO build This fix resolves CI/CD compilation errors in both build_5pt (with __LCAO) and build_1p (without __LCAO) environments. The The root cause was 1. init_sc has different parameter order in LCAO vs non-LCAO builds - LCAO: psi, dm, pelec - non-LCAO: psi, pelec 2. cal_mi_lcao is only defined in LCAO build Modified files: - source_hsolver/diago_params.h: add setup_diago_params_sdft declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add conditional compilation This follows the refactoring principle: handle conditional compilation properly when code has different implementations for different build configurations. * refactor(esolver): extract SDFT diagonalization parameters setup - Add setup_diago_params_sdft() function for SDFT diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_sdft_pw.cpp - Encapsulate diagonalization parameter setup logic for SDFT Modified files: - source_esolver/esolver_sdft_pw.cpp: replace inline code with function call - source_hsolver/diago_params.cpp: add setup_diago_params_sdft implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. Note: SDFT has different parameter setup logic compared to PW: - Different need_subspace condition - No SCF_ITER setting - Always set PW_DIAG_NMAX (no nscf check) * refactor(hamilt): introduce HamiltBase non-template base class - Create HamiltBase as a non-template base class for Hamilt<T, Device> - Modify Hamilt<T, Device> to inherit from HamiltBase - Change ESolver_KS::p_hamilt type from Hamilt<T, Device>* to HamiltBase* - Add static_cast where needed when passing p_hamilt to functions expecting Hamilt<T, Device>* This is the first step towards removing template parameters from ESolver. Modified files: - source/source_esolver/esolver_ks.h - source/source_esolver/esolver_ks_lcaopw.cpp - source/source_esolver/esolver_ks_pw.cpp - source/source_esolver/esolver_sdft_pw.cpp - source/source_hamilt/hamilt.h New files: - source/source_hamilt/hamilt_base.h * refactor(esolver): add static_cast for p_hamilt in esolver files - Add static_cast<hamilt::Hamilt<T>*> when passing p_hamilt to functions expecting Hamilt<T, Device>* type - Split long cast statements into multiple lines for better readability - Files modified: - esolver_ks_pw.cpp: setup_pot, stp.init calls - esolver_ks_lcao.cpp: init_chg_hr, hsolver_lcao_obj.solve calls - esolver_ks_lcao_tddft.cpp: solve_psi, cal_edm_tddft, matrix calls - esolver_gets.cpp: ops access, output_SR call This follows the HamiltBase refactoring strategy where p_hamilt is stored as HamiltBase* and cast to Hamilt<T, Device>* when needed. * refactor(esolver): remove psi member from ESolver_KS base class Move psi::Psi<T>* psi from ESolver_KS base class to derived classes to eliminate template parameter dependency and improve code organization. Changes: 1. ESolver_KS base class: - Remove psi::Psi<T>* psi member variable - Remove Setup_Psi<T>::deallocate_psi() call in destructor - Remove unnecessary includes: psi.h and setup_psi.h 2. ESolver_KS_LCAO: - Add psi::Psi<TK>* psi member variable - Add Setup_Psi<TK>::deallocate_psi() in destructor - Add include: setup_psi.h 3. ESolver_KS_LCAO_TDDFT: - Improve psi_laststep deallocation with nullptr check - psi member inherited from ESolver_KS_LCAO 4. ESolver_KS_PW: - Use stp.psi_cpu directly instead of base class psi - Remove unnecessary memory allocation in after_scf() 5. pw_others.cpp (BUG FIX): - Fix gen_bessel: use *(this->stp.psi_cpu) instead of this->psi[0] - Previous code accessed uninitialized base class psi (nullptr) - This was a latent bug that could cause crashes Benefits: - Eliminates template parameter T dependency in ESolver_KS base class - Clearer memory management: each derived class manages its own psi - Reduces compilation dependencies - Fixes potential memory access bug in pw_others.cpp Tested: Compiled successfully in build_5pt and build_1p * refactor(esolver): remove template parameters from ESolver_KS base class This is a major milestone in ESolver refactoring! ESolver_KS no longer needs template parameters because: - All member variables are non-template types - All member functions do not use T or Device parameters - Template parameters were only needed for derived classes Changes: 1. ESolver_KS base class: - Remove template <typename T, typename Device> declaration - Remove all template declarations from member functions - Remove template instantiation code at end of file - Fix Tab indentation to spaces for better readability 2. Derived classes: - ESolver_KS_PW: public ESolver_KS (was ESolver_KS<T, Device>) - ESolver_KS_LCAO: public ESolver_KS (was ESolver_KS<TK>) - ESolver_GetS: public ESolver_KS (was ESolver_KS<std::complex<double>>) - Update base class calls: ESolver_KS:: (was ESolver_KS<T, Device>::) Code reduction: - esolver_ks.h: 78 -> 77 lines (-1 line) - esolver_ks.cpp: 346 -> 317 lines (-29 lines) - Total ESolver code: 424 -> 394 lines (-30 lines) - Overall: 8 files changed, 50 insertions(+), 80 deletions(-), net -30 lines Benefits: - Simpler base class without template complexity - Faster compilation (no template instantiation needed) - Clearer inheritance hierarchy - Easier to extract common code in future refactoring - Sets foundation for further ESolver template removal Tested: Compiled successfully in build_5pt --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* small format changes * refactor(esolver): extract charge density symmetrization to Symmetry_rho::symmetrize_rho - Add static method symmetrize_rho() in Symmetry_rho class - Replace 7 duplicate code blocks with single function call - Simplify code from 35 lines to 7 lines (80% reduction) - Improve code readability and maintainability Modified files: - source_estate/module_charge/symmetry_rho.h: add static method declaration - source_estate/module_charge/symmetry_rho.cpp: implement static method - source_esolver/esolver_ks_lcao.cpp: 2 calls updated - source_esolver/esolver_ks_pw.cpp: 1 call updated - source_esolver/esolver_ks_lcao_tddft.cpp: 1 call updated - source_esolver/esolver_ks_lcaopw.cpp: 1 call updated - source_esolver/esolver_of.cpp: 1 call updated - source_esolver/esolver_sdft_pw.cpp: 1 call updated This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DeltaSpin lambda loop to deltaspin_lcao module - Create new files deltaspin_lcao.h/cpp in module_deltaspin - Extract DeltaSpin lambda loop logic from ESolver_KS_LCAO - Simplify code from 18 lines to 1 line in hamilt2rho_single - Separate LCAO and PW implementations for DeltaSpin Modified files: - source_esolver/esolver_ks_lcao.cpp: replace inline code with function call - source_lcao/module_deltaspin/CMakeLists.txt: add new source file New files: - source_lcao/module_deltaspin/deltaspin_lcao.h: function declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: function implementation This refactoring follows the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): complete DeltaSpin refactoring in LCAO - Add init_deltaspin_lcao() function for DeltaSpin initialization - Add cal_mi_lcao_wrapper() function for magnetic moment calculation - Refactor all DeltaSpin-related code in esolver_ks_lcao.cpp - Simplify code from 29 lines to 3 lines (90% reduction) Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 3 code blocks with function calls - source_lcao/module_deltaspin/deltaspin_lcao.h: add 2 new function declarations - source_lcao/module_deltaspin/deltaspin_lcao.cpp: implement 2 new functions This completes the DeltaSpin refactoring for LCAO method: 1. init_deltaspin_lcao() - initialize DeltaSpin calculation 2. cal_mi_lcao_wrapper() - calculate magnetic moments 3. run_deltaspin_lambda_loop_lcao() - run lambda loop optimization All functions follow the ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract DFT+U code to dftu_lcao module - Create new files dftu_lcao.h/cpp in source_lcao directory - Add init_dftu_lcao() function for DFT+U initialization - Add finish_dftu_lcao() function for DFT+U finalization - Simplify code from 32 lines to 2 lines in esolver_ks_lcao.cpp - Remove conditional checks from ESolver, move them to functions Modified files: - source_esolver/esolver_ks_lcao.cpp: replace 2 code blocks with function calls - source_lcao/CMakeLists.txt: add new source file New files: - source_lcao/dftu_lcao.h: function declarations - source_lcao/dftu_lcao.cpp: function implementations This refactoring prepares for unifying old and new DFT+U implementations: - Old DFT+U: source_lcao/module_dftu/ - New DFT+U: source_lcao/module_operator_lcao/op_dftu_lcao.cpp All functions follow ESolver cleanup principle: keep ESolver focused on high-level workflow control. * refactor(esolver): extract diagonalization parameters setup to hsolver module - Create new files diago_params.h/cpp in source_hsolver directory - Add setup_diago_params_pw() function for PW diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_ks_pw.cpp - Encapsulate diagonalization parameter setup logic Modified files: - source_esolver/esolver_ks_pw.cpp: replace inline code with function call - source_hsolver/CMakeLists.txt: add new source file New files: - source_hsolver/diago_params.h: function declaration - source_hsolver/diago_params.cpp: function implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. * fix(deltaspin): add sc_mag_switch check in cal_mi_lcao_wrapper - Add Input_para parameter to cal_mi_lcao_wrapper function - Add sc_mag_switch check to avoid calling cal_mi_lcao when DeltaSpin is disabled - Fix 'atomCounts is not set' error in non-DeltaSpin calculations - Update function call in esolver_ks_lcao.cpp This fix resolves the CI/CD failure caused by commit 2a520e3. The root cause was that cal_mi_lcao_wrapper was called without checking sc_mag_switch, leading to uninitialized atomCounts error. Modified files: - source_esolver/esolver_ks_lcao.cpp: update function call - source_lcao/module_deltaspin/deltaspin_lcao.h: add parameter - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add check This follows the refactoring principle: preserve original condition checks when extracting code to wrapper functions. * fix(deltaspin): add #ifdef __LCAO for conditional compilation - Add #ifdef __LCAO conditional compilation in init_deltaspin_lcao and cal_mi_lcao_wrapper - Fix parameter order in init_sc call for LCAO and non-LCAO builds - Fix undefined reference to cal_mi_lcao in non-LCAO build This fix resolves CI/CD compilation errors in both build_5pt (with __LCAO) and build_1p (without __LCAO) environments. The The root cause was 1. init_sc has different parameter order in LCAO vs non-LCAO builds - LCAO: psi, dm, pelec - non-LCAO: psi, pelec 2. cal_mi_lcao is only defined in LCAO build Modified files: - source_hsolver/diago_params.h: add setup_diago_params_sdft declaration - source_lcao/module_deltaspin/deltaspin_lcao.cpp: add conditional compilation This follows the refactoring principle: handle conditional compilation properly when code has different implementations for different build configurations. * refactor(esolver): extract SDFT diagonalization parameters setup - Add setup_diago_params_sdft() function for SDFT diagonalization parameters - Simplify code from 11 lines to 1 line in esolver_sdft_pw.cpp - Encapsulate diagonalization parameter setup logic for SDFT Modified files: - source_esolver/esolver_sdft_pw.cpp: replace inline code with function call - source_hsolver/diago_params.cpp: add setup_diago_params_sdft implementation This refactoring follows ESolver cleanup principle: keep ESolver focused on high-level workflow control. Note: SDFT has different parameter setup logic compared to PW: - Different need_subspace condition - No SCF_ITER setting - Always set PW_DIAG_NMAX (no nscf check) * refactor(hamilt): introduce HamiltBase non-template base class - Create HamiltBase as a non-template base class for Hamilt<T, Device> - Modify Hamilt<T, Device> to inherit from HamiltBase - Change ESolver_KS::p_hamilt type from Hamilt<T, Device>* to HamiltBase* - Add static_cast where needed when passing p_hamilt to functions expecting Hamilt<T, Device>* This is the first step towards removing template parameters from ESolver. Modified files: - source/source_esolver/esolver_ks.h - source/source_esolver/esolver_ks_lcaopw.cpp - source/source_esolver/esolver_ks_pw.cpp - source/source_esolver/esolver_sdft_pw.cpp - source/source_hamilt/hamilt.h New files: - source/source_hamilt/hamilt_base.h * refactor(esolver): add static_cast for p_hamilt in esolver files - Add static_cast<hamilt::Hamilt<T>*> when passing p_hamilt to functions expecting Hamilt<T, Device>* type - Split long cast statements into multiple lines for better readability - Files modified: - esolver_ks_pw.cpp: setup_pot, stp.init calls - esolver_ks_lcao.cpp: init_chg_hr, hsolver_lcao_obj.solve calls - esolver_ks_lcao_tddft.cpp: solve_psi, cal_edm_tddft, matrix calls - esolver_gets.cpp: ops access, output_SR call This follows the HamiltBase refactoring strategy where p_hamilt is stored as HamiltBase* and cast to Hamilt<T, Device>* when needed. * refactor(esolver): remove psi member from ESolver_KS base class Move psi::Psi<T>* psi from ESolver_KS base class to derived classes to eliminate template parameter dependency and improve code organization. Changes: 1. ESolver_KS base class: - Remove psi::Psi<T>* psi member variable - Remove Setup_Psi<T>::deallocate_psi() call in destructor - Remove unnecessary includes: psi.h and setup_psi.h 2. ESolver_KS_LCAO: - Add psi::Psi<TK>* psi member variable - Add Setup_Psi<TK>::deallocate_psi() in destructor - Add include: setup_psi.h 3. ESolver_KS_LCAO_TDDFT: - Improve psi_laststep deallocation with nullptr check - psi member inherited from ESolver_KS_LCAO 4. ESolver_KS_PW: - Use stp.psi_cpu directly instead of base class psi - Remove unnecessary memory allocation in after_scf() 5. pw_others.cpp (BUG FIX): - Fix gen_bessel: use *(this->stp.psi_cpu) instead of this->psi[0] - Previous code accessed uninitialized base class psi (nullptr) - This was a latent bug that could cause crashes Benefits: - Eliminates template parameter T dependency in ESolver_KS base class - Clearer memory management: each derived class manages its own psi - Reduces compilation dependencies - Fixes potential memory access bug in pw_others.cpp Tested: Compiled successfully in build_5pt and build_1p * refactor(esolver): remove template parameters from ESolver_KS base class This is a major milestone in ESolver refactoring! ESolver_KS no longer needs template parameters because: - All member variables are non-template types - All member functions do not use T or Device parameters - Template parameters were only needed for derived classes Changes: 1. ESolver_KS base class: - Remove template <typename T, typename Device> declaration - Remove all template declarations from member functions - Remove template instantiation code at end of file - Fix Tab indentation to spaces for better readability 2. Derived classes: - ESolver_KS_PW: public ESolver_KS (was ESolver_KS<T, Device>) - ESolver_KS_LCAO: public ESolver_KS (was ESolver_KS<TK>) - ESolver_GetS: public ESolver_KS (was ESolver_KS<std::complex<double>>) - Update base class calls: ESolver_KS:: (was ESolver_KS<T, Device>::) Code reduction: - esolver_ks.h: 78 -> 77 lines (-1 line) - esolver_ks.cpp: 346 -> 317 lines (-29 lines) - Total ESolver code: 424 -> 394 lines (-30 lines) - Overall: 8 files changed, 50 insertions(+), 80 deletions(-), net -30 lines Benefits: - Simpler base class without template complexity - Faster compilation (no template instantiation needed) - Clearer inheritance hierarchy - Easier to extract common code in future refactoring - Sets foundation for further ESolver template removal Tested: Compiled successfully in build_5pt * refactor(device): remove explicit template parameter from get_device_type calls - Move get_device_type implementation to header file using std::is_same - Add DEVICE_DSP support - Remove template specialization declarations and definitions - Update all call sites to use automatic template parameter deduction - The compiler now deduces Device type from the ctx parameter * refactor(esolver): remove device member variable from ESolver_KS_PW - Modify copy_d2h to accept ctx parameter and call get_device_type internally - Remove device parameter from ctrl_scf_pw function - Remove device member variable from ESolver_KS_PW class - Simplify function interfaces by using automatic template deduction * style(esolver): explicitly initialize ctx to nullptr in constructor * feat(device): add runtime device type support to DeviceContext - Add device_type_ member variable to DeviceContext class - Add set_device_type() and get_device_type() methods - Add is_cpu(), is_gpu(), is_dsp() convenience methods - Add get_device_type(const DeviceContext*) overload for runtime device type query - Maintain backward compatibility with existing template-based get_device_type * feat(device): add runtime device context overloads for gradual migration - Add copy_d2h(const DeviceContext*) overload to Setup_Psi_pw - Add ctrl_scf_pw(..., const DeviceContext*, ...) overload - Add ctrl_runner_pw(..., const DeviceContext*, ...) overload - Keep original functions for backward compatibility - Replace tabs with spaces in modified files --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* Refactor: add nullptr for uninitialized pointer * remove nullptr in MatrixBlock --------- Co-authored-by: linpz <linpz@mail.ustc.edu.cn>
* hybrid gauge tddft force * fix no MPI compile * pass td_stype * add warning quit
…7497) * step 1 to remove current_R * fix * step 3 * fix tests * keep updating, still has bugs * fix bugs * fix bug * fix deepks nspin=2 scf bug in update_dmr after removing current_R The PR 4a201ad removed the current_R mutable member from AtomPair, but add_from_matrix was incorrectly rewritten to use values[0] instead of values[current_R]. As a result, when updating the density matrix for non-zero R vectors in DeePKS_domain::update_dmr, the data was always written into the (0,0,0) R block, leaving other R blocks empty. This caused the nspin=2 DeePKS SCF test to fail with a large deviation in deepks_desc and deepks_dm_eig. Add thread-safe add_from_matrix overloads that take an explicit R_index and use values[R_index], and call them in update_dmr via the r_index returned by find_R. --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* add getter function in parallel_2d.h * refactor(parallel): Add MPI_Type type mapping template to eliminate duplicate specializations - Add MPI_Type<T> template struct to map C++ types to MPI_Datatype - Replace 30+ duplicate template specializations with 8 generic templates - Add explicit instantiations for all required types - Maintain full backward compatibility * fix is_serial * fix pv->coord[0] and pv->coord[1] * update parallel_orbital, delete useless variable, use vector instead of new * update parallel_orbital.h, change get_col_size(int iat) to get_ncol_atom(int iat), same for row * add a new function paraV->is_invalid_atom_pair(iat1, iat2) * add the function * update * delete useless run_symmetry.cpp * delete useless functions and variables * update * fix bugs * update * update --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* update module_neighlist * remove magic numbers * update * update * update * update, add page_allocator * update --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* Rename Makov-Payne energy term * Fix elecstate energy unit test link dependencies * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
* refactor(xc): Decouple XC_Functional from global PARAM by using function parameters for nspin, domag, domag_z * feat(xc): Decouple XC_Functional from global PARAM object This commit decouples XC_Functional and related libxc functions from the global PARAM object by adding explicit parameters: 1. Modified XC_Functional::v_xc() to accept nspin, domag, domag_z parameters instead of accessing PARAM 2. Modified XC_Functional::gradcorr() to accept nspin, domag, domag_z parameters 3. Modified XC_Functional::set_xc_type() to accept nspin parameter 4. Modified XC_Functional_Libxc::v_xc_libxc() to accept nspin, domag, domag_z parameters 5. Modified XC_Functional_Libxc::v_xc_meta() to accept nspin parameter Updated all call sites in: - source_estate/module_pot/pot_xc.cpp - source_estate/module_pot/pot_xc_fdm.cpp - source_pw/module_pwdft/forces_cc.cpp - source_pw/module_pwdft/stress_cc.cpp - source_hamilt/module_xc/xc_pot.cpp - source_hamilt/module_xc/libxc_pot.cpp - source_hamilt/module_xc/libxc_abacus.h Updated test files to remove PARAM dependencies: - test_xc3.cpp: Removed PARAM include and initialization - test_xc5.cpp: Removed PARAM include and initialization, updated v_xc, v_xc_meta calls - xctest.h: Removed PARAM include and initialization Default parameter values are provided for backward compatibility. * update tests * Refactor: Remove PARAM references from XC functional interface and improve parameter passing Summary of changes: 1. Modified libxc_abacus.h: - Removed default value (=1) for nspin parameter in v_xc_libxc - Removed default value (=nullptr) for scaling_factor parameter in v_xc_libxc 2. Modified xc_functional.h: - Changed set_xc_type signature to only accept const std::string xc_func_in - Removed nspin and basis_type parameters from set_xc_type - Removed default parameters from v_xc and gradcorr 3. Modified xc_functional.cpp: - Updated set_xc_type implementation to match new signature - Removed meta-GGA nspin=4 check from set_xc_type (moved to gradcorr) - Removed hybrid functional LCAO check from set_xc_type (no longer needed) - Updated internal set_xc_type calls to use single parameter 4. Modified xc_grad.cpp: - Added meta-GGA nspin=4 check at the beginning of gradcorr function - This is the correct place for runtime validation since nspin is known here 5. Modified xc_pot.cpp: - Updated v_xc_libxc call to pass parameters correctly 6. Modified libxc_pot.cpp: - Updated v_xc_libxc implementation to match new signature 7. Modified stress_gga.cpp: - Changed direct 'true' argument to named variable 'is_stress' for gradcorr call - Improved code readability and maintainability 8. Updated all set_xc_type call sites (12 files): - test_xc.cpp, test_xc1.cpp, test_xc2.cpp, test_xc3.cpp, test_xc5.cpp - xc_functional.cpp, esolver_double_xc.cpp, esolver_ks_lcaopw.cpp - esolver_fp.cpp, Exx_LRI_interface.hpp, xc_kernel.cpp, exx_helper.cpp - All calls now pass only the xc_func_in parameter 9. Updated test_xc3.cpp and test_xc5.cpp: - Added named variables (nspin1, nspin2, nspin4, domag, domag_z, domag_true) - Removed direct numeric literals in function calls Rationale: - Separated functional setup (set_xc_type) from runtime configuration (nspin, basis_type) - Runtime validation checks moved to actual computation functions (gradcorr) - Parameter passing improved with meaningful variable names instead of magic numbers - Code readability and maintainability enhanced - Preparation for future improvements to XC functional interface * update --------- Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v6...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat(md): add CSVR thermostat for NVT molecular dynamics Implement the Canonical Sampling through Velocity Rescaling (CSVR) thermostat as described in: G. Bussi, D. Donadio, M. Parrinello, J. Chem. Phys. 126, 014101 (2007) Features: - New thermostat option: md_thermostat = csvr - New parameter: md_csvr_tau (characteristic time scale) - Properly samples the canonical (NVT) ensemble - Simple implementation with only one parameter Implements #6941 * docs(md): add CSVR thermostat documentation - Add csvr option to md_thermostat parameter description - Add md_csvr_tau parameter documentation Implements #6941 * test(md): add unit test for CSVR thermostat Add CSVR thermostat test case to verlet_test.cpp: - Test position update correctness - Verify temperature is in reasonable range Implements #6941 * fix: address review comments for CSVR thermostat - Fix degrees of freedom: use 3N - frozen_freedom instead of frozen_freedom - Use MD_func::gaussrand() instead of std::random for consistency - Simplify CSVR core formula with factor2 variable - Remove unused #include <random> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com> Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com> --------- Co-authored-by: monkeycode-ai <monkeycode-ai@chaitin.com>
* refactor(pw): remove dead esolver include from hamilt_pw.h HamiltPW does not reference any ESolver symbol; the include of source_esolver/esolver_ks_pw.h was unused. Removing it cuts the only source_pw -> source_esolver back-edge (an operator header depending on its driver) and drops 15 transitively-included headers from every consumer of hamilt_pw.h (fan 114 -> 99). All types named in the header (UnitCell, ModulePW::PW_Basis_K, etc.) remain provided by klist.h / vnl_pw.h -> structure_factor.h. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(surchem): forward-declare pw types in surchem.h Structure_Factor and Parallel_Grid are used in surchem.h only as pointer/reference parameters, so replace the heavy source_pw includes with forward declarations. This cuts the hamilt -> pw back-edge from surchem.h (hamilt->pw edge 4 -> 2) and drops 6 transitively-included headers from surchem.h's closure (54 -> 48), benefiting its ~160 transitive consumers. Two consumers relied on the transitive include and now include it directly (include-what-you-use): - esolver_fp.h: has a Parallel_Grid value member -> add parallel_grid.h - forces.cpp: accesses p_sf->strucFac -> add structure_factor.h Other surchem.h consumers use these types only via pointer/reference and are covered by the forward declarations; verified the remaining parallel_grid.h users still reach it through other includes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(surchem): include structure_factor.h in cal_pseudo.cpp cal_pseudo.cpp dereferences Structure_Factor (sf->strucFac) but only included surchem.h, which now forward-declares the type. Add the direct include so the complete type is available. Fixes the CI build error "invalid use of incomplete type 'class Structure_Factor'". Verified via closure analysis that this is the only remaining file in surchem.h's affected set that requires the complete type; all other consumers use Structure_Factor / Parallel_Grid by pointer or reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style(surchem): drop verbose comment on forward declarations Match the house style used across the codebase (e.g. makov_payne.h, exx_helper_base.h, cube_io.h), where forward declarations are bare `class Foo;` lines without an explanatory comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style(surchem): add a one-line note on the forward declarations Brief comment explaining why the source_pw types are forward-declared (pointer/reference use only) so the includes are not re-added later. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* Reset BFGS history after cell changes * Add reset-after-cell-change coverage Fixes #4140. This PR resets ionic BFGS state after an actual cell update in cell-relax so the optimizer does not reuse coordinates, gradients, Hessian history, trust radius, or traditional BFGS initialization from the previous cell. The test coverage now lives in the existing ions_move_methods_test.cpp target and checks both new BFGS and traditional BFGS reset paths. --------- Co-authored-by: Fei Yang <2501213217@stu.pku.edu.cn>
…encies (#7521) * refactor(cell): remove dead source_lcao include from read_atom_species read_atom_species.cpp included source_lcao/module_ri/serialization_cereal.h (guarded by __EXX) but uses no cereal/serialization symbols. Removing it cuts a source_cell -> source_lcao reverse dependency edge. Add the direct <sstream> include the file actually needs (std::stringstream), which was previously only available transitively through the cereal header. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(cell): move Magnetism from source_estate to source_cell The Magnetism class only depends on source_base and is held by value as a member of UnitCell (source_cell/unitcell.h). It is a fundamental property of the unit cell, so it belongs in source_cell rather than source_estate. This removes the unitcell.h -> source_estate header dependency (a core data structure no longer reaches up into the electronic-state module) and breaks one direction of the source_cell <-> source_estate cycle. - git mv source_estate/magnetism.{h,cpp} -> source_cell/ - update all includers to source_cell/magnetism.h - move the source file entry between CMakeLists and fix the unit-test path Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * refactor(base): move output print helpers from source_io to source_base The `output` class (output.{h,cpp}) is a pure formatter that only operates on source_base types (realArray, matrix, matrix3, ComplexMatrix). It was sitting in source_io/module_output but has no dependency on anything above source_base, so it belongs in source_base as a leaf utility. Relocating it removes a batch of source_cell -> source_io (and source_pw/ source_psi -> source_io) reverse edges that existed only to reach this printer, without changing any behavior or namespace. - git mv source_io/module_output/output.{h,cpp} -> source_base/ - fix the relocated header's own includes (drop ../../source_base/ prefix) - repoint all includers to source_base/output.h - move the source entry from source_io to source_base CMakeLists and update the relative output.cpp paths in all affected unit-test CMakeLists Verified: full abacus_basic_para executable builds and links cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add ASCII Art for ABACUS * Align the title a bit * remove original abacus title
…7525) * Toolchain: Block installation of prebuilt libtorch when enabling MKL * Remove dead CMake logic
* fix: align module hs sparse output with threshold * fix: stabilize module hs sparse output controls * test: fix module hs regression test builds
…ay (#7536) The HContainer copy constructor was unconditionally zeroing out the data_array when wrapping existing memory. This caused getHR_vector() to erase both spin channels' HR data for nspin=2, resulting in all-zero HR output when out_mat_hs2 is enabled. Fix: only zero memory when data_array is nullptr (fresh allocation); preserve existing data when wrapping external memory. Also add integration test scf_out_hsr_spin2 (nspin=2 + out_mat_hs2) and update catch_properties.sh to compare hrs2_nao.csr for nspin=2.
) * fix: correct Pauli-to-spinor Hamiltonian conversion for nspin=4 Fix two bugs in LCAO non-collinear Hamiltonian construction: 1. Wrong sign in off-diagonal elements: H_{up,down} = B_x + i*B_y (wrong) should be B_x - i*B_y (correct), and vice versa for H_{down,up}. Fixed by correcting clx_j coefficients in merge_hr_part_to_hR(). 2. Missing complex conjugate in lower triangle fill: H(-R) used transpose instead of conjugate transpose, breaking Hermiticity for complex matrices. Fixed by using std::conj() when filling lower triangle. These errors caused the non-collinear Hamiltonian to be the complex conjugate of the correct result, leading to incorrect spin textures in nspin=4 calculations. The PW code path was not affected. Add test case and verification script to validate: - H(R=0) Hermiticity: max|H - H^dagger| < 1e-10 - Off-diagonal phase: Im(H_{up,down}) < 0 for m||+y direction See tests/03_NAO_multik/verify_hamiltonian_convention/TEST_DESIGN.md for details. * fix: correct Pauli-to-spinor conversion in DFT+U and DeltaSpin for nspin=4 Fix three critical bugs in non-collinear (nspin=4) LCAO calculations: 1. DFT+U transfer_vu (dftu_lcao.cpp): Fix sign error in Pauli-to-spinor conversion. The off-diagonal elements had wrong imaginary part sign: - Before: V_{up,down} = 0.5*(V_x + i*V_y) (wrong) - After: V_{up,down} = 0.5*(V_x - i*V_y) (correct, from sigma_y) 2. DFT+U force/stress (dftu_force_stress.hpp): Convert VU from Pauli basis to spinor basis before force calculation. The old code incorrectly mixed Pauli-basis VU with spinor-basis DM. 3. DeltaSpin force/stress (dspin_force_stress.hpp): Convert lambda from Pauli basis to spinor basis. The constraint force F = lambda·dM/dR requires proper Pauli-to-spinor conversion: - lambda_spinor = (lambda_z, lambda_x, lambda_x, -lambda_z) for (uu, ud, du, dd) components. These fixes ensure consistent Pauli-to-spinor conversion across all modules: - H construction (gint_common.cpp): already fixed - DFT+U Hamiltonian: fixed in this commit - DFT+U force/stress: fixed in this commit - DeltaSpin force/stress: fixed in this commit Verified by scf_u_spin4 test (nspin=4 + DFT+U): SCF converges correctly. * chore: remove .py and .md test files from PR * fix: correct DFT+U force for nspin=4 - DM is stored in Pauli basis, not spinor basis Two bugs fixed in dftu_force_stress.hpp: 1. Removed incorrect VU Pauli-to-spinor conversion: DM for nspin=4 is stored in Pauli basis (rho_0, rho_x, rho_y, rho_z) per func_xyz_to_updown(), so VU must also stay in Pauli basis for the force trace formula F = -Tr(VU * dDM/dR). 2. Removed force *= 2.0 for nspin=4: Pauli basis already includes all spin channels, unlike nspin=1 where the factor of 2 accounts for spin degeneracy. Updated scf_u_spin4 result.ref accordingly. * fix: remove force*=2.0 for nspin=4 in DeltaSpin - Pauli basis already covers all spin channels * fix: add missing blacs_context to ELPA Constructor 1 for nspin=4 support Constructor 1 of ELPA_Solver was missing elpa_set_integer("blacs_context", ...) while Constructor 2 (otherParameter) already had it. Without blacs_context, ELPA's internal MPI operations (e.g. MPI_Bcast in complex Cholesky and invert_triangular) can fail with INVALID DATATYPE when using complex eigensolves. Also update scf_angle_spin4 result.ref with corrected reference energy. * fix: correct rho_y sign in spinor-to-Pauli DM conversion (func_xyz_to_updown) For Pauli decomposition: rho = rho_0*I + rho_x*sigma_x + rho_y*sigma_y + rho_z*sigma_z sigma_y = [[0,-i],[i,0]], so rho_updown = rho_x + i*rho_y, rho_downup = rho_x - i*rho_y Thus rho_y = Im(rho_updown - rho_downup) = tmp[1].imag() - tmp[2].imag]. Previously the real version had -tmp[1].imag()+tmp[2].imag() = -2*rho_y (wrong sign), and the complex version had i*(tmp[1].imag()-tmp[2].imag()) = 2i*rho_y (wrong formula). This broke rotational invariance: mag along y gave wrong energy (~4 eV deviation vs x/z). * test: update scf_angle_spin4 and scf_u_spin4 result.ref after DM rho_y fix * chore: revert density_matrix.cpp rho_y fix (wrong branch) and remove verify_hamiltonian_convention test dir - Revert density_matrix.cpp func_xyz_to_updown rho_y sign fix from commit 52ee608 (belongs on a separate DM-fix branch) - Remove tests/03_NAO_multik/verify_hamiltonian_convention/ (debug helper) - Update result.ref for scf_angle_spin4 and scf_u_spin4 to match current code (Pauli-to-spinor + ELPA fixes only) * fix: restore density_matrix.cpp rho_y sign fix (paired with gint_common clx_j fix) The gint_common.cpp fix corrects Pauli→spinor (H construction) and the density_matrix.cpp fix corrects spinor→Pauli (DM Fourier transform). Both must use the same σ_y convention for self-consistency. Also update result.ref files for both test cases. * fix: correct DFT+U force/stress reference values and clean up empty nspin=4 block Both VU (from cal_v_of_u) and DMR are stored in Pauli basis for nspin=4, so the Pauli-to-spinor conversion in force/stress calculation is NOT needed. The previous result.ref for scf_u_spin4 (totalforceref=6.562) was incorrect because it was generated with code that mixed Pauli-basis VU with incorrectly converted values. The correct force is 11.33, consistent with the physical Pauli-basis trace Tr(VU * dDM/dR). Changes: - Remove empty if(nspin==4) block in dftu_force_stress.hpp (no conversion needed) - Update scf_u_spin4/result.ref: totalforceref 6.562 -> 11.332 (correct value) - Update scf_angle_spin4/result.ref: energy/stress to match computed values - Add scf_angle_spin4/threshold: relax energy threshold to 1e-5 eV for non-collinear calculation numerical reproducibility - Update scf_out_dos_spin4/result.ref: force/stress to match computed values
…on and add unit test (#7539) * Refactor: Share RT-TDDFT projector snap integration * Docs: Comment RT-TDDFT projector snap integration
* Toolchain: Rely on installed CMake config file for Cereal and RapidJSON * Remove FindLibxc.cmake * CMake: Use interface target for feature dependencies * Add "-Werror=dev" in CMake for "Test" workflow * Follow-up CMake cleanups * Document CMAKE_PREFIX_PATH and remove hints for LibXC_DIR * Fix Libxc version issue and remove fatals that do not make sense * Follow up to #7521 * CI: Build ABACUS with Ninja generator * Sync abacus_disable_feature_definitions settings * Guard every "apt" system package installation under "sudo"
Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>
* Test: Refactor DeePKS unit tests * Test: Address DeePKS unit test review comments
* refactor(cell): remove unused cross-module includes in read_atoms.cpp
Drop two dead includes that create needless reverse dependencies from
source_cell onto higher layers:
- source_estate/read_orb.h (elecstate::read_orb_file not used here;
the real user is read_atoms_helper.cpp)
- source_basis/module_ao/ORB_read.h (ORB / LCAO_Orbitals not used here)
Verified by compiling the `cell` target with ENABLE_LCAO=ON so the
former `#ifdef __LCAO` block was actually exercised.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: remove dead cross-module includes on reverse-dependency edges
Static scan + per-target compile verification identified 9 unused
includes that create reverse/lateral dependency edges between modules.
Removing them weakens the coupling without any behavior change:
io -> md input_conv.cpp (md_func.h)
estate -> lcao elecstate_energy_terms.cpp, elecstate_print.cpp
(module_deepks/LCAO_deepks.h)
lcao -> pw rdmft_tools.cpp (structure_factor.h),
wavefunc_in_pw.cpp (soc.h)
lcao -> io FORCE_gamma.cpp, FORCE_k.cpp (module_hs/write_HS.h)
pw -> io forces_cc.cpp, forces_scc.cpp (module_output/output_log.h)
Verified by building io_basic, elecstate, rdmft, hamilt_lcao and
module_pwdft (ENABLE_LCAO=ON) after removal; all link targets compile.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(esolver): remove 29 dead io includes (esolver -> io hygiene)
Remove unused source_io includes across the esolver drivers. These are
on the allowed esolver->io direction, so this is include hygiene rather
than decoupling, but it trims 29 needless includes.
Verified three ways:
1. `make esolver` (ENABLE_LCAO=ON) recompiles all 21 TUs, 0 errors.
2. Feature-guarded headers checked explicitly since __RAPIDJSON,
__EXX/__LIBRI and __MLALGO are OFF in this build: the json
(init_info.h/output_info.h) and restart_exx_csr.h symbols are
unused in their consumers (Json::add_output_scf_mag in
esolver_ks.cpp comes from output_info.h, which is kept).
3. Whole-file precise-symbol sweep (incl. all #ifdef blocks) finds
no specific symbol of any removed header in its consumer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: remove 2 more dead cross-module includes
Two dead includes missed by the first reverse-edge pass:
estate -> lcao elecstate_energy_terms.cpp
(module_deltaspin/spin_constrain.h; SpinConstrain
is not referenced anywhere in the file)
esolver -> io esolver_double_xc.cpp
(module_hs/write_HS.h; only a comment mentions
ModuleIO::write_hsk(), no actual call)
Verified: no header symbol appears anywhere in the consumer (guards
included), and `make elecstate` / `make esolver` build cleanly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* feat: update interfaces with ATAT * feat: update path to PP&ORB * feat: re-run the examples use pp&orb in tests/ * feat: update the validation of .orb/.upf extensions * feat: update the validation of .orb/.upf extensions --------- Co-authored-by: Zanthoxylum <chenshengjun@localhost.localdomain>
* Support NPZ output for LCAO HSR matrices * Write NPZ outputs under OUT directory * Run NPZ integration tests only with CNPY --------- Co-authored-by: nscc-gz_pinchen_1 <nscc-gz_pinchen_1@users.noreply.github.com>
* Add FindKML.cmake and resolve FFTW3 issue * FindKML: Add compiler check * Detect fftwf only if ENABLE_FLOAT_FFTW
* checkpoint: skeleton gpu file before full implementation * feat: GPU-accelerated WT KEDF multi_kernel convolution Add GPU backend for KEDF_WT::multi_kernel() using cuFFT via PW_Basis _gpu interface. Key changes: - kedf_wt_gpu.cu: single CUDA kernel (kedf_wt_recip_multiply) for G-space element-wise kernel multiplication, plus multi_kernel_gpu() method that pipelines real2recip → kernel multiply → recip2real entirely on GPU. Persistent buffers allocated via memory_op. - kedf_wt.h: GPU method declarations and buffer members under #ifdef __CUDA guard (zero overhead when CUDA disabled). - kedf_wt.cpp: GPU dispatch at top of multi_kernel() — when pw_rho->device == "gpu", delegates to multi_kernel_gpu(). - source/CMakeLists.txt: add kedf_wt_gpu.cu to USE_CUDA block. Design follows existing ABACUS GPU patterns (memory_op for device memory, thrust::complex in kernels, CHECK_CUDA_SYNC for safety). * fix: move cufft.h include to file scope, fix memory_op type mismatch - kedf_wt.h: #include <cufft.h> was erroneously inside the class body (both in destructor and private section). This caused the cuFFT header extern "C" block to appear inside a C++ class definition, triggering "linkage specification is not allowed" and all cuFFT types undeclared. Moved the include to file scope, guarded by #ifdef __CUDA. - kedf_wt_gpu.cu: d_result_ is double* but resmem_zd_op/delmem_zd_op are typed std::complex<double>*. Changed to resmem_dd_op/delmem_dd_op (nrxx*2 doubles = nrxx complex doubles). * test: add GPU WT KEDF test case (31_OF_KE_WT_GPU) - Add test directory with INPUT (device=gpu), STRU, KPT, result.ref - Test identical to 09_OF_KE_WT but exercises GPU code path - Add CASES_GPU.txt for GPU test discovery - GPU results should match CPU reference within tolerance * refactor: move kedf_wt_gpu.cu to kernels/cuda/ for module consistency Per reviewer request (sunliang98): keep GPU kernel files organized under kernels/cuda/ subdirectory, consistent with other ABACUS modules. * fix: use full include path for kedf_wt.h in moved GPU kernel file After moving kedf_wt_gpu.cu to kernels/cuda/, the bare include #include "kedf_wt.h" no longer resolves since the header is now in the parent directory. Use full module path consistent with other CUDA kernel files (e.g., module_pwdft/kernels/cuda/*.cu). * perf: optimize WT KEDF GPU kernels — double2 + grid-stride + GPU rho^exponent Replace thrust::complex<double> with native double2 (cufftDoubleComplex) to eliminate AoS memory layout overhead (50% bandwidth waste from unused imag component). Add grid-stride loops for flexible occupancy. Move rho^exponent (std::pow) from CPU to GPU, eliminating one H→D transfer per SCF iteration. Kernel changes: - kedf_wt_rho_power (new): GPU-side pow() replaces CPU loop - kedf_wt_recip_multiply: double2 replaces thrust::complex, grid-stride - kedf_wt_real_to_complex: double2 + grid-stride - kedf_wt_complex_to_real_norm: double2 + grid-stride Benchmark (RTX 4060 Laptop, 96^3 grid): ~3.3x end-to-end speedup vs thrust::complex baseline. Kernel-only section: ~76% faster. See wt_kernel_opt/ standalone benchmark for full comparison. Thread coarsening (4x) was tested but showed regression on Ada Lovelace (SM 8.9) — fewer active warps reduced latency hiding for memory-bound kernels. Left for future architecture-specific tuning. * docs: update of_kinetic parameter to note WT GPU acceleration support * fix: pass nspin as parameter to avoid PARAM link error in CUDA unit multi_kernel_gpu in kedf_wt_gpu.cu referenced PARAM.inp.nspin, but the global PARAM symbol is not available during CUDA link in non-OFDFT test targets (dftu_core_test, dftu_operator_test). Pass nspin as a function parameter from the caller in kedf_wt.cpp. * docs: clarify GPU acceleration is enabled via device=gpu for WT KEDF * docs: remove incorrect GPU note from ext-wt KEDF ext-WT KEDF is a separate CPU-only implementation in kedf_extwt.cpp and is not modified by this PR; only WT KEDF has a GPU kernel. Drop the GPU acceleration note from the ext-wt line. --------- Co-authored-by: Liang Sun <50293369+sunliang98@users.noreply.github.com> Co-authored-by: Mohan Chen <mohanchen@pku.edu.cn>
…scf hard to converge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Fix #7125
What's changed?
mixing_beta&mixing_beta_magto suggest smaller parameters for scf hard to converge, as in #7125.