Car Axis Model
Model the motion of a car as it goes down a bumpy road.
The car is modeled as springs connected to two bars. The bottom of the left tire is the origin. The car chassis is represented by a bar of mass M. The position of the chassis is given by
and
:
The left tire is always on a flat surface, while the right tire periodically goes over a bump. The bump is defined as follows:
yB[t_] = h Sin[ω t];The distance between the wheels must always remain fixed, and the car chassis must always have a fixed length:
constraints = {xL[t] xB[t] + yL[t] yB[t] == 0, (xL[t] - xR[t])^2 + (yL[t] - yR[t])^2 == L^2};m = ((ϵ^2M)/2);
xB[t_] = Sqrt[L^2 - yB[t]^2];
Lleft = Sqrt[xL[t]^2 + yL[t]^2];
Lright = Sqrt[(xR[t] - xB[t])^2 + ( yR[t] - yB[t])^2];
eqns = (| |
| ----------------------------------------------------------------------------------- |
| m xL''[t] == ((L0 - Lleft)xL[t]/Lleft) + λ1[t] xB[t] + 2 λ2[t] (xL[t] - xR[t]) |
| m yL''[t] == ((L0 - Lleft) yL[t]/Lleft ) + λ1[t] yB[t] + 2 λ2[t] (yL[t] - yR[t]) - m |
| m xR''[t] == (L0 - Lright)((xR[t] - xB[t])/Lright) - 2 λ2[t] (xL[t] - xR[t]) |
| m yR''[t] == (L0 - Lright) ((yR[t] - yB[t])/Lright) - 2 λ2[t] (yL[t] - yR[t]) - m |);
ics = {xL[0] == 0, yL[0] == 1 / 2, yR[0] == 1 / 2, yL'[0] == 0, yR'[0] == 0};params = {L -> 1, L0 -> (1/2), ϵ -> 10^-2, M -> 10, h -> 10^-1, ω -> 10};
vars = {xL, yL, xR, yR, λ1, λ2};carAxis = NDSolve[{eqns, constraints, ics} /. params, vars, {t, 0, 3}, Method -> {"IndexReduction" -> Automatic}, AccuracyGoal -> 7] ;Animate[
With[{t = tt},
Show[
(* ground *)
Plot[Evaluate[{h * Exp[-5 * (x - 1.2) ^ 2] * Sin[ω t]} - 0.14 /. params], {x, -0.9, 2}, Filling -> -0.5, FillingStyle -> Hue[.1, .2, .4], Prolog -> {Polygon[{Scaled[{0, 0}], Scaled[{1, 0}], Scaled[{1, 1}], Scaled[{0, 1}]}, VertexColors -> {Hue[.6, .2, 1], Hue[.6, .2, 1], Hue[.6, .7, .5], Hue[.6, .7, .5]}]}, PlotStyle -> Hue[.1, .4, .2], PlotRange -> {{-0.9, 1.9}, {-0.5, 1.5}}, Frame -> True, Axes -> False],
Graphics[{
(* Axle *)
{Thickness[0.03], Hue[.6, 1, .3], Line[{{xL[t] - 0.2, yL[t]} / 2, {(xB[t]) + 0.2, (yR[t] - 0 * yB[t]) / 2}}]},
(* tires *)
{Thickness[0.09], GrayLevel[.2], Line[{{Mean[{0 - 0.22, xL[t] - 0.22}], 0}, {Mean[{0 - 0.22, xL[t] - 0.22}], yL[t]}}]},
{Thickness[0.09], GrayLevel[.2], Line[{{Mean[{xB[t] + 0.22, xR[t] + 0.22}], yB[t]}, {Mean[{xB[t] + 0.22, xR[t] + 0.22}], yR[t]}}]},
(* springs *)
{Thickness[0.025], Hue[.1, 1, .9], Line[{{0 + 0.01, yL[0] / 2 + 0.03}, {xL[t] + 0.01, yL[t] + 0.2}}]},
{Thickness[0.025], Hue[.1, 1, .9], Line[{{xB[t], yB[t] / 2 + 0.28}, {xR[t] - 0.01, yR[t] + 0.2}}]},
(* chassis *)
{Thickness[0.01], Hue[.6, 1, .3], Line[{{xL[t] - 0.03, yL[t] + 0.2}, {xR[t] + 0.03, yR[t] + 0.2}}]}
} /. params /. carAxis], ImageSize -> 400
]
]
, {{tt, 0, "time"}, 0, .2Pi}, SaveDefinitions -> True, AnimationRunning -> False]