# Rear Suspension

 Download this example as a Mathematica notebook.

This sample notebook analyzes the motion of an inboard damper rear suspension system using the Mechanical Systems kinematics package.

### Preparation

The Mech2D package is loaded into Mathematica with the Needs command, while the KillMech removes all of the Mech function and their contexts, as if the Mech had never been loaded.

In[1]:=KillMech[]
In[2]:=Needs["Mech`Mech2D`"]

Bodies in a Mech model are referenced by a positive integer body number. The following names are used to reference each of the bodies in the suspension model throughout the analysis.

In[3]:=ground=1;chassis=2;carrier=3;rocker=4;

#### Body Definitions

Body objects are defined for each of the bodies in the model. The body objects contain the coordinates of points in each body's local coordinate system. Other Mech functions can reference these local point coordinates by their positive integer point numbers. The body objects also contain initial guesses for the global coordinates of each body.
##### The Ground
Two points are defined on the ground, body 1.
P1 and P2 define the vertical translation line of the chassis relative to the ground.

In[4]:=bd[ground]=Body[ground,PointList->{
(*P1*) {0,0},
(*P2*) {0,10}}];

##### The Chassis
Six points are defined on the chassis, body 2.
P1 and P2 define the vertical translation line of the chassis.
P3 is the pivot point of the lower A-arm.
P4 is the pivot point of the upper A-arm.
P5 is the pivot point of the rocker arm.
P6 is the upper mounting point of the damper.

In[5]:=bd[chassis]=Body[chassis,PointList->{
(*P1*) {0,0},
(*P2*) {0,10},
(*P3*) {7.5,5},
(*P4*) {8,11},
(*P5*) {6,4.125},
(*P6*) {9.5,13}},
InitialGuess->{{0,2.5},0}];

##### The Wheel Carrier
Six points are defined on the wheel carrier, body 3.
P1 is the attachement point of the lower A-arm (at the local origin).
P2 is the attachement point of the upper A-arm and the connecting rod.
P3 is the bottom of the tire, where it contacts the road.
P4 is the top of the tire.
P5 is the center of the tire.
P6 is the center of the wheel carrier.

Points 4, 5, and 6 are not actually used for the mathematical model, only for the graphics.

In[6]:=bd[carrier]=Body[carrier,PointList->{
(*P1*) {0,0},
(*P2*) {-1,9},
(*P3*) {1.25,-5.5},
(*P4*) {1.25,14.5},
(*P5*) {1.25,4.5},
(*P6*) {0.8,4.5}},
InitialGuess->{{22.,5.5},0.0}];

##### The Rocker
Four points are defined on the rocker arm, body 4.
P1 is the rotational axis of the rocker arm (at the local origin).
P2 is the attachment point of the damper.
P3 is the attachment point of the connecting rod.
P4 is a fourth point to be used in the graphic image.

In[7]:=bd[rocker]=Body[rocker,PointList->{
(*P1*) {0,0},
(*P2*) {4.1,2.6},
(*P3*) {2.7,0},
(*P4*) {1,1}},
InitialGuess->{{6.0,6.6},-.7}];

##### SetBodies
The data contained in the body objects are incorporated into the current model with SetBodies.

In[8]:=SetBodies[bd[ground],bd[chassis], bd[carrier],bd[rocker]]

#### Constraint Definitions

Seven constraint objects are required to model the inboard damper rear suspension. The constraint objects contain algebraic constraint equations that enforce the specified relationships between the coordinates of each body in the model.
##### Constraints for the Chassis
Constraint 1 is a driving constraint that controls the vertical position of the chassis. Constraint 2 is a translational constraint that allows the chassis to move vertically relative to the ground. These two constraints completely constrain the chassis.

In[9]:=cs[1]=RelativeY1[1,Point[chassis,1],T];

In[10]:=cs[2]=Translate2[2,
Line[ground,2,1],Line[chassis,2,1]];

