MATH52809/28/18

Mini-Lab 05

In a two-mini-lab sequence, we study a realistic model: the dynamics of a car. In this first mini-lab we solve some simpler lead-up problems involving point masses and springs

m2rq¨2r = k1r(q1r-q2r)-k2r(q2r-zr)+d1r(q˙1r-q˙2r)-d2r(q˙2r-z˙r) m2fq¨2f = k1f(q1f-q2f)-k2f(q2f-zf)+d1f(q˙1f-q˙2f)-d2f(q˙2f-z˙f) m1q¨1r+q¨1f2 = -k1r(q1r-q2r)-k1f(q1f-q2f)-d1r(q˙1r-q˙2r)-d1f(q˙1f-q˙2f) Iq¨1f-q¨1r2a = a[k1r(q1r-q2r)+d1r(q˙1r-q˙2r)]-a[k1f(q1f-q2f)+d1f(q˙1f-q˙2f)]

1Warm-up problems: lossless oscillators in series

1.1Single spring

Figure 1. Two springs connected in series

Consider the model resulting from conservation of momentum

u1˙ = -k1m1x1 x˙1 = u1

that can expressed in vector form as

𝒚'=𝑨𝒚+𝒇,𝒚=( u1 x1 ),𝑨=( 0 -k1m1 1 0 ),𝒇=( f1 0 )

Define the system matrix in Mathematica

In[1]:=

A={{0,-k1/m1},{1,0}};

MatrixForm[A]

( 0 -k1m1 1 0 )

In[2]:=

Define the number of components in the dependent variable 𝒚(t) and the forcing term f

In[2]:=

y[t_]={y1[t],y2[t]};

f[t_]={f1[t],0};

SYS = y'[t] == A . y[t] + f[t];

MatrixForm[A . y[t] + f[t]]

( f1(t)-k1y2(t)m1 y1(t) )

In[3]:=

Now, look at the solutions for some typical initial conditions and forcing terms:

Case 1

No initial velocity, point masses out of equilibrium position, no forcing. Define a set of replacement rules for the system parameters defining this case

In[3]:=

F1[t_]=0;

case1 = {f1->F1,m1->1,k1->1}

{f1F1,m11,k11}

In[4]:=

The system matrix for this case:

In[4]:=

MatrixForm[A /. case1]

( 0 -1 1 0 )

In[5]:=

Find the eigenvalues

In[5]:=

MatrixForm[DiagonalMatrix[Eigenvalues[A /. case1]]]

( i 0 0 -i )

In[6]:=

MatrixForm[Eigenvectors[A /. case1]]

( i 1 -i 1 )

In[7]:=

As expected, eigenvalues are purely imaginary indicating oscillations with no dampening. Solve the system for some chosen set of initial conditions

In[7]:=

iCond = {0,1};

F1[t_]=0;

MatrixForm[SYS /. case1]

{y1'(t),y2'(t)}={-y2(t),y1(t)}

In[8]:=

GenSol[t_] = DSolveValue[ SYS /. case1, y[t],t]

{c1cos(t)-c2sin(t),c1sin(t)+c2cos(t)}

In[9]:=

c={C[1],C[2]};

sol[t_] = GenSol[t] /. Solve[GenSol[0] == iCond,c]

( -sin(t) cos(t) )

In[11]:=

SingleOscPlt1 = ParametricPlot[sol[t],{t,0,2Pi},Axes->True,Frame->True,FrameLabel->{"y1","y2"}];

Export["/home/student/courses/MATH528/L05Fig01.pdf",SingleOscPlt1]

/home/student/courses/MATH528/L05Fig01.pdf

In[12]:=

Figure 2. Phase plane trajectory for unforced harmonic oscillator

Case 2

No initial velocity, point masses at equilibrium, with forcing

In[12]:=

F1[t]=Sin[2t];

case2 = {f1->F1,m1->1,k1->1};

GenSol[t_] = DSolveValue[ SYS /. case1, y[t],t]

{-c2sin(t)+c1cos(t)+2sin4(t)3+cos(t)(-cos(t)2-16cos(3t)),c1sin(t)+c2cos(t)-23sin3(t)cos(t)+sin(t)(-cos(t)2-16cos(3t))}

