Refactor: move read_orb from source_estate to source_cell (#7634) - #7648
Merged
mohanchen merged 2 commits intoJul 17, 2026
Merged
Conversation
…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
approved these changes
Jul 17, 2026
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
Fixes #7634.
source_cellis a data-structure layer that should not depend on the highersource_estatelayer, yetread_atoms_helper.cppcalledelecstate::read_orb_file(...), pullingsource_cellback up ontosource_estate(a circular dependency).Root cause
read_orb_fileis misplaced. It only:Atomfields (nw,nwl,l_nchi,label_orb,Rcut) — allsource_celldata;source_cell/unitcell.h(same layer) andsource_base/formatter.h(base layer).Its only non-test caller is
source_cell/read_atoms_helper.cpp; nothing insource_estateuses it. Theelecstate::namespace was a vestigial label — there is nothing electronic-structure about it.Change
read_orb.{h,cpp}fromsource_estate/down intosource_cell/.elecstate→unitcellto match the module.read_atoms_helper.cpp.source_cell/test,source_cell/test_pw,source_lcao/module_deepks/test,source_md/test,source_pw/module_pwdft/test) and thecell/estateobject libraries.After the change
source_cellno longer#includessource_estate/...;read_orbonly depends downward (source_base) and same-layer (unitcell.h), so no new cycle is introduced.Verification
source_estate/read_orborelecstate::read_orb_filereferences.g++ -std=c++14 -fsyntax-only -I sourcepasses on both the movedread_orb.cppand the callerread_atoms_helper.cpp.MODULE_CELL_unitcell_testcoversread_orb_file(two cases) and continues to build against the new location.