Refactor: remove source_lcao dependency from source_hsolver - #7683
Merged
mohanchen merged 1 commit intoJul 24, 2026
Merged
Conversation
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
approved these changes
Jul 24, 2026
mohanchen
left a comment
Collaborator
There was a problem hiding this comment.
OK, that's reasonable.
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.
Background
As part of dependency cleanup for
source_hsolver, the target is to keep it depending only onsource_estate,source_psi,source_cell,source_basis, andsource_base(source_iotolerated 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 callLCAO_domain::dm2rhofor computing the charge density after solving the Hamiltonian.Change
HSolverLCAO::solvenow delegates the charge-density calculation through a new thin wrapperElecStateLCAO::dmToRho, instead of calling thesource_lcaofree function directly.source_estate/elecstate_lcao.{h,cpp}: adddmToRho(...), forwarding toLCAO_domain::dm2rho.source_estatealready depends onsource_lcao(e.g.module_gint,rho_tau_lcao.h), so this introduces no new cross-module dependency edge.source_hsolver/hsolver_lcao.cpp: calldynamic_cast<ElecStateLCAO<TK>*>(pes)->dmToRho(...)and remove thesource_lcaoinclude.This mirrors the existing patterns in the codebase:
_pes->dm2rho(...);ElecStatePW::psiToRho.After this change,
source_hsolverhas no directsource_lcaoinclude orLCAO_domainreference.Notes
LCAO_domain::dm2rhois executed, just reached through theElecStateinterface.dynamic_castprecondition (pesis anElecStateLCAOon the LCAO path) is already relied upon by the pre-existing pexsi branch.