Skip to content

Commit ae81e3f

Browse files
committed
added example configurations
1 parent d9a850d commit ae81e3f

File tree

4 files changed

+178
-83
lines changed

4 files changed

+178
-83
lines changed

examples/example_configurations.py

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import sys
2+
import os
3+
4+
import numpy as np
5+
6+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
7+
from rocketflightsim.rocket_classes import Motor, Rocket, LaunchConditions, Airbrakes
8+
9+
# Example motor configurations
10+
Cesaroni_7579M1520_P = Motor(
11+
# source: https://www.thrustcurve.org/simfiles/5f4294d20002e900000006b1/
12+
dry_mass = 2.981,
13+
thrust_curve = {
14+
0: 0,
15+
0.04: 1427.8,
16+
0.082: 1706.39,
17+
0.176: 1620.49,
18+
0.748: 1734.25,
19+
1.652: 1827.11,
20+
2.676: 1715.68,
21+
3.89: 1423.15,
22+
4.399: 1404.58,
23+
4.616: 661.661,
24+
4.877: 69.649,
25+
4.897: 0
26+
},
27+
fuel_mass_curve = {
28+
0: 3.737,
29+
0.04: 3.72292,
30+
0.082: 3.69047,
31+
0.176: 3.61337,
32+
0.748: 3.14029,
33+
1.652: 2.34658,
34+
2.676: 1.45221,
35+
3.89: 0.512779,
36+
4.399: 0.157939,
37+
4.616: 0.0473998,
38+
4.877: 0.000343417,
39+
4.897: 0
40+
}
41+
)
42+
43+
Cesaroni_7450M2505_P = Motor(
44+
dry_mass = 2.866, # source: http://www.pro38.com/products/pro98/motor/MotorData.php?prodid=7450M2505-P
45+
thrust_curve = { # source: https://www.thrustcurve.org/simfiles/5f4294d20002e900000005a0/
46+
0: 0,
47+
0.12: 2600,
48+
0.21: 2482,
49+
0.6: 2715,
50+
0.9: 2876,
51+
1.2: 2938,
52+
1.5: 2889,
53+
1.8: 2785,
54+
2.1: 2573,
55+
2.4: 2349,
56+
2.7: 2182,
57+
2.99: 85,
58+
3: 0
59+
},
60+
fuel_mass_curve = { # source: https://www.thrustcurve.org/simfiles/5f4294d20002e900000005a0/
61+
0: 3.423,
62+
0.12: 3.35069,
63+
0.21: 3.24469,
64+
0.6: 2.77495,
65+
0.9: 2.38622,
66+
1.2: 1.98198,
67+
1.5: 1.57684,
68+
1.8: 1.18234,
69+
2.1: 0.809811,
70+
2.4: 0.467594,
71+
2.7: 0.152563,
72+
2.99: 0.000196996,
73+
3: 0
74+
}
75+
)
76+
77+
# Example rocket configuration
78+
example_rocket = Rocket(
79+
A_rocket = 0.015326, # m^2
80+
rocket_mass = 14, # kg
81+
motor = Cesaroni_7579M1520_P,
82+
Cd_rocket_at_Ma = 0.4,
83+
h_second_rail_button = 0.69 # m
84+
)
85+
86+
# LaunchConditions class configuration for Spaceport America Cup
87+
T_lapse_rate_SA = -0.00817 # K/m
88+
""" How T_lapse_rate at Spaceport America was determined
89+
90+
Only one source was found with the lapse rate for Spaceport America:
91+
- https://egusphere.copernicus.org/preprints/2023/egusphere-2023-633/egusphere-2023-633.pdf
92+
- luckily, they took their measurements in June
93+
- The lapse rates for the stratosphere for each of three flights were reported as follows:
94+
- June 1st 2021 -8.4 K/km
95+
- June 4th 2021 -7.9 K/km
96+
- June 6th 2021 -8.2 K/km
97+
- An average of these is what was chosen for the simulation
98+
- The linear lapse rate was valid for the first 10 km AGL
99+
100+
For future reference, it should be noted that time of year has a large effect on the lapse rate, as reported in:
101+
- https://mdpi-res.com/d_attachment/remotesensing/remotesensing-14-00162/article_deploy/remotesensing-14-00162.pdf?version=1640917080
102+
- https://hwbdocs.env.nm.gov/Los%20Alamos%20National%20Labs/TA%2004/2733.PDF
103+
- states that the average lapse rate in NM is:
104+
- -4.0F/1000ft (-7.3 K/km) in July
105+
- -2.5F/1000ft (-4.6 K/km) in January
106+
- -8.2 K/km is higher than the summer average, but generally desert areas have higher-than-normal lapse rates
107+
108+
The following was the most comprehensive source found for temperature lapse rates in New Mexico:
109+
- https://pubs.usgs.gov/bul/1964/report.pdf
110+
- No values were found for Spaceport itself, but values for other locations in New Mexico were found
111+
- the report says that in the western conterminous United States, temperature lapse rates are generally significantly less than the standard -6.5 K/km
112+
- the report didn't include the date (or month) of the measurements, so I'd assume that it happened in the winter due to the low lapse rates, and/or the data being several decades old means that it's no longer as accurate due to the changing global climate
113+
- has values for many locations in New Mexico (search for n. mex), and they ranged from -1.4 to -3.9 K/km
114+
- the closest station to SC was Datil, which had a lapse rate of -3.1 K/km
115+
"""
116+
L_launch_rail_ESRA_provided_SAC = 5.18 # m,
117+
""" ESRA provides teams with a 5.18m rail at competition """
118+
launchpad_pressure_SAC = 86400 # Pa
119+
""" How the launchpad pressure at Spaceport America was determined
120+
121+
- 86400 2022/06/24 WE Rocketry 2022 TeleMega/TeleMetrum data
122+
- 86405 2022/06/23 https://github.com/ISSUIUC/flight-data/tree/master/20220623
123+
- 86170 2023/06/21 https://github.com/ISSUIUC/flight-data/tree/master/20230621
124+
"""
125+
launchpad_temp_SAC = 35 # deg C
126+
""" Ground-level temperature at Spaceport America Cup note
127+
128+
Flights can occur between about 07:00 and 16:30 local time, so the temperature at the time of launch can vary significantly. 35 C is about what it has been historically during the competition in mid-late June. Getting closer to launch day, it would be more accurate to use a weather forecast to get a value for expected temperature(s).
129+
130+
You can also consider running simulations with a range of temperatures that have been seen on launch days in the past (normally between 25 and 45 C) to see how different ground-level temperatures could affect a rocket's flight.
131+
"""
132+
latitude_SA = 32.99 # deg, Spaceport America's latitude
133+
""" https://maps.app.goo.gl/rZT6MRLqHneA7wNX7 """
134+
altitude_SA = 1401 # m, Spaceport America's elevation
135+
""" https://www.spaceportamerica.com/faq/#toggle-id-15 """
136+
launch_angle_SAC = 84 # deg from horizontal
137+
""" How the standard launch angle at Spaceport America Cup was determined
138+
DTEG 10.1.1:
139+
> Launch vehicles will nominally launch at an elevation angle of 84° ±1°
140+
DTEG 10.1.2:
141+
> Range Safety Officers reserve the right to require certain vehicles’ launch elevation be
142+
lower or higher if flight safety issues are identified during pre-launch activities
143+
144+
Teams have noted that they've been told to use angles at least as low as 80°. The Range Safety Officer picks the angle based on various factors, including the rocket being launched, the weather, and the location of the launch pad. In the design, simulation, and testing phases, use the nominal angle of 84°, but consider the possibility of the launch angle being more or less than that on competition day.
145+
"""
146+
147+
Spaceport_America_avg_launch_conditions = LaunchConditions(
148+
launchpad_pressure = launchpad_pressure_SAC,
149+
launchpad_temp = launchpad_temp_SAC,
150+
L_launch_rail = L_launch_rail_ESRA_provided_SAC,
151+
launch_angle = launch_angle_SAC,
152+
local_T_lapse_rate = T_lapse_rate_SA,
153+
latitude = latitude_SA,
154+
altitude = altitude_SA
155+
)
156+
157+
# Default airbrakes model
158+
default_airbrakes_model = Airbrakes(
159+
num_flaps = 3,
160+
A_flap = 0.004, # m^2 flap area
161+
Cd_brakes = 1,
162+
max_deployment_speed = 5, # deg/s
163+
max_deployment_angle = 45 # deg
164+
)
165+
166+
if __name__ == "__main__":
167+
from rocketflightsim.flight_simulation import simulate_flight, simulate_airbrakes_flight
168+
from rocketflightsim.plotting_functions import plot_ascent, plot_aerodynamics, plot_airbrakes_ascent
169+
170+
dataset, liftoff_index, launch_rail_cleared_index, burnout_index, apogee_index = simulate_flight(rocket = example_rocket, launch_conditions = Spaceport_America_avg_launch_conditions, timestep = 0.001)
171+
print(f"Motor burnout: \n\tHeight: {dataset['height'].iloc[burnout_index - 1]} m\n\tSpeed: {dataset['speed'].iloc[burnout_index - 1]} m/s\n\tTime: {dataset['time'].iloc[burnout_index - 1]} s\n")
172+
print(f"Apogee: \n\tHeight: {dataset['height'].iloc[apogee_index - 1]} m\n\tTime: {dataset['time'].iloc[apogee_index - 1]} s\n")
173+
174+
plot_ascent(dataset['time'], dataset['height'], dataset['speed'], dataset['v_y'], dataset['a_y'])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='rocketflightsim',
5-
version='0.1.0',
5+
version='0.1.1',
66
description='A lightweight rocket flight simulator.',
77
long_description=open('README.md').read(),
88
long_description_content_type='text/markdown',

