Skip to content

Refactor: move LR-TDDFT solver logic out of ESolver_LR into module_lrRefactor: move LR-TDDFT solver logic out of ESolver_LR into module_lr #8438

Done

Description

@mohanchen

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 into module_lr.
  • Keep the esolver responsible only for: ESolver_FP setup (PW grids, structure
    factor, kv.set, neighbour lists, symmetry), EXX ownership, the ESolver interface
    adapters (cal_energy / cal_force / cal_stress), and the BSE subclass hookup.
  • module_lr must not include any esolver header; dependencies are passed explicitly
    through POD handles.
  • No behaviour change. No new PARAM/GlobalV dependencies (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-lr before the embedded ground-state SCF).

Acceptance criteria

  • ESolver_LR implementation is one esolver_lr.cpp + esolver_lr.h.
  • LR algorithms are callable from module_lr without 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.587347
    • 08_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.

Activity

  1. added
    Refactor
    EXX/lr-TDDFT/RPA/BSE/GW
    The Absolute Zero
    on Nov 28, 2026
  2. added a commit that references this issue on Nov 30, 2026
    43a749f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EXX/lr-TDDFT/RPA/BSE/GWRefactorSolve before 3.11The Absolute Zero

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions