lab 1 demo 2 - university of calgary in...
TRANSCRIPT
Lab. 1 - Example 2Modeling of the system with 2 masses dealt with in Lect. 4
Correct directions of the forces in FBDDevelopment History: see inside of this folded "cell"
0. Setting notebook styles - optional (read inside of the cell)
1. Preparing Mathematica
2. Defining the problem (see also Lecture 4 for details)
3. Defining basic equations
eq1 = -m1 y1££@tD + k Hy2@tD - y1@tDL ã 0;
eq2 = -m2 y2££@tD - k Hy2@tD - y1@tDL ã 0;
4. Defining initial conditions - SI units
ic1 = y1@0D ã 0.5;
ic2 = y1£@0D ã -0.2;
File: lab_1_demo_2.nb Date: 2/25/11 14:01:56
ENME 599, Instructor: S. Spiewak, [email protected] , ph. (403) 220 8976 Page 1
ic3 = y2@0D ã 0;
ic4 = y2£@0D ã 0;
5. Solving
m1 = 10; m2 = 20; k = 100;
res = NDSolve@8eq1, eq2, ic1, ic2, ic3, ic4<, 8y1@tD, y2@tD<, 8t, 0, 5<D;
The above cell solves the ODE(s) and returns the result, res, which may be confusing. In particular, this solution has many properties of a symbolic function although it is obtained by numerical method. Some explanation(s) will be given in class/lab
Expressingthesolutionascontinuousfunctionsoftime
ysoln1@t_D = y1@tD ê. resP1T;
ysoln2@t_D = y2@tD ê. resP1T;
In the above cell the solution is converted into an explicit function of time. This function is tested and plotted below
6. Plotting : y1[t] - red ; y2[t] - blue
Plot@8ysoln1@tD, ysoln2@tD<, 8t, 0, 5<, PlotRange Ø All,PlotStyle -> 88Red, [email protected]<, 8Blue, [email protected]<<D
1 2 3 4 5
-0.4
-0.2
0.2
0.4
Cool Plot
imageWidth = 700;
File: lab_1_demo_2.nb Date: 2/25/11 14:01:58
ENME 599, Instructor: S. Spiewak, [email protected] , ph. (403) 220 8976 Page 2
shapePlot = Plot@8ysoln1@tD, ysoln2@tD<, 8t, 0, 5<, PlotRange Ø All,PlotStyle Ø 88Red, [email protected]<, 8Blue, [email protected]<<,Frame -> True, FrameLabel Ø 8"Time, @sD", "Response, @mD"<,FrameStyle Ø Directive@Black, 36D, FrameTicksStyle Ø Directive@Blue, 28D,TextStyle Ø 8FontFamily Ø "Helvetica", FontWeight -> "Bold", FontSize Ø 16<,ImageSize -> 8imageWidth, imageWidth ê GoldenRatio<,GridLines -> Automatic, GridLinesStyle Ø Directive@Gray, DashedDD
0 1 2 3 4 5-0.4
-0.2
0.0
0.2
0.4
Time, @sD
Response,@mD
File: lab_1_demo_2.nb Date: 2/25/11 14:01:58
ENME 599, Instructor: S. Spiewak, [email protected] , ph. (403) 220 8976 Page 3