/
test_Stopped_Rotor.py
415 lines (330 loc) · 18.1 KB
/
test_Stopped_Rotor.py
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
# test_Stopped_Rotor.py
#
# Created: Feb 2020, M. Clarke
# Sep 2020, M. Clarke
# Jul 2021, R. Erhard
# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------
import SUAVE
from SUAVE.Core import Units , Data
from SUAVE.Plots.Performance.Mission_Plots import *
from SUAVE.Methods.Performance.estimate_stall_speed import estimate_stall_speed
from SUAVE.Plots.Geometry import *
import sys
import numpy as np
sys.path.append('../Vehicles')
# the analysis functions
from Stopped_Rotor import vehicle_setup, configs_setup
# ----------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------
def main():
# ------------------------------------------------------------------------------------------------------------------
# Stopped-Rotor
# ------------------------------------------------------------------------------------------------------------------
# build the vehicle, configs, and analyses
configs, analyses = full_setup()
configs.finalize()
analyses.finalize()
# Print weight properties of vehicle
weights = configs.base.weight_breakdown
print(weights)
print(configs.base.mass_properties.center_of_gravity)
# check weights
empty_r = 1013.0718119599941
structural_r = 330.4958877631757
total_r = 1213.0718119599942
lift_rotors_r = 16.445392185186808
propellers_r = 3.2944573008378044
prop_motors_r = 2.0
rot_motors_r = 36.0
weights_error = Data()
weights_error.empty = abs(empty_r - weights.empty)/empty_r
weights_error.structural = abs(structural_r - weights.structural)/structural_r
weights_error.total = abs(total_r - weights.total)/total_r
weights_error.lift_rotors = abs(lift_rotors_r - weights.lift_rotors)/lift_rotors_r
weights_error.propellers = abs(propellers_r - weights.propellers)/propellers_r
weights_error.propellers = abs(prop_motors_r - weights.propeller_motors)/prop_motors_r
weights_error.propellers = abs(rot_motors_r - weights.lift_rotor_motors)/rot_motors_r
for k, v in weights_error.items():
assert (np.abs(v) < 1E-6)
# evaluate mission
mission = analyses.missions.base
results = mission.evaluate()
# plot results
plot_mission(results,configs.base)
# save, load and plot old results
#save_stopped_rotor_results(results)
old_results = load_stopped_rotor_results()
plot_mission(old_results,configs.base, 'k-')
# RPM of rotor check during hover
RPM = results.segments.climb_1.conditions.propulsion.lift_rotor_rpm[0][0]
RPM_true = 2403.004214209376
print(RPM)
diff_RPM = np.abs(RPM - RPM_true)
print('RPM difference')
print(diff_RPM)
assert np.abs((RPM - RPM_true)/RPM_true) < 1e-3
# Battery Energy Check During Transition
battery_energy_hover_to_transition = results.segments.transition_1.conditions.propulsion.battery_energy[:,0]
battery_energy_hover_to_transition_true = np.array([3.36372833e+08, 3.34188971e+08, 3.32108816e+08])
print(battery_energy_hover_to_transition)
diff_battery_energy_hover_to_transition = np.abs(battery_energy_hover_to_transition - battery_energy_hover_to_transition_true)
print('battery_energy_hover_to_transition difference')
print(diff_battery_energy_hover_to_transition)
assert all(np.abs((battery_energy_hover_to_transition - battery_energy_hover_to_transition_true)/battery_energy_hover_to_transition) < 1e-3)
# lift Coefficient Check During Cruise
lift_coefficient = results.segments.departure_terminal_procedures.conditions.aerodynamics.lift_coefficient[0][0]
lift_coefficient_true = 0.8281462046145501
print(lift_coefficient)
diff_CL = np.abs(lift_coefficient - lift_coefficient_true)
print('CL difference')
print(diff_CL)
assert np.abs((lift_coefficient - lift_coefficient_true)/lift_coefficient_true) < 1e-3
return
# ----------------------------------------------------------------------
# Analysis Setup
# ----------------------------------------------------------------------
def full_setup():
# vehicle data
vehicle = vehicle_setup()
configs = configs_setup(vehicle)
plot_vehicle(vehicle,plot_control_points = False)
# vehicle analyses
configs_analyses = analyses_setup(configs)
# mission analyses
mission = mission_setup(configs_analyses,vehicle)
missions_analyses = missions_setup(mission)
analyses = SUAVE.Analyses.Analysis.Container()
analyses.configs = configs_analyses
analyses.missions = missions_analyses
return configs, analyses
# ----------------------------------------------------------------------
# Define the Vehicle Analyses
# ----------------------------------------------------------------------
def analyses_setup(configs):
analyses = SUAVE.Analyses.Analysis.Container()
# build a base analysis for each config
for tag,config in configs.items():
analysis = base_analysis(config)
analyses[tag] = analysis
return analyses
def base_analysis(vehicle):
# ------------------------------------------------------------------
# Initialize the Analyses
# ------------------------------------------------------------------
analyses = SUAVE.Analyses.Vehicle()
# ------------------------------------------------------------------
# Basic Geometry Relations
sizing = SUAVE.Analyses.Sizing.Sizing()
sizing.features.vehicle = vehicle
analyses.append(sizing)
# ------------------------------------------------------------------
# Weights
weights = SUAVE.Analyses.Weights.Weights_eVTOL()
weights.vehicle = vehicle
analyses.append(weights)
# ------------------------------------------------------------------
# Aerodynamics Analysis
aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
aerodynamics.geometry = vehicle
aerodynamics.settings.drag_coefficient_increment = 0.4*vehicle.excrescence_area_spin / vehicle.reference_area
analyses.append(aerodynamics)
# ------------------------------------------------------------------
# Energy
energy= SUAVE.Analyses.Energy.Energy()
energy.network = vehicle.networks
analyses.append(energy)
# ------------------------------------------------------------------
# Noise Analysis
noise = SUAVE.Analyses.Noise.Fidelity_One()
noise.settings.level_ground_microphone_x_resolution = 2
noise.settings.level_ground_microphone_y_resolution = 2
noise.geometry = vehicle
analyses.append(noise)
# ------------------------------------------------------------------
# Planet Analysis
planet = SUAVE.Analyses.Planets.Planet()
analyses.append(planet)
# ------------------------------------------------------------------
# Atmosphere Analysis
atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976()
atmosphere.features.planet = planet.features
analyses.append(atmosphere)
return analyses
def mission_setup(analyses,vehicle):
# ------------------------------------------------------------------
# Initialize the Mission
# ------------------------------------------------------------------
mission = SUAVE.Analyses.Mission.Sequential_Segments()
mission.tag = 'the_mission'
# airport
airport = SUAVE.Attributes.Airports.Airport()
airport.altitude = 0.0 * Units.ft
airport.delta_isa = 0.0
airport.atmosphere = SUAVE.Attributes.Atmospheres.Earth.US_Standard_1976()
mission.airport = airport
# unpack Segments module
Segments = SUAVE.Analyses.Mission.Segments
# base segment
base_segment = Segments.Segment()
base_segment.state.numerics.number_control_points = 3
base_segment.process.initialize.initialize_battery = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery
base_segment.process.iterate.conditions.planet_position = SUAVE.Methods.skip
# VSTALL Calculation
vehicle_mass = vehicle.mass_properties.max_takeoff
reference_area = vehicle.reference_area
altitude = 0.0
CL_max = 1.2
Vstall = estimate_stall_speed(vehicle_mass,reference_area,altitude,CL_max)
# ------------------------------------------------------------------
# First Climb Segment: Constant Speed, Constant Rate
# ------------------------------------------------------------------
segment = Segments.Hover.Climb(base_segment)
segment.tag = "climb_1"
segment.analyses.extend( analyses.base )
segment.altitude_start = 0.0 * Units.ft
segment.altitude_end = 40. * Units.ft
segment.climb_rate = 500. * Units['ft/min']
segment.battery_energy = vehicle.networks.lift_cruise.battery.max_energy
segment.process.iterate.unknowns.mission = SUAVE.Methods.skip
segment.process.iterate.conditions.stability = SUAVE.Methods.skip
segment.process.finalize.post_process.stability = SUAVE.Methods.skip
segment = vehicle.networks.lift_cruise.add_lift_unknowns_and_residuals_to_segment(segment,\
initial_lift_rotor_power_coefficient = 0.01,
initial_throttle_lift = 0.9)
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# First Cruise Segment: Transition
# ------------------------------------------------------------------
segment = Segments.Transition.Constant_Acceleration_Constant_Pitchrate_Constant_Altitude(base_segment)
segment.tag = "transition_1"
segment.analyses.extend( analyses.base )
segment.altitude = 40. * Units.ft
segment.air_speed_start = 500. * Units['ft/min']
segment.air_speed_end = 0.8 * Vstall
segment.acceleration = 9.8/5
segment.pitch_initial = 0.0 * Units.degrees
segment.pitch_final = 5. * Units.degrees
ones_row = segment.state.ones_row
segment.state.unknowns.throttle = 1. * ones_row(1)
segment.process.iterate.unknowns.mission = SUAVE.Methods.skip
segment.process.iterate.conditions.stability = SUAVE.Methods.skip
segment.process.finalize.post_process.stability = SUAVE.Methods.skip
segment = vehicle.networks.lift_cruise.add_transition_unknowns_and_residuals_to_segment(segment,
initial_throttle_lift = 0.9,)
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# First Cruise Segment: Transition
# ------------------------------------------------------------------
segment = Segments.Transition.Constant_Acceleration_Constant_Angle_Linear_Climb(base_segment)
segment.tag = "transition_2"
segment.analyses.extend( analyses.base )
segment.altitude_start = 40.0 * Units.ft
segment.altitude_end = 50.0 * Units.ft
segment.climb_angle = 1 * Units.degrees
segment.acceleration = 0.5 * Units['m/s/s']
segment.pitch_initial = 5. * Units.degrees
segment.pitch_final = 7. * Units.degrees
segment.state.unknowns.throttle = 0.95 * ones_row(1)
segment.process.iterate.unknowns.mission = SUAVE.Methods.skip
segment.process.iterate.conditions.stability = SUAVE.Methods.skip
segment.process.finalize.post_process.stability = SUAVE.Methods.skip
segment = vehicle.networks.lift_cruise.add_transition_unknowns_and_residuals_to_segment(segment,
initial_prop_power_coefficient = 0.2,
initial_lift_rotor_power_coefficient = 0.01,
initial_throttle_lift = 0.9,)
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# Second Climb Segment: Constant Speed, Constant Rate
# ------------------------------------------------------------------
segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "climb_2"
segment.analyses.extend( analyses.base )
segment.air_speed = 1.1*Vstall
segment.altitude_start = 50.0 * Units.ft
segment.altitude_end = 300. * Units.ft
segment.climb_rate = 500. * Units['ft/min']
segment.state.unknowns.throttle = 0.80 * ones_row(1)
segment = vehicle.networks.lift_cruise.add_cruise_unknowns_and_residuals_to_segment(segment)
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# Second Cruise Segment: Constant Speed, Constant Altitude
# ------------------------------------------------------------------
segment = Segments.Cruise.Constant_Speed_Constant_Altitude_Loiter(base_segment)
segment.tag = "departure_terminal_procedures"
segment.analyses.extend( analyses.base )
segment.altitude = 300.0 * Units.ft
segment.time = 60. * Units.second
segment.air_speed = 1.2*Vstall
segment.state.unknowns.throttle = 0.80 * ones_row(1)
segment = vehicle.networks.lift_cruise.add_cruise_unknowns_and_residuals_to_segment(segment,\
initial_prop_power_coefficient = 0.16)
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# Third Climb Segment: Constant Acceleration, Constant Rate
# ------------------------------------------------------------------
segment = Segments.Climb.Linear_Speed_Constant_Rate(base_segment)
segment.tag = "climb_2"
segment.analyses.extend( analyses.base)
segment.altitude_start = 300.0 * Units.ft
segment.altitude_end = 1000. * Units.ft
segment.climb_rate = 500. * Units['ft/min']
segment.air_speed_start = 1.2*Vstall
segment.air_speed_end = 110. * Units['mph']
segment.state.unknowns.throttle = 0.90 * ones_row(1)
segment = vehicle.networks.lift_cruise.add_cruise_unknowns_and_residuals_to_segment(segment)
mission.append_segment(segment)
# ------------------------------------------------------------------
# Cruise Segment: constant speed, constant altitude
# ------------------------------------------------------------------
segment = Segments.Cruise.Constant_Speed_Constant_Altitude(base_segment)
segment.tag = "cruise"
segment.analyses.extend( analyses.base )
segment.altitude = 1000.0 * Units.ft
segment.air_speed = 110. * Units['mph']
segment.distance = 50. * Units.miles
segment.state.unknowns.throttle = 0.60 * ones_row(1)
segment = vehicle.networks.lift_cruise.add_cruise_unknowns_and_residuals_to_segment(segment)
mission.append_segment(segment)
return mission
def missions_setup(base_mission):
# the mission container
missions = SUAVE.Analyses.Mission.Mission.Container()
# ------------------------------------------------------------------
# Base Mission
# ------------------------------------------------------------------
missions.base = base_mission
# done!
return missions
# ----------------------------------------------------------------------
# Plot Results
# ----------------------------------------------------------------------
def plot_mission(results,vec_configs,line_style='bo-'):
# Plot Flight Conditions
plot_flight_conditions(results, line_style)
# Plot Aerodynamic Coefficients
plot_aerodynamic_coefficients(results, line_style)
# Plot Aircraft Flight Speed
plot_aircraft_velocities(results, line_style)
# Plot Aircraft Electronics
plot_battery_pack_conditions(results, line_style)
# Plot Electric Motor and Propeller Efficiencies of Lift Cruise Network
plot_lift_cruise_network(results, line_style)
return
def load_stopped_rotor_results():
return SUAVE.Input_Output.SUAVE.load('results_stopped_rotor.res')
def save_stopped_rotor_results(results):
for segment in results.segments.values():
del segment.conditions.noise
SUAVE.Input_Output.SUAVE.archive(results,'results_stopped_rotor.res')
return
if __name__ == '__main__':
main()
plt.show(block=True)