Skip to content

Fix NEB IS/FS independent wrapping producing spurious atom "jumps" - #14

Merged
Azeezakinyemi999 merged 1 commit into
fix_redundant_min_npt_runfrom
fix-neb-is-fs-periodic-wrap
Jul 22, 2026
Merged

Fix NEB IS/FS independent wrapping producing spurious atom "jumps"#14
Azeezakinyemi999 merged 1 commit into
fix_redundant_min_npt_runfrom
fix-neb-is-fs-periodic-wrap

Conversation

@Azeezakinyemi999

Copy link
Copy Markdown
Owner

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.

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.
Copilot AI review requested due to automatic review settings July 22, 2026 18:15
@Azeezakinyemi999
Azeezakinyemi999 merged commit b729d1d into fix_redundant_min_npt_run Jul 22, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 generated run_neb.py template to align FS to IS using find_mic(..., pbc=(True, True, False)) instead of calling fs_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.

@Azeezakinyemi999
Azeezakinyemi999 deleted the fix-neb-is-fs-periodic-wrap branch July 22, 2026 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants