Canonical Hamiltonian of a magnetic elastic ring (source code)

= Canonical Hamiltonian of a magnetic elastic ring

Although the energy in velocities is $m(\dot r^2+r^2\dot\phi^2)/2+2\pi^2k(r-r_0)^2$, the <Hamiltonian> in <canonical variables> is
$$
H=\frac{p_r^2}{2m}+\frac{(p_\phi-qBr^2/2)^2}{2mr^2}+2\pi^2k(r-r_0)^2.
$$
The field therefore enters <Hamilton's equations> through the relation between canonical and <mechanical momentum>, even though a <magnetic field> does no work.