Coursework Rocket
Coursework Rocket
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
Page 2 of 5 Continued
SCEE08014 Programming Skills for Engineers Referred Coursework
# mass loss
if m < RocketMass:
DeltaM = 0.0
else:
DeltaM = -JetArea*JetVel
# acceleration
DeltaV = - JetVel / m * DeltaM - Grav
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.
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]))
# 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
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