Avoid crashing kernel by NDsolve

I would like to numerically solve set of diff. eq. with various int. conditions, the problem is for some combitaions of them NDSovle crashes so as the kernel. Is there any possibility to avoid it ? I have chcecked Evaluation control, but nothing seem to avoid the crashing.

For example: this conf:

   {Equations, IntCond} ={{Derivative[1][r][τ] ==
pr[τ] (1 - 2/r[τ])^0.4 ((-2 r[τ] +
r[τ]^2)/(-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2))^0.84,
Derivative[1][
pr][τ] == -(0.484709/((1 - 2/r[τ])^1.4 r[τ]^2)) - (
0.4 pr[τ]^2 ((-2 r[τ] + r[τ]^2)/(-2 r[τ] +
r[τ]^2 + Sin[θ[τ]]^2))^0.84)/((1 - 2/
r[τ])^0.6 r[τ]^2) + (
0.42 pθ[τ]^2 (1 - 2/r[τ])^0.4 (-2 +
2 r[τ]))/((-2 r[τ] +
r[τ]^2)^0.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^1.84) + (
0.08 pθ[τ]^2 (1 - 2/r[τ])^0.4 (-2 +
2 r[τ]))/((-2 r[τ] +
r[τ]^2)^1.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^0.84) - (
0.4 pθ[τ]^2)/((1 - 2/
r[τ])^0.6 r[τ]^2 (-2 r[τ] +
r[τ]^2)^0.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^0.84) - (
Csc[θ[τ]]^2 (1 - 2/
r[τ])^0.4 (0.14 (-2 +
r[τ])^0.6 r[τ]^0.4 Sin[θ[τ]]^2 + (
0.06 r[τ]^1.4 Sin[θ[τ]]^2)/(-2 +
r[τ])^0.4) (0.641512 +
0.1 (-2 +
r[τ])^0.6 r[τ]^1.4 Sin[θ[τ]]^2))/(-2
r[τ] + r[τ]^2) + (
Csc[θ[τ]]^2 (1 - 2/r[τ])^0.4 (-2 +
2 r[τ]) (0.641512 +
0.1 (-2 +
r[τ])^0.6 r[τ]^1.4 Sin[θ[τ]]^2)^2)/(
2 (-2 r[τ] + r[τ]^2)^2) - (
0.4 Csc[θ[τ]]^2 (0.641512 +
0.1 (-2 +
r[τ])^0.6 r[τ]^1.4
Sin[θ[τ]]^2)^2)/((1 - 2/
r[τ])^0.6 r[τ]^2 (-2 r[τ] + r[τ]^2)) - (
0.42 pr[τ]^2 (1 - 2/
r[τ])^0.4 (-(((-2 + 2 r[τ]) (-2 r[τ] +
r[τ]^2))/(-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^2) + (-2 +
2 r[τ])/(-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)))/((-2 r[τ] +
r[τ]^2)/(-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2))^0.16,
Derivative[1][θ][τ] == (
pθ[τ] (1 - 2/r[τ])^0.4)/((-2 r[τ] +
r[τ]^2)^0.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^0.84),
Derivative[1][pθ][τ] == (
0.84 Cos[θ[τ]] pr[τ]^2 (1 - 2/
r[τ])^0.4 (-2 r[τ] +
r[τ]^2) Sin[θ[τ]])/(((-2 r[τ] +
r[τ]^2)/(-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2))^0.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^2) + (
0.84 Cos[θ[τ]] pθ[τ]^2 (1 - 2/
r[τ])^0.4 Sin[θ[τ]])/((-2 r[τ] +
r[τ]^2)^0.16 (-2 r[τ] + r[τ]^2 +
Sin[θ[τ]]^2)^1.84) - (
0.2 Cot[θ[τ]] (1 - 2/r[τ])^0.4 (-2 +
r[τ])^0.6 r[τ]^1.4 (0.641512 +
0.1 (-2 +
r[τ])^0.6 r[τ]^1.4 Sin[θ[τ]]^2))/(-2
r[τ] + r[τ]^2) + (
Cot[θ[τ]] Csc[θ[τ]]^2 (1 - 2/
r[τ])^0.4 (0.641512 +
0.1 (-2 +
r[τ])^0.6 r[τ]^1.4
Sin[θ[τ]]^2)^2)/(-2 r[τ] + r[τ]^2),
Derivative[1][ϕ][τ] ==
0.1 + (0.641512 Csc[θ[τ]]^2 (1 - 2/
r[τ])^0.4)/(-2 r[τ] + r[τ]^2)}, {r[0] == 6,
pr[0] == 0, θ[0] == π/2,
pθ[0] == 0, ϕ[0] == 0}};


and then e.g.

myMethod = {"FixedStep",
Method -> {"ExplicitRungeKutta",
"DifferenceOrder" -> 4}}; stepsize = 10^-2;

NDSolve[{Equations, IntCond}, {r, pr, θ,
pθ, ϕ}, {τ, 0,
xEND}, {Method -> {"EventLocator",
"Event" -> {r[τ] - 2, r[τ] - 1000},
"EventAction" :> {Throw[ Null, "StopIntegration"],
Throw[Null, "StopIntegration"]}, "Method" -> myMethod}}];


On my machine this crashes, but then another init. conds and ODE parameters produces a numerical solution, is there any chance to just mark the set of init. conds. as a non-existing num. and not to crash. It is necesery for automatized caluclation in order not to lose previous results.

• Why not use WhenEvent? (IDK if that's the problem.) – Michael E2 Mar 30 at 14:35
• Did you mean to include StartingStepSize -> stepsize or did you omit it on purpose? – Michael E2 Mar 30 at 14:38
• Your code does not run (some missing definitions like xEND). There seems to be nothing wrong with the code on the face of it. – Michael E2 Mar 30 at 14:39
• With these initial models, the finite motion describes. Therefore, the second event can not be. The first event also does not occur, because at the point $r=2, r'=0$. – Alex Trounev Mar 30 at 15:55
• Thanks for comments ! I was considering WhenEvent, but I dont know how to howt to use it to prevent crashing. To StartingStepSize -> stepsize I have tried it, but it doesnt seem to help. Actually xEND is important factor - the integration time, as I have found out, for some parameters I can get a solution till some Integration time let say, sometimes when xEND = 2000, I get a trajectory, whem more, it crashes. – user244980 Apr 1 at 6:29