Creating the perfect magnetic field