You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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>
0 commit comments