Solution (source code)

= Solution

The symmetric <stress-energy tensor> obtained by metric variation is
$$
T^{\mu\nu}=-F^{\mu\rho}F^\nu{}_{\rho}
+\frac14\eta^{\mu\nu}F^{\rho\sigma}F_{\rho\sigma}
+m^2\left(A^\mu A^\nu-\frac12\eta^{\mu\nu}A^\rho A_\rho\right).
$$
It is conserved on shell. With signature $(+---)$ its energy density is
$$
T^{00}=\frac12(\mathbf E^2+\mathbf B^2)
+\frac{m^2}{2}\{(A^0)^2+\mathbf A^2\}\geq0.
$$
The <canonical stress-energy tensor> differs from this symmetric tensor by the divergence of $F^{\mu\rho}A^\nu$ plus terms proportional to the field equation. Thus its integrated energy agrees after discarding the corresponding total spatial derivative, and positivity holds on shell.