##### Constraints for the Carrier
Constraints 3 and 4 are two relative-distance constraints that model the upper and lower A-arms. Constraint 5 is a vertical position constraint that forces the bottom of the tire to remain in contact with the ground.

In[11]:=cs[3]=RelativeDistance1[3,Point[chassis,3], Point[carrier,1],14.6];

In[12]:=cs[4]=RelativeDistance1[4,Point[chassis,4],             Point[carrier,2],13.0];

In[13]:=          cs[5]=RelativeY1[5,Point[carrier,3],0];

##### Constraints for the Rocker Arm
Constraint 6 is a revolute joint that places the axis of the rocker arm. Constraint 7 is a relative-distance constraint that models the connecting rod. The length of the connecting rod is assigned to the symbol rodlength, which must be given a numerical definition before SolveMech will be able to find a solution.

In[14]:= cs[6]=Revolute2[6,Point[chassis,5], Point[rocker,1]];

In[15]:= rodlength=
cs[7]=RelativeDistance1[7,Point[carrier,2], Point[rocker,3],rodlength];

##### SetConstraints
The data contained in the constraint objects are incorporated into the current model with SetConstraints.

In[16]:= SetConstraints[cs[1],cs[2],cs[3],cs[4],cs[5], cs[6],cs[7]]

#### Running the Model

The rodlength is defined and the model checked for mathematical consistency.

In[17]:= rodlength=15.5;
In[18]:= CheckSystem[]

Out[18]= True

SolveMech is used to seek a solution to the model with the chassis 1.5 units off of the ground.

In[19]:= SolveMech[1.5]

Out[19]= {T->1.5`,X2->-3.4443706549728956`*^-26, Y2->1.5`,Th2->0.`,X3->22.063575988270866`,Y3->5.469342717553401`, Th3->0.023330508909981583`,X4->6.`,Y4->5.625`,Th4->-293.9807691543304`}

This generates a list of 12 solution sets, spaced evenly from T = 0.5 to T = 3.5.

In[20]:=postab=SolveMech[{0.5,3.5},12];

In[21]:= ?SolveMech

Out[21]=
SolveMech[t] attempts to find a location solution to the current model at time t.  SolveMech returns a list of rules containing the global coordinates of each body. SolvMech[{t1, t2,....tn}] returns a nested list of solution rules containing solution points at all of the ti.  SolveMech accepts the Solution option to determine what order of solution to seek.  Interpolation->True causes SolveMech to interpolate the solution rules returned.

### Graphics

#### Mechanism Image

In[22]:=graph=Graphics[{
{Thickness[.02],Line[{{0,0},{27,0}}]},
{RGBColor[1,0,0],Thickness[.006], Edge[chassis,{2,4,3,1,2,3},{4,5,3}, {4,6,3}]},
{RGBColor[0,0,1],Facet[carrier,{1,2,6}], Thickness[.03], Edge[carrier,{5,6}]}, {PointSize[.01],Vertex[rocker,{2,3,1}], Vertex[carrier,{1,2}], Vertex[chassis,{6}],RGBColor[0,.8,.2], Facet[rocker,{1,2,3}]}, {RGBColor[.6,0,1], Bar[Line[rocker,2,chassis,6],.7]}, {Thickness[.007], Line[{Location[carrier,2],Location[rocker,3]}], Line[{Location[chassis,3],Location[carrier,1]}], Line[{Location[chassis,4], Location[carrier,2]}]}, {RGBColor[.3,.3,.2], Bar[Line[carrier,3,4],0,4]}}, Frame->True, PlotRange->{{-1,28},{-1,21}}, AspectRatio->Automatic];

In[23]:=Show[graph/.LastSolve[]];

#### Animation

The following input will generate the series of 12 graphics in the animation cell at the beginning of this notebook.

