Stochastic Port-Hamiltonian Neural Networks: Universal Approximation with Passivity Guarantees
Authors: Luca Di Persio, Matthias Ehrhardt, Youness Outaleb
Organizations: Department of Computer Science - College of Mathematics University of Verona, Strada le Grazie 15 - 37134 Verona, Italy · University of Wuppertal, Chair of Applied and Computational Mathematics, Gaußstrasse 20, 42119 Wuppertal, Germany · Doctoral School in Mathematics, University of Trento Via Sommarive, 14 - 38123 Povo, Italy
Stochastic port-Hamiltonian systems represent open dynamical systems with dissipation, inputs, and stochastic forcing in an energy based form. We introduce stochastic port-Hamiltonian neural networks, SPH-NNs, which parameterize the Hamiltonian with a feedforward network and enforce skew symmetry of the interconnection matrix and positive semidefiniteness of the dissipation matrix. For Itô dynamics we establish a weak passivity inequality in expectation under an explicit generator condition, stated for a stopped process on a compact set. We also prove a universal approximation result showing that, on any compact set and finite horizon, SPH-NNs approximate the coefficients of a target stochastic port-Hamiltonian system with C2 accuracy of the Hamiltonian and yield coupled solutions that remain close in mean square up to the exit time. Experiments on noisy mass spring, Duffing, and Van der Pol oscillators show improved long horizon rollouts and reduced energy error relative to a multilayer perceptron baseline.
Figures & tables
Variant
Objective
SPH-NN-IB
Increment-based loss LIB
SPH-NN-CE
Conditional-expectation loss LCE
SPH-NN-NLL
Euler-Maruyama neg. log-likelihood LNLL
Table 1: SPH-NN variants trained with three objectives.
System
Model
True-MSE
Mean ∣Δq∣
Mean ∣Δp∣
Mean ∣ΔH∣
Mass-spring
Baseline
3.63×10−3
0.259
0.269
0.557
Mass-spring
SPH-NN-IB
2.68×10−3
0.065
0.049
0.065
Mass-spring
SPH-NN-CE
1.14×10−3
0.059
0.057
0.011
Mass-spring
SPH-NN-NLL
2.65×10−3
0.065
0.052
0.055
Duffing
Baseline
5.67×10−3
0.331
0.393
0.083
Duffing
SPH-NN-IB
2.60×10−3
0.018
0.017
0.005
Table 2: One-step drift error (True-MSE) and mean absolute rollout errors on the deterministic mean dynamics over t∈[0,20] from (q0,p0)=(1,0) . The energy error uses the ground-truth Hamiltonian H .
Figure 1: Phase space - Mass spring oscillator.
Figure 2: Mean squared error of the rollout - Mass-spring oscillator: the baseline error grows quickly, while the SPH methods keep the error low and stable.
Figure 3: Energy error - Mass-spring oscillator: SPH-NN models significantly reduce energy error compared to the baseline, with the CE loss achieving the most accurate and stable energy behavior over time.
Figure 4: Energy evolution - Mass-spring oscillator: the baseline loses energy steadily, while SPH models keep energy close to the true constant value.
Figure 5: Position and momentum time evolution - Mass-spring oscillator: the baseline drifts and loses amplitude, while SPH methods track the true oscillation and keep errors much smaller.
Figure 6: Phase space - Duffing oscillator: the baseline spirals inward, while SPH methods stay close to the true closed trajectory.
Figure 7: Mean squared error of the rollout - Duffing oscillator.
Figure 8: Energy error - Duffing oscillator.
Figure 9: Energy evolution - Duffing oscillator.
Figure 10: Position and momentum evolution - Duffing oscillator.
Figure 11: Phase space - Van der Pol.
Figure 12: Mean squared error of the rollout - Van der Pol: the baseline error explodes with large spikes, while SPH methods keep the error low and stable across the rollout.
Figure 13: Energy error - Van der Pol oscillator.
Figure 14: Energy evolution - Van der Pol oscillator: SPH methods match the true energy oscillations closely, while the baseline slowly drifts and becomes misaligned.
Figure 15: Position and momentum evolution - Van der Pol oscillator.
We introduce Quantum Port-Hamiltonian Neural Networks (Q-pHNNs), a family of parameterised quantum circuits that learn classical dynamics in a structure-preserving manner. The framework relies on the Isomorphic Hamiltonian Mapping (IHM): the skew-symmetric interconnection matrix J corresponds to unitary gate evolution, and the positive-semidefinite dissipation matrix R corresponds to Measurement-Induced NonLinearity (MINL) realised via mid-circuit measurement and classical feedforward. This ensures conservation and passivity are enforced by construction rather than penalty terms. We instantiate the IHM in four architectures: (1) a Quantum HNN that learns conservative energy manifolds and extracts Hamilton's equations exactly via the Parameter-Shift Rule; (2) a Q-pHNN using Born-rule measurement for dissipation; (3) a Q-pHNN jointly learning the energy ansatz and damping coefficient; and (4) a topology-entangled Quantum Graph Neural Network for N-node coupled-phasor networks. Experiments on the nonlinear pendulum and damped harmonic oscillator demonstrate: (i)1.35% relative energy drift with a symplectic integrator and scale correction; (ii)100% energy monotonicity for the MINL circuit; and (iii)~12.1% error in damping-coefficient identification from vector-field snapshots with no direct supervision on the damping coefficient.
This paper investigates the problem of data-driven modeling of port-Hamiltonian systems while preserving their intrinsic Hamiltonian structure and stability properties. We propose a novel neural-network-based port-Hamiltonian modeling technique that relaxes the convexity constraint commonly imposed by neural network-based Hamiltonian approximations, thereby improving the expressiveness and generalization capability of the model. By removing this restriction, the proposed approach enables the use of more general non-convex Hamiltonian representations to enhance modeling flexibility and accuracy. Furthermore, the proposed method incorporates information about stable equilibria into the learning process, allowing the learned model to preserve the stability of multiple isolated equilibria rather than being restricted to a single equilibrium as in conventional methods. Two numerical experiments are conducted to validate the effectiveness of the proposed approach and demonstrate its ability to achieve more accurate structure- and stability-preserving learning of port-Hamiltonian systems compared with a baseline method.
Binh Nguyen, Nam T. Nguyen, Truong X. Nghiem
Department of Electrical and Computer Engineering, College of Engineering and Computer Science, University of Central Florida, Orlando, FL 32816, USA
Learning dynamical systems through purely data-driven methods is challenging as they do not learn the underlying conservation laws that enable them to correctly generalize. Existing port-Hamiltonian neural network methods have recently been successfully applied for modeling mechanical systems. However, even though these methods are designed on power-balance principles, they usually do not consider power-preserving discretizations and often rely on Runge-Kutta numerical methods. In this work, we propose to use a second-order discrete gradient method embedded in the learning of dynamical systems with port-Hamiltonian neural networks. Numerical results are provided for three systems deliberately selected to span different ranges of dynamical behavior under control: a baseline harmonic oscillator with quadratic energy storage; a Duffing oscillator, with a non-quadratic Hamiltonian offering amplitude-dependent effects; and a self-sustained oscillator, which can stabilize in a controlled limit cycle through the incorporation of a nonlinear dissipation. We show how the use of this discrete gradient method outperforms the performance of a Runge-Kutta method of the same order. Experiments are also carried out to compare two theoretically equivalent port-Hamiltonian systems formulations and to analyze the impact of regularizing the Jacobian of port-Hamiltonian neural networks during training.
Maximino Linares, Guillaume Doras, Thomas Hélie
IRCAM, 1, place Igor-Stravinsky, 75004, Paris, France