2
$\begingroup$

I have a double pendulum system with the following equations

$(m_1+m_2)a_1\ddot{θ_1}+m_2a_2\ddot{θ_2}cos(θ_1-θ_2)+m_2a_2\dot{θ_2}^2sin(θ_1-θ_2)+(m_1+m_2)gsin{θ_1}=0$

$m_2a_2\ddot{θ_2}+m_2a_1\ddot{θ_1}cos(θ_1-θ_2)-m_2a_1\dot{θ_2}^2sin(θ_1-θ_2)+m_2gsin{θ_2}=0$

where $a_1=a_2=m_1=m_2=1$ and $θ_1=θ_2=π/2$, and $\dot{θ_1}=\dot{θ_2}=0$. And I'm trying to use ParametricPlot to show the motion of the 2nd mass only. I have tried doing the following but it's not working,

With[{g = 9.8}, {θ1, θ2} = NDSolveValue[{2*θ1''[t] + θ2''[t]*Cos[θ1[t] - θ2[t]] + θ2'[t]^(2)*Sin[θ1[t] - θ2[t]] + 2*9.8*Sin[θ1[t]] == 0, θ2''[t] + θ1''[t]*Cos[θ1[t] - θ2[t]] - θ1'[t]^(2)*Sin[θ1[t] - θ2[t]] + g*Sin[θ2[t]] == 0, θ1[0] == Pi/2, θ2[0] == Pi/2, θ1'[0] == 0, θ2'[0] == 0}, {θ1[t], θ2[t]}, {t, 0, 100}]]

but when I tried the ParametricPlot nothing showed up. How could I edit this so as to get the plot for only the second mass?

$\endgroup$
3
$\begingroup$

First, let's define the solution variables to be different than the equation variables (harmless in this case, but could result in problems down the line):

With[{g = 9.8}, {θ1Sol, θ2Sol} = 
  NDSolveValue[{2*θ1''[t] + θ2''[t]*
       Cos[θ1[t] - θ2[t]] + θ2'[t]^(2)*
       Sin[θ1[t] - θ2[t]] + 2*9.8*Sin[θ1[t]] == 0, 
       θ2''[t] + θ1''[t]*
       Cos[θ1[t] - θ2[t]] - θ1'[t]^(2)*
       Sin[θ1[t] - θ2[t]] + g*Sin[θ2[t]] == 0, 
       θ1[0] == Pi/2, θ2[0] == Pi/2, θ1'[0] == 0, 
       θ2'[0] == 0}, {θ1, θ2}, {t, 0, 100}]]

Then, I believe you want to be adding θ1Sol + θ2Sol, and converting to cartesian coordinates to plot the location of the second mass:

With[{θ0 = π/2},
 ParametricPlot[{Cos[θ1Sol[t] - θ0], Sin[θ1Sol[t] - θ0]} 
 + {Cos[θ2Sol[t] - θ0], Sin[θ2Sol[t] - θ0]}, {t, 0, 100}]]

enter image description here

$\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.