3

StoppingTest isn't available anymore in the newer versions of Mathematica. You should use WhenEvent or "EventLocator" method instead.
For example:
magneticCurves[n_, m_, k_] :=
With[{conds = Or@@Table[EuclideanDistance[xyz[s], source[kk]] < 1,
{kk, 1, Nspheres}] || r[s, k] > 25},
NDSolve[...