Repository navigation
Refactor occupation matrix initialization - #8147
Merged
mohanchen merged 5 commits intoOct 17, 2026
Merged
Conversation
Summary:
- Split occupation-matrix allocation and correlated-orbital mapping
into private helpers allocate_atom_matrices() and build_corr_iwt()
so init() is a clear top-level loop.
- Remove duplicated saved-matrix flattening branches in
write_save_to_flat(): channel 0 copy is shared across all supported
spin modes, only nspin=2 additionally copies channel 1; use std::copy.
- Add direct nspin=1/2/4 layout and flattening tests in
MODULE_ESTATE_occ_matrix.
No change to numerical behavior, data layout, or public interface.
Tests:
- cmake --build build --target MODULE_ESTATE_occ_matrix MODULE_ESTATE_occ_mixer -j2
- ctest --test-dir build -V -R 'MODULE_ESTATE_occ_(matrix|mixer)'
-> 100% tests passed, 0 tests failed out of 2 (13 gtest cases)
- python3 tools/03_code_analysis/code_quality_score.py source/source_estate/occ_matrix.cpp
-> 100/100 (was 98/100; both high_cyclomatic_complexity deductions gone)
- git diff --check: PASS
- python3 tools/03_code_analysis/agent_governance_check.py --staged
-> one warning only: documentation sync review (no user-visible
behavior change, so no docs update required)
ABACUS-PR-BOT
left a comment
Collaborator
There was a problem hiding this comment.
Static review of 4d1069d: no correctness regression found in the inspected allocation, mapping, and saved-flattening paths. One optional test improvement below. No build or runtime tests were run; CI diagnostics were unavailable through the configured connector.
mohanchen
approved these changes
Oct 17, 2026
Collaborator
|
LGTM. Thanks for your contributions. @lanshuyue |
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.
Summary
allocate_atom_matrices()andbuild_corr_iwt()soinit()is a clear top-level loop.write_save_to_flat(): channel 0 copy is shared across all supported spin modes, only nspin=2 additionally copies channel 1; usestd::copy.MODULE_ESTATE_occ_matrix.This is a behavior-preserving maintainability refactor; no numerical behavior, data layout, or public interface change.
Tests
cmake --build build --target MODULE_ESTATE_occ_matrix MODULE_ESTATE_occ_mixer -j2-> both targets built successfullyctest --test-dir build -V -R 'MODULE_ESTATE_occ_(matrix|mixer)'-> 100% tests passed, 0 tests failed out of 2 (13 gtest cases total)python3 tools/03_code_analysis/code_quality_score.py source/source_estate/occ_matrix.cpp-> 100/100 (was 98/100; bothhigh_cyclomatic_complexitydeductions eliminated)git diff --check-> PASSpython3 tools/03_code_analysis/agent_governance_check.py --staged-> one warning only: documentation sync review (no user-visible behavior change, so no docs update required)