Solution (source code)

= Solution

Keep the electromagnetic units of the supplied <Lagrangian>, including its factor $c$, and regard $e$ as the signed coupling used there. Set $a_B=e\Phi_B/(2\pi c)$. The <canonical momentum> is $p_\phi=I\dot\phi+a_B$, so the <Legendre transform> gives
$$
H=\frac{(p_\phi-a_B)^2}{2I},\qquad \boxed{\hat H=\frac1{2I}\left(-i\hbar\partial_\phi-\frac{e\Phi_B}{2\pi c}\right)^2.}
$$
Single-valued periodic wavefunctions have normalized eigenstates $e^{in\phi}/\sqrt{2\pi}$ with integer $n$. Defining dimensionless flux $f=e\Phi_B/(hc)$ gives $E_n=\hbar^2(n-f)^2/(2I)$, and the <trace> is therefore
$$
\boxed{Z=\sum_{n\in\mathbb Z}\exp\left[-\frac{\beta\hbar^2}{2I}(n-f)^2\right].}
$$
The <flux-threaded quantum rotor> spectrum is periodic under $f\mapsto f+1$ after relabelling $n$, corresponding to flux period $hc/|e|$ in these units. A local gauge change can remove the <magnetic vector potential> from the differential operator but then imposes a <twisted boundary condition> with phase $e^{-2\pi if}$; it cannot remove the flux dependence from both the <Hamiltonian> and boundary condition simultaneously. In SI conventions the flux coupling has no $c$, so one must not mix the two unit systems.