In[17]:=

c={C[1],C[2]};

sol[t_] = TrigReduce[GenSol[t] /. Solve[GenSol[0] == iCond,c]]

( 13(2cos(t)-2cos(2t)-3sin(t)) 13(3cos(t)+2sin(t)-sin(2t)) )

In[18]:=

SingleOscPlt2 = ParametricPlot[sol[t],{t,0,2Pi},Axes->True,Frame->True,FrameLabel->{"y1","y2"}];

Export["/home/student/courses/MATH528/L05Fig02.pdf",SingleOscPlt2]

/home/student/courses/MATH528/L05Fig02.pdf

In[19]:=

Figure 3. Phase trajectory for forced oscillator

1.2Two springs in series

Figure 4. Two springs connected in series

Consider the model resulting from conservation of momentum

x˙1 = u1 x2˙ = u2 u1˙ = -k1m1x1+k2m1(x2-x1)+f1 u2˙ = -k2m2(x2-x1)+f2

that can expressed in vector form as

𝒚'=𝑨𝒚+𝒇,𝒚=( u1 u2 x1 x2 ),𝑨=( 0 0 -k1+k2m1 k2m1 0 0 -k2m2 -k2m2 1 0 0 0 0 1 0 0 ),𝒇=( f1 f2 0 0 )

Define the system matrix in Mathematica

In[1]:=

A={{0,0,-(k1+k2)/m1,k2/m1},{0,0,k2/m2,-k2/m2},{1,0,0,0},{0,1,0,0}};

MatrixForm[A]

( 0 0 -k1+k2m1 k2m1 0 0 k2m2 -k2m2 1 0 0 0 0 1 0 0 )

In[2]:=

Define the number of components in the dependent variable 𝒚(t) and the forcing term f

In[2]:=

y[t_]={y1[t],y2[t],y3[t],y4[t]};

f[t_]={f1[t],f2[t],0,0};

SYS = y'[t] == A . y[t] + f[t];

MatrixForm[A . y[t] + f[t]]

( f1(t)-(k1+k2)y3(t)m1+k2y4(t)m1 f2(t)+k2y3(t)m2-k2y4(t)m2 y1(t) y2(t) )

In[3]:=

Now, look at the solutions for some typical initial conditions and forcing terms:

Case 1

No initial velocity, point masses out of equilibrium position, no forcing. Define a set of replacement rules for the system parameters defining this case

In[3]:=

case1 = {f1->F1,f2->F2,m1->1,m2->1,k1->1,k2->1}

{f1F1,f2F2,m11,m21,k11,k21}

In[4]:=

The system matrix for this case:

In[4]:=

MatrixForm[A /. case1]

( 0 0 -2 1 0 0 1 -1 1 0 0 0 0 1 0 0 )

In[5]:=

Find the eigenvalues

In[5]:=

MatrixForm[DiagonalMatrix[Eigenvalues[A /. case1]]]

( i12(3+5) 0 0 0 0 -i12(3+5) 0 0 0 0 i12(3-5) 0 0 0 0 -i12(3-5) )

In[6]:=

As expected, eigenvalues are purely imaginary indicating oscillations with no dampening. Solve the system for some chosen set of initial conditions. As the system matrix size increases analytical expressions for the eigenvalues, eigenvectors become complicated or impossible to find.

In[8]:=

iCond = {0,0,1,2};

{F1[t_],F2[t_]}={0,0};

MatrixForm[A . y[t] + f[t] /. case1]

( y4(t)-2y3(t) y3(t)-y4(t) y1(t) y2(t) )

In[9]:=

We turn to numerical evaluation of the solution to the system of ODEs

In[20]:=

sol[t_]=NDSolveValue[ {y'[t]==A . y[t] + f[t] /. case1,y[0]==iCond}, y[t],{t,0,32Pi}];

DoubleOscPlt1 = ParametricPlot[sol[t][[1;;2]],{t,0,32Pi},Axes->True,Frame->True,FrameLabel->{"u1","u2"}];

Export["/home/student/courses/MATH528/L05Fig03.pdf",DoubleOscPlt1]

/home/student/courses/MATH528/L05Fig03.pdf

In[21]:=

Figure 5. Phase plane of velocities of the double spring