forked from suavecode/Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut_payload_range.py
974 lines (692 loc) · 31.9 KB
/
tut_payload_range.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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
# tut_payload_range.py
#
# Created: Aug 2014, SUAVE Team
# Modified: Apr 2016, T. Orra
# ----------------------------------------------------------------------
# Imports
# ----------------------------------------------------------------------
import SUAVE
from SUAVE.Core import Units
import numpy as np
import pylab as plt
import copy, time
from SUAVE.Core import (
Data, Container,
)
from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
from SUAVE.Methods.Performance import payload_range
# ----------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------
def main():
# define the problem
configs, analyses = full_setup()
configs.finalize()
analyses.finalize()
# weight analysis
weights = analyses.configs.base.weights
breakdown = weights.evaluate()
# mission analysis
mission = analyses.missions
results = mission.evaluate()
# run payload diagram
config = configs.base
cruise_segment_tag = "cruise"
reserves = 1750.
payload_range_results = payload_range(config,mission,cruise_segment_tag,reserves)
# plot the results
plot_mission(results)
return
# ----------------------------------------------------------------------
# Analysis Setup
# ----------------------------------------------------------------------
def full_setup():
# vehicle data
vehicle = vehicle_setup()
configs = configs_setup(vehicle)
# vehicle analyses
configs_analyses = analyses_setup(configs)
# mission analyses
mission = mission_setup(configs_analyses)
analyses = SUAVE.Analyses.Analysis.Container()
analyses.configs = configs_analyses
analyses.missions = mission
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
# adjust analyses for configs
# takeoff_analysis
analyses.takeoff.aerodynamics.drag_coefficient_increment = 0.1000
# landing analysis
aerodynamics = analyses.landing.aerodynamics
# do something here eventually
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()
weights.vehicle = vehicle
analyses.append(weights)
# ------------------------------------------------------------------
# Aerodynamics Analysis
aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
aerodynamics.geometry = vehicle
aerodynamics.settings.drag_coefficient_increment = 0.0050
analyses.append(aerodynamics)
# ------------------------------------------------------------------
# Stability Analysis
stability = SUAVE.Analyses.Stability.Fidelity_Zero()
stability.geometry = vehicle
analyses.append(stability)
# ------------------------------------------------------------------
# Propulsion Analysis
energy= SUAVE.Analyses.Energy.Energy()
energy.network = vehicle.propulsors #what is called throughout the mission (at every time step))
analyses.append(energy)
# ------------------------------------------------------------------
# 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)
# done!
return analyses
# ----------------------------------------------------------------------
# Define the Vehicle
# ----------------------------------------------------------------------
def vehicle_setup():
# ------------------------------------------------------------------
# Initialize the Vehicle
# ------------------------------------------------------------------
vehicle = SUAVE.Vehicle()
vehicle.tag = 'Embraer_E190'
# ------------------------------------------------------------------
# Vehicle-level Properties
# ------------------------------------------------------------------
# mass properties
vehicle.mass_properties.max_takeoff = 51800.0 # kg
vehicle.mass_properties.operating_empty = 29100.0 # kg
vehicle.mass_properties.takeoff = 51800.0 # kg
vehicle.mass_properties.max_zero_fuel = 45600.0 # kg
vehicle.mass_properties.cargo = 0.0 * Units.kg
vehicle.mass_properties.max_payload = 11786. * Units.kg
vehicle.mass_properties.max_fuel = 12970.
# envelope properties
vehicle.envelope.ultimate_load = 3.5
vehicle.envelope.limit_load = 1.5
# basic parameters
vehicle.reference_area = 92.00
vehicle.passengers = 114
vehicle.systems.control = "fully powered"
vehicle.systems.accessories = "medium range"
# ------------------------------------------------------------------
# Main Wing
# ------------------------------------------------------------------
wing = SUAVE.Components.Wings.Wing()
wing.tag = 'main_wing'
wing.aspect_ratio = 8.4
wing.sweeps.quarter_chord = 22.0 * Units.deg
wing.thickness_to_chord = 0.11
wing.taper = 0.16
wing.span_efficiency = 1.0
wing.spans.projected = 27.8
wing.chords.root = 5.7057
wing.chords.tip = 0.9129
wing.chords.mean_aerodynamic = 3.8878
wing.areas.reference = 92.0
wing.areas.wetted = 2.0 * wing.areas.reference
wing.areas.exposed = 0.8 * wing.areas.wetted
wing.areas.affected = 0.6 * wing.areas.wetted
wing.twists.root = 2.0 * Units.degrees
wing.twists.tip = 0.0 * Units.degrees
wing.origin = [20,0,0]
wing.aerodynamic_center = [3,0,0]
wing.vertical = False
wing.symmetric = True
wing.dynamic_pressure_ratio = 1.0
# add to vehicle
vehicle.append_component(wing)
# ------------------------------------------------------------------
# Horizontal Stabilizer
# ------------------------------------------------------------------
wing = SUAVE.Components.Wings.Wing()
wing.tag = 'horizontal_stabilizer'
wing.aspect_ratio = 5.5
wing.sweeps.quarter_chord = 34.5 * Units.deg
wing.thickness_to_chord = 0.11
wing.taper = 0.11
wing.span_efficiency = 0.9
wing.spans.projected = 11.958
wing.chords.root = 3.9175
wing.chords.tip = 0.4309
wing.chords.mean_aerodynamic = 2.6401
wing.areas.reference = 26.0
wing.areas.wetted = 2.0 * wing.areas.reference
wing.areas.exposed = 0.8 * wing.areas.wetted
wing.areas.affected = 0.6 * wing.areas.wetted
wing.twists.root = 2.0 * Units.degrees
wing.twists.tip = 2.0 * Units.degrees
wing.origin = [50,0,0]
wing.aerodynamic_center = [2,0,0]
wing.vertical = False
wing.symmetric = True
wing.dynamic_pressure_ratio = 0.9
# add to vehicle
vehicle.append_component(wing)
# ------------------------------------------------------------------
# Vertical Stabilizer
# ------------------------------------------------------------------
wing = SUAVE.Components.Wings.Wing()
wing.tag = 'vertical_stabilizer'
wing.aspect_ratio = 1.7 #
wing.sweeps.quarter_chord = 25 * Units.deg
wing.thickness_to_chord = 0.12
wing.taper = 0.10
wing.span_efficiency = 0.9
wing.spans.projected = 5.2153 #
wing.chords.root = 5.5779
wing.chords.tip = 0.5577
wing.chords.mean_aerodynamic = 3.7524
wing.areas.reference = 16.0 #
wing.areas.wetted = 2.0 * wing.areas.reference
wing.areas.exposed = 0.8 * wing.areas.wetted
wing.areas.affected = 0.6 * wing.areas.wetted
wing.twists.root = 0.0 * Units.degrees
wing.twists.tip = 0.0 * Units.degrees
wing.origin = [50,0,0]
wing.aerodynamic_center = [2,0,0]
wing.vertical = True
wing.symmetric = False
wing.dynamic_pressure_ratio = 1.0
# add to vehicle
vehicle.append_component(wing)
# ------------------------------------------------------------------
# Fuselage
# ------------------------------------------------------------------
fuselage = SUAVE.Components.Fuselages.Fuselage()
fuselage.tag = 'fuselage'
fuselage.number_coach_seats = vehicle.passengers
fuselage.seats_abreast = 4
fuselage.seat_pitch = 0.7455
fuselage.fineness.nose = 2.0
fuselage.fineness.tail = 3.0
fuselage.lengths.nose = 6.0
fuselage.lengths.tail = 9.0
fuselage.lengths.cabin = 21.24
fuselage.lengths.total = 36.24
fuselage.lengths.fore_space = 0.
fuselage.lengths.aft_space = 0.
fuselage.width = 3.0
fuselage.heights.maximum = 3.4
fuselage.heights.at_quarter_length = 3.4
fuselage.heights.at_three_quarters_length = 3.4
fuselage.heights.at_wing_root_quarter_chord = 3.4
fuselage.areas.side_projected = 239.20
fuselage.areas.wetted = 327.01
fuselage.areas.front_projected = 8.0110
fuselage.effective_diameter = 3.2
fuselage.differential_pressure = 10**5 * Units.pascal # Maximum differential pressure
# add to vehicle
vehicle.append_component(fuselage)
# ------------------------------------------------------------------
# Turbofan Network
# ------------------------------------------------------------------
#initialize the gas turbine network
gt_engine = SUAVE.Components.Energy.Networks.Turbofan()
gt_engine.tag = 'turbofan'
gt_engine.number_of_engines = 2.0
gt_engine.bypass_ratio = 5.4
gt_engine.engine_length = 2.71
gt_engine.nacelle_diameter = 2.05
#set the working fluid for the network
working_fluid = SUAVE.Attributes.Gases.Air
#add working fluid to the network
gt_engine.working_fluid = working_fluid
#Component 1 : ram, to convert freestream static to stagnation quantities
ram = SUAVE.Components.Energy.Converters.Ram()
ram.tag = 'ram'
#add ram to the network
gt_engine.ram = ram
#Component 2 : inlet nozzle
inlet_nozzle = SUAVE.Components.Energy.Converters.Compression_Nozzle()
inlet_nozzle.tag = 'inlet nozzle'
inlet_nozzle.polytropic_efficiency = 0.98
inlet_nozzle.pressure_ratio = 0.99
#add inlet nozzle to the network
gt_engine.inlet_nozzle = inlet_nozzle
#Component 3 :low pressure compressor
low_pressure_compressor = SUAVE.Components.Energy.Converters.Compressor()
low_pressure_compressor.tag = 'lpc'
low_pressure_compressor.polytropic_efficiency = 0.91
low_pressure_compressor.pressure_ratio = 1.9
#add low pressure compressor to the network
gt_engine.low_pressure_compressor = low_pressure_compressor
#Component 4 :high pressure compressor
high_pressure_compressor = SUAVE.Components.Energy.Converters.Compressor()
high_pressure_compressor.tag = 'hpc'
high_pressure_compressor.polytropic_efficiency = 0.91
high_pressure_compressor.pressure_ratio = 10.0
#add the high pressure compressor to the network
gt_engine.high_pressure_compressor = high_pressure_compressor
#Component 5 :low pressure turbine
low_pressure_turbine = SUAVE.Components.Energy.Converters.Turbine()
low_pressure_turbine.tag='lpt'
low_pressure_turbine.mechanical_efficiency = 0.99
low_pressure_turbine.polytropic_efficiency = 0.99
#add low pressure turbine to the network
gt_engine.low_pressure_turbine = low_pressure_turbine
#Component 5 :high pressure turbine
high_pressure_turbine = SUAVE.Components.Energy.Converters.Turbine()
high_pressure_turbine.tag='hpt'
high_pressure_turbine.mechanical_efficiency = 0.99
high_pressure_turbine.polytropic_efficiency = 0.99
#add the high pressure turbine to the network
gt_engine.high_pressure_turbine = high_pressure_turbine
#Component 6 :combustor
combustor = SUAVE.Components.Energy.Converters.Combustor()
combustor.tag = 'Comb'
combustor.efficiency = 0.99
combustor.alphac = 1.0
combustor.turbine_inlet_temperature = 1500
combustor.pressure_ratio = 0.95
combustor.fuel_data = SUAVE.Attributes.Propellants.Jet_A()
#add the combustor to the network
gt_engine.combustor = combustor
#Component 7 :core nozzle
core_nozzle = SUAVE.Components.Energy.Converters.Expansion_Nozzle()
core_nozzle.tag = 'core nozzle'
core_nozzle.polytropic_efficiency = 0.95
core_nozzle.pressure_ratio = 0.99
#add the core nozzle to the network
gt_engine.core_nozzle = core_nozzle
#Component 8 :fan nozzle
fan_nozzle = SUAVE.Components.Energy.Converters.Expansion_Nozzle()
fan_nozzle.tag = 'fan nozzle'
fan_nozzle.polytropic_efficiency = 0.95
fan_nozzle.pressure_ratio = 0.98
#add the fan nozzle to the network
gt_engine.fan_nozzle = fan_nozzle
#Component 9 : fan
fan = SUAVE.Components.Energy.Converters.Fan()
fan.tag = 'fan'
fan.polytropic_efficiency = 0.93
fan.pressure_ratio = 1.7
#add the fan to the network
gt_engine.fan = fan
#Component 10 : thrust (to compute the thrust)
thrust = SUAVE.Components.Energy.Processes.Thrust()
thrust.tag ='compute_thrust'
#total design thrust (includes all the engines)
thrust.total_design = 37278.0* Units.N #Newtons
#design sizing conditions
altitude = 35000.0*Units.ft
mach_number = 0.78
isa_deviation = 0.
# add thrust to the network
gt_engine.thrust = thrust
#size the turbofan
turbofan_sizing(gt_engine,mach_number,altitude)
# add gas turbine network gt_engine to the vehicle
vehicle.append_component(gt_engine)
# ------------------------------------------------------------------
# Vehicle Definition Complete
# ------------------------------------------------------------------
return vehicle
# ----------------------------------------------------------------------
# Define the Configurations
# ---------------------------------------------------------------------
def configs_setup(vehicle):
# ------------------------------------------------------------------
# Initialize Configurations
# ------------------------------------------------------------------
configs = SUAVE.Components.Configs.Config.Container()
base_config = SUAVE.Components.Configs.Config(vehicle)
base_config.tag = 'base'
configs.append(base_config)
# ------------------------------------------------------------------
# Cruise Configuration
# ------------------------------------------------------------------
config = SUAVE.Components.Configs.Config(base_config)
config.tag = 'cruise'
configs.append(config)
# ------------------------------------------------------------------
# Takeoff Configuration
# ------------------------------------------------------------------
config = SUAVE.Components.Configs.Config(base_config)
config.tag = 'takeoff'
config.wings['main_wing'].flaps.angle = 20. * Units.deg
config.wings['main_wing'].slats.angle = 25. * Units.deg
config.V2_VS_ratio = 1.21
config.maximum_lift_coefficient = 2.
configs.append(config)
# ------------------------------------------------------------------
# Landing Configuration
# ------------------------------------------------------------------
config = SUAVE.Components.Configs.Config(base_config)
config.tag = 'landing'
config.wings['main_wing'].flaps_angle = 30. * Units.deg
config.wings['main_wing'].slats_angle = 25. * Units.deg
config.Vref_VS_ratio = 1.23
config.maximum_lift_coefficient = 2.
configs.append(config)
# done!
return configs
# ----------------------------------------------------------------------
# Define the Mission
# ----------------------------------------------------------------------
def mission_setup(analyses):
# ------------------------------------------------------------------
# Initialize the Mission
# ------------------------------------------------------------------
mission = SUAVE.Analyses.Mission.Sequential_Segments()
mission.tag = 'embraer_e190ar test mission'
# atmospheric model
atmosphere = SUAVE.Attributes.Atmospheres.Earth.US_Standard_1976()
planet = SUAVE.Attributes.Planets.Earth()
#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()
# ------------------------------------------------------------------
# First Climb Segment: constant Mach, constant segment angle
# ------------------------------------------------------------------
segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "climb_1"
# connect vehicle configuration
segment.analyses.extend( analyses.takeoff )
# define segment attributes
segment.altitude_start = 0.0 * Units.km
segment.altitude_end = 3.0 * Units.km
segment.air_speed = 125.0 * Units['m/s']
segment.climb_rate = 6.0 * Units['m/s']
# add to misison
mission.append_segment(segment)
# ------------------------------------------------------------------
# Second Climb Segment: constant Speed, constant segment angle
# ------------------------------------------------------------------
segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "climb_2"
# connect vehicle configuration
segment.analyses.extend( analyses.cruise )
# segment attributes
segment.altitude_end = 8.0 * Units.km
segment.air_speed = 190.0 * Units['m/s']
segment.climb_rate = 6.0 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Third Climb Segment: constant Mach, constant segment angle
# ------------------------------------------------------------------
segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "climb_3"
# connect vehicle configuration
segment.analyses.extend( analyses.cruise )
# segment attributes
segment.altitude_end = 10.668 * Units.km
segment.air_speed = 226.0 * Units['m/s']
segment.climb_rate = 3.0 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Cruise Segment: constant speed, constant altitude
# ------------------------------------------------------------------
segment = Segments.Cruise.Constant_Speed_Constant_Altitude(base_segment)
segment.tag = "cruise"
# connect vehicle configuration
segment.analyses.extend( analyses.cruise )
# segment attributes
segment.atmosphere = atmosphere
segment.planet = planet
segment.air_speed = 447. * Units.knots #230. * Units['m/s']
## 35kft:
# 415. => M = 0.72
# 450. => M = 0.78
# 461. => M = 0.80
## 37kft:
# 447. => M = 0.78
segment.distance = 2100. * Units.nmi
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# First Descent Segment: consant speed, constant segment rate
# ------------------------------------------------------------------
segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "descent_1"
# connect vehicle configuration
segment.analyses.extend( analyses.cruise )
# segment attributes
segment.altitude_end = 8.0 * Units.km
segment.air_speed = 220.0 * Units['m/s']
segment.descent_rate = 4.5 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Second Descent Segment: consant speed, constant segment rate
# ------------------------------------------------------------------
segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "descent_2"
# connect vehicle configuration
segment.analyses.extend( analyses.landing )
analyses.landing.aerodynamics.settings.spoiler_drag_increment = 0.00
# segment attributes
segment.altitude_end = 6.0 * Units.km
segment.air_speed = 195.0 * Units['m/s']
segment.descent_rate = 5.0 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Third Descent Segment: consant speed, constant segment rate
# ------------------------------------------------------------------
segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "descent_3"
# connect vehicle configuration
segment.analyses.extend( analyses.landing )
analyses.landing.aerodynamics.settings.spoiler_drag_increment = 0.00
# segment attributes
segment.altitude_end = 4.0 * Units.km
segment.air_speed = 170.0 * Units['m/s']
segment.descent_rate = 5.0 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Fourth Descent Segment: consant speed, constant segment rate
# ------------------------------------------------------------------
segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "descent_4"
segment.analyses.extend( analyses.landing )
analyses.landing.aerodynamics.settings.spoiler_drag_increment = 0.00
segment.altitude_end = 2.0 * Units.km
segment.air_speed = 150.0 * Units['m/s']
segment.descent_rate = 5.0 * Units['m/s']
# add to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Fifth Descent Segment: consant speed, constant segment rate
# ------------------------------------------------------------------
segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment)
segment.tag = "descent_5"
segment.analyses.extend( analyses.landing )
analyses.landing.aerodynamics.settings.spoiler_drag_increment = 0.00
segment.altitude_end = 0.0 * Units.km
segment.air_speed = 145.0 * Units['m/s']
segment.descent_rate = 3.0 * Units['m/s']
# append to mission
mission.append_segment(segment)
# ------------------------------------------------------------------
# Mission definition complete
# ------------------------------------------------------------------
return mission
#: def define_mission()
# ----------------------------------------------------------------------
# Plot Mission
# ----------------------------------------------------------------------
def plot_mission(results,line_style='bo-'):
# ------------------------------------------------------------------
# Throttle
# ------------------------------------------------------------------
plt.figure("Throttle History")
axes = plt.gca()
for i in range(len(results.segments)):
time = results.segments[i].conditions.frames.inertial.time[:,0] / Units.min
eta = results.segments[i].conditions.propulsion.throttle[:,0]
axes.plot(time, eta, line_style)
axes.set_xlabel('Time (mins)')
axes.set_ylabel('Throttle')
axes.grid(True)
# ------------------------------------------------------------------
# Angle of Attack
# ------------------------------------------------------------------
plt.figure("Angle of Attack History")
axes = plt.gca()
for i in range(len(results.segments)):
time = results.segments[i].conditions.frames.inertial.time[:,0] / Units.min
aoa = results.segments[i].conditions.aerodynamics.angle_of_attack[:,0] / Units.deg
axes.plot(time, aoa, line_style)
axes.set_xlabel('Time (mins)')
axes.set_ylabel('Angle of Attack (deg)')
axes.grid(True)
# ------------------------------------------------------------------
# Fuel Burn Rate
# ------------------------------------------------------------------
plt.figure("Fuel Burn Rate")
axes = plt.gca()
for i in range(len(results.segments)):
time = results.segments[i].conditions.frames.inertial.time[:,0] / Units.min
mdot = results.segments[i].conditions.weights.vehicle_mass_rate[:,0]
axes.plot(time, mdot, line_style)
axes.set_xlabel('Time (mins)')
axes.set_ylabel('Fuel Burn Rate (kg/s)')
axes.grid(True)
# ------------------------------------------------------------------
# Altitude
# ------------------------------------------------------------------
plt.figure("Altitude")
axes = plt.gca()
for i in range(len(results.segments)):
time = results.segments[i].conditions.frames.inertial.time[:,0] / Units.min
altitude = results.segments[i].conditions.freestream.altitude[:,0] / Units.km
axes.plot(time, altitude, line_style)
axes.set_xlabel('Time (mins)')
axes.set_ylabel('Altitude (km)')
axes.grid(True)
# ------------------------------------------------------------------
# Vehicle Mass
# ------------------------------------------------------------------
plt.figure("Vehicle Mass")
axes = plt.gca()
for i in range(len(results.segments)):
time = results.segments[i].conditions.frames.inertial.time[:,0] / Units.min
mass = results.segments[i].conditions.weights.total_mass[:,0]
axes.plot(time, mass, line_style)
axes.set_xlabel('Time (mins)')
axes.set_ylabel('Vehicle Mass (kg)')
axes.grid(True)
# ------------------------------------------------------------------
# Aerodynamics
# ------------------------------------------------------------------
fig = plt.figure("Aerodynamic Forces")
for segment in results.segments.values():
time = segment.conditions.frames.inertial.time[:,0] / Units.min
Lift = -segment.conditions.frames.wind.lift_force_vector[:,2]
Drag = -segment.conditions.frames.wind.drag_force_vector[:,0]
Thrust = segment.conditions.frames.body.thrust_force_vector[:,0]
axes = fig.add_subplot(3,1,1)
axes.plot( time , Lift , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('Lift (N)')
axes.grid(True)
axes = fig.add_subplot(3,1,2)
axes.plot( time , Drag , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('Drag (N)')
axes.grid(True)
axes = fig.add_subplot(3,1,3)
axes.plot( time , Thrust , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('Thrust (N)')
axes.grid(True)
# ------------------------------------------------------------------
# Aerodynamics 1
# ------------------------------------------------------------------
fig = plt.figure("Aerodynamic Coefficients")
for segment in results.segments.values():
time = segment.conditions.frames.inertial.time[:,0] / Units.min
CLift = segment.conditions.aerodynamics.lift_coefficient[:,0]
CDrag = segment.conditions.aerodynamics.drag_coefficient[:,0]
Drag = -segment.conditions.frames.wind.drag_force_vector[:,0]
Thrust = segment.conditions.frames.body.thrust_force_vector[:,0]
axes = fig.add_subplot(3,1,1)
axes.plot( time , CLift , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('CL')
axes.grid(True)
axes = fig.add_subplot(3,1,2)
axes.plot( time , CDrag , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('CD')
axes.grid(True)
axes = fig.add_subplot(3,1,3)
axes.plot( time , Drag , line_style )
axes.plot( time , Thrust , 'ro-' )
axes.set_xlabel('Time (min)')
axes.set_ylabel('Drag and Thrust (N)')
axes.grid(True)
# ------------------------------------------------------------------
# Aerodynamics 2
# ------------------------------------------------------------------
fig = plt.figure("Drag Components")
axes = plt.gca()
for i, segment in enumerate(results.segments.values()):
time = segment.conditions.frames.inertial.time[:,0] / Units.min
drag_breakdown = segment.conditions.aerodynamics.drag_breakdown
cdp = drag_breakdown.parasite.total[:,0]
cdi = drag_breakdown.induced.total[:,0]
cdc = drag_breakdown.compressible.total[:,0]
cdm = drag_breakdown.miscellaneous.total[:,0]
cd = drag_breakdown.total[:,0]
if line_style == 'bo-':
axes.plot( time , cdp , 'ko-', label='CD_P' )
axes.plot( time , cdi , 'bo-', label='CD_I' )
axes.plot( time , cdc , 'go-', label='CD_C' )
axes.plot( time , cdm , 'yo-', label='CD_M' )
axes.plot( time , cd , 'ro-', label='CD' )
if i == 0:
axes.legend(loc='upper center')
else:
axes.plot( time , cdp , line_style )
axes.plot( time , cdi , line_style )
axes.plot( time , cdc , line_style )
axes.plot( time , cdm , line_style )
axes.plot( time , cd , line_style )
axes.set_xlabel('Time (min)')
axes.set_ylabel('CD')
axes.grid(True)
return
if __name__ == '__main__':
main()
plt.show()