I'm using the NDSolve command to find a closed curve (it's a magnetic field line). It works, but I need to end the calculation at a specific point in space, so I don't get a curve with many turns. I only want a single turn to draw a complete loop. How can I use the StoppingTest options to tell Mathematica to find a single turn loop ? The specific code is like this :
NDSolve[
{
x'[t] == Bx[x[t], y[t], z[t]],
y'[t] == By[x[t], y[t], z[t]],
z'[t] == Bz[x[t], y[t], z[t]],
x[0] == 0,
y[0] == 1,
z[0] == 0,
}, {x, y, z}, {t, 0, 100}, StoppingTest -> ( ? ? ? )]
Suppose I want the curve to stop at coordinates {x, y, z} = {1, 2, 3}, or better, I want it to be a complete loop with a single turn (stop when it's back at the initial coordinates). How can I tell that to Mathematica ?