  Topology optimization, a technique to determine where material should be
placed within a predefined volume in order to minimize a physical objective, is
used across a wide range of scientific fields and applications. A general
application for topology optimization is inverse magnetostatics; a desired
magnetic field is prescribed, and a distribution of steady currents is computed
to produce that target field. In the present work, electromagnetic coils are
designed by magnetostatic topology optimization, using volume elements (voxels)
of electric current, constrained so the current is divergence-free. Compared to
standard electromagnet shape optimization, our method has the advantage that
the nonlinearity in the Biot-Savart law with respect to position is avoided,
enabling convex cost functions and a useful reformulation of topology
optimization as sparse regression. To demonstrate, we consider the application
of designing electromagnetic coils for a class of plasma experiments known as
stellarators. We produce topologically-exotic coils for several new stellarator
designs and show that these solutions can be interpolated into a filamentary
representation and then further optimized.
