Lab 5, simulation of car trailer. EME 121, Spring 2011, UC Davis
By Nasser M. Abbasi. May 22, 2011
ManipulateBprocess@u, m, L, abRatio, IgGain, Ct, v0, r0, Θ0, ∆, f, maxt, noslipD,
88u, 79.2, "speed U km�hr"<, 10, 200, 1,
Appearance ® "Labeled", ImageSize ® Small<,
88m, 1800 � 2.2, "mass kg"<, 1, 1000, 1,
Appearance ® "Labeled", ImageSize ® Small<,
88L, 7 * 0.3048, "trailer length m"<, 1, 10, 0.1,
Appearance ® "Labeled", ImageSize ® Small<,
88abRatio, 0.85, "a�b ratio"<, 0.1, 0.9, 0.1,
Appearance ® "Labeled", ImageSize ® Small<,
88IgGain, 0.8, "Ig gain"<, 80.8 ® 0.8, 0.9 ® 0.9, 1 ® 1, 1.1 ® 1.1,
1.2 ® 1.2, 1.3 ® 1.3<, ControlType ® SetterBar, ImageSize ® Small<,
88Ct, 210 * 4.448 * 180 � Pi, "Ct N�rad"<, 30 000, 100 000,
1000, Appearance ® "Labeled", ImageSize ® Small<,
88f, 1, "spring f HHzL"<, 0.1, 3, 0.1,
Appearance ® "Labeled", ImageSize ® Small<,
88maxt, 10, "simulation time HsecL"<, 0.1, 40, 0.1,
Appearance ® "Labeled", ImageSize ® Small<,
Delimiter,
Control@88noslip, False, "Apply no-slip condition"<,
8False, True<, ControlType ® Checkbox, ImageSize ® Small<D,
Delimiter,
Text@"Initial conditions"D,
88v0, 0, "VH0L km�hr"<, 0, 10,
1, Appearance ® "Labeled", ImageSize ® Small<,
88r0, 0, "rH0L degree�sec"<, 0, 7, 1,
Appearance ® "Labeled", ImageSize ® Small<,
88Θ0, 2, "ΘH0L degree"<, 0, 7, .1,
Appearance ® "Labeled", ImageSize ® Small<,
88∆, 0, "∆sH0L mm"<, 0, 100, 1, Appearance ® "Labeled", ImageSize ® Small<,
SynchronousUpdating ® False, H*important to have this*LContinuousAction ® False,
Initialization ¦
Printed by Mathematica for Students
process@uu0_, m_, L_, abRatio_, IgGain_,
c_, vv0_, rr0_, ΘΘ0_, ∆∆0_, f_, maxt_, noslip_D := ModuleB8b = 1. � H1 + abRatioL, a, k = m * H2. * Pi * fL^2, u0 = uu0 * 1000 � 3600.,
v0 = vv0 * 1000 � 3600., Θ0 = ΘΘ0 * Pi � 180., ∆0 = ∆∆0 � 1000.,
r0 = rr0 * Pi � 180., F, eq1, eq2, eq3, eq4, t, r, v, Θ, ∆, Ig, sol, data<,
a = L - b;
F = c Hb r@tD - v@tDL � u0;
Ig = IgGain m a b;
IfBnoslip � False, :
eq1 = v'@tD �F
m+
k ∆@tDm
- r@tD u0;
eq2 = r'@tD �k ∆@tD a
Ig-
F b
Ig;
eq3 = Θ'@tD � r@tD;
eq4 = ∆'@tD � -Hv@tD + u0 Θ@tD + a r@tDL;
sol = First�DSolve@8eq1, eq2, eq3, eq4, v@0D � v0, r@0D � r0,
Θ@0D � Θ0, ∆@0D � ∆0<, 8v@tD, r@tD, Θ@tD, ∆@tD<, tD>, :
eq1 = r'@tD �-r@tD Hm b u0L + Hb + aL k ∆@tD
Ig + m b^2;
eq2 = Θ'@tD � r@tD;
eq3 = ∆'@tD � -Hb r@tD + u0 Θ@tD + a r@tDL;
sol = First�DSolve@8eq1, eq2, eq3,
r@0D � r0, Θ@0D � Θ0, ∆@0D � ∆0<, 8r@tD, Θ@tD, ∆@tD<, tD>
F;
Grid@8
8Plot@Chop�Evaluate@r@tD �. solD * 180 � Pi,
8t, 0, maxt<, PlotRange ® All, Frame ® True, FrameLabel ®
88"rHtL Hdeg�secL", None<, 8"t HsecL", "rHtL vs. time"<<,
ImagePadding ® 8840, 10<, 840, 40<<,
ImageSize ® 250, AspectRatio ® 0.8D<,
8
2 lab5.nb
Printed by Mathematica for Students
8Row@8
Plot@Chop�Evaluate@Θ@tD �. solD * 180 � Pi,
8t, 0, maxt<, PlotRange ® All, Frame ® True, FrameLabel ®
88None, None<, 8"t HsecL", Row@8"Θ in deg vs. time"<D<<,
ImagePadding ® 8840, 10<, 850, 40<<, ImageSize ® 180D,
Plot@Chop�Evaluate@∆@tD �. solD, 8t, 0, maxt<,
PlotRange ® All, Frame ® True, FrameLabel ® 88None, None<,
8"t HsecL", Row@8"spring displacement HmmL vs. time"<D<<,
ImagePadding ® 8840, 10<, 850, 40<<, ImageSize ® 180D<D
<<, Frame ® All, Spacings ® 0
DF
F
lab5.nb 3
Printed by Mathematica for Students
speed U km�hr 79.2
mass kg 818.182
trailer length m 2.1336
a�b ratio 0.85
Ig gain 0.8 0.9 1 1.1 1.2 1.3
Ct N�rad 53518.8
spring f HHzL 1
simulation time HsecL 10
Apply no-slip condition
Initial conditions
VH0L km�hr 0
rH0L degree�sec 0
ΘH0L degree 2
∆sH0L mm 0
0 2 4 6 8 10
-30
-20
-10
0
10
20
30
t HsecL
rHtLH
deg�
secL
rHtL vs. time
0 2 4 6 8 10-4
-3
-2
-1
0
1
2
t HsecL
Θ in deg vs. time
0 2 4 6 8 10-0.06
-0.04
-0.02
0.00
0.02
0.04
t HsecL
spring displacement HmmL vs. time
4 lab5.nb
Printed by Mathematica for Students