Repository navigation
Done
Labels
EXX/lr-TDDFT/RPA/BSE/GWRelated to beyond DFT methodsRefactorRefactor ABACUS codesSolve before 3.11The Absolute ZeroReduce the "entropy" of the code to 0
Description
Describe the Code Quality Issue
Background
ESolver_LR (linear-response TDDFT, Tamm-Dancoff) is both the solver-interface adapter
and the place where every LR algorithm lives. Its implementation is spread over seven
files under source/source_esolver/:
- esolver_lr_init.cpp (483 lines)
- esolver_lr_cfg.cpp (172 lines)
- esolver_lr_grad.cpp (436 lines)
- esolver_lr_lcao_tddft.cpp / .h (355 / 378 lines)
- esolver_lr_orb.cpp (336 lines)
- esolver_lr_rlx.cpp (394 lines)
The actual LR physics -- amplitude setup, ground-state reading, kernel potentials,
the TDA eigenproblem, Z-vector/force path, excited-state relaxation, tendency tracking,
spectrum/density output -- is in the esolver layer, not in
source_lcao/module_lr/ where the rest of the LR machinery lives.
This causes:
- poor cohesion: LR algorithms cannot be reused or unit-tested without an esolver;
- a very large, hard-to-review esolver surface;
- duplicated state scattered across the esolver (dimensions, wavefunctions, amplitudes,
potentials, forces, relaxation targets).
Goal
Make ESolver_LR a thin adapter and move the LR state and algorithms into
source_lcao/module_lr.
Scope
- Introduce an
LR::Core<T>aggregate that owns the LR solver state. - Move dimension resolution, ground-state wavefunction/charge reading, kernel
potentials, the TDA solve, electron-hole density/spectrum output, the force path
and the excited-state relaxation/tendency tracking intomodule_lr. - Keep the esolver responsible only for:
ESolver_FPsetup (PW grids, structure
factor,kv.set, neighbour lists, symmetry), EXX ownership, theESolverinterface
adapters (cal_energy/cal_force/cal_stress), and the BSE subclass hookup. module_lrmust not include any esolver header; dependencies are passed explicitly
through POD handles.- No behaviour change. No new
PARAM/GlobalVdependencies (net delta must stay <= 0). - Collapse the LR esolver files into a single
esolver_lr.{h,cpp}. - Remove dead wrappers/accessors left over from the split.
Non-goals
- No change to the numerical algorithm, inputs, outputs or file formats.
- No change to BSE behaviour (only its call sites are adjusted).
- No JSON-output changes (still build-gated by
ENABLE_JSON, still initialised for
ks-lrbefore the embedded ground-state SCF).
Acceptance criteria
ESolver_LRimplementation is oneesolver_lr.cpp+esolver_lr.h.- LR algorithms are callable from
module_lrwithout an esolver. - Builds pass for CPU/GPU configurations, plus the LR unit-test targets.
- Integration regressions unchanged:
08_RI/lr_tddft_lda_gamma:CompareLRForce_pass 0,
totalforceref 115.0726395253,excitationenergyref1 0.58734708_RI/lr_relax_lda_ch4:CompareStateTracking_pass 0
- Repository governance check reports 0 errors and no global-dependency increase.
Additional Context
No response
Task list for Issue attackers (only for developers)
- Identify the specific code file or section with the code quality issue.
- Investigate the issue and determine the root cause.
- Research best practices and potential solutions for the identified issue.
- Refactor the code to improve code quality, following the suggested solution.
- Ensure the refactored code adheres to the project's coding standards.
- Test the refactored code to ensure it functions as expected.
- Update any relevant documentation, if necessary.
- Submit a pull request with the refactored code and a description of the changes made.
Metadata
Metadata
Assignees
Labels
EXX/lr-TDDFT/RPA/BSE/GWRelated to beyond DFT methodsRefactorRefactor ABACUS codesSolve before 3.11The Absolute ZeroReduce the "entropy" of the code to 0
Activity
refactor(lr): slim ESolver_LR by moving LR state and logic into modul…