Reconstruct continuous bonded coordinates from wrapped XYZ trajectories by combining bond-graph minimum-image unwrapping with temporal continuity fallbacks, while preserving strict output invariants. Use when periodic boundary wrapping makes bonded atoms appear discontinuous and grading checks enforce exact frame/format preservation.
Parse inputs robustly.
n, comment line, atom lines).Preserve invariants early.
Construct a traversal order over the bond graph.
Unwrap frame 1 as identity.
For each subsequent frame, unwrap with MIC first.
(p -> u), compute wrapped delta d = w[u] - w[p].d -= L * round(d / L).u from already placed parent coordinate.Apply temporal continuity fallback when MIC is implausible.
|d| exceeds bond threshold (e.g., >2.0 Å), replace/adjust using previous unwrapped frame’s bond vector (u_prev - p_prev).Write output with strict formatting discipline.
10.500000 changed original text 10.5.Run verification immediately after writing output:
Schema checks
Reference-frame immutability
Bond-distance checks
Final harness check
pytest /tests/test_outputs.py) to confirm all contract checks pass.d' = d - L * round(d/L)