LNNs and HNNs for a dissipative system

1, 2University of Richmond

Project Video Coming Soon

Abstract

We investigate the applicability of Largrangian and Hamiltonian Neural Network models to a dissipative system that has explicit time dependence in its Lagrangian, Hamiltonian, and total energy. To do so we consider these neural network models for simulated systems of a harmonic one-dimensional, one-component oscillator with damping, as well as without damping for comparison. We find that both the Lagrangian and Hamiltonian approaches are able to predict the empirical physical behavior of the damped oscillator systems and to effectively "learn" to varying degrees the underlying Lagrangians and Hamiltonians, as has previously been shown to be the case with undamped oscillator systems. These investigations elucidate important properties of Lagrangian and Hamiltonian mechanics, including properties that are not manifest when considering systems without explicit time dependence.

What happens when energy is no longer conserved?

Lagrangian and Hamiltonian Neural Networks are designed to learn hidden mechanical structure from observed trajectories. Foundational demonstrations largely focus on conservative systems, where the Lagrangian and Hamiltonian have no explicit time dependence and the Hamiltonian is often identified with a conserved total energy.

Dissipation changes that picture. Friction, drag, and other interactions can make the Lagrangian and Hamiltonian explicitly time-dependent. In the damped oscillator studied here, the Hamiltonian is not generally equal to the total energy and is not conserved. This gives us a simple but revealing question: can LNNs and HNNs still learn the dynamics, and what physical quantity do they learn when the usual conservative assumptions break?

Damped-oscillator example illustrating the open problem of dissipative systems.

Figure 1. Dissipation introduces explicit time dependence and separates the Hamiltonian from conserved total energy.

Learning the mechanics, not just the motion

A standard neural network can directly map a state to its time derivative. LNNs and HNNs instead predict a scalar mechanical function first, then use in-network derivatives of that learned function to reproduce the observed dynamics.

The Lagrangian model learns a function of position, velocity, and, when needed, time. The Hamiltonian model learns a function of position, momentum, and time. Their gradients are then constrained by the Euler-Lagrange or Hamilton equations.

This lets us ask a more interesting question than whether the trajectory is accurate: what hidden physical function did the network actually recover?

LNN and HNN architecture schematic.

Figure 2. LNN and HNN architecture schematic.

What did we find?

Dissipation is still learnable.

Both LNNs and HNNs can be extended to the damped oscillator when time is provided as an input. The models recover the observed dynamics even though the system is no longer energy-conserving.

Time changes what the network learns.

Removing time does not always destroy predictive performance. Under special structural relationships, the networks can still reproduce the dynamics, but the learned scalar may no longer be the actual Lagrangian or Hamiltonian.

A surprising "Energy NN" emerges.

In the damped HNN, replacing generalized momentum with observable linear momentum and omitting time produces a convergent model that learns the total non-dissipative kinetic plus potential energy instead of the Hamiltonian.

The LNN learns damped dynamics

The oscillation decays, but the learned dynamics stay on track. The Lagrangian NN successfully predicts the damped oscillator dynamics in both the noise-free and noisy experiments.

With time supplied as an input, the model can recover an actual Lagrangian for the dissipative system. We also test a second strategy that removes time from the network and exploits the special relationship between the explicit time derivative of the Lagrangian and the Lagrangian itself.

That second model still predicts the dynamics, but what it learns is a modified Lagrangian function rather than the actual time-dependent Lagrangian. The result separates two questions that are easy to conflate: did the network predict the motion correctly, and did it recover the physical function we intended it to learn?

Damped Oscillator: Lagrangian NN

No Noise
With Noise

With Time Parameter

Actual and LNN-predicted acceleration over time with a time parameter and no noise. Actual and LNN-predicted acceleration over time with a time parameter and simulated noise. Actual and LNN-predicted Lagrangian over time with a time parameter and no noise. Actual and LNN-predicted Lagrangian over time with a time parameter and simulated noise.

Without Time Parameter

Actual and LNN-predicted acceleration over time without a time parameter and with no noise. Actual and LNN-predicted acceleration over time without a time parameter and with simulated noise. Actual and LNN-predicted modified Lagrangian over time without a time parameter and with no noise. Actual and LNN-predicted modified Lagrangian over time without a time parameter and with simulated noise.
Figure 3. Actual and predicted acceleration q̈D(t) versus time (upper panels) and actual and predicted Lagrangian LD versus time (lower panels) for the damped oscillator, with no noise (left) and full simulated noise (right) in the observed data. Within each parameter group, the acceleration comparison appears above the Lagrangian comparison.

