I want to solve a little bit complicated system of ODEs, where I have to vary initial conditions. My attempt to solution is like this (similar to what I found here Using ndsolve within manipulate):
ClearAll[w, x, y, t, k, x0, x1, y0, y1];
k = 2.5;
x0 = 5.5828*10^(-5);
x1 = 5.5828;
y0 = 1.05371*10^(-18);
y1 = 1.05371*10^(-19);
t0 = 6.7*10^(-5);
p = 3000;
sol[w_, z_] := sol[w, z] =
NDSolve[{x'[t] ==-((x[t]/p)^(1/k) + x[t])(y[t] + 4 Pi t^3 x[t])/(t^2 - y[t] t),
y'[t] == 4 Pi t^2(x[t]/p)^(1/k),
x[t0] == w,
y[t0] == z}, {x, y}, {t, t0, 10}, MaxSteps -> 1000];
Manipulate[Plot[({x[t] /. sol[w, z], y[t] /. sol[w, z]}), {t, t0, 10}],
{w, x0,x1}, {z, y0, y1}]
First, when the initial conditions set to some constant numbers equation solves perfectly, although mathematica shows me that at some point stiffness or singularity detected (it is not shown in this picture because I changed all the units to natural one to make it easier to understand, though there is another error shown instead). The plot shown in the picture is exactly what I predicted Then when I tried to vary initial conditions using Manipulate
, some crazy stuff comes out (
Error notifications shown by mathematica). I also tried to solve it using WhenEvent
to take into account point of stiffness or singularity, but it doesn't lead to anywhere.
So now I am in thoughts how to solve my problem. I think error comes out, because of the stiffness or singularity detection, but I'm not sure.
P.s. I am relatively new to mathematica, so any help would be appreciated.
EDIT
I also need that points of stiffness for further investigation, that is why I cannot use smaller limit in the case above. Actually, after overcoming this problem, I wanted to extract the points where singularity/stiffness detected for different initial conditions and put them in a List using WhenEvent
. Although, I cannot even solve problem described above.