  We present a novel Active Magnetic Shield (AMS), designed and implemented for
the n2EDM experiment at the Paul Scherrer Institute. The experiment will
perform a high-sensitivity search for the electric dipole moment of the
neutron. Magnetic-field stability and control is of key importance for n2EDM. A
large, cubic, 5m side length, magnetically shielded room (MSR) provides a
passive, quasi-static shielding-factor of about 10^5 for its inner sensitive
volume. The AMS consists of a system of eight complex, feedback-controlled
compensation coils constructed on an irregular grid spanned on a volume of less
than 1000m^3 around the MSR. The AMS is designed to provide a stable and
uniform magnetic-field environment around the MSR, while being reasonably
compact. The system can compensate static and variable magnetic fields up to
+-50muT (homogeneous components) and +-5muT (first-order gradients),
suppressing them to a few muT in the sub-Hertz frequency range. The presented
design concept and implementation of the AMS fulfills the requirements of the
n2EDM experiment and can be useful for other applications, where magnetically
silent environments are important and spatial constraints inhibit simpler
geometrical solutions.
