Add a new mesh plane, adjust its dimensions so it matches the desired size of the coil square section.
In Edit Mode move it along the X axis the desired distance you want for the larger radius.
Erase the outer edge and rotate both vertices along the Z axis a desired angle $α$ so it roughly forms a spiral.
Use an Array modifier set to Object Offset and as offset use an empty rotated about the Z axis $α$ degrees just like the vertex previously.
Complete the array, apply the modifier, and in Edit Mode use Remove Doubles so it becomes a continuous loop.
You can then transform into a curve objects to bevel and add thickness as desired.
To give it a more smoothed square section set the curve type to Bezier select all handles and make them Automatic first, then converto to Free. Once as free you can scale them all individually to adjust the smoothness of the squircle.
Add curve extras toroidal spiral
Install Add Curve Extra
Add > Curve > Curve Spirals > Torus
In front view Numpad 1 add a plane inside the torus to be our magnet profile.
Spin the plane 360 degrees in top view
Add and apply a shrinkwrap modifier on the spiral, to the magnet.