0% found this document useful (0 votes)
41 views5 pages

Coursework Rocket

This document provides instructions for a referred coursework assignment on programming skills for engineers. Students must write a Python program to simulate the flight of a rocket using numerical integration techniques to solve the rocket equations of motion. The program must display telemetry data during the simulation and include a video commentary. The tasks involve: (1) simulating a 31cm rocket using simplified and full rocket equations, (2) including atmospheric drag in the simulation, (3) developing a real-time telemetry display, and (4) creating a video of a simulated launch with audio commentary. Comments and documentation are required.

Uploaded by

Abdul Qadir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views5 pages

Coursework Rocket

This document provides instructions for a referred coursework assignment on programming skills for engineers. Students must write a Python program to simulate the flight of a rocket using numerical integration techniques to solve the rocket equations of motion. The program must display telemetry data during the simulation and include a video commentary. The tasks involve: (1) simulating a 31cm rocket using simplified and full rocket equations, (2) including atmospheric drag in the simulation, (3) developing a real-time telemetry display, and (4) creating a video of a simulated launch with audio commentary. Comments and documentation are required.

Uploaded by

Abdul Qadir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SCEE08014 Programming Skills for Engineers Referred Coursework

The following question is to be uploaded to the resit assignment drop boxes by 1600
on Monday the 31st of July 2023. This is a referred coursework and to pass the
course you must complete the coursework and obtain a mark of more than 40% for this
assignment – marks from your work in Semester 1 are not included in this calculation.
You must upload both a PDF created from a JuPyTer notebook containing your
solution (Python, Explanatory text in MarkDown, and all graphs produced) and a
narrated video of your simulation running. The PDF files will be passed through turn-
it-in and checked for plagiarism. Your video will be watched and both the video content
and your narration marked.
Remember that the submitted work must be your own and that there are serious
consequences for using the work of others without proper citation or acknowledgement.
Please also remember that while generative AI systems like ChatGPT can write python
code the is no guarantee that such code will work. It may contain serious bugs, fail to
answer the question set, or even plagiarise the work of others, and include fake references.
This assessment does not use a blinkstick. It can be completed either using the Uni-
versity’s Notable service (using a web browser) or in your own Jupyter Lab environment.
It uses the numpy, scipy and matplotlib libraries though you may wish to use other
libraries to enhance the telemetry report.

Figure 1: Single stage rocket with instantaneous mass, m, in flight at a velocity u and an
angle of inclination, θ. The rocket exhaust has an exhaust with gas travelling at velocity
ue and pressure pe in a jet with area Ae . The dashed line indicates the control volume
containing the rocket.

Figure 1 shows a single stage rocket in flight. A large fraction (typically 90%) of the
mass of a rocket is propellant, it is thus important to consider the change in mass of the
rocket as it accelerates. By applying the momentum theorem to a small amount of mass
dm ejected from the rocket during a short period of time dt we can write down the rocket
equation

Page 1 of 5 Continued
SCEE08014 Programming Skills for Engineers Referred Coursework

du mv ue dmv Av ρu2
= (pe − p0 ) − − Cd − g cos θ (1)
dt A e mv dt 2mv
where p0 is atmospheric pressure, Cd is the drag coefficient and Av is the cross sectional
area of the rocket.
Equation (1) can be simplified by assuming that p0 = pe , ignoring drag and making
ue constant, giving the differential equation
du ue dmv
= −g (2)
dt mv dt
which can be integrated to give
mv (t)
u(t) = −ue ln − gt. (3)
mv (0)
Assuming the burn rate is constant the mass of the rocket,
t
mv (t) = mv0 (mv0 − mvb )
tb
where mv0 is the mass of the rocket at ignition, mvb is the mass of the rocket at burn out
(i.e. when the fuel is exhausted) and tb is the time at which all the propellant has been
used.
scipy.integrate.solve_ivp can be used to solve (2) and can also be used to calcu-
late the altitude of the rocket by solving the additional equation
dh
= u.
dt
scipy.integrate.solve_ivp requires a function which defines the differential equations
to be solved.
import numpy as np
from scipy.integrate import solve_ivp
from matplotlib import pyplot as plt

# Constants
Grav = 9.81
RocketMass = 1000 # Kg
JetArea = 0.1**2*np.pi # m^2
JetVel = 1500.0 # m/s

def rocket(t, state):


