Organizations: Department of Mechanical Engineering, The University of British Columbia, 2054-6250 Applied Science Lane, Vancouver, V6T 1Z4, British Columbia, Canada
There has been increasing interest in methodologies that incorporate physics priors into neural network architectures to enhance their modeling capabilities. Among these methodologies, Hamiltonian neural networks (HNNs) and their variants have gained considerable attention. These architectures explicitly encode Hamiltonian mechanics both in their structure and loss function, resulting in desirable properties and additional modeled information. A crucial limitation of HNNs is their reliance on data on the target system's generalized momenta. This severely hampers their applicability when the analytical form of the generalized momenta is unknown, which frequently is the case in real-world applications. The goal of the present work is to develop a general extension of Hamiltonian-based architectures that addresses this issue by simultaneously learning the system's generalized momenta, Hamiltonian structure, and dynamics from data. The proposed architecture learns the generalized momenta when their analytical form is unknown, and only (potentially non-sequential) data on the state and its derivatives is available. A dissipative mass-spring system, a double pendulum, and a rolling disk under nonholonomic constraints are considered as canonical examples to assess the performance of the proposed architecture.
Figures & tables
Figure 1: Network architectures incorporating the proposed extension. Solid arrows represent explicit network inputs and outputs. a) Two-network architecture to learn the Hamiltonian and momenta of conservative, unconstrained systems. b) Hamiltonian NN architecture for modeling systems under nonholonomic constraints extended to learn generalized momenta from data. c) Architecture used to model the parameter-dependent dissipative mass-spring system. Dashed lines indicate quantities used to construct the Hamiltonian. kc and d2 are parameters of the system.
Figure 2: a) Notations and coordinates of the chosen dissipative mass-spring system. b) Choice of coordinates for the double pendulum. c) Disk rolling without slipping. The coordinates q1 and q2 indicate the horizontal position of the center of the disk, q4 is the angle of rotation with respect to the vertical axis, and q5 represents the rolling angle of the disk about its main symmetry axis. R is the radius of the disk. d) q3 is the leaning angle of the disk from its fully vertical position.
Figure 3: Evolution of the training loss function for a) the mass spring system, b) the double pendulum, and c) the rolling disk.
m1
m2
k1
k2
kc
c1
c2
cc
2
1
1
1
2.41421
0
2.61313
0
Table 1: Parameters associated with the chosen non-Hermitian degeneracy of the mass-spring system.
Figure 4: Modeled and ground truth trajectories for the test systems. A family of test trajectories in coordinate space of a) the mass-spring system and b) the double pendulum. c) Trajectory in space of the center of the disk and d) orientation angles of the rolling disk.
Figure 5: Phase shift as a function of the circling radius in parameter space, for one and two cycles.
Figure 6: Comparison between learned and analytical generalized momenta for all systems. Different colors correspond to different components of the momenta, and every component, with the exception of the angular components of the rolling disk, was centered around 0 and scaled to unit mean absolute value for ease of visualization. First row shows momenta along the test trajectories for a) the mass-spring system, b) the double pendulum, c) spatial components of the rolling disk [p1,p2] , and d) angular components of the rolling disk [p3,p4,p5] . Angular components of the rolling disk are plotted unmodified when constant along the trajectory for ease of visualization. The second row compares the analytical momenta along the test trajectory with the learned momenta after being transformed as in Eq. 15 . Panel e) corresponds to the mass-spring system, f) to the double pendulum, and g) and h) to the spatial and angular components of the rolling disk momenta, respectively.
Appendix figures & tables4 assets
Supplementary material from the paper’s appendix.
Appendix
Parameter
p
K and D
M
Hidden layers
2
2
N/A
Neurons per layer
30
10
N/A
Activation function
Tanh
Tanh
N/A
Learning rate
1×10−5
1×10−4
1×10−4
Epochs
5e4
Training set
5e4 points
Appendix
Table 1: Training parameters used for the mass-spring experiment.
Parameter
Value
Hidden layers
2
Neurons per layer
30
Activation function
Tanh
Learning rate
5e-5
Epochs
3e6
Training set
4e3 points
Appendix
Table 2: Parameters used for the double pendulum experiment.
Parameter
H
λ
A
p
Hidden layers
2
2
2
2
Neurons per layer
400
400
100
400
Activation function
Tanh
Tanh
Tanh
Tanh
Learning rate
1e-5
1e-5
1e-5
1e-5
Epochs
6e4
Training set
4.9e4 points
Appendix
Table 3: Parameters used for the rolling disk experiment.
Coordinate
Lower limit
Upper limit
q1
−2.3
2.3
q2
−2.3
2.3
q3
0.3
0.5
q4
−0.3
7
q5
−0.3
16
q˙1
−2.6
2.6
Appendix
Table 4: Ranges of values for generated points for the rolling disk experiment.
Hamiltonian neural networks provide a principled framework for learning conservative dynamics. A scalar Hamiltonian is parameterized by a neural network and the vector field is derived using Hamilton's equations. However, preserving Hamiltonian structure does not guarantee that the energy function itself is represented accurately. When modeled by a conventional multilayer perceptron, the Hamiltonian inherits the spectral bias of coordinate-based neural representations, favoring smooth over fine-scale structure. These fine-scale errors can be amplified by differentiation when computing the dynamics. To address this limitation, we introduce Local Multiscale Hamiltonian Neural Network (LM-HNN), which restructures the Hamiltonian according to its physical interaction structure. LM-HNN decomposes the energy into kinetic and potential components and represents them as sums of shared local functions over multiple interaction neighborhoods. This replaces a single high-dimensional approximation problem with lower-dimensional, reusable interaction laws, making fine-scale energy structure easier to resolve while preserving Hamiltonian dynamics. Across low-dimensional, interacting, and fast--slow systems, LM-HNN consistently achieves more accurate Hamiltonian derivatives and long-horizon rollouts than competing structure-preserving models, while substantially extending the effective spectral range of the learned energy. The same structured representation also generalizes more reliably to energy levels not observed during training. These results show that accuracy depends on the Hamiltonian representation as well as its structure, and that incorporating locality, decomposition, and shared interaction laws provides a simple and effective route to more accurate and generalizable Hamiltonian learning.
When learning dynamical systems from data, embedding physical structure can constrain the solution space and improve generalization, but many physics-informed models assume access to the full system state. This limits their use in partially observed settings, where some state variables are completely unobserved and must be inferred without direct supervision. Here, we present neural Hamiltonian ordinary differential equations (NHODE), a framework that combines Hamiltonian neural networks (HNNs) with neural ordinary differential equations (neural ODEs) to learn partially observed dynamical systems from data. The Hamiltonian structure enforces energy conservation by construction, while the neural ODE framework enables a flexible training procedure that allows the loss to be defined only on observed variables. We also incorporate additional physical constraints through symmetry-aware coordinate transformations and separable energy formulations. The framework is evaluated on systems of increasing complexity, from linear and nonlinear mass-spring systems to the chaotic three-body problem. Across all examples, increasing the amount of embedded physical structure improves the accuracy and long-horizon stability of the predictions. Even in the most challenging regimes, the NHODE framework captures both observed and latent dynamics, whereas purely data-driven baselines become unstable.
Sunniva Meltzer, Sølve Eidnes, Alexander Johannes Stasik
Department of Mathematics and Cybernetics, SINTEF Digital, Norway · Department of Physics, University of Oslo, Norway · Department of Data Science, Norwegian University of Life Science, Norway
We develop a geometric framework for learning deterministic and stochastic forced Hamiltonian systems with neural networks. Motivated by the Lagrange-d'Alembert principle and the theory of variational integrators, we introduce the notion of a Lagrange-d'Alembert map and establish a Cr convergence theorem for first-order one-step methods. Building on these results, we propose Generalized Forced Hamiltonian Neural Networks (GFHNNs), a class of structure-preserving neural networks obtained by concatenating Lagrange-d'Alembert-Euler maps, and prove a universal approximation theorem for this architecture. We further extend the framework to parameter-dependent systems, leading to Parametric Generalized Forced Hamiltonian Neural Networks (PGFHNNs). By interpreting the multiple Stratonovich integrals appearing in the Stratonovich-Taylor expansion as parameters, the same framework can be applied to stochastic forced Hamiltonian systems whenever information about the underlying Wiener process is available. Our numerical experiments demonstrate that the proposed geometric architectures provide significantly improved long-time stability and accuracy compared to non-geometric residual neural networks, while requiring substantially less training data to achieve a comparable level of performance.
Benedikt Brantner, Tomasz Tyranowski
Max-Planck-Institut für Plasmaphysik Boltzmannstraße 2, 85748 Garching, Germany · Technische Universität München, Zentrum Mathematik Boltzmannstraße 3, 85748 Garching, Germany · University of Twente, Department of Applied Mathematics PO Box 217, 7500AE Enschede, The Netherlands