SCEE 08014 Programming Skills for Engineers Single Stage Rocket Script

User Generated

Fghqrag128

Programming

SCEE 08014

SCEE

Description

Unformatted Attachment Preview

SCEE08014 Programming Skills for Engineers Referred Coursework The following question is to be handed in to the ETO by 1400 on Thursday the 5th of August 2021. This is the referred coursework and to pass the course you must complete the coursework and obtain a mark of more than 40%. 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 mv ue dmv Av ρu2 du = (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 dt mv dt (2) which can be integrated to give u(t) = −ue ln mv (t) − gt. mv (0) (3) Assuming the burn rate is constant the mass of the rocket, mv (t) = mv0 (mv0 − mvb ) Page 1 of 4 t tb Continued SCEE08014 Programming Skills for Engineers Referred Coursework 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 calculate 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 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. Page 2 of 4 Continued SCEE08014 Programming Skills for Engineers Referred Coursework # 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)) #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 rocket carrying 1500 kg of fuel. Produce a graph to compare the results obtained against the results obtained using (3 ). Page 3 of 4 Continued [10] SCEE08014 Programming Skills for Engineers Referred Coursework 2. Modify the python code so it solves (1), including the aerodynamic drag on the rocket. 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. [30] 3. Using the solution from scipy.integrate.solve ivp write a python program which simulates the flight of a rocket t in real time. The rocket Your program should display on the screen [40] • a 10 second count down. • a telemetry report every 5 seconds starting with the tag “T+n seconds” and reporting the velocity and altitude of the rocket together with the remaining fuel level (as a percentage). This text should be Green if the engine is running, amber if the engine has stopped and red if the rocket is descending. • the telemetry report report should also include the exact time of key events, e.g. ignition, burnout, apogee, etc. Your answer to Q3 should be a maximum of three sides of A4. It must discuss 1. the flight dynamics of the rocket and any changes you have made to the model to make the simulation more realistic, 2. the approach taken to simulate the telemetry from the rocket. 3. the testing of the Python program to ensure the code is behaving as expected, You should also include an appendix containing your properly documented python code. This is not included in the page count. 4. Create a video showing your program running with an audio commentary explaining the flight of a rocket launched from a pad with an 83m tall launch tower, carrying 5000 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 4 of 4 END [20]
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Please vi...


Anonymous
Just what I needed…Fantastic!

Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Related Tags