This assignment gives you an opportunity to work on a small-scale engineering design problem in python. The engineering system that you will be working on is a passive suspension, which is used in vehicles to reduce the amount of vertical vibration. A passive suspension is made of multiple components and the parameter of each component must be chosen correctly so that the passengers get a comfortable ride. The engineering design problem is to choose the right parameters and you will use python programming to solve this problem. The first step is to write a program to simulate the motion of a vehicle with suspension. You will then use the simulation result to evaluate the level of comfort for different choices of suspension parameters.
This assignment is divided in 4 main tasks:
Passive suspensions are used to reduce the vibration experienced by passengers, but they can also be used to improve the tyre grip and other performance measures. For this assignment, we will only be concerned about vibration reduction or comfort.
There are many designs for passive suspension. For this assignment, we consider a passive suspension consisting of a spring, a damper and an inerter in parallel, as depicted in Figure 1.
The classical method to reduce vibration is to use a spring and a damper
where the damper is used to slow down the motion of the car body. A new
method is to use a new mechanical device called an inerter
[1]. An inerter can store kinetic energy temporarily. Intuitively, a
shaking car has excessive kinetic energy in the vertical axis, so the
inerter can absorb and store some of this energy temporarily. The energy
in the inerter can be released later in an orderly manner without the
passengers feeling sudden movements. The first ever deployment of inerter
was in the 2005 Spanish Grand Prix by the MaLaren Formula 1 racing team,
which also happened to have won that race. There are a few interesting
tidbits surrounding the use of inerters, including McLaren invented the
decoy name J-damper so that its rivals would not know that it was actually
an inerter and a spy scandal, see [1] if you are interested.
The passive suspension has three parameters:
For this assignment, we will use a quarter car model for the vehicle. The quarter car model consists of one wheel/tyre and a quarter of the car body. It is commonly used to evaluate suspension designs at the initial stage. Of course, a full car model will be used for the final design but it is too complicated for this assignment.
Engineers very often have to make simplified models in order to derive mathematical models for real-life engineering systems. You will learn how to do this in later years. Figure 2 shows a simplified quarter car model.
The quarter car model consists of two lumps of masses. The mass ms (python variable name ms), which is on top, is the mass of 1/4 of the car body. (Note: The technical name is the sprung mass, hence the subscript s.) The lower mass mu (variable name mu) is the mass of the tyre and wheel. (Note: Technically this is the unsprung mass, hence subscript u.) The tyre is a bit elastic and is represented by a spring with stiffness kt (variable name kt). The passive suspension sits between the car body and the wheel/tyre.
There are three vertical displacements (see Figure 2) that we are interested in:
As the quarter car moves, yr, yu and ys change. That means these displacements are functions of time and we should write them as yr(t), yu(t) and ys(t). The corresponding python variables y_road, yu and ys are therefore arrays.
We also need two velocities for the quarter car model:
These velocities should be functions of time and we write them as vu(t) and vs(t). The corresponding python variables vu and vs are arrays.
The aim of the mathematical model for the quarter car is to determine ys(t), yu(t), vs(t) and vu(t). The mathematical model assumes the following are given:We have placed the mathematical model for the quarter car on a separate
page. We believe it is best for you to understand what you need to do for
this assignment first before dwelling into the mathematical model. You
should be able to understand what you need to do for the assignment
without going into the mathematical model at this stage.
(The model is here
and you can read it later.) We will now describe what you need to do for
the three tasks.
We have divided the work into a number of tasks.
The supplied files are in assign2.zip (click here)
Hint: You are strongly encouraged to read (or re-read!) the lecture notes, the code examples and the labs on numpy. In particular, look for numpy functions relevant to the following tasks. See the code examples on numpy from week-05 (click), week-07 (click) and week-08 (click) .
Outputs: ys the verticle displacement of the center of the car body from a reference level (array of floats) yu the verticle displacement of the center of the wheel/tyre from a reference level (array of floats) vs the verticle velocity of the quarter car body (array of floats) vu the verticle velocity of the wheel/tyre (array of floats)The inputs are:
Inputs: time time_array y_road an array of road heights ms the mass of 1/4 of the car body mu the mass of the tyre and wheel kt tyre stiffness k spring stiffness b inertance c damping coefficient
The implementation of simulate_qc requires the mathematical model for the quarter car. The model is here (click here), you need to use equations 7 to 12. You can use the python simulation programs from the lab.
Hint: You can use the python simulation program para_ODE_ext_lib.py and para_speed_height_by_ODE.py (code from Week 7's lecture) or the material from "Lab 08: Simulation and its applications" as a starting point to develop the function for this task.
You can assume the following initial conditions: vs(0) = vu(0) = ys(0) = yu(0) = 0.
Testing: You can test "Task 1" using the file test_task1_task2.py (available in assign2.zip).
The aim of Task 2 is to determine the discomfort level for a given set of suspension parameters. Intuitively, a comfortable ride means the passengers are not experiencing much vibration. We can express this quantitatively by calculating how much acceleration the car body experiences. The higher or longer the acceleration is, the more uncomfortable the ride is. (Note: An important part of using computers to perform engineering design is to express the design objective quantitatively. You will learn that in later years but this assignment will show you how to do that.)
Since the function simulate_qc
gives us the velocity of the car body, we can use it to determine the
acceleration and subsequently the discomfort level. For this task, you are
asked to write a python function
The above function should be in a file calc_discomfort.py .
The inputs and output values are:Purpose: Determining the discomfort level for a given set of suspension parameters Inputs: vs the verticle velocity of the quarter car body dt time increment Output: discomfort: a scalar representing the discomfort level for the given vehicle and suspension parameters
Let us assume that the array vs has n elements and let us use dt to denote the time increment used in the array time. We can use vs to calculate the acceleration at (n-1) time instances:
a[i]
= ( vs[i+1] - vs[i] ) / dt
where i = 0, 1, ..., n-3, n-2
where vs[i] is the i-th element of the array vs and a[i] is the i-th element of the acceleration array a. The discomfort level is then given by
discomfort = a[0]2 + a[1]2 + ... + a[n-3]2 + a[n-2]2
This should be the output of the function calc_discomfort. Intuitively, this calculation says the discomfort is higher if the acceleration is higher.
Hint: Consider the python and numpy functions like numpy.sum, and numpy.diff, they may prove useful here.
Testing: You can use the python program test_task1_task2.py (a file in assign2.zip) to test whether your calc_discomfort function is working correctly. If the reported error is small, i.e. less than 10-4, then it should be fine.
Important requirement on implementation: The calculation of the discomfort level from the array vs can be done without using any loops. You will only receive full marks for this part if the calculation is done without using loops, otherwise you will receive a reduced mark if loops are used.
The function calc_discomfort
allows you to determine the discomfort level for each set of suspension
parameters: spring stiffness k,
damping coefficient c and
inertance b. For simplicity, we
will not change the value of k.
We will calculate the discomfort level for many different pairs of
(inertance,damping coefficient) or (b,c)
values.
The above function should be in a file explore_qc.py .
Purpose: Determining the discomfort levels for a given damper values and inerter values Inputs: time time_array y_road an array of road heights ms the mass of 1/4 of the car body mu the mass of the tyre and wheel kt tyre stiffness k spring stiffness inerter_values inertance values (array of type float) damping_coefficient_values damping coefficient values (array of type float) Output: discomfort_array 2-dimentional numpy array with discomfort values for given damper values and inerter values (read the specs)
The steps for this Task are:
For example,
You can use loops to complete this task.
Testing: You can use the file test_task3_task4.py to check whether you have calculated the array discomfort_array correctly or not.
Hint: please read the examples in the file numpy_2d_examples.py
The engineering design problem is to choose good design parameters to meet our design requirements. In our case, a design has two design parameters inertance and damping coefficient.
By using the discomfort_array, determine the (inertance, damping coefficient) pair that gives the best comfort. For example, the pair that gives the smallest value of discomfort level in the array discomfort_array.
For comparison purpose, we will also determine a poor design which we define as the design that maximises the level of discomfort, that is less than or equal to discomfort_upper_limit. Determine the (inertance, damping coefficient) pair that gives the worst comfort, that is less than or equal to discomfort_upper_limit. For example, the pair that gives the largest value of discomfort level in the array discomfort_array, that is less than or equal to discomfort_upper_limit.
Once you have obtained the best design and the poor design, you need to return these four values from the following function you need to implement for his task.
The input and output values are:
Inputs: discomfort_array 2-dimentional numpy array with discomfort values for given inerter_values and damping_coefficient_values (read the specs) inerter_values inertance values (array of type float) damping_coefficient_values damping coefficient values (array of type float) discomfort_upper_limit maximum discomfort value to calculate worst comfort (i.e. 'max_inerter' and 'max_damping_coefficient' values) Output: min_inerter and min_damping_coefficient the pair that gives the smallest value of discomfort max_inerter and max_damping_coefficient the pair that gives the worst value of discomfort, that is less than or equal to a given 'discomfort_upper_limit'
You should complete this task using the min and max functions, without using any loops. You can only get full marks if your solution does not use loops. If your solution requires loops, then you can only get a reduced mark.
A requirement for Task 4 is that you should complete this task without using any loops. You can only get full marks if your solution does not use loops. If your solution requires a loop(s) for this task, then you can only get a reduced mark.
Hint: You can easily implement this function WITHOUT using a loop structure. Please read (or re-read!) lecture notes, the code examples and the labs on numpy. In particular, look for numpy functions that may help you to solve problems related to Task-4. For example, min, max, argmin, argmax, boolean indexing, boolean masking (Boolean addressing for assignment ), etc. See the code examples on numpy from week-05 (click), week-07 (click) and week-08 (click) . You may find the following example useful, week-08 lecture example (click) .
Testing: You can use the file test_task3_task4.py to check your answers for this task.
Remark: We have used exhaustive search here to determine the best and worst suspension parameters. This is certainly not the most efficient algorithm but you will learn better optimization methods in later years.
You should make sure that all your files are properly documented with appropriate comments. Variables that you use should have well chosen names and their meaning explained. Appropriate style should be used.
Marks | Feature/Assessable Item |
---|---|
7 | Task 1 (Simulation of the quarter car). |
3 | Task 2 (A function to calculate discomfort). Reduced maximum (for loop usage): 1.5 |
6 | Task 3 (Calculating discomfort level for many pairs of (inertance, damping coefficient)). |
4 | Task 4 (Determining the best and worst suspension), Reduced maximum (for loop usage): 1.5 |
5 | Style analysis |
25 | Total mark (rescaled to 10% of overall assessment) |
The complete submission should contain the following four files, you need to submit all four files together.
In case you have not completed a task(s), you need to submit the corresponding empty file(s).
The submission system will accept the above four filenames. You must not submit any other files.
Submission system is now available. To Submit this assignment, go to the Submission page and click the tab named "Make Submission".