  The effectiveness of the Physics Informed Neural Networks (PINNs) for
learning the dynamics of constrained Hamiltonian systems is demonstrated using
the Dirac theory of constraints for regular systems with holonomic constraints
and systems with non-standard Lagrangians. By utilizing Dirac brackets we
derive the Hamilton-Dirac equations and we minimize their residual
incorporating also energy conservation and the Dirac constraints using
appropriate regularization terms in the loss function. The resulting PINNs,
referred to as Hamilton-Dirac Neural Networks (HDNNs), successfully learn
constrained dynamics without deviating from the constraint manifold. Two
examples with holonomic constraints are presented: the simple pendulum in
Cartesian coordinates and a two-dimensional elliptically restricted harmonic
oscillator. In both cases, HDNNs exhibit superior performance in preserving
energy and the constraints compared to traditional explicit solvers. To
demonstrate applicability in systems with singular Lagrangians, we computed the
guiding center motion in a strong magnetic field starting from the guiding
center Lagrangian. The imposition of energy conservation during the neural
network training proved essential for accurately determining the orbits of the
guiding center.
