Skip to content

Refactor: remove source_lcao dependency from source_hsolver - #7683

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:cleanup/hsolver-remove-source_lcao-dep
Jul 24, 2026
Merged

Refactor: remove source_lcao dependency from source_hsolver#7683
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:cleanup/hsolver-remove-source_lcao-dep

Conversation

@Critsium-xy

@Critsium-xy Critsium-xy commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Background

As part of dependency cleanup for source_hsolver, the target is to keep it depending only on source_estate, source_psi, source_cell, source_basis, and source_base (source_io tolerated for now).

A scan showed one direct dependency on source_lcao:

  • source/source_hsolver/hsolver_lcao.cpp#include "source_lcao/rho_tau_lcao.h", used to call LCAO_domain::dm2rho for computing the charge density after solving the Hamiltonian.

Change

HSolverLCAO::solve now delegates the charge-density calculation through a new thin wrapper ElecStateLCAO::dmToRho, instead of calling the source_lcao free function directly.

  • source_estate/elecstate_lcao.{h,cpp}: add dmToRho(...), forwarding to LCAO_domain::dm2rho. source_estate already depends on source_lcao (e.g. module_gint, rho_tau_lcao.h), so this introduces no new cross-module dependency edge.
  • source_hsolver/hsolver_lcao.cpp: call dynamic_cast<ElecStateLCAO<TK>*>(pes)->dmToRho(...) and remove the source_lcao include.

This mirrors the existing patterns in the codebase:

  • the pexsi branch in the same function already delegates via _pes->dm2rho(...);
  • the plane-wave path delegates charge computation via ElecStatePW::psiToRho.

After this change, source_hsolver has no direct source_lcao include or LCAO_domain reference.

Notes

  • No functional change — pure dependency refactor; the same LCAO_domain::dm2rho is executed, just reached through the ElecState interface.
  • The dynamic_cast precondition (pes is an ElecStateLCAO on the LCAO path) is already relied upon by the pre-existing pexsi branch.

HSolverLCAO::solve computed the charge density directly via the
source_lcao free function LCAO_domain::dm2rho, making source_hsolver
depend on source_lcao.

Delegate the charge-density calculation through a new thin
ElecStateLCAO::dmToRho wrapper (source_estate, which already depends on
source_lcao). This mirrors the existing pexsi branch (_pes->dm2rho) and
the plane-wave path (ElecStatePW::psiToRho), and removes the only direct
source_lcao include from source_hsolver.

No functional change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@mohanchen mohanchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that's reasonable.

@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Jul 24, 2026
@mohanchen
mohanchen merged commit 820a367 into deepmodeling:develop Jul 24, 2026
18 checks passed
@Critsium-xy
Critsium-xy deleted the cleanup/hsolver-remove-source_lcao-dep branch July 27, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants