Skip to content

Refactor: extract shared ion–cell geometry operations from simultaneous CG - #8337

Open
Growl1234 wants to merge 1 commit into
deepmodeling:developfrom
Growl1234:relax
Open

Growl1234 wants to merge 1 commit into
deepmodeling:developfrom
Growl1234:relax

Conversation

@Growl1234

@Growl1234 Growl1234 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

This is a prerequisite for moving towards #7970.

@Growl1234 Growl1234 added Refactor Refactor ABACUS codes GeometryRelaxation Issues related to geometry relaxation labels Nov 19, 2026
@Growl1234
Growl1234 marked this pull request as ready for review November 20, 2026 05:01

@ABACUS-PR-BOT ABACUS-PR-BOT 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.

Static review found no introduced correctness defect in this extraction.

Non-blocking: Please record the actual validation commands, configuration and observed results for the extraction and new regression cases in the PR description, including checks that were not run.

Reviewed 9edc0acbb7d4 against eba09c937c73. git diff --check passed; builds and tests were not run, and CI results were not verified.

Comment thread source/source_relax/relax_sync.cpp Resolved
Comment thread source/source_relax/relax_sync.cpp Resolved
@Growl1234

Copy link
Copy Markdown
Collaborator Author

The CUDA failure seems unrelated to this PR as I didn't touch LCAO code.

@MrLi000001

Copy link
Copy Markdown
Collaborator

Overall: LGTM. A behavior-preserving refactor with meaningful new tests. Beyond CI, I built and ran the relax unit tests with sanitizers on two real machines, comparing against the pre-PR baseline — no regressions or hidden issues found.
Verification performed

  • x86_64 workstation (Ubuntu 24.04, GCC 13.3, ASan + UBSan): relax_sync_test 14/14, relax_nsync_test 12/12, relax_driver_test 9/9 — all pass, zero sanitizer reports. The 3 new tests (ProjectedForceAndStressInSkewCell, UsesOldReciprocalCellAndNewLattice, SymmetryPreservesSearchStateForCorrection) confirmed present and passing.
  • aarch64 cluster (GCC 9.4, MPICH 4.0.2, UBSan): relax_sync_test 14/14, relax_nsync_test 12/12 pass. relax_driver_test fails identically on the baseline (PMIX_Init returned -25) — a cluster PMI environment issue, unrelated to this PR.
  • Baseline (parent commit 36a3ebf) shows the same results throughout: PR = baseline + 3 new passing tests.
    Non-blocking suggestions
  1. Document the side effects of lattice_step. The header comment reads like a pure query, but the function transposes/symmetrizes search_dr_cell in place (which later CG dot products rely on) and updates latvec_save when is_new_dir. Please state both in relax_sync.h — calling it twice by mistake would transpose the search direction twice.
  2. Make includes explicit in relax_geometry.cpp. It directly uses Matrix3::Det/Inverse/Transpose and ModuleSymmetry::Symmetry but relies on transitive includes via unitcell.h. Per the repo's explicit-dependency rule, please include source_base/matrix3.h and the symmetry header directly.
  3. Guard the global state in the new test. SymmetryPreservesSearchStateForCorrection modifies the global Symmetry::symm_flag and restores it by hand — fine with non-fatal assertions, but a future ASSERT_* or exception would leak it into later tests. A small RAII guard is safer. Also, the shared symmetrize_mat3 mock in relax_test.h changed from a no-op to actually zeroing components; it only triggers when symm_flag && nrotk > 0, but that is worth a note in the PR description.
  4. Expand the PR description. One sentence is thin for a 400+ line refactor of the core relaxation path. Suggest adding: (a) an explicit "behavior-preserving" statement; (b) the moved-function list (update_lattice / update_ion_positions / update_reciprocal_cell → relax_geometry); (c) how it was verified.

@Growl1234

Growl1234 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

The main purpose of this PR is simply to extract a sharable source file from current CG implementation, so if this doesn't preserve the previous behaviour it will become a regression bug. I would actually prefer minimum additional adjustment about this PR as I have in fact done the whole process of resolving #7970 locally; but I will carefully take a look of the advice anyways.

@Growl1234

Copy link
Copy Markdown
Collaborator Author

The suggested patches are included in the new rebase & force-push.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GeometryRelaxation Issues related to geometry relaxation Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants