Introduction 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...


Introduction


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.


Learning objectives



  • Applying programming to solve a simple engineering design problem

  • Writing a python program to simulate an engineering system

  • Applying a number of python features, which include vectorisation, built-in functions and others

  • Applying good software engineering practices, proper documentation, program style


Assignment overview


This assignment is divided in 4 main tasks:



  • Task-1 and Task-2 (Simulation):Simulation of a vehicle with a passive suspension.

  • Task-3 and Task-4: (Design)Evaluating the comfort level of different suspension designs, and choose the designs that give the most and least comfortable rides. (Note: The normal practice is to look at the best few designs and don't care about the worst. As an exercise, we look at the best and the worst so that you can see the contrast.)

In the following, we will first give an introduction to passive suspension and vehicle modelling. The introduction is meant to give you some intuition on the design problem. After that we will tell you what you need to do for each task.

Passive suspensions


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.



Figure 1. A passive suspension. Figure modified from [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 aninerter[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:



  • Spring stiffnessk. (A largekmeans a stiff spring which is hard to stretched.) (python variablek)

  • Damping coefficientc. (A largercmeans a larger resistance to movement.) (python variablec)

  • Inertanceb. (A largebmeans the interter can store more kinetic energy.) (python variableb)

The design problem is to choose values ofk,candbso that the ride is comfortable. A passive suspension can only be designed together with a vehicle, so we need to look at the vehicle model now.

The vehicle model


For this assignment, we will usea quarter carmodel 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.



Figure 2. A quarter car. Figure modified from [1].

The quarter car model consists of two lumps of masses. The mass ms(python variable namems), which is on top, is the mass of 1/4 of the car body. (Note: The technical name is the sprung mass, hence the subscripts.) The lower mass mu(variable namemu) is the mass of the tyre and wheel. (Note: Technically this is the unsprung mass, hence subscriptu.) The tyre is a bit elastic and is represented by a spring with stiffness kt(variable namekt). 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:



  • yris the height of the road surface from a reference level (variable nameyRoad)

  • yuis the vertical displacement of the center of wheel/tyre from a reference level (variable nameyu)

  • ysis the vertical displacement of the center of the quarter car body from a reference level (variable nameys)


As the quarter car moves, yr, yuand yschange. That means these displacements are functions of time and we should write them as yr(t), yu(t) and ys(t). The corresponding python variablesyRoad,yuandysare therefore arrays.


We also need two velocities for the quarter car model:



  • vuis the vertical velocity of the wheel/tyre (variable namevu)

  • vsis the vertical velocity of the quarter car body (variable namevs)


These velocities should be functions of time and we write them as vu(t) and vs(t). The corresponding python variablesvuandvsare 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:


  • The height of the road yr(t) over time. We call this the road profile.

  • The parameters: k, c and b (from the passive suspension) and ms, muand kt(from the quarter car)


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 ishereand you can read it later.) We will now describe what you need to do for the three tasks.


Overview of tasks


We have divided the work into a number of tasks.



  • Task 1 and Task 2: are on simulation

  • Task 3 and Task 4: are on engineering design



Supplied files


The supplied files are inassign2.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 fromweek-06 (click),week-07 (click)andweek-08 (click).


Task 1: Simulation of the quarter car

The aim of this task is to write a python functionsimulate_qc(which should be in a file with namesimulate_qc.py) to simulate the quarter car. You can find a template for this function insimulate_qc_template.py(inassign2.zip). You should rename it assimulate_qc.pybefore you start. The declaration of the functionsimulate_qcis:



def simulate_qc(time_array, y_road, ms, mu, kt, k, b, c) :

The above functionreturns four arrays. These four arrays contain the following simulation outputs:


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 ofsimulate_qcrequires 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 programpara_ODE_ext_lib.pyandpara_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 followinginitial conditions: vs(0) = vu(0) = ys(0) = yu(0) = 0.



Testing:You can test "Task 1" using the filetest_task1_task2.py(available in assign2.zip).





Task 2: A function to calculate discomfort


The aim of Task 2 is to determine thediscomfortlevel 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 functionsimulate_qcgives 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


def calc_discomfort(vs , dt):

The above function should be in a filecalc_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 arrayvshasnelements and let us usedtto denote the time increment used in the arraytime. We can usevsto calculate the acceleration at(n-1)time instances:


a[i] = ( vs[i+1] - vs[i] ) / dt
wherei = 0, 1, ..., n-3, n-2


wherevs[i]is thei-th element of the arrayvsanda[i]is thei-th element of the acceleration arraya. 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 functioncalc_discomfort. Intuitively, this calculation says the discomfort is higher if the acceleration is higher.



Hint:Consider the python and numpy functions likenumpy.sum, andnumpy.diff, they may prove useful here.



Testing:You can use the python programtest_task1_task2.py(a file inassign2.zip) to test whether yourcalc_discomfortfunction 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 arrayvscan be done without using any loops. You will only receive full marks for this part if the calculation is donewithoutusing loops, otherwise you will receive areducedmark if loops are used.


Task 3: Calculating discomfort level for many pairs of (inertance,damping coefficient)


The functioncalc_discomfortallows you to determine the discomfort level for each set of suspension parameters: spring stiffnessk, damping coefficientcand inertanceb. For simplicity, we will not change the value ofk. We will calculate the discomfort level for many different pairs of (inertance,damping coefficient) or (b,c) values.


def explore_qc(time_array, y_road, ms, mu, kt, k, inerter_array, damping_coefficient_array):

The above function should be in a fileexplore_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:



  1. Create a 2-dimentional zero arraydiscomfort_arraywithlen(inerter_array)rows andlen(damping_coefficient_array)columns.

  2. The(i, j)element of the 2-dimentional arraydiscomfort_array, i.e.discomfort_array(i,j), should be assigned the discomfort level of a suspension wheninerter_values[i]anddamping_coefficient_values[j]are used.

    For example,


    You can assume all other parameters are as specified.


Youcan use loopsto completethis task.



Testing:You can use the filetest_task3_task4.pyto check whether you have calculated the arraydiscomfort_arraycorrectly or not.


Hint: please read the examples in the filenumpy_2d_examples.py


Task 4: Determining the (inertance,damping coefficient) pairs that give, respectively, the best and worst comfort


The engineering design problem is to choose good design parameters to meet our design requirements. In our case, a design has two design parametersinertanceanddamping coefficient.


By using thediscomfort_array, determine the (inertance, damping coefficient) pair that gives thebestcomfort. For example, the pair that gives thesmallestvalue of discomfort level in the arraydiscomfort_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 todiscomfort_upper_limit. Determine the (inertance, damping coefficient) pair that gives theworstcomfort, that is less than or equal todiscomfort_upper_limit. For example, the pair that gives thelargestvalue of discomfort level in the arraydiscomfort_array, that is less than or equal todiscomfort_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.


def optimise_qc(discomfort_array, inerter_array, damping_coefficient_array, discomfort_upper_limit):

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 theminandmaxfunctions,withoutusing any loops. You can only get full marks if your solution doesnotuse loops. If your solution requires loops, then you can only get areducedmark.


A requirement for Task 4 is that you should complete this taskwithoutusing any loops. You can only get full marks if your solution doesnotuse loops. If your solution requires a loop(s) for this task, then you can only get areducedmark.


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 fromweek-06 (click),week-07 (click)andweek-08 (click). You may find the following example useful,week-08 lecture example (click).



Testing:You can use the filetest_task3_task4.pyto 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.


Style


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.


Assessment

The following table shows the maximum possible marks for the tasks. Note that there are specific requirements for some tasks and the maximum is reduced is those requirements are not met.

































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)


Submission


The complete submission should contain the followingfour files, you need to submit allfour filestogether.


In case you have not completed a task(s), you need to submit the corresponding empty file(s).



  • simulate_qc.py

  • calc_discomfort.py

  • explore_qc.py

  • optimise_qc.py


The submission system will accept the above four filenames. You must not submit any other files.



Aug 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here