In[24]:=(Show[graph/.#1]&)/@postab;

### Calculations

#### Optimal Damper Length

##### Setup
To find the optimal damper length for the rear suspension, SolveMech is used to generate a list of 12 solution sets, spaced evenly from T = 0.5 to T = 3.5, with the chassis 1.5 units off of the ground

In[25]:= postab=SolveMech[{0.5,3.5},12];

The damper length can be defined as a symbolic function of the coordinates of each body.

In[26]:=damperlength=Distance[Point[rocker,2], Point[chassis,6]]

Out[26]:=

Sqrt((Y2-Y4+13.` Cos[Th2]-2.6` Cos[Th4]+9.5` Sin[Th2]-4.1` Sin[Th4])^2(X2-X4+9.5` Cos[Th2]-4.1` Cos[Th4]-13.` Sin[Th2]+2.6` Sin[Th4])^2)

Using the solution rules that were developed previously, damper length as a function of time can be plotted with ListPlot.

##### Graphics
In[27]:=ListPlot[{T,damperlength}/.postab, PlotJoined->True,GridLines->Automatic,Frame->True];

Out[27]= -Graphics-

### Velocity Analysis

To analyze the velocity of the bodies in the model, components of the mathematical model must be differentiated with respect to time. This is done automatically when SolveMech is called with the Solution->Velocity option.

In[28]:= SolveMech[1.0,Solution->Velocity]

Out[28]=

The the damper length is obtained by differentiating the expression returned by Distance with Dt.

In[29]:=Dt[damperlength,T]/.LastSolve[]

Out[29]=1.05137

A table of velocity solutions is created in the same way that the table of location solutions postab was.

In[30]:=veltab=SolveMech[{0.5,3.5},12, Solution->Velocity];

In[31]:=ListPlot[{T,Dt[damperlength,T]}/.veltab, PlotJoined->True,GridLines->Automatic,Frame->True];

Out[31]= -Graphics-

This plot shows that the velocity of the damper, relative to the velocity of the wheel, is increasing as the suspension of the car is compressed. Thus, the suspension is a "rising rate" suspension.

### Acceleration Analysis

To analyze the acceleration of the bodies in the model, components of the mathematical model must be differentiated twice with respect to time. This is done automatically when SolveMech is called with the Solution->Acceleration option.

In[32]:=SolveMech[1.0,Solution->Acceleration]

Out[32]={T->1.,X2->1.3384733184171396`*^-23, Y2->1.,Th2->0.,X3->22.08973852666825, Y3->5.452706912658127, Th3->0.035127328418305785, X4->6.,Y4->5.125,Th4->-0.1471127628108614, X2d->-9.131538766887195`*^-17, Y2d->0.9999999999999999, Th2d->0.,X3d->-0.036227741330542976, Y3d->0.034240911041826715, Th3d->-0.02373901933945989, X4d->-6.341277449846002`*^-17,Y4d->1., Th4d->-0.22554067944233058, X2dd->-1.4611537945708706`*^-17, Y2dd->1.6199888194662392`*^-17,Th2dd->0.`, X3dd->-0.06416644481509073, Y3dd->-0.0039623831197289775, Th3dd->0.0006167259472788075, X4dd->-2.3779790436922506`*^-17,Y4dd->0., Th4dd->0.022861463203498487}

To avoid wasting computation time, SolveMech is able to update existing position (or position and velocity) rules without resolving for the lower-order solutions. The following example shows how SolveMech is passed an existing location solution (LastSolve[]) to be updated to a velocity solution. The CheckRules->False option prevents SolveMech from checking the validity of the solution rules that it is passed.

In[33]:=SetGuess[];
In[34]:=SolveMech[1.0];
In[35:=Timing[SolveMech[LastSolve[], Solution->Velocity,CheckRules->False];]

Out[35]={0.` Second,Null}

This time-saving method is used to update the table of velocity rules veltab with the acceleration solution.

In[36]:=acctab=SolveMech[veltab, Solution->Acceleration,CheckRules->False];

Here is a plot of the second time derivative of the damper length.

In[37]:=ListPlot[{T,Dt[damperlength,T,T]}/.acctab, PlotJoined->True,GridLines->Automatic,Frame->True];

Out[37]= -Graphics-