Fix NEB IS/FS independent wrapping producing spurious atom "jumps" - #14
Merged
Azeezakinyemi999 merged 1 commit intoJul 22, 2026
Merged
Conversation
build_neb_images() and write_ase_neb_script()'s template (the one that generates every real run_neb.py) wrapped IS and FS independently before NEB.interpolate(). An atom whose real relaxation crosses a cell boundary in one endpoint but not the other got mapped to opposite sides of the cell, and NEB.interpolate() (raw Cartesian, no periodic awareness) treated that as a literal path to traverse. Confirmed on the real reference pair (Hastelloy_N_1234_supercell, s_145__s_73+s_144): 3 metal atoms showed ~12.6 Å naive IS->FS displacement (essentially the full 12.619 Å cell x-length) vs ~0.01 Å true (minimum-image) displacement -- almost certainly a major contributor to that pair's abnormally high starting fmax (1118 eV/A) and the slow convergence fought all session. Fix: align FS to IS's frame via find_mic() (minimum-image convention) instead of wrapping independently. IS still gets a normal .wrap() as the anchor frame; FS is repositioned to the periodic image of each atom closest to its IS counterpart. H atoms' own displacement is unaffected (verified identical naive vs MIC on the real pair), so this only corrects the spuriously-wrapped metal atoms. Hardening added on top of the core fix: - pbc=(True, True, False) passed to find_mic (not to is_raw/fs_raw's own .pbc, which is left untouched to avoid changing calculator behaviour elsewhere in the NEB run) -- these are slabs with a vacuum gap, not periodic in z; a blanket pbc=True would let find_mic treat a real z-motion (e.g. toward desorption) as if it wrapped through the vacuum. - Half-cell-length warning (find_mic cannot distinguish a genuine displacement > L/2 from a shorter wrap-around candidate), gated by the same pbc mask so an unambiguous large z-motion doesn't false-positive. - IS/FS cell-mismatch guard (find_mic uses is_raw.cell only) raises RuntimeError before any silent misuse. Verified via 13 new synthetic tests (numeric reproduction of the real bug plus each hardening case) and content-assertion tests on the generated template, plus re-running the real reference pair after each change (identical result: 3 flagged atoms, same magnitudes, zero warnings) to confirm the hardening is additive, not a behaviour change. Full suite: 1585/1585 passing. Separately identified but deliberately out of scope for this fix: is_raw/fs_raw's own .pbc is left at ASE's lammps-data reader default (True, True, True), meaning MACE's periodic neighbour search also treats z as periodic during actual NEB force evaluations. With r_max=6-8 A and MACE's standard 2-layer architecture, the effective receptive field (12-16 A) is close to or may exceed the configured 15 A vacuum gap -- a real, separate, force/energy-level concern (distinct from this purely geometric interpolation fix) to be investigated on its own branch.
There was a problem hiding this comment.
Pull request overview
This PR fixes a NEB path construction artifact caused by independently wrapping the initial state (IS) and final state (FS) before interpolation. It realigns FS into IS’s periodic frame using ASE’s minimum-image convention (find_mic), preventing spurious near–cell-length “jumps” in Cartesian interpolation, and adds guards/warnings to make misuse more detectable.
Changes:
- Update
build_neb_images()and the generatedrun_neb.pytemplate to align FS to IS usingfind_mic(..., pbc=(True, True, False))instead of callingfs_raw.wrap(). - Add hardening: IS/FS cell mismatch check (raises) and a half-cell displacement ambiguity warning (periodic axes only).
- Add/extend regression tests: numeric reproduction + template-content assertions, and expand functional guards to accept
find_mic(...)realignment as wrap-equivalent.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
MHI_Nickel/models/ase_neb.py |
Replaces independent FS wrapping with MIC-based IS→FS alignment; adds cell guard + periodic-axis ambiguity warning; updates generated script template similarly. |
MHI_Nickel/tests/test_ase_neb.py |
Adds template assertions and numeric tests reproducing the boundary-wrap “jump” bug plus hardening behaviors (cell mismatch, z non-periodic, warning gating). |
MHI_Nickel/tests/functional/test_ft_script_generation.py |
Updates .wrap() regression guard to allow find_mic(...) realignment and expands the post-read inspection window. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
build_neb_images() and write_ase_neb_script()'s template (the one that generates every real run_neb.py) wrapped IS and FS independently before NEB.interpolate(). An atom whose real relaxation crosses a cell boundary in one endpoint but not the other got mapped to opposite sides of the cell, and NEB.interpolate() (raw Cartesian, no periodic awareness) treated that as a literal path to traverse.
Confirmed on the real reference pair (Hastelloy_N_1234_supercell, s_145__s_73+s_144): 3 metal atoms showed ~12.6 Å naive IS->FS displacement (essentially the full 12.619 Å cell x-length) vs ~0.01 Å true (minimum-image) displacement -- almost certainly a major contributor to that pair's abnormally high starting fmax (1118 eV/A) and the slow convergence fought all session.
Fix: align FS to IS's frame via find_mic() (minimum-image convention) instead of wrapping independently. IS still gets a normal .wrap() as the anchor frame; FS is repositioned to the periodic image of each atom closest to its IS counterpart. H atoms' own displacement is unaffected (verified identical naive vs MIC on the real pair), so this only corrects the spuriously-wrapped metal atoms.
Hardening added on top of the core fix:
Verified via 13 new synthetic tests (numeric reproduction of the real bug plus each hardening case) and content-assertion tests on the generated template, plus re-running the real reference pair after each change (identical result: 3 flagged atoms, same magnitudes, zero warnings) to confirm the hardening is additive, not a behaviour change. Full suite: 1585/1585 passing.
Separately identified but deliberately out of scope for this fix: is_raw/fs_raw's own .pbc is left at ASE's lammps-data reader default (True, True, True), meaning MACE's periodic neighbour search also treats z as periodic during actual NEB force evaluations. With r_max=6-8 A and MACE's standard 2-layer architecture, the effective receptive field (12-16 A) is close to or may exceed the configured 15 A vacuum gap -- a real, separate, force/energy-level concern (distinct from this purely geometric interpolation fix) to be investigated on its own branch.