When a Hamiltonian NN becomes an Energy NN

The most surprising result appears when we remove time. For the damped oscillator, the generalized momentum required by Hamiltonian mechanics is not the same as the directly observable linear momentum.

Using generalized momentum together with time, the HNN converges and recovers the damped dynamics and Hamiltonian. Removing time while keeping generalized momentum does not converge. But replacing generalized momentum with linear momentum allows the network to converge again.

The resulting model does not learn the Hamiltonian. Instead, it learns the total non-dissipative kinetic plus potential energy while still reproducing the observed dynamics. The same differentiation machinery used by an HNN has effectively become an Energy NN without explicitly designing one.

Damped Oscillator: Hamiltonian NN

Placeholder for forthcoming damped-oscillator Hamiltonian NN results.
Figure 4. Damped-oscillator Hamiltonian NN results. Coming Soon.

Equivalent Lagrangians

No Noise
With Noise
Default and equivalent alternative Lagrangians for the undamped no-noise case. Default and equivalent alternative Lagrangians for the undamped noisy case.
Figure 5. Calculated default Lagrangian and the equivalent alternative L' for the undamped oscillator. These curves can be compared with the learned functions in Figure 7.

A different Lagrangian can still be the right Lagrangian

The learned function does not need to look like the textbook expression. Some LNN predictions initially appear to disagree with the analytical Lagrangian even though the predicted dynamics are correct.

This exposes a fundamental property of Lagrangian mechanics: multiple Lagrangians can generate the same equations of motion. In particular, transformations of the form

\[ L' = A'\!\left(L + \frac{dF}{dt}\right) + C \]

leave the physical dynamics unchanged under the conditions discussed in the paper. Comparing the learned functions with these equivalent forms shows that the LNN can recover a correct Lagrangian even when it is not numerically identical to the expression we started with.

Results at a glance

Across the undamped and damped experiments, the models consistently recover the observed dynamics. What changes across formulations is the interpretation of the learned scalar function. Time-aware damped models recover the intended Lagrangian or Hamiltonian, while carefully chosen time-free formulations can preserve the dynamics by learning a related physical quantity instead.

Summary table of LNN and HNN results across undamped and damped cases.

Figure 6. Which models recover the dynamics and which physical quantity each formulation learns.

Additional Results

Undamped Oscillator: Lagrangian NN

No Noise
With Noise
Actual and LNN-predicted acceleration for the undamped oscillator with no noise. Actual and LNN-predicted acceleration for the undamped oscillator with simulated noise. Actual and predicted undamped-oscillator Lagrangian with no noise. Actual and predicted undamped-oscillator Lagrangian with simulated noise.
Figure 7. Actual and predicted acceleration (upper) and Lagrangian (lower) for the undamped oscillator, with no noise (left) and full simulated noise (right) in the observed data.

Undamped Oscillator: Hamiltonian NN

No Noise
With Noise
Actual and HNN-predicted velocity for the undamped oscillator with no noise. Actual and HNN-predicted velocity for the undamped oscillator with simulated noise. Actual and HNN-predicted phase-space dynamics with no noise. Actual and HNN-predicted phase-space dynamics with simulated noise. Actual and predicted Hamiltonian with no noise. Actual and predicted Hamiltonian with simulated noise.
Figure 8. Actual and predicted velocity (upper), momentum derivative versus velocity (middle), and Hamiltonian (lower) for the undamped oscillator, with no noise (left) and full simulated noise (right).

Conclusion

This project extends Lagrangian and Hamiltonian Neural Networks beyond the usual conservative setting to a simple dissipative system with explicit time dependence. The experiments show that both approaches can recover the damped dynamics under appropriate conditions.

More importantly, the results expose physical structure that is easy to miss in conservative benchmarks: time can be essential for recovering the intended mechanical function, generalized and linear momenta need not coincide, the Hamiltonian need not equal the total energy, and multiple Lagrangians can describe the same motion.

Conclusions summarizing the dissipative LNN and HNN findings.

Figure 9. The main findings for extending LNNs and HNNs to dissipative systems.