'''Simplified rocket equation including height.
t is the current, time, state is an array containing

Page 2 of 5 Continued
SCEE08014 Programming Skills for Engineers Referred Coursework

the values of the variables h, u and m. These are


the height of the rocket, the velocity of the rocket
and the mass of rocket.'''

# unpack the variables


h, u, m = state

# mass loss
if m < RocketMass:
DeltaM = 0.0
else:
DeltaM = -JetArea*JetVel

# acceleration
DeltaV = - JetVel / m * DeltaM - Grav

return [u, DeltaV, DeltaM]

Three additional event functions are defined so we know the times at which the rocket
burns out, achieves apogee (it’s maximum altitude) and crashes.

# event for when rocket crashes back to earth


def hit_ground(t, y): return y[0]
hit_ground.terminal = True
hit_ground.direction = -1

# event for burnout


def burnout(t, y): return y[2]-RocketMass
burnout.terminal = False
burnout.direction = -1

# event for apogee


def apogee(t, y): return y[1]
apogee.terminal = False
apogee.direction = -1

#Launch a rocket with 1500kg of fuel and see what happens


sol = solve_ivp(rocket,
[0, 3600], # 1 hour of flight maximum
[ 0.0, 0.0, RocketMass + 1500.0], # initial conditions
method = 'LSODA', # stiff ODE solver
dense_output=True,events=(burnout,apogee,hit_ground))

Page 3 of 5 Continued
SCEE08014 Programming Skills for Engineers Referred Coursework

#Interpret results
print('Burn out at t={:.2f}s, maximum velocity is {:.2f} m/s '.format(
sol.t_events[0][0],sol.y_events[0][0][1]))
print('Apogee at t={:.2f}s, maximum altitude is {:.2f} km'.format(
sol.t_events[1][0],sol.y_events[1][0][0]/1000))
print('Impact at t={:.2f}s'.format(sol.t_events[2][0]))

Finally the graph can be plotted

# Plot a graph
t = np.linspace(0.0,sol.t_events[2][0],500)
h = sol.sol(t)
plt.plot(t,h[0]/1000.0)
plt.ylabel('Altitude (km)')
plt.xlabel('Time (s)')
plt.axvline(sol.t_events[0][0],color='red')
plt.show()

1. Use the above python code to solve (2) for a 31cm diameter rocket, carrying 1750 kg [10]
of fuel. Produce a graph to compare the results obtained against the results obtained
using (3).

2. Modify the python code so it solves (1), including the aerodynamic drag on the rocket. [30]
The drag force is
A
Fd = Cd ρu2
2
where A is the cross-sectional area of the rocket, ρ is the density of the air and u
is the velocity of the rocket. Compare the results for a simple rocket with a 31 cm
diameter in atmospheric flight with that of the rocket in a vacuum from the previous
question. You may assume that Cd = 0.75.

3. Using the solution from scipy.integrate.solve_ivp write a python program which [40]
simulates the flight of a rocket in real time. Your program should display on the screen

• a 10 second count down.


• a telemetry report every 5 seconds with time indicated as “T+n seconds” re-
porting the velocity and altitude of the rocket together with the remaining fuel
level (as a percentage). As a minimum this should use green text if the engine
is running, amber text if the engine has stopped and red text if the rocket is
descending.
• the telemetry report report should also include the exact time of key events,
including: ignition, tower clearance, burnout, apogee and impact.

Page 4 of 5 Continued
SCEE08014 Programming Skills for Engineers Referred Coursework

Your answer to Q1, Q2 and Q3 should include MarkDown text boxes alongside the
Python code. These must

• discuss the flight dynamics of the rocket and any changes you have made to
make the simulation more realistic,
• explain the approach you have used to dsiplaying the telemetry from the rocket.
• validate the Python programs to ensure your code is behaving as expected,

Finally please remember that all Python code should be properly laid out, make good
use of comments and have appropriate variable names.

4. Create a video showing your program running with an audio commentary explaining [20]
the flight of a 50cm diameter rocket launched from a pad (at sea level) with an 3084
mm tall launch tower, carrying 5250 kg of fuel. The video must have a duration of no
more than 3 minutes. To achieve this you may run your simulation at double speed
(i.e. 1 simulated seconds is equivalent to two seconds of flight time).

Each component of Questions 3 and 4 will be marked against the University common
marking scheme, with equal weighting. You are advised to watch the short video which
explains how this scheme works (https://media.ed.ac.uk/id/1_7d7uwivg).

Page 5 of 5 END

You might also like