Math 272 - Roller Coaster Project - Phase 2 Goal To build a differential equation model for the motion of a roller coaster car along a track, and to use ode45 to simulate the motion. Deliverables A MATLAB function file, rollerCoasterDE.m, that • takes as input the current state of the car, in the form of the 4-element column vector: w ~ = [x, x0 , y, y 0 ]T , and • returns a 4-element column vector holding the resulting rate of change of each variable, d d w ~= ([x, x0 , y, y 0 ]). dt dt The complete set of input parameters for the function is: • the current time of the simulation, in t, • the current state values (positions and velocities) in w, • the spline parameters for the track, pp • the friction coefficient mu, • the mass of the car m, • the magnitude of the motor force, Fm, and • the time span the motor is turned on: time_span_m. – time_span_m is a 2-element vector. If time_span_m = [3, 4.5] were used as input, then the motor would exert its force during the time interval 3 ≤ t ≤ 4.5 seconds during the simulation. Outside of that time interval, the force from the motor would be zero. Format of the function: • format: function dw_dt = rollerCoasterDE(t, w, pp, mu, m, Fm, time_span_m) Phase 2 Details You must read the Background document on this project before beginning. In that document, it defines the variables we are using, and the general problem. Furthermore, you should review the notes from Weeks 8 and 9, where a similar Newtonian problem was presented, and ode45 was used to simulate the motion based on the forces in play. To arrive at the deliverables, the following steps are recommended: • Use the notes from Week 8 to get started on your rollerCoasterDE.m function file. • Once you have your draft rollerCoasterDE.m written, test it using the script Phase2TestCase1.m. That script will define an inclined plane with a spline, and compare the predicted distance travelled with a ode45-computed simulation using your differential equation (Test Case 1). • Once your differential equation is written so the simulation passes the first test case, extend your script so that it compares your results to the later test cases in this document. Notes on simulation: • We are in a MATH class, so the acceleration due to gravity is just g = 9.8 m/s2 . Not 9.81, not 9.806. (You’re lucky I’m not rounding it to 10...) • All of the simulations with ode45 should use the following accuracy options: options = odeset(’AbsTol’, 1e-10, ’RelTol’, 1e-8); 1 Test Cases Test Case 1 The first test case is contained in Phase2TestCase1Sample.m. That script defines the constants for the car and track, and defines a linear track. It then uses ode45 and your rollerCoasterDE.m to predict the motion of the car down an inclined plane, and compares the total distance travelled over 1 second with the analytic prediction for frictionless motion. Test Case 2 The second test case is identical to the first, except that friction is added. The force of friction at any instant has magnitude µ v, and acts in the direction opposite the current velocity. The test conditions are: • If µ = 2 N/ (m/s), then in 1 second the car will travel 2.17681 meters down the Test Case 1 track. • If µ = 10 N/ (m/s), then in 1 second the car will travel 2.12009 meters. Test Case 3 The next test case is identical to the first (no friction, µ = 0), except that the motor force is added. The test conditions are: • If the motor exerts Fm = 50 N, and time_span_m = [0.0, 1.0], the car will travel 2.44135 meters down the Test Case 1 track. • If Fm = 50 and time_span_m = [0.0, 0.5], the car will travel 2.37885 meters. • If Fm = 50 and time_span_m = [0.75, 1.0], the car will travel 2.20697 meters. (More test cases on following pages.) 2 Test Case 4 In this test case, we add curvature to the track. We will use part of a circular track, so that the curvature will remain roughly constant. (We are using splines as an approximation to a real circle, though, so the curvature will actually vary a little from point to point.) For simplicity, we will set the both friction and Fm back to zero. You will need to set up the following supports. L = 3; theta0 = pi/4; t = linspace(theta0, -theta0, 21); x = -L*sin(t); y = -L*cos(t); plot(x, y, ’.’); N = length(x) - 1; The car will behave like a pendulum while on this near-circular track. We can validate our differential equation by running the simulation for fractions of one period, T . L (m) 3 T (s) 3.61534 If we set up this track in a script, and start at x0 = −L ∗ sin(π/4) with zero initial velocity, then use ode45 to predict the motion of the car, we should see • simulating on t ∈ [0, T /2], we should end at x = +L sin(π/4) • simulating on t ∈ [0, T /4] or [0, 3T /4], we should end at x = 0. Test Case 5 A more complicated track is defined by the following supports. support_x = linspace(0, 10, 11); support_y = cos(pi/2*support_x) - 0.5 * support_x; Reset your Fm to zero at the beginning of these test cases. 3 Test Case 5a If you start the car at (x, y) = (0, 1), with zero initial velocity, µ = 2 and Fm = 0, your simulation should predict the following positions over time. t x y 0.0000 0.2000 0.4000 0.6000 0.8000 1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 0.0000 0.0788 0.3056 0.6419 1.0824 1.7476 2.9719 4.0364 4.8200 5.6408 7.1492 1.0000 0.9515 0.7214 0.1933 -0.6645 -1.7862 -1.5281 -1.0202 -2.1429 -3.6500 -3.3525 Test Case 5b If we keep the same starting condition, but increase the friction, the car will no longer make it over the first bump in the track. Setting µ = 100 N/(m/s), your simulation should predict the following positions over time. t x y 0.0000 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000 0.0000 0.4070 1.3008 3.0144 3.3608 2.6545 1.6708 2.1337 2.5767 2.0057 2.1466 1.0000 0.5817 -1.0880 -1.4856 -1.1627 -1.8249 -1.6907 -2.0412 -1.8854 -2.0028 -2.0426 Test Case 5c With µ= 100 N/(m/s), but now adding the motor force Fm = 90 N and a motor time span of time_span_m = [0, 2] seconds, the motor will be strong enough to push the car over the first bump, but then will cut off and leave the car rolling in the second valley. Your simulation should predict the following positions over time. t x y 0.0000 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000 0.0000 0.4676 1.4887 3.2904 3.9413 4.6450 5.7730 7.2920 7.2482 6.2357 5.6758 1.0000 0.4894 -1.4191 -1.2218 -0.9757 -1.8124 -3.8151 -3.2205 -3.2595 -4.0411 -3.6973 4
© Copyright 2024