Skip to content

Refactor: read EXX ABFS/JLE file lists via UnitCell, fully decouple source_cell (#7598) - #7667

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-read_atom_species-exx
Jul 22, 2026
Merged

Refactor: read EXX ABFS/JLE file lists via UnitCell, fully decouple source_cell (#7598)#7667
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-read_atom_species-exx

Conversation

@Critsium-xy

Copy link
Copy Markdown
Collaborator

Background

Related to #7598 (source_cell should not depend back on higher layers).

After the earlier cleanups (#7633/#7636/#7637 relocations, #7635 broadcast move), the only remaining reverse dependency in non-test source_cell was:

source/source_cell/read_atom_species.cpp
    #include "source_hamilt/module_xc/exx_info.h"   // writes GlobalC::exx_info

read_atom_species parsed the STRU ABFS_ORBITAL / ABFS_JLES_ORBITAL sections and pushed the filenames straight into GlobalC::exx_info.info_ri / info_opt_abfs — the STRU parser (geometry layer) writing into the XC module's global state.

Change

Route the lists through UnitCell, where STRU orbital-file names already live (orbital_fn, descriptor_file):

  • UnitCell gains neutral members abfs_orbital_files / jle_orbital_files.
  • read_atom_species parses the sections into those members; the exx_info.h include and the cal_exx || rpa guard are removed (an absent section is a no-op via SCAN_LINE_BEGIN).
  • bcast_cell broadcasts the two members as part of bcast_unitcell.
  • Exx_NAO::init(ucell) copies them into GlobalC::exx_info before Exx_LRI copies info_ri, keeping the EXX-specific routing (which list feeds info_ri vs info_opt_abfs) in the LCAO EXX layer.

Data flow:

read_atom_species → UnitCell members → bcast_unitcell (all ranks) → Exx_NAO::init copies → exx_info → Exx_LRI / opt-ABFs / RPA

Because the lists now travel inside the already-broadcast UnitCell, the dedicated bcast_exx_file_lists() added in #7635 is redundant and removed.

Result

source_cell (non-test) now #includes only source_base and itself — the reverse-dependency goal of #7598 is met. (Test files still cross layers to build fixtures, which is conventional.)

Timing / correctness

init(ucell) runs in ESolver_KS_LCAO::before_all_runners (reused by TDDFT / DM2rho / DoubleXC; LR reuses the moved Exx_LRI), on all ranks, after driver_run has called setup_cell (which reads STRU on rank 0 and broadcasts UnitCell), and before every consumer:

  • RI-EXX: the copy is immediately before Exx_LRI copies info_ri.
  • opt-ABFs: generate_matrix runs later in the same before_all_runners.
  • RPA: RPA_LRI(GlobalC::exx_info.info_ri) is built during SCF, later still.

Behaviour is preserved. The cal_exx guard removal is a no-op in practice: when EXX/RPA is off the ABFS lists are simply unused (Exx_LRI is constructed but not run).

Verification

  • Repo-wide grep: non-test source_cell has no remaining exx_info/GlobalC::exx reference; no dangling bcast_exx_file_lists.
  • g++ -std=c++14 -fsyntax-only passes on read_atom_species.cpp (with __LCAO), bcast_cell.cpp (with __MPI, stubbed mpi.h), and the init() copy logic compiled against the real exx_info + UnitCell structs. setup_exx.cpp/esolver pull LibRI and are exercised by CI.
  • No unit test asserts on the ABFS lists and no STRU fixture contains the sections, so no test behaviour changes.

Minor note

The now-unused rpa parameter of read_atom_species is left in place to avoid rippling the setup_cell signature; it can be dropped in a follow-up.

…cell (deepmodeling#7598)

read_atom_species.cpp (source_cell) parsed the STRU ABFS_ORBITAL /
ABFS_JLES_ORBITAL sections directly into GlobalC::exx_info, making the
source_cell data-structure layer depend on source_hamilt/module_xc. This
was the last remaining reverse dependency in source_cell.

Route the lists through UnitCell instead — the same place STRU orbital-file
names already live (orbital_fn, descriptor_file):

- UnitCell gains neutral members abfs_orbital_files / jle_orbital_files.
- read_atom_species parses the sections into those members; the exx_info.h
  include and the cal_exx guard are removed (absent sections are no-ops).
- bcast_cell broadcasts the two members as part of bcast_unitcell.
- Exx_NAO::init(ucell) copies them into GlobalC::exx_info before Exx_LRI
  copies info_ri, keeping the EXX-specific routing in the LCAO EXX layer.

Because the lists now travel inside the (already broadcast) UnitCell, the
dedicated bcast_exx_file_lists() added in deepmodeling#7635 is redundant and removed.

After this, source_cell (non-test) includes only source_base and itself.

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

Copy link
Copy Markdown
Collaborator Author

Source_cell should be a clean module after this PR.

@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.

Nice job

@mohanchen mohanchen added Refactor Refactor ABACUS codes Interfaces Interfaces with other packages labels Jul 22, 2026
@mohanchen
mohanchen merged commit f67e344 into deepmodeling:develop Jul 22, 2026
17 checks passed
@Critsium-xy
Critsium-xy deleted the decouple/source_cell-read_atom_species-exx 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

Interfaces Interfaces with other packages Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants