I have been trying to find the point at which one of the solutions of a system of two ODEs crosses zero. I used the method suggested in this answer to a previous question, which seemed to be the most efficient:
https://mathematica.stackexchange.com/a/16448/38989
(PS- I had tried FindRoot, but it was not useful as it finds only one root).
My problem is that the solution I am looking at crosses zero and falls very rapidly to large negative numbers. The above code doesn't seem to work in this case. Here is the code I used:
DiffEq1 = Derivative[2][h][r] + (2/r)*Derivative[1][h][r] - D[Potential[a, b], a] /. {a -> h[r], b -> s[r]};
DiffEq2 = Derivative[2][s][r] + (2/r)*Derivative[1][s][r] - D[Potential[a, b], b] /. {a -> h[r], b -> s[r]};
Reap[NDSolve[{DiffEq1 == 0, DiffEq2 == 0, h[10^(-18)] == 225, s[10^(-18)] == 10,
Derivative[1][h][10^(-18)] == 0, Derivative[1][s][10^(-18)] == 0,
WhenEvent[h[r] == 0, Sow[s[r]]]}, {h, s}, {r, 10^(-18), 1}]]
The differential equations have a $2/r$ factor, which is why I am starting from $10^{-18}$. (This singularity is not an actual problem since the initial first derivative is 0).
When I run this, I don't get any solutions at all, even though it does work for some other initial starting points. I know that the solution to h[r] does cross zero at least once, as it starts from a positive value, and it ends up at a very large negative value:
I am struggling to find the reason for this. Does the Event Locator method have a problem with solutions that blow up and go to large numbers?
Edit: Potential[a,b] is a degree 4 polynomial in a and b. If I put in the numbers, this is what I get:
Potential[h_,s_]:= 1.1868147535541435*^8 - (15625*h^2)/4 + (15625*h^4)/524288 - 12768*s^2 + (h^2*s^2)/2 + 0.34340200000000004*s^4
Potential[a, b]
? $\endgroup$h
is strictly positive and blows up at 0.0472 so it never gets to yourWhenEvent
$\endgroup${r,10^-18,1}
. Why would it not calculate beyondr=0.0472
? $\endgroup$