last day (16 days later) » 

18:37
3
A: Why is StoppingTest in red? What other option to stop NDSolve?

DomenStoppingTest 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[...

Why is the cond event declared inside a With environment, and not the other conditions?
@Cham, because r[s, k] has to be evaluated to Sqrt[...] > 25 before it is fed into NDSolve.
@Domen, then what about the r[s, k] < 1 condition? Why not put it alongside with >25? I don't understand this part
@Cham, I have simplified the code to make it more clear. Let me know if there is still anything unclear.
If I use {cond = (r[s, k] > 25 || Apply[Or, Table[r[s, kk] < 1, {kk, 1, Nspheres}]])} inside the With environment, I get exactly the same output (which is nice) as using the StoppingTest line, and still get the error messages: "Event location failed to converge to the requested accuracy or \ precision within 100 iterations between ..."
I want to solve these error messages. I don't know how.
18:37
Please use Clear["Global`*"] first to clear all definitions, and rerun the code. It should work fine, as seen in this screenshot.
I do use this command on all of my codes. Still getting the error messages. Maybe not related to the conditions, I don't know.
@Cham, this is the notebook with complete code: wolframcloud.com/obj/825b9cf2-84b1-4bfc-be9b-1385d85c0953 It runs without error on my computer.
I tried with three spheres, no messages
But if I add more sphere, lets see
Wait a minute...
Compiling right now with 8 magnetized spheres. I'm getting the error messages
I'll give you the modification to the code (it's simple)
I'm just watching if the output is normal...
Yep, the output is good, but I get several error (warning) messages about precision.
Here's the code input for 8 magnetized sphere, at the beginning of the code: MomMagn = {1, 1, 1, 1, 1, 1}; (*norm of each magnetic moment*)
thetaMu = {45, 45, 0, 90, 180, 60} Pi/
180; (*inclinaison relative to Z axis*)
phiMu = {90, 270, 0, 90, 60, 180} Pi/
180; (*azimutal angle around Z axis*)

source[k_] := {{3, 0, 0}, {-8, 0, 0}, {0, 8, 0}, {0, -4, 0}, {0, 0,
6}, {0, 0, -6}}[[k]] (*position of each magnetic sphere*)
6 spheres, sorry, not 8
I can give you the whole code if you wish (I think it's a cool one!). It draws colorfull curbes and balls in 3D, and the manupilation is very nice...
19:28
I just noticed that only 4 spheres cause the warning messages. There's no warning with 3 spheres or less.
 
1 hour later…
20:53
@Cham
A simple solution is to use

WhenEvent[conds, "StopIntegration", "LocationMethod" -> "LinearInterpolation"]

This probably won't produce an error.

  last day (16 days later) »