Troubleshooting Mathematica Pendulum Equation: Finding Solutions with NDSolve

  • Context: Mathematica 
  • Thread starter Thread starter DannyS
  • Start date Start date
  • Tags Tags
    Mathematica Pendulum
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
DannyS
Messages
3
Reaction score
0
I am trying to input the equation of motion for a pendulum:
θ1'' = −g (2 m1 + m2) sin θ1 − m2 g sin(θ1 − 2 θ2) − 2 sin(θ1 − θ2) m2 (θ2'2 L2 + θ1'2 L1 cos(θ1 − θ2))
L1 (2 m1 + m2 − m2 cos(2 θ1 − 2 θ2))

with θ2 and θ2'2 being the only unknowns but I am not getting the results that are needed. Can someone please check if there are any mistakes in my equation.

NDSolve[{20.64*-Cos[
6.3 t] == ((-9.8*(1.61)*
Sin[.52*Sin [6.3 t]]) - (1.61*9.8*
Sin[Sin [6.3 t] - 2 Theta[t]] - (2*
Sin[Sin [6.3 t] -
Theta[t]])*1.61*((Theta'[t])^2 *0.48 + (3.21*
Cos[6.3 t])^2*.3*Cos[.52*Sin [6.3 t]] -
Theta[t])/(.30 (1.61 -
1.61*Cos[2*.52*Sin [6.3 t] - 2*Theta[t]])))),
Theta[0] == 10000}, Theta[t], {t, 0, 10}]

Thanks!
 
Physics news on Phys.org
It appears, at least with the version I am running, that the solver is running into limits on the number of steps to take trying to find a solution before it finishes.

By reducing the accuracy and precision demands greatly it is possible to get it to solve.

In[1]:= s=NDSolve[{20.64*-Cos[6.3 t]==((-9.8*(1.61)*Sin[.52*Sin[6.3 t]])-(1.61*9.8*Sin[Sin[6.3 t]-2 Theta[t]]-(2*Sin[Sin[6.3 t]-Theta[t]])*1.61*((Theta'[t])^2*0.48+(3.21*Cos[6.3 t])^2*.3*Cos[.52*Sin[6.3 t]]-Theta[t])/(.30 (1.61-1.61*Cos[2*.52*Sin[6.3 t]-2*Theta[t]])))),Theta[0]==10000},Theta[t],{t,0,10},
AccuracyGoal->1,PrecisionGoal->1]

Out[1]= {{Theta[t]->InterpolatingFunction[{{0.,10.}},<>][t]},{Theta[t]->InterpolatingFunction[{{0.,10.}},<>][t]}}

This should then show you one of the solutions:

In[2]:= ListPlot[Table[{j,First[First]/.t->j},{j,0,10,.1}]/.->[_,v_]->v]

And this should then show you the other solution.

In[3]:= ListPlot[Table[{j,First[Last]/.t->j},{j,0,10,.1}]/.Rule[_,v_]->v]

If you GENTLY increase the AccuracyGoal and PrecisionGoal you should start to see it produce something more like what the real solutions are, but by the time I get up to 4 I start getting complaints about a complex component being introduced, although the plot does start to look a little bit like a sine wave oscillating around 9993.

I used the ListPlot to look at these because my first few attempts at getting anything sensible to Plot directly from the InterpolatingFunction failed. You can bump down the step size in that ListPlot and see a little more detail.

Take a look at the results from the ListPlot s and see if this is anything like what your real system should be doing. If it is then this may be moving in the direction of getting you something useful. If so then you might look at Options[NDSolve] and use the help system to take a look at what each of those options do. Those will be used, in a way similar to how I used AccuracyGoal, to control the solver and get it to find a way to deliver the solution you desire.