Skip to content

Commit dbc8e40

Browse files
authored
Merge pull request #20 from suavecode/develop
Develop
2 parents 7a5a446 + 171cb61 commit dbc8e40

File tree

16 files changed

+604
-1418
lines changed

16 files changed

+604
-1418
lines changed

B737_AVL_Tutorial/tut_mission_B737_AVL.py

Lines changed: 29 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
# Imports
77
# ----------------------------------------------------------------------
88

9-
# Python Imports
10-
import numpy as np
11-
import pylab as plt
12-
139
# SUAVE Imports
1410
import SUAVE
1511
from SUAVE.Core import Data, Units
12+
from SUAVE.Plots.Mission_Plots import *
1613
from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
1714
from SUAVE.Methods.Geometry.Two_Dimensional.Cross_Section.Propulsion import compute_turbofan_geometry
1815
from SUAVE.Input_Output.Results import print_parasite_drag, \
@@ -21,6 +18,10 @@
2118
print_mission_breakdown, \
2219
print_weight_breakdown
2320

21+
# Python Imports
22+
import numpy as np
23+
import pylab as plt
24+
2425
# ----------------------------------------------------------------------
2526
# Main
2627
# ----------------------------------------------------------------------
@@ -100,20 +101,22 @@ def base_analysis(vehicle):
100101

101102
# ------------------------------------------------------------------
102103
# Weights
103-
weights = SUAVE.Analyses.Weights.Weights_Tube_Wing()
104+
weights = SUAVE.Analyses.Weights.Weights_Transport()
104105
weights.vehicle = vehicle
105106
analyses.append(weights)
106107

107108
# ------------------------------------------------------------------
108109
# Aerodynamics Analysis
109110
aerodynamics = SUAVE.Analyses.Aerodynamics.AVL()
111+
aerodynamics.process.compute.lift.inviscid.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
110112
#aerodynamics.process.compute.lift.inviscid.settings.spanwise_vortex_density = 3
111113
aerodynamics.geometry = vehicle
112114
analyses.append(aerodynamics)
113115

114116
# ------------------------------------------------------------------
115117
# Stability Analysis
116118
stability = SUAVE.Analyses.Stability.AVL()
119+
stability.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
117120
#stability.settings.spanwise_vortex_density = 3
118121
stability.geometry = vehicle
119122
analyses.append(stability)
@@ -200,42 +203,41 @@ def vehicle_setup():
200203
wing.sweeps.quarter_chord = 25 * Units.deg
201204
wing.thickness_to_chord = 0.1
202205
wing.taper = 0.1
203-
wing.span_efficiency = 0.9
204206
wing.spans.projected = 34.32 * Units.meter
205207
wing.chords.root = 7.760 * Units.meter
206208
wing.chords.tip = 0.782 * Units.meter
207209
wing.chords.mean_aerodynamic = 4.235 * Units.meter
208210
wing.areas.reference = 124.862 * Units['meters**2']
209211
wing.twists.root = 4.0 * Units.degrees
210212
wing.twists.tip = 0.0 * Units.degrees
211-
wing.origin = [13.61,0,-1.27] # meters
213+
wing.origin = [[13.61 * Units.meter, 0, -1.27 * Units.meter]]
212214
wing.vertical = False
213215
wing.symmetric = True
214216
wing.high_lift = True
215217
wing.dynamic_pressure_ratio = 1.0
216218

219+
# add to vehicle
217220
vehicle.append_component(wing)
218221

219222
# ------------------------------------------------------------------
220223
# Horizontal Stabilizer
221224
# ------------------------------------------------------------------
222225

223-
wing = SUAVE.Components.Wings.Wing()
226+
wing = SUAVE.Components.Wings.Horizontal_Tail()
224227
wing.tag = 'horizontal_stabilizer'
225228

