-
-
Notifications
You must be signed in to change notification settings - Fork 251
Expand file tree
/
Copy pathflight_prints.py
More file actions
474 lines (422 loc) · 15 KB
/
flight_prints.py
File metadata and controls
474 lines (422 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
class _FlightPrints:
"""Class that holds prints methods for Flight class.
Attributes
----------
_FlightPrints.flight : Flight
Flight object that will be used for the prints.
"""
def __init__(
self,
flight,
):
"""Initializes _FlightPrints class
Parameters
----------
flight: Flight
Instance of the Flight class.
Returns
-------
None
"""
self.flight = flight
return None
def initial_conditions(self):
"""Prints all initial conditions data available about the Flight.
Returns
-------
None
"""
print("\nInitial Conditions\n")
# Post-process results
if self.flight.post_processed is False:
self.flight.post_process()
print(
"Position - x: {:.2f} m | y: {:.2f} m | z: {:.2f} m".format(
self.flight.x(0), self.flight.y(0), self.flight.z(0)
)
)
print(
"Velocity - Vx: {:.2f} m/s | Vy: {:.2f} m/s | Vz: {:.2f} m/s".format(
self.flight.vx(0), self.flight.vy(0), self.flight.vz(0)
)
)
print(
"Attitude - e0: {:.3f} | e1: {:.3f} | e2: {:.3f} | e3: {:.3f}".format(
self.flight.e0(0),
self.flight.e1(0),
self.flight.e2(0),
self.flight.e3(0),
)
)
print(
"Euler Angles - Spin φ : {:.2f}° | Nutation θ: {:.2f}° | Precession ψ: {:.2f}°".format(
self.flight.phi(0), self.flight.theta(0), self.flight.psi(0)
)
)
print(
"Angular Velocity - ω1: {:.2f} rad/s | ω2: {:.2f} rad/s| ω3: {:.2f} rad/s".format(
self.flight.w1(0), self.flight.w2(0), self.flight.w3(0)
)
)
return None
def numerical_integration_settings(self):
"""Prints out the Numerical Integration settings available about the
flight.
Returns
-------
None
"""
print("\nNumerical Integration Settings\n")
print("Maximum Allowed Flight Time: {:f} s".format(self.flight.max_time))
print("Maximum Allowed Time Step: {:f} s".format(self.flight.max_time_step))
print("Minimum Allowed Time Step: {:e} s".format(self.flight.min_time_step))
print("Relative Error Tolerance: ", self.flight.rtol)
print("Absolute Error Tolerance: ", self.flight.atol)
print("Allow Event Overshoot: ", self.flight.time_overshoot)
print("Terminate Simulation on Apogee: ", self.flight.terminate_on_apogee)
print("Number of Time Steps Used: ", len(self.flight.time_steps))
print(
"Number of Derivative Functions Evaluation: ",
sum(self.flight.function_evaluations_per_time_step),
)
print(
"Average Function Evaluations per Time Step: {:3f}".format(
sum(self.flight.function_evaluations_per_time_step)
/ len(self.flight.time_steps)
)
)
return None
def surface_wind_conditions(self):
"""Prints out the Surface Wind Conditions available about the flight.
Returns
-------
None
"""
if self.flight.post_processed is False:
self.flight.post_process()
print("\nSurface Wind Conditions\n")
print(
"Frontal Surface Wind Speed: {:.2f} m/s".format(
self.flight.frontal_surface_wind
)
)
print(
"Lateral Surface Wind Speed: {:.2f} m/s".format(
self.flight.lateral_surface_wind
)
)
return None
def launch_rail_conditions(self):
"""Prints out the Launch Rail Conditions available about the flight.
Returns
-------
None
"""
print("\nLaunch Rail\n")
print("Launch Rail Length:", self.flight.rail_length, " m")
print("Launch Rail Inclination: {:.2f}°".format(self.flight.inclination))
print("Launch Rail Heading: {:.2f}°".format(self.flight.heading))
return None
def out_of_rail_conditions(self):
"""Prints out the Out of Rail Conditions available about the flight.
Returns
-------
None
"""
if self.flight.post_processed is False:
self.flight.post_process()
print("\nRail Departure State\n")
print("Rail Departure Time: {:.3f} s".format(self.flight.out_of_rail_time))
print(
"Rail Departure Velocity: {:.3f} m/s".format(
self.flight.out_of_rail_velocity
)
)
print(
"Rail Departure Stability Margin: {:.3f} c".format(
self.flight.stability_margin(self.flight.out_of_rail_time)
)
)
print(
"Rail Departure Angle of Attack: {:.3f}°".format(
self.flight.angle_of_attack(self.flight.out_of_rail_time)
)
)
print(
"Rail Departure Thrust-Weight Ratio: {:.3f}".format(
self.flight.rocket.thrust_to_weight(self.flight.out_of_rail_time)
)
)
print(
"Rail Departure Reynolds Number: {:.3e}".format(
self.flight.reynolds_number(self.flight.out_of_rail_time)
)
)
return None
def burn_out_conditions(self):
"""Prints out the Burn Out Conditions available about the flight.
Returns
-------
None
"""
print("\nBurn out State\n")
print("Burn out time: {:.3f} s".format(self.flight.rocket.motor.burn_out_time))
print(
"Altitude at burn out: {:.3f} m (AGL)".format(
self.flight.z(self.flight.rocket.motor.burn_out_time)
- self.flight.env.elevation
)
)
print(
"Rocket velocity at burn out: {:.3f} m/s".format(
self.flight.speed(self.flight.rocket.motor.burn_out_time)
)
)
print(
"Freestream velocity at burn out: {:.3f} m/s".format(
(
self.flight.stream_velocity_x(
self.flight.rocket.motor.burn_out_time
)
** 2
+ self.flight.stream_velocity_y(
self.flight.rocket.motor.burn_out_time
)
** 2
+ self.flight.stream_velocity_z(
self.flight.rocket.motor.burn_out_time
)
** 2
)
** 0.5
)
)
print(
"Mach Number at burn out: {:.3f}".format(
self.flight.mach_number(self.flight.rocket.motor.burn_out_time)
)
)
print(
"Kinetic energy at burn out: {:.3e} J".format(
self.flight.kinetic_energy(self.flight.rocket.motor.burn_out_time)
)
)
return None
def apogee_conditions(self):
"""Prints out the Apogee Conditions available about the flight.
Returns
-------
None
"""
if self.flight.post_processed is False:
self.flight.post_process()
print("\nApogee State\n")
print(
"Apogee Altitude: {:.3f} m (ASL) | {:.3f} m (AGL)".format(
self.flight.apogee, self.flight.apogee - self.flight.env.elevation
)
)
print("Apogee Time: {:.3f} s".format(self.flight.apogee_time))
print(
"Apogee Freestream Speed: {:.3f} m/s".format(
self.flight.apogee_freestream_speed
)
)
return None
def events_registered(self):
"""Prints out the Events Registered available about the flight.
Returns
-------
None
"""
if self.flight.post_processed is False:
self.flight.post_process()
print("\nParachute Events\n")
if len(self.flight.parachute_events) == 0:
print("No Parachute Events Were Triggered.")
for event in self.flight.parachute_events:
trigger_time = event[0]
parachute = event[1]
open_time = trigger_time + parachute.lag
velocity = self.flight.free_stream_speed(open_time)
altitude = self.flight.z(open_time)
name = parachute.name.title()
print(name + " Ejection Triggered at: {:.3f} s".format(trigger_time))
print(name + " Parachute Inflated at: {:.3f} s".format(open_time))
print(
name
+ " Parachute Inflated with Freestream Speed of: {:.3f} m/s".format(
velocity
)
)
print(
name
+ " Parachute Inflated at Height of: {:.3f} m (AGL)".format(
altitude - self.flight.env.elevation
)
)
return None
def impact_conditions(self):
"""Prints out the Impact Conditions available about the flight.
Returns
-------
None
"""
if self.flight.post_processed is False:
self.flight.post_process()
if len(self.flight.impact_state) != 0:
print("\nImpact Conditions\n")
print("X Impact: {:.3f} m".format(self.flight.x_impact))
print("Y Impact: {:.3f} m".format(self.flight.y_impact))
print("Latitude: {:.7f}°".format(self.flight.latitude(self.flight.t_final)))
print(
"Longitude: {:.7f}°".format(self.flight.longitude(self.flight.t_final))
)
print("Time of Impact: {:.3f} s".format(self.flight.t_final))
print("Velocity at Impact: {:.3f} m/s".format(self.flight.impact_velocity))
elif self.flight.terminate_on_apogee is False:
print("End of Simulation")
t_final = self.flight.solution[-1][0]
print("Time: {:.3f} s".format(t_final))
print("Altitude: {:.3f} m".format(self.flight.solution[-1][3]))
print("Latitude: {:.3f}°".format(self.flight.latitude(t_final)))
print("Longitude: {:.3f}°".format(self.flight.longitude(t_final)))
return None
def maximum_values(self):
"""Prints out the Maximum Values available about the flight.
Returns
-------
None
"""
print("\nMaximum Values\n")
print(
"Maximum Speed: {:.3f} m/s at {:.2f} s".format(
self.flight.max_speed, self.flight.max_speed_time
)
)
print(
"Maximum Mach Number: {:.3f} Mach at {:.2f} s".format(
self.flight.max_mach_number, self.flight.max_mach_number_time
)
)
print(
"Maximum Reynolds Number: {:.3e} at {:.2f} s".format(
self.flight.max_reynolds_number, self.flight.max_reynolds_number_time
)
)
print(
"Maximum Dynamic Pressure: {:.3e} Pa at {:.2f} s".format(
self.flight.max_dynamic_pressure, self.flight.max_dynamic_pressure_time
)
)
print(
"Maximum Acceleration During Motor Burn: {:.3f} m/s² at {:.2f} s".format(
self.flight.max_acceleration_power_on,
self.flight.max_acceleration_power_on_time,
)
)
print(
"Maximum Gs During Motor Burn: {:.3f} g at {:.2f} s".format(
self.flight.max_acceleration_power_on / self.flight.env.standard_g,
self.flight.max_acceleration_power_on_time,
)
)
print(
"Maximum Acceleration After Motor Burn: {:.3f} m/s² at {:.2f} s".format(
self.flight.max_acceleration_power_off,
self.flight.max_acceleration_power_off_time,
)
)
print(
"Maximum Gs After Motor Burn: {:.3f} g at {:.2f} s".format(
self.flight.max_acceleration_power_off / self.flight.env.standard_g,
self.flight.max_acceleration_power_off_time,
)
)
print(
"Maximum Stability Margin: {:.3f} c at {:.2f} s".format(
self.flight.max_stability_margin, self.flight.max_stability_margin_time
)
)
if (
len(self.flight.rocket.rail_buttons) == 0
or self.flight.out_of_rail_time_index == 0
):
pass
else:
print(
"Maximum Upper Rail Button Normal Force: {:.3f} N".format(
self.flight.max_rail_button1_normal_force
)
)
print(
"Maximum Upper Rail Button Shear Force: {:.3f} N".format(
self.flight.max_rail_button1_shear_force
)
)
print(
"Maximum Lower Rail Button Normal Force: {:.3f} N".format(
self.flight.max_rail_button2_normal_force
)
)
print(
"Maximum Lower Rail Button Shear Force: {:.3f} N".format(
self.flight.max_rail_button2_shear_force
)
)
return None
def stability_margin(self):
"""Prints out the maximum and minimum stability margin available
about the flight."""
print("\nStability Margin\n")
print(
"Maximum Stability Margin: {:.3f} c at {:.2f} s".format(
self.flight.max_stability_margin, self.flight.max_stability_margin_time
)
)
print(
"Minimum Stability Margin: {:.3f} c at {:.2f} s".format(
self.flight.min_stability_margin, self.flight.min_stability_margin_time
)
)
return None
def all(self):
"""Prints out all data available about the Flight.
Returns
-------
None
"""
# Print initial conditions
self.initial_conditions()
print()
# Print surface wind conditions
self.surface_wind_conditions()
print()
# Print launch rail orientation
self.launch_rail_conditions()
print()
# Print out of rail conditions
self.out_of_rail_conditions()
print()
# Print burn out conditions
self.burn_out_conditions()
print()
# Print apogee conditions
self.apogee_conditions()
print()
# Print events registered
self.events_registered()
print()
# Print impact conditions
self.impact_conditions()
print()
# Print stability margin
self.stability_margin()
print()
# Print maximum values
self.maximum_values()
print()
# Print Numerical Integration Information
self.numerical_integration_settings()
print()
return None