Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Computational Methods II (CI2-221)

Tutorial 1

Exercise 1a    Jumping Jack

Your cousin Jack wants to be a stunt man and intends to establish himself by jumping with a car over a river. As he is quite ambitious he has chosen river of 30 m wide, and made a hill (6m high) on either side of the river. The hills are 50m apart. Because he knows you are studying at Imperial College, he wants you to ind out how fast he needs to drive to get over the river safely. If he drives too slow, he’ll crash into the second hill, and if he drives too fast he will slam into the ground far beyond the second hill. As he is unwilling to change his mind, it seems his life is in your hands.

Fortunately, you have a MATLAB script that can determine the path of lying vehicles.  The only thing you need to do is to create a function which describes the two hills before you can start your analysis.

 

Download all the iles from Blackboard to your work directory.

- The ile ex01.m is the master script for the tutorial.

- The function fJumpingJack.mcontains a mathematical model for the motion of Jack’s car. This function can be used as a black box: you provide the initial velocity u0  and the function for the ramp, and the function returns Jack’s horizontal and vertical position, x and y, respectively, as a function of time t.

- The function fHill.m is a template for the single hill.

- The function fRamp.m is a template for the ramp.

You think it is a good idea to start with creating a function for a single hill, which you construct using a hyperbolic tangent function:

f (x) = a (1 —   tanh2 b(x —   x0 )) .

(1)

Here, a [L] is the amplitude of the hill, b [L 1] controls the steepness, and x0  [L] is the ofset.

a. Implement eq. (1) into the function fHill.m. In the master ile, create a vector x which contains

200 elements in the range of 0 < x < 250 using the function linspace.  Using a for-loop, create a vector y with elements yi  = f (xi ), using the parameter values a = 6 m, b = 0.06 m 1  and x0  = 100

m. Plot y against x. Annotate the igure1 .

 

Ramp  Jack

 

200

x [m]

15

u0=45 m/s

10

5

0

250

x [m]

Figure 1: Jack’s trajectory. a) too slow; b) too fast.

b. Make the function fHill.m suitable for when the input parameter x is a vector, by using elemen- twise operators2 . Plot the results of the previous question and this question in one igure and show that the result is identical. Use the figure command to create a new igure window.

c.  Jack’s ramp can be modelled by using superposition of two individual hills.  In the ile fRamp.m, create the ramp by calling fHill.m twice. For both hills, a = 6 m and b = 0.06 m 1 , but for hill 1, x0  = 100, while for hill 2, x0  = 150. Do not change the input parameters of framp! Plot the result, which should be identical to the ramp shown in Fig. 1. Apply the same formatting to the igure as in the previous question.

d. At this point, the code fragment under ”question d”in ex01.m should reproduce Fig. 1b. Determine Jack’s vertical velocity v = dy/dt using MATLAB’s built-in gradient function. Create an annotated igure of v as a function of t.

The G-force, which is related to the force that Jack experiences, is deined by

G = ayg + 1,                                                                    (2)

where g is the gravitational acceleration. For Jack to come out of the car unhurt, G has to remain smaller than 20.

e.  Calculate the vertical acceleration, ay  = dv/dt, and use it to calculate G.  Create an annotated igure which shows G against x, together with the G = 20 limit.  Would you recommend Jack to approach the ramp at 45 m/s?

f.  Determine, by trial and error, the velocity u0  for which the peak G-force is smallest.  Write a comment in the master ile which states the optimal velocity u0 .