0
$\begingroup$

I am trying to solve the following set of differential equations to obtain $\phi[t]$, $y[t]$, and $z[t]$. The 3 differential equations are here:

m y''[t] == -k z[t]^(3/2) - c z'[t] - m g,

φ''[t] == ((-k z[t]^(3/2) - c z'[t]) l Sin[φ[t]] + μ (-k z[t]^(3/2) - c z'[t]) Cos[φ[t]] )/i,

z[t] == y[t] - l Cos[φ[t]] 

The constants are defined here:

k = 50000000;
c = 37;
g = 9.81;
μ = 0.3;
i = 10^-5;
l = 0.1;
m = 0.35

The initial conditions are here:

y[0] == 0, y'[0] == -3,
φ[0] == 0.1, φ'[0] == 0.1,
z[0] == 0, z'[0]==0

However, I got the following error message when I tried to use NDSolve:

NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions.

What exactly do these error messages mean? Is there anything wrong with the differential equations that in fact there are only two unknowns, $y[t]$ and $\phi [t]$, and $z[t]$ is redundant? Thank you.

Here's my code:

k = 50000000;
c = 37;
g = 9.81;
\[Mu] = 0.3;
i = 10^-5;
l = 0.1;
m = 0.35;
NDSolve[{m y''[t] == -k z[t]^(3/2) - c z'[t] - m g, \[CurlyPhi]''[
    t] == ((-k z[t]^(3/2) - c z'[t]) l Sin[\[CurlyPhi][
         t]] + \[Mu] (-k z[t]^(3/2) - c z'[t]) Cos[\[CurlyPhi][t]])/i,
   z[t] == y[t] - l Cos[\[CurlyPhi][t]], y[0] == 0, 
  y'[0] == -3, \[CurlyPhi][0] == 0, \[CurlyPhi]'[0] == 0, z[0] == 0, 
  z'[0] == 0}, {y[t], z[t], \[CurlyPhi][t]}, {t, 0, 1}]
$\endgroup$
6
  • $\begingroup$ I guess you forgot a pair of braces around your equations and initial conditions. If you post the code that produced the error message it will be easier to help you. $\endgroup$
    – kglr
    Dec 15 '20 at 7:10
  • 1
    $\begingroup$ Hi, you are right. Thanks. But after I added a pair of braces around my equations and initial conditions, there are still error messages. I have added the error messages and the code that produced them. $\endgroup$ Dec 15 '20 at 8:04
  • $\begingroup$ (1) Cos[[t]] should be Cos[t]. (2) m is not assigned a value. $\endgroup$
    – kglr
    Dec 15 '20 at 8:17
  • 1
    $\begingroup$ Thanks. Really sorry that I am making this kind of stupid mistakes and have to let you guys check for me. However, the code still doesnt seem to work $\endgroup$ Dec 15 '20 at 8:19
  • $\begingroup$ i got NDSolve::icfail: Unable to find initial conditions that satisfy the residual function within specified tolerances. Try giving initial conditions for both values and derivatives of the functions. $\endgroup$ Dec 15 '20 at 8:39
1
$\begingroup$

This more of an extended comment, but maybe this will help someone get further than me.

First, some starting code:

deqn = {m y''[t] == -k z[t]^(3/2) - c z'[t] - m g, \[CurlyPhi]''[t] == ((-k z[t]^(3/2) - c z'[t]) l Sin[\[CurlyPhi][t]] + \[Mu] (-k z[t]^(3/2) - c z'[t]) Cos[\[CurlyPhi][t]])/i,D[z[t] == y[t] - l Cos[\[CurlyPhi][t]], {t, 2}]};

params = {k -> 50 10^6, c -> 37, g -> 9.81, \[Mu] -> 0.3, i -> 1 10^-5, l -> 0.1, m -> 0.35 } // Rationalize;

Looking at your equations, I see that y[t] shows up in deqn[[1]] as a second derivative and deqn[[2]] isn't coupled directly with y[t]...so I differentiated the third equation twice giving y''[t]...now we can subtract one from the other giving:

sol1 = Solve[deqn[[1]], y''[t]] /. y''[t] -> s1 // First 
sol2 = Solve[deqn[[3]], y''[t]] /. y''[t] -> s2 // First 
sol3 = Solve[s1  - s2  == 0 /. Join[sol1, sol2], z''[t]] // First

Create new deqn2 and ics2:

deqn2 = {deqn[[2]], z''[t] == ((-g m - k z[t]^(3/2) - c Derivative[1][z][t] + l m Cos[\[CurlyPhi][t]] Derivative[1][\[CurlyPhi]][t]^2 + l m Sin[\[CurlyPhi][t]] (\[CurlyPhi]^\[Prime]\[Prime])[t])/m};

ics2 = {\[CurlyPhi][0] == 0.1, \[CurlyPhi]'[0] == 0.1, z[0] == 0, z'[0] == 0};

Solve,

sols = NDSolve[{deqn2 /. params, ics2}, {z[t], \[CurlyPhi][t]}, {t, 0,1}] // First

It appears your functions give real and imaginary solutions...

Plot[Re[{z[t], \[CurlyPhi][t]} /. sols], {t, 0, 1}, PlotRange -> All]

enter image description here

I admit, I have vague memories of running this kind of method for DAEs of index 1 (which your system appears to be). However. I cannot tell you if this is the actual correct solution to your system or not....But maybe someone smarter than me can take this advice further, Good luck!

update it appears I had changed one of the equations by accident leading it to be solveable in the OPs intended way...I have updated the code with the OPs original code...this has however changed the plot/result, but not the method.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.