  We describe a new method to include magnetic fields into smooth particle
hydrodynamics. The derivation of the self-gravitating hydrodynamics equations
from a variational principle is discussed in some detail. The non-dissipative
magnetic field evolution is instantiated by advecting so-called Euler
potentials. This approach enforces the crucial
$\nabla\cdot\vec{B}=0$-constraint by construction. These recent developments
are implemented in our three-dimensional, self-gravitating magnetohydrodynamics
code MAGMA. A suite of tests is presented that demonstrates the superiority of
this new approach in comparison to previous implementations.
