I want to solve this no-linear differential equation system:
$1.2 (1 + 20(r(t)^2 + 2^2 + 4 r(t) \sin(\phi(t)))^2) \ddot\phi(t) + \dot \phi(t) + \phi(t) = 50 \sin(4 t)$
$\textbf{If}$ ($|-r(t)\dot\phi^2(t)+9.8\sin\phi(t)|$<$0.7\times 9.8\cos\phi(t)$)$\Rightarrow$ $\ddot r(t)=0$
$\textbf{If}$ ($-r(t)\dot\phi^2(t)=<9.8\sin\phi(t)$)$\Rightarrow$ $\ddot r(t)-r(t)\dot\phi^2+9.8(\sin\phi(t)-0.7\cos\phi(t))=0$
$\textbf{If}$ ($-r(t)\dot\phi^2(t)>9.8\sin\phi(t)$)$\Rightarrow$ $\ddot r(t)-r(t)\dot\phi^2+9.8(\sin\phi(t)+0.7\cos\phi(t))=0$
Besides, When $r(t)>1\Rightarrow\dot r(0)=0$ and $r(t)=1$ or $r(t)<-1\Rightarrow\dot r(0)=0$ and $r(t)=-1$.
So to solve this differential equation system, I use NDSolve
method. Nevertheless, i am getting the following error: NDSolve: Encountered non-numerical value for a derivative at t == 0
and i do not know Where it is the error. The code used is below:
Clear["Global`*"]
sol = NDSolve[{If[
Abs[-r[t] phi'[t]^2 + 9.8 Sin[phi[t]]] <= 9.8*0.7 Cos[phi[t]],
r''[t], If[-r[t] phi'[t]^2 + 9.8 Sin[phi[t]] >= 0,
r''[t] - r[t] phi'[t]^2 + 9.8 (Sin[phi[t]] - 0.7*Cos[phi[t]]),
r''[t] - r[t] phi'[t]^2 +
9.8 (Sin[phi[t]] + 0.7*Cos[phi[t]])]] == 0,
1.2 (1 + 20*(r[t]^2 + 2^2 + 4 r[t] Sin[phi[t]])^2) phi''[t] +
phi'[t] + phi[t] == 50 Sin[4 t],
r[0] == phi[0] == r'[0] == phi'[0] == 0,
WhenEvent[r[t] > 1, {r[t] -> 0.99998, r'[t] -> 0}],
WhenEvent[r[t] < -1, {r[t] -> -0.99998, r'[t] -> 0}]}, {r,
phi}, {t, 0, 100}]
Plot[Evaluate[{r'[t], r[t]} /. sol], {t, 0, 100}, PlotRange -> All,
PlotStyle -> {Blue, Black}, PlotLegends -> {"Speed", "Position"}]
If I remove the if condition and i put the following code r''[t] - r[t] phi'[t]^2 + 9.8 (Sin[phi[t]] - 0.7*Cos[phi[t]])
That it is the then condition of the second If ti works...
Thank you for you time