226229
wing.aspect_ratio = 6.16
227230
wing.sweeps.quarter_chord = 40 * Units.deg
228231
wing.thickness_to_chord = 0.08
229232
wing.taper = 0.2
230-
wing.span_efficiency = 0.9
231233
wing.spans.projected = 14.2 * Units.meter
232234
wing.chords.root = 4.7 * Units.meter
233235
wing.chords.tip = .955 * Units.meter
234-
wing.chords.mean_aerodynamic = 8.0 * Units.meter
236+
wing.chords.mean_aerodynamic = 3.0 * Units.meter
235237
wing.areas.reference = 32.488 * Units['meters**2']
236238
wing.twists.root = 3.0 * Units.degrees
237239
wing.twists.tip = 3.0 * Units.degrees
238-
wing.origin = [32.83,0,1.14] # meters
240+
wing.origin = [[32.83 * Units.meter, 0 , 1.14 * Units.meter]]
239241
wing.vertical = False
240242
wing.symmetric = True
241243
wing.dynamic_pressure_ratio = 0.9
@@ -247,22 +249,21 @@ def vehicle_setup():
247249
# Vertical Stabilizer
248250
# ------------------------------------------------------------------
249251

250-
wing = SUAVE.Components.Wings.Wing()
252+
wing = SUAVE.Components.Wings.Vertical_Tail()
251253
wing.tag = 'vertical_stabilizer'
252254

253255
wing.aspect_ratio = 1.91
254256
wing.sweeps.quarter_chord = 25. * Units.deg
255257
wing.thickness_to_chord = 0.08
256258
wing.taper = 0.25
257-
wing.span_efficiency = 0.9
258259
wing.spans.projected = 7.777 * Units.meter
259260
wing.chords.root = 8.19 * Units.meter
260261
wing.chords.tip = 0.95 * Units.meter
261262
wing.chords.mean_aerodynamic = 4.0 * Units.meter
262263
wing.areas.reference = 27.316 * Units['meters**2']
263264
wing.twists.root = 0.0 * Units.degrees
264265
wing.twists.tip = 0.0 * Units.degrees
265-
wing.origin = [28.79,0,1.54] # meters
266+
wing.origin = [[28.79 * Units.meter, 0, 1.54 * Units.meter]] # meters
266267
wing.vertical = True
267268
wing.symmetric = False
268269
wing.t_tail = False
@@ -317,7 +318,7 @@ def vehicle_setup():
317318
turbofan.bypass_ratio = 5.4
318319
turbofan.engine_length = 2.71 * Units.meter
319320
turbofan.nacelle_diameter = 2.05 * Units.meter
320-
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]] # meters
321+
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]]
321322

322323
#compute engine areas
323324
turbofan.areas.wetted = 1.1*np.pi*turbofan.nacelle_diameter*turbofan.engine_length
@@ -415,6 +416,7 @@ def vehicle_setup():
415416

416417
# setup
417418
combustor.efficiency = 0.99
419+
combustor.alphac = 1.0
418420
combustor.turbine_inlet_temperature = 1450 # K
419421
combustor.pressure_ratio = 0.95
420422
combustor.fuel_data = SUAVE.Attributes.Propellants.Jet_A()
@@ -493,6 +495,7 @@ def vehicle_setup():
493495

494496
return vehicle
495497

498+
496499
# ----------------------------------------------------------------------
497500
# Define the Configurations
498501
# ---------------------------------------------------------------------
@@ -717,167 +720,17 @@ def missions_setup(base_mission):
717720

718721
def plot_mission(results,line_style='bo-'):
719722

