Introduction

This page contains information on:

If you want to go back to the main page for Assignment 2, click here.


Mathematical model 

The model consists of (2+N) ordinary differential equations where N is the number of pedestrians. The first two ordinary differential equations allow you to compute x(t) and v(t), which are, respectively, the displacement and velocity of the bridge at time t. The two equations are:

 

The meaning of M, B, K, G and N are explained in the main assignment description, see here. The symbol Θi(t) is the phase of the pedestrian whose index is i.

By using x(t) and v(t), we can compute the phase of the bridge Ψ(t) using:

There are also N ordinary ordinary differential equations where each one describe the time evolution of one pedestrian's phase. These equations are

[Corrections (13 Nov 2019): I made a mistake in my previous version where I used one symbol (Ω0) to denote two different quantities. The Ω0 in Equations (3) and (4) have a different meaning from the Ω0 in the equation immediately below this text. In this correction, I have distinguished them by using Ω0 enclosed within a red rectangle (see Equations (3) and (4)) and Ω0 on its own as in the equation immediately below.  Note that Ω0 with a red rectangular box also appears in Equation (12) below. ]

For convenience, we will condense these N ordinary differential equations to:

These are all the equations for the mode: ordinary differentiation equations (1), (2) and (5), together with auxiliary equations (3) and (4). 

(Euler's forward method)

The next step is to apply Euler's forward method to the ordinary differential equations (1), (2) and (5), which results in the following equations you need for simulation.


Note that you will also need to compute Ψ(t) by using (3) before you compute the right-hand side of (8).

In your simulation code, you will need to identify x(t) and x(t+Δ) with the appropriate elements in dis_array; the same with v(t) and v(t+Δ) for vel_array, and Θi(t) and Θi(t+Δ) for ped_array,

(How to use Omega_array)

You will need the constants Ωi (for i = 0, ..., N-1) for (8). We have provided the value of Ωi (for i = 0, ..., N-1) to you in the numpy array Omega_array. If you take a look at the test code in test_sim_bridge(), you will find the following two lines of code:

Omega_array_whole = np.loadtxt('ped_freq_array.txt')
Omega_array = Omega_array_whole[:N]

We have stored the values of Ωi in an external file ped_freq_array.txt. The first line of code reads the contents of ped_freq_array.txt into the numpy array Omega_array_whole. The second line of code slices the first N elements out so that Omega_array is an array with N elements. The array Omega_array  is passed to sim_bridge() when the function is called.

For the calculation of Θi(t+Δ) in (8), you should use Omega_array[i]  for Ωi


Incremental development

You can develop  sim_bridge() incrementally in three steps. Let us begin with the full model, which is:

We will refer to the three steps of development as Step 0, Step 1 and Step 2.


(Step 0) In Step 0, you assume G = 0 and C = 0. You will only need to implement (10) and part of (11) of the full model. We have repeated the full model below using the following colour code: black means "you need to implement for this step" and yellow means "you do not yet have to implement". Note that we have kept the same equation numbers so that you can easily compare to the full model.


You can test Step 0 by setting test_num to 0 in the test file test_sim_bridge.py .Note that this test will only check  dis_array  and  vel_array.


(Step 1) For Step 1, you assume C = 0 but G is non-zero. With respect to Step 0, you need to implement the complete (11) as well as part of (13). We have repeated the full model below with the colour code that black means "you need to implement in this step" and yellow means "you do not yet have to implement".


You can test Step 1 by setting test_num to 1 in the test file test_sim_bridge.py .


(Step 2) This is the full model where both G and C are non-zero. For this step, you will need to implement (12) and the entire (13), i.e. the parts that are shown in yellow under (Step 1).

You can test Step 2 by setting test_num to 2 and 3 in the test file test_sim_bridge.py.

Note that it is possible to use numpy to implement (13) using just one line of code without using any loops. This applies to both Step 1 and Step 2.