examples/test_configs.py renamed to tests/test_configs.py

Lines changed: 1 addition & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -935,84 +935,4 @@ def Juno3_Cd_rocket_at_Ma(Ma):
935935
Could diagnose more by comparing plots of data from the flight computer to plots from the sim, but a bit busy atm
936936
"""
937937

938-
past_flights = [NDRT_2020_flight, Valetudo_flight, Juno3_flight, Bella_Lui_flight]
939-
940-
default_airbrakes_model = Airbrakes(
941-
num_flaps = 3,
942-
A_flap = 0.004, # m^2 flap area
943-
Cd_brakes = 1,
944-
max_deployment_speed = 5, # deg/s
945-
max_deployment_angle = 45 # deg
946-
)
947-
948-
# LaunchConditions class configurations
949-
T_lapse_rate_SA = -0.00817 # K/m
950-
""" How T_lapse_rate at Spaceport America was determined
951-
952-
Only one source was found with the lapse rate for Spaceport America:
953-
- https://egusphere.copernicus.org/preprints/2023/egusphere-2023-633/egusphere-2023-633.pdf
954-
- luckily, they took their measurements in June
955-
- The lapse rates for the stratosphere for each of three flights were reported as follows:
956-
- June 1st 2021 -8.4 K/km
957-
- June 4th 2021 -7.9 K/km
958-
- June 6th 2021 -8.2 K/km
959-
- An average of these is what was chosen for the simulation
960-
- The linear lapse rate was valid for the first 10 km AGL
961-
962-
For future reference, it should be noted that time of year has a large effect on the lapse rate, as reported in:
963-
- https://mdpi-res.com/d_attachment/remotesensing/remotesensing-14-00162/article_deploy/remotesensing-14-00162.pdf?version=1640917080
964-
- https://hwbdocs.env.nm.gov/Los%20Alamos%20National%20Labs/TA%2004/2733.PDF
965-
- states that the average lapse rate in NM is:
966-
- -4.0F/1000ft (-7.3 K/km) in July
967-
- -2.5F/1000ft (-4.6 K/km) in January
968-
- -8.2 K/km is higher than the summer average, but generally desert areas have higher-than-normal lapse rates
969-
970-
The following was the most comprehensive source found for temperature lapse rates in New Mexico:
971-
- https://pubs.usgs.gov/bul/1964/report.pdf
972-
- No values were found for Spaceport itself, but values for other locations in New Mexico were found
973-
- the report says that in the western conterminous United States, temperature lapse rates are generally significantly less than the standard -6.5 K/km
974-
- the report didn't include the date (or month) of the measurements, so I'd assume that it happened in the winter due to the low lapse rates, and/or the data being several decades old means that it's no longer as accurate due to the changing global climate
975-
- has values for many locations in New Mexico (search for n. mex), and they ranged from -1.4 to -3.9 K/km
976-
- the closest station to SC was Datil, which had a lapse rate of -3.1 K/km
977-
"""
978-
L_launch_rail_ESRA_provided_SAC = 5.18 # m,
979-
""" ESRA provides teams with a 5.18m rail at competition """
980-
launchpad_pressure_SAC = 86400 # Pa
981-
""" How the launchpad pressure at Spaceport America was determined
982-
983-
- 86400 2022/06/24 WE Rocketry 2022 TeleMega/TeleMetrum data
984-
- 86405 2022/06/23 https://github.com/ISSUIUC/flight-data/tree/master/20220623
985-
- 86170 2023/06/21 https://github.com/ISSUIUC/flight-data/tree/master/20230621
986-
- Truth or Consequences, NM, USA, which has an elevation 90 m lower than Spaceport America
987-
- 84780 http://cms.ashrae.biz/weatherdata/STATIONS/722710_s.pdf
988-
"""
989-
launchpad_temp_SAC = 35 # deg C
990-
""" Ground-level temperature at Spaceport America Cup note
991-
992-
Flights can occur between about 07:00 and 16:30 local time, so the temperature at the time of launch can vary significantly. 35 C is about what it has been historically during the competition in mid-late June. Getting closer to launch day, it would be more accurate to use a weather forecast to get a value for expected temperature(s).
993-
994-
You can also consider running simulations with a range of temperatures that have been seen on launch days in the past (normally between 25 and 45 C) to see how different ground-level temperatures could affect a rocket's flight.
995-
"""
996-
latitude_SA = 32.99 # deg, Spaceport America's latitude
997-
""" https://maps.app.goo.gl/rZT6MRLqHneA7wNX7 """
998-
altitude_SA = 1401 # m, Spaceport America's elevation
999-
""" https://www.spaceportamerica.com/faq/#toggle-id-15"""
1000-
launch_angle_SAC = 84 # deg from horizontal
1001-
"""DTEG 10.1.1:
1002-
> Launch vehicles will nominally launch at an elevation angle of 84° ±1°
1003-
DTEG 10.1.2:
1004-
> Range Safety Officers reserve the right to require certain vehicles’ launch elevation be
1005-
lower or higher if flight safety issues are identified during pre-launch activities
1006-
1007-
Teams have noted that they've been told to use angles at least as low as 80°. The Range Safety Officer picks the angle based on various factors, including the rocket being launched, the weather, and the location of the launch pad. In the design, simulation, and testing phases, use the nominal angle of 84°, but consider the possibility of the launch angle being more or less than that on competition day.
1008-
"""
1009-
1010-
Spaceport_America_avg_launch_conditions = LaunchConditions(
1011-
launchpad_pressure = launchpad_pressure_SAC,
1012-
launchpad_temp = launchpad_temp_SAC,
1013-
L_launch_rail = L_launch_rail_ESRA_provided_SAC,
1014-
launch_angle = launch_angle_SAC,
1015-
local_T_lapse_rate = T_lapse_rate_SA,
1016-
latitude = latitude_SA,
1017-
altitude = altitude_SA
1018-
)
938+
past_flights = [NDRT_2020_flight, Valetudo_flight, Juno3_flight, Bella_Lui_flight]

tests/test_flight_simulation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class TestAirbrakesFlightSimulation(unittest.TestCase):
3030
def test_airbrakes_flight_simulation(self):
3131
print("\n--------------------")
3232
print("Testing airbrakes flight simulation")
33-
from test_configs import Juno3_rocket, Juno3_launch_conditions, default_airbrakes_model
33+
from test_configs import Juno3_rocket, Juno3_launch_conditions
34+
from example_configurations import default_airbrakes_model
3435

3536
dataset, liftoff_index, launch_rail_cleared_index, burnout_index, apogee_index = simulate_flight(rocket=Juno3_rocket, launch_conditions=Juno3_launch_conditions, timestep=0.001)
3637
print(f"Burnout: \n\tHeight: {dataset['height'].iloc[burnout_index - 1]} m\n\tSpeed: {dataset['speed'].iloc[burnout_index - 1]} m/s\n\tTime: {dataset['time'].iloc[burnout_index - 1]} s\n")

0 commit comments

Comments
 (0)