I'm experiencing several problems with the manipulate code below. This code numerically solves three first-order non-linear differential equations, and then output a 3D plot of the curve, using the initial conditions entered by the user from the three sliders :
Clear["Global`*"]
Theta1 = -20;
Theta2 = 20;
dynamics[om_, or_, ol_] := dynamics[om, or, ol] = NDSolve[{
oM'[theta] == (oM[theta] + 2oR[theta] - 2oL[theta] - 1)oM[theta],
oR'[theta] == (oM[theta] + 2oR[theta] - 2oL[theta] - 2)oR[theta],
oL'[theta] == (oM[theta] + 2oR[theta] - 2oL[theta] + 2)oL[theta],
oM[0] == om, oR[0] == or, oL[0] == ol
}, {oM, oR, oL}, {theta, Theta1, Theta2},
Method -> "StiffnessSwitching"
(* constraints to be imposed : oM, oR, oL > 0 only *)
]
Tmin[om_, or_, ol_] := Theta1 (* to be fixed *)
Tmax[om_, or_, ol_] := Theta2 (* to be fixed *)
solution[om_, or_, ol_] := ParametricPlot3D[
Evaluate[{oM[theta], oR[theta], oL[theta]}/.dynamics[om, or, ol]],
{theta, Tmin[om, or, ol], Tmax[om, or, ol]}
]
Manipulate[
Show[
solution[om, or, ol],
PlotRange -> {{0, 2}, {0, 2}, {0, 2}},
SphericalRegion -> True
],
{{om, 0.3, a}, 0, 2, 0.01},
{{or, 0.0, b}, 0, 2, 0.01},
{{ol, 0.7, c}, 0, 2, 0.01}
]
At compilation, I'm getting several error messages that I don't know how to solve. The manipulate box should be regular for all values entered from the sliders (from 0 up to 2 or more), especially when any of the variables is set to 0. The oM, oR and oL variables should only be positive, so a constraint should be added to the NDSolve part, and the curve extremities should be properly defined with the Tmin and Tmax definitions above. Currently, it doesn't work well.
How can I fix these problems ?
EDIT : Here are two typical messages that annoys me :
... step size is effectively zero; singularity or stiff system suspected
... lies outside the range of data in the interpolating function. Extrapolation will be used.
InterpolatingFunction::dmval: "Input value {-20.} lies outside the range of data in the interpolating function. Extrapolation will be used. "
, right? Or other errors? Always state what the errors are in the OP. $\endgroup$oM[Theta1] == om
? $\endgroup$NDSolve::ndsz
or whatever they are). It's useful for searching. -- The first one can be taken care of withQuiet[..., NDSolve::ndsz]
or whatever, assuming it blows up in finite time, which is not an error. $\endgroup$