Solution (source code)

= Solution

By <Hamiltonian of a charged particle>,
$$
\mathbf p=m\dot{\mathbf r}+e\mathbf A,\qquad
H=\frac{|\mathbf p-e\mathbf A|^2}{2m}+e\phi.
$$