MATH52809/28/18
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
Terrain modeled by known functions
Car suspension described by:
Dynamics described by Newton's law for linear and angular momentum
![]() |
Consider the model resulting from conservation of momentum
that can expressed in vector form as
Define the system matrix in Mathematica
In[1]:=
A={{0,-k1/m1},{1,0}};
MatrixForm[A]
In[2]:=
Define the number of components in the dependent variable and the forcing term
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]]
In[3]:=
Now, look at the solutions for some typical initial conditions and forcing terms:
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}
In[4]:=
The system matrix for this case:
In[4]:=
MatrixForm[A /. case1]
In[5]:=
Find the eigenvalues
In[5]:=
MatrixForm[DiagonalMatrix[Eigenvalues[A /. case1]]]
In[6]:=
MatrixForm[Eigenvectors[A /. case1]]
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]
In[8]:=
GenSol[t_] = DSolveValue[ SYS /. case1, y[t],t]
In[9]:=
c={C[1],C[2]};
sol[t_] = GenSol[t] /. Solve[GenSol[0] == iCond,c]
In[11]:=
SingleOscPlt1 =
ParametricPlot[sol[t],{t,0,2Pi},Axes->True,Frame->True,FrameLabel->{"y1","y2"}];
Export["/home/student/courses/MATH528/L05Fig01.pdf",SingleOscPlt1]
In[12]:=
![]() |
Figure 2. Phase plane trajectory for
unforced harmonic oscillator
|
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]
In[17]:=
c={C[1],C[2]};
sol[t_] = TrigReduce[GenSol[t] /. Solve[GenSol[0] ==
iCond,c]]
In[18]:=
SingleOscPlt2 =
ParametricPlot[sol[t],{t,0,2Pi},Axes->True,Frame->True,FrameLabel->{"y1","y2"}];
Export["/home/student/courses/MATH528/L05Fig02.pdf",SingleOscPlt2]
In[19]:=
![]() |
![]() |
Consider the model resulting from conservation of momentum
that can expressed in vector form as
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]
In[2]:=
Define the number of components in the dependent variable and the forcing term
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]]
In[3]:=
Now, look at the solutions for some typical initial conditions and forcing terms:
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}
In[4]:=
The system matrix for this case:
In[4]:=
MatrixForm[A /. case1]
In[5]:=
Find the eigenvalues
In[5]:=
MatrixForm[DiagonalMatrix[Eigenvalues[A /. case1]]]
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]
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]
In[21]:=
![]() |