720-
axis_font = {'fontname':'Arial', 'size':'14'}
721-
722-
# ------------------------------------------------------------------
723-
# Aerodynamics
724-
# ------------------------------------------------------------------
725-
726-
727-
fig = plt.figure("Aerodynamic Forces",figsize=(8,6))
728-
for segment in results.segments.values():
729-
730-
time = segment.conditions.frames.inertial.time[:,0] / Units.min
731-
Thrust = segment.conditions.frames.body.thrust_force_vector[:,0] / Units.lbf
732-
eta = segment.conditions.propulsion.throttle[:,0]
733-
734-
axes = fig.add_subplot(2,1,1)
735-
axes.plot( time , Thrust , line_style )
736-
axes.set_ylabel('Thrust (lbf)',axis_font)
737-
axes.grid(True)
738-
739-
axes = fig.add_subplot(2,1,2)
740-
axes.plot( time , eta , line_style )
741-
axes.set_xlabel('Time (min)',axis_font)
742-
axes.set_ylabel('Throttle',axis_font)
743-
axes.grid(True)
744-
745-
plt.savefig("B737_engine.pdf")
746-
plt.savefig("B737_engine.png")
747-
748-
# ------------------------------------------------------------------
749-
# Aerodynamics 2
750-
# ------------------------------------------------------------------
751-
fig = plt.figure("Aerodynamic Coefficients",figsize=(8,10))
752-
for segment in results.segments.values():
753-
754-
time = segment.conditions.frames.inertial.time[:,0] / Units.min
755-
CLift = segment.conditions.aerodynamics.lift_coefficient[:,0]
756-
CDrag = segment.conditions.aerodynamics.drag_coefficient[:,0]
757-
aoa = segment.conditions.aerodynamics.angle_of_attack[:,0] / Units.deg
758-
l_d = CLift/CDrag
759-
760-
axes = fig.add_subplot(3,1,1)
761-
axes.plot( time , CLift , line_style )
762-
axes.set_ylabel('Lift Coefficient',axis_font)
763-
axes.grid(True)
764-
765-
axes = fig.add_subplot(3,1,2)
766-
axes.plot( time , l_d , line_style )
767-
axes.set_ylabel('L/D',axis_font)
768-
axes.grid(True)
769-
770-
axes = fig.add_subplot(3,1,3)
771-
axes.plot( time , aoa , 'ro-' )
772-
axes.set_xlabel('Time (min)',axis_font)
773-
axes.set_ylabel('AOA (deg)',axis_font)
774-
axes.grid(True)
775-
776-
plt.savefig("B737_aero.pdf")
777-
plt.savefig("B737_aero.png")
778-
779-
# ------------------------------------------------------------------
780-
# Aerodynamics 2
781-
# ------------------------------------------------------------------
782-
fig = plt.figure("Drag Components",figsize=(8,10))
783-
axes = plt.gca()
784-
for i, segment in enumerate(results.segments.values()):
785-
786-
time = segment.conditions.frames.inertial.time[:,0] / Units.min
787-
drag_breakdown = segment.conditions.aerodynamics.drag_breakdown
788-
cdp = drag_breakdown.parasite.total[:,0]
789-
cdi = drag_breakdown.induced.total[:,0]
790-
cdc = drag_breakdown.compressible.total[:,0]
791-
cdm = drag_breakdown.miscellaneous.total[:,0]
792-
cd = drag_breakdown.total[:,0]
793-
794-
if line_style == 'bo-':
795-
axes.plot( time , cdp , 'ko-', label='CD parasite' )
796-
axes.plot( time , cdi , 'bo-', label='CD induced' )
797-
axes.plot( time , cdc , 'go-', label='CD compressibility' )
798-
axes.plot( time , cdm , 'yo-', label='CD miscellaneous' )
799-
axes.plot( time , cd , 'ro-', label='CD total' )
800-
if i == 0:
801-
axes.legend(loc='upper center')
802-
else:
803-
axes.plot( time , cdp , line_style )
804-
axes.plot( time , cdi , line_style )
805-
axes.plot( time , cdc , line_style )
806-
axes.plot( time , cdm , line_style )
807-
axes.plot( time , cd , line_style )
808-
809-
axes.set_xlabel('Time (min)')
810-
axes.set_ylabel('CD')
811-
axes.grid(True)
812-
plt.savefig("B737_drag.pdf")
813-
plt.savefig("B737_drag.png")
814-
815-
# ------------------------------------------------------------------
816-
# Altitude, sfc, vehicle weight
817-
# ------------------------------------------------------------------
818-
819-
fig = plt.figure("Altitude_sfc_weight",figsize=(8,10))
820-
for segment in results.segments.values():
821-
822-
time = segment.conditions.frames.inertial.time[:,0] / Units.min
823-
aoa = segment.conditions.aerodynamics.angle_of_attack[:,0] / Units.deg
824-
mass = segment.conditions.weights.total_mass[:,0] / Units.lb
825-
altitude = segment.conditions.freestream.altitude[:,0] / Units.ft
826-
mdot = segment.conditions.weights.vehicle_mass_rate[:,0]
827-
thrust = segment.conditions.frames.body.thrust_force_vector[:,0]
828-
sfc = (mdot / Units.lb) / (thrust /Units.lbf) * Units.hr
829-
830-
axes = fig.add_subplot(3,1,1)
831-
axes.plot( time , altitude , line_style )
832-
axes.set_ylabel('Altitude (ft)',axis_font)
833-
axes.grid(True)
834-
835-
axes = fig.add_subplot(3,1,3)
836-
axes.plot( time , sfc , line_style )
837-
axes.set_xlabel('Time (min)',axis_font)
838-
axes.set_ylabel('sfc (lb/lbf-hr)',axis_font)
839-
axes.grid(True)
840-
841-
axes = fig.add_subplot(3,1,2)
842-
axes.plot( time , mass , 'ro-' )
843-
axes.set_ylabel('Weight (lb)',axis_font)
844-
axes.grid(True)
845-
846-
plt.savefig("B737_mission.pdf")
847-
plt.savefig("B737_mission.png")
848-
849-
# ------------------------------------------------------------------
850-
# Velocities
851-
# ------------------------------------------------------------------
852-
fig = plt.figure("Velocities",figsize=(8,10))
853-
for segment in results.segments.values():
854-
855-
time = segment.conditions.frames.inertial.time[:,0] / Units.min
856-
Lift = -segment.conditions.frames.wind.lift_force_vector[:,2]
857-
Drag = -segment.conditions.frames.wind.drag_force_vector[:,0] / Units.lbf
858-
Thrust = segment.conditions.frames.body.thrust_force_vector[:,0] / Units.lb
859-
velocity = segment.conditions.freestream.velocity[:,0]
860-
pressure = segment.conditions.freestream.pressure[:,0]
861-
density = segment.conditions.freestream.density[:,0]
862-
EAS = velocity * np.sqrt(density/1.225)
863-
mach = segment.conditions.freestream.mach_number[:,0]
864-
865-
axes = fig.add_subplot(3,1,1)
866-
axes.plot( time , velocity / Units.kts, line_style )
867-
axes.set_ylabel('velocity (kts)',axis_font)
868-
axes.grid(True)
869-
870-
axes = fig.add_subplot(3,1,2)
871-
axes.plot( time , EAS / Units.kts, line_style )
872-
axes.set_xlabel('Time (min)',axis_font)
873-
axes.set_ylabel('Equivalent Airspeed',axis_font)
874-
axes.grid(True)
875-
876-
axes = fig.add_subplot(3,1,3)
877-
axes.plot( time , mach , line_style )
878-
axes.set_xlabel('Time (min)',axis_font)
879-
axes.set_ylabel('Mach',axis_font)
880-
axes.grid(True)
723+
# Plot Aerodynamic Forces
724+
plot_aerodynamic_forces(results, line_style)
725+
726+
# Plot Aerodynamic Coefficients
727+
plot_aerodynamic_coefficients(results, line_style)
728+
729+
# Drag Components
730+
plot_drag_components(results, line_style)
731+
732+
# Plot Velocities
733+
plot_aircraft_velocities(results, line_style)
881734

882735
return
883736

0 commit comments

Comments
 (0)