Lecture 5Neural ODEHamiltonianSymODENConservation LawsSymplectic

Neural ODEs & Geometric Mechanics

Structure-preserving deep learning for Hamiltonian systems

Overview

Physical systems obey conservation laws — energy, momentum, symplecticity. A standard neural network trained on trajectory data will violate these laws during long-term rollout, leading to unphysical energy drift. This lecture covers the adjoint method for Neural ODEs, Hamiltonian mechanics in phase space, and three structure-preserving architectures: Hamiltonian Neural Networks (HNN), Lagrangian Neural Networks (LNN), and SymODEN. The key insight is that embedding the scalar Hamiltonian as the network output — rather than the vector field — guarantees symplectic dynamics by construction.


Benchmark & Results

Setup

Nonlinear pendulum, 800-epoch training

Result

12× less energy drift vs. baseline; SymODEN recovers true V(q) and M(q)

Neural ODEs & Geometric Mechanics benchmark results
Figure: Neural ODEs & Geometric Mechanics — benchmark results

Lecture Slides

The full slide deck for this lecture is available as a PDF. Each slide includes speaker notes for the presenter.


Code

The annotated implementation for this lecture is in train_minimal.py. All code is written in PyTorch and prioritizes clarity over cleverness.

# train_minimal.py # See the attached file for the full annotated implementation. # Key classes and functions are documented with docstrings.


References

  1. [1]Chen, R. T. Q., Rubanova, Y., Bettencourt, J., & Duvenaud, D. (2018). Neural Ordinary Differential Equations. NeurIPS 2018. arXiv: 1806.07366
  2. [2]Greydanus, S., Dzamba, M., & Yosinski, J. (2019). Hamiltonian Neural Networks. NeurIPS 2019. arXiv: 1906.01563
  3. [3]Zhong, Y. D., Dey, B., & Chakraborty, A. (2020). Symplectic ODE-Net: Learning Hamiltonian Dynamics with Control. ICLR 2020. arXiv: 1909.12077

Cite As

If you use this lecture material in your research or teaching, please cite the primary reference:

@misc{jing2025sciml5,
  title  = {Lecture 5: Neural ODEs & Geometric Mechanics},
  author = {Jing, Cheng},
  year   = {2025},
  note   = {An Intro Course to Scientific Machine Learning, Arizona State University},
  url    = {https://jessecj.me/course/lecture-5-neural-odes-geometric-mechanics},
  howpublished = {\url{https://jessecj.me/course/lecture-5-neural-odes-geometric-mechanics}}
}