1. What this solves
You fit a potential energy model to forces, for example a neural network trained on DFT forces, and then run dynamics with it. The usual recipe fits the forces as closely as possible and leaves accuracy to the integrator, so a leapfrog (Verlet) simulation still carries an error that grows with the square of the time step, and you pay for accuracy with small steps and many force calls. This method instead trains the potential for the step size you will simulate with, so that the integration error is compensated during training. With a small change to the integrator (a fixed change of variables at the start and at each saved frame), the simulation becomes fourth-order accurate for the step-specific target potential, while each step still costs one ordinary force evaluation. Training uses the same position-force pairs as ordinary force matching.
In technical terms: for a separable Hamiltonian with constant diagonal mass matrix , plain leapfrog has a momentum-dependent error term that no learned potential can cancel (paper, Proposition 4.2). Processed leapfrog, (Eq. (36)), removes that term, leaving a position-only term (Lemma 4.3) that a potential can absorb. Modified-Equation-Aware Learning (MEAL) fits so that its corrected gradient matches the force labels (Eqs. (41)–(42)). The processed map is explicit, symplectic and symmetric ().
2. When to use
- Equations of motion , : conservative forces from a scalar potential, constant diagonal masses (repeat each atom's mass over ), no velocity or time dependence (paper Eq. (26)).
- You train the potential from samples with : DFT forces, or forces of a frozen teacher model you want to distil. No momenta, energies, trajectories or derivatives of the labels are needed. The model must be smooth enough to differentiate twice in position during training (one Hessian-vector product per configuration).
- One fixed step per trained checkpoint, and physical output on a regular grid, ideally every several steps: each output costs four extra force evaluations.
- Forces are expensive (a neural network or quantum chemistry), so saving force calls matters.
What the paper reports (Jiang, Guo, Zhu & Li, 2026, Section 5), on all ten molecules of rMD17 with a MACE potential:
- Against a teacher potential (Section 5.2), the fitted convergence order is 3.6 for MEAL with processed leapfrog versus 2.0 for leapfrog with the classically trained potential. At equal accuracy with physical output every 10 fs, it is up to 6.8× faster than classical leapfrog and up to 4.6× faster than fourth-order Yoshida integration (Table 4). The trained models do not show verified fourth-order convergence.
- Trained directly on DFT forces and compared with independent DFT trajectories (Section 5.3), it reduces the trajectory error by 56% relative to leapfrog at a 1 fs step and, with output every 10 fs, is 3.3× faster than leapfrog and 6.1× faster than Yoshida at equal accuracy (Table 5 and Figure 8). Below 1 fs all methods reach an error floor set by the potential and the reference calculation, not by the integrator.
- At 2 fs, 19 of 40 MEAL trajectories stayed intact for 200 ps against one for each classical integrator (Section 5.4, teacher-student setting).
- The gains depend on output frequency: at 2 fs with output every 2 fs, 400 of 504 force evaluations go to postprocessing and MEAL was slower than the matched leapfrog run (0.60×).
3. When not to use (and what to use instead)
| Situation | Use instead |
|---|---|
| The force law is given (a formula, an existing force field, a quantum-chemistry call at every step) and you will not train a model | stormer-verlet, or yoshida4 for higher accuracy on smooth problems |
| Output needed at every step, or very short runs | stormer-verlet at a smaller step, or yoshida4; count the four evaluations per output before choosing (paper Section 4.5) |
| One model for several step sizes, or a step that changes during the run | Classical force matching with a standard integrator. A MEAL checkpoint is specific to its : in the paper, using a checkpoint at another step raised the error by a factor of 2.0 to 451 |
| Adaptive steps or output at arbitrary times | dormand-prince-rk45 over short runs; otherwise a fixed step with the output times on the step grid |
| Friction, thermostats, Langevin or other stochastic dynamics | A splitting designed for those equations (not in this library). The derivation does not cover them; any new splitting must be analysed and tested separately |
| Holonomic constraints (rigid water, fixed bond lengths) | RATTLE, SHAKE or SETTLE (not in this library) |
| Non-separable Hamiltonian or position-dependent mass | implicit-midpoint |
| Non-diagonal constant mass matrix | Not covered by the paper or the reference; the paper assumes |
| Your model predicts forces directly, without an energy (a non-conservative force head) | Not applicable: the correction acts on a scalar potential. Train an energy model whose forces are its gradient first, or run your model with stormer-verlet |
| You learn the full vector field, not a potential | The general MEAL objective with an automatic-differentiation modified field (paper Section 3), for example with RK2; not this skill |
| You need sixth order | Not available with this processor: an velocity term remains for any potential (paper Appendix A.5) |
| Fast modes you want to step over, or close encounters | Multiple time stepping, regularization or adaptive time transformations (not in this library). The leapfrog stability limit still applies |
4. Algorithm
Notation: , , , (Eq. (30)). Drift and kick (Eq. (28)).
Why plain leapfrog is not enough. The modified Hamiltonians are (Lemma 4.1, Eqs. (31)–(32))
depends on momenta, so its gradient enters and no change of removes it (Proposition 4.2, Remark A.4).
Processing. With a near-identity symplectic map , the processed DKD has (Lemma 4.3, Eq. (37)). For the target potential (Proposition 4.4, Eq. (39)) the processed map has one-step error and global error in the physical on bounded intervals with bounded derivatives. Both ingredients are needed: processing with , or without processing, stays second order (paper Table 7, reproduced in verify/check_paper.py).
Training (Section 4.4, Algorithm 3). Fit to labels by minimizing
(Eqs. (40)–(42)). In an autodiff framework: with the graph kept, , , then backpropagate through both copies of . The minimizer approximates . Start from a classically trained checkpoint.
Simulation (Section 4.3, Algorithm 2). Use the ordinary gradient in every kick; never .
- Set . The postprocessor applies the eight shears (Appendix A.4, Eq. (68))in this order. The preprocessor is its exact inverse: the same shears in reverse order with every duration negated.
- Preprocess the physical initial state once to get the auxiliary state.
- Advance the auxiliary state with ordinary DKD, , one force per step.
- At each output step (every steps and at the final step), postprocess a copy of the auxiliary state and emit it. Never write the output back.
Cost for steps with output every steps and at the end (Eq. (43)):
so with output only at the end. The processor depends on , so running with integrates backwards exactly ().
5. Parameters
| Parameter | How to choose it |
|---|---|
| Step size | Train one checkpoint per candidate and check accuracy and stability on short runs against a reference at a much smaller step. The leapfrog stability limit applies ( for the fastest harmonic mode, with margin). The paper used 0.25 to 2 fs for small organic molecules. Keep checkpoint, processor and core tied to the same . |
| Output interval | As large as your analysis allows; each output costs four forces. Step is time . Changing does not change the trajectory. |
| Masses and units | One positive mass per coordinate, canonical momentum , consistent units for positions, energies, forces, masses and time (the paper uses atomic units). |
| Loss weighting | The basic loss is Eq. (42). For several molecules, the paper divided each configuration's mean squared component error by a per-molecule force scale squared and by (Eq. (69)); the second factor does not change the minimizer. |
| Model and optimizer | Initialize from a classically trained checkpoint and fine-tune with Adam; choose learning rate and stopping from held-out loss and short rollouts. No transferable defaults. |
7. Verification
Step 1: check your implementation against this skill. Do this after porting and before training or production runs. Show the output to the user.
Get the files: put
checks/check_port.pyandchecks/cases.jsonin the same folder (the script readscases.jsonfrom beside itself). Through MCP, fetch both withget_file; or download and unpack the skill's zip.Python: create
port_adapter.pyin your working directory withPARTS = ("training", "simulation")(or the part you implemented) and the functions described at the top ofcheck_port.py:modified_gradientandloss_and_derivativefor a fixed two-coordinate polynomial potential that you write in your framework, andprocessandrollout, which receive the gradient as a plain function. Then run it from the directory that containsport_adapter.py, with the Python environment in which your code works:python <folder-with-the-check-files>/check_port.pyIt compares your results with fixed cases computed by the reference implementation (only rounding differences are allowed), checks that your is the derivative of your own loss, and checks order 4 on the quartic double well with , the processor round trip, returning to the start with , output-interval independence and the force count .
Other languages: run each case in
checks/cases.jsonwith your code (problem, inputs and interface are described there) and compare withexpectedwithintol.
A failed fixed case almost always means a porting mistake: and mixed up, a detached gradient copy in the loss, pre- and postprocessor swapped or shears in the wrong order, , momentum used as velocity, a force sign error, the corrected gradient used in simulation kicks, or the output written back into the auxiliary state.
Step 2: check the method on your own problem.
- Convergence order of the simulation code. With an analytic (or a small model trained separately for , , ), integrate to a fixed time and compare with a much finer reference. Processed leapfrog with should give errors falling about 16× per halving; plain DKD with about 4×.
- Trained model against classical training. Same initial states, horizon, output times and error metric; record the step size and force calls of each. Expect the gain to shrink at small , where the fitting error of the potential dominates, and with frequent output.
- Step specificity. Evaluate the checkpoint at its training step and at a neighbouring one; it should be best at its own step.
- Energy and stability. Over long runs the energy error should stay bounded without drift; watch failure rates at the largest , checked on a fine enough output grid.
8. Failure signatures
| Symptom | Likely cause |
|---|---|
| Only order 2 with an analytic | Output not postprocessed, processor shears in the wrong order or with the wrong , or and confused. verify/check_method.py shows unpostprocessed output and a checkpoint trained for both at order 2. |
| Good training loss, poor trajectories | Checkpoint used at a step it was not trained for; units or mass mismatch between training and simulation; corrected gradient used in the kicks; configurations outside the training data. |
| Results change with the output interval | The postprocessed output is written back into the auxiliary state. |
| Round trip pre then post does not return the input | The preprocessor is not the exact inverse: reverse the order and negate every duration. |
| Blow-ups at larger | Leapfrog stability limit for the fastest modes, or out-of-domain configurations. Reduce or extend the training data. |
| Expected speed-up disappears | Output too frequent (four forces per output), or the run is too short for the eight processor forces to pay off. |
| Momentum-flip round trip misses by a small amount | Expected: the method is symmetric () but not reversible under momentum flip, because the processor is not; the round trip agrees only to the processor error. Test with instead, which is exact. |
9. Files and commands
Run from this folder with uv and Python 3.11 or newer; only the standard library is used.
uv run examples/fit_harmonic.py
uv run examples/double_well.py
uv run verify/check_method.py
uv run verify/check_paper.py
uv run verify/check_cases.py
reference/processed_dkd.py: corrected gradient and loss, drift, kick, DKD step, processors and the rollout of Algorithm 2.examples/: fitting a spring from four force labels and simulating it (MEAL versus classical training with leapfrog), and the quartic double well of the paper's Table 7; expected output in*.expected.txt.checks/: for checking your implementation.cases.jsonholds fixed cases;check_port.pyruns them and the property checks throughport_adapter.py;make_cases.pyregeneratescases.jsonfrom the reference implementation.verify/: evidence for the claims in this file, run on the reference implementation: order 4 and the documented order-2 failures, symplecticity, symmetry, processor inversion, output independence and cost (check_method.py); reproduction of the paper's Table 7, the coefficients of Lemmas 4.1 and 4.3 and Remark A.4, the sixth-order obstruction and the force counts (check_paper.py); and that the fixed cases catch nine typical porting mistakes (check_cases.py).
10. Sources
- H. Jiang, Y. Guo, A. Zhu, Q. Li. Accelerating Dynamical Systems Simulation via Modified-Equation-Aware Learning. 2026. arXiv:2612.01280v1. Equation, lemma, proposition, section and table numbers in this file refer to arXiv v1.
- E. Hairer, C. Lubich, G. Wanner. Geometric Numerical Integration, 2nd ed. Springer, 2006. https://doi.org/10.1007/3-540-30666-8
- E. Hairer, R. I. McLachlan, R. D. Skeel. On energy conservation of the simplified Takahashi–Imada method. ESAIM: Mathematical Modelling and Numerical Analysis 43(4) (2009) 631–644.
- S. A. Chin. Quantum statistical calculations and symplectic corrector algorithms. Physical Review E 69 (2004) 046118.