Skip to content

Refactor: move read_orb from source_estate to source_cell (#7634) - #7648

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-read_orb-7634
Jul 17, 2026
Merged

Refactor: move read_orb from source_estate to source_cell (#7634)#7648
mohanchen merged 2 commits into
deepmodeling:developfrom
Critsium-xy:decouple/source_cell-read_orb-7634

Conversation

@Critsium-xy

Copy link
Copy Markdown
Collaborator

Background

Fixes #7634.

source_cell is a data-structure layer that should not depend on the higher source_estate layer, yet read_atoms_helper.cpp called elecstate::read_orb_file(...), pulling source_cell back up onto source_estate (a circular dependency).

Root cause

read_orb_file is misplaced. It only:

  • parses an orbital-file header and writes the results into Atom fields (nw, nwl, l_nchi, label_orb, Rcut) — all source_cell data;
  • depends solely on source_cell/unitcell.h (same layer) and source_base/formatter.h (base layer).

Its only non-test caller is source_cell/read_atoms_helper.cpp; nothing in source_estate uses it. The elecstate:: namespace was a vestigial label — there is nothing electronic-structure about it.

Change

  • Move read_orb.{h,cpp} from source_estate/ down into source_cell/.
  • Rename the namespace elecstateunitcell to match the module.
  • Update the include paths and the two call sites in read_atoms_helper.cpp.
  • Update every CMake target that compiled the file by its old path (source_cell/test, source_cell/test_pw, source_lcao/module_deepks/test, source_md/test, source_pw/module_pwdft/test) and the cell / estate object libraries.

After the change source_cell no longer #includes source_estate/...; read_orb only depends downward (source_base) and same-layer (unitcell.h), so no new cycle is introduced.

Verification

  • Repo-wide grep confirms no remaining source_estate/read_orb or elecstate::read_orb_file references.
  • g++ -std=c++14 -fsyntax-only -I source passes on both the moved read_orb.cpp and the caller read_atoms_helper.cpp.
  • Behaviour is unchanged — this is a pure file move + namespace rename with no logic edits. MODULE_CELL_unitcell_test covers read_orb_file (two cases) and continues to build against the new location.

Critsium-xy and others added 2 commits July 17, 2026 11:30
…ng#7634)

read_orb_file only parses an orbital-file header into Atom fields and
depends solely on source_cell/unitcell.h and source_base. Its only
non-test caller lives in source_cell (read_atoms_helper.cpp), so its
placement in source_estate created a circular source_cell -> source_estate
dependency.

Move read_orb.{h,cpp} down into source_cell and rename the namespace from
elecstate to unitcell to match its module. Update the include paths, the
call sites, and every CMake target that referenced the old estate path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This test target compiles read_atoms_helper.cpp, which now calls
unitcell::read_orb_file, but did not list read_orb.cpp in its SOURCES,
causing an undefined-reference link error. Add ../read_orb.cpp so the
definition is linked in.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Jul 17, 2026
@mohanchen
mohanchen merged commit cb86cc4 into deepmodeling:develop Jul 17, 2026
17 checks passed
@Critsium-xy
Critsium-xy deleted the decouple/source_cell-read_orb-7634 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.

[source_cell] read_atoms_helper.cpp relies on source_estate/read_orb.h

2 participants