  We present a target field approach to analytically design magnetic fields
using permanent magnets. We assume that their magnetisation is bound to a
two-dimensional surface and is composed of a complete basis of surface modes.
By posing the Poisson's equation relating the magnetic scalar potential to the
magnetisation using Green's functions, we derive simple integrals which
determine the magnetic field generated by each mode. This approach is
demonstrated by deriving the governing integrals for optimising axial
magnetisation on cylindrical and circular-planar surfaces. We approximate the
governing integrals numerically and implement them into a regularised
least-squares optimisation routine to design permanent magnets that generate
uniform axial and transverse target magnetic fields. The resulting uniform
axial magnetic field profiles demonstrate more than a tenfold increase in
uniformity across equivalent target regions compared to the field generated by
an optimally separated axially magnetised pair of rings, as validated using
finite element method simulations. We use a simple example to examine how
two-dimensional surface magnetisation profiles can be emulated using thin
three-dimensional volumes and determine how many discrete intervals are
required to accurately approximate a continuously-varying surface pattern.
Magnets designed using our approach may enable higher quality bias fields for
electric machines, nuclear fusion, fundamental physics, magnetic trapping, and
beyond.
