Skip to content

Commit e1425b0

Browse files
committed
Updating tutorial scripts
1 parent dbc8e40 commit e1425b0

4 files changed

Lines changed: 29 additions & 29 deletions

File tree

Regional_Jet_Optimization/Optimize.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ def main():
2727

2828
## Base Input Values
2929
#output = problem.objective()
30+
import time
31+
t = time.time()
3032

31-
## Uncomment to view contours of the design space
32-
#variable_sweep(problem)
33+
# Uncomment to view contours of the design space
34+
variable_sweep(problem)
35+
36+
t_elapsed = time.time() - t
3337

3438
## Uncomment for the first optimization
35-
output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
36-
print (output)
39+
#output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
40+
#print (output)
3741

3842
## Uncomment these lines when you want to start an optimization problem from a different initial guess
3943
#inputs = [1.28, 1.38]
@@ -64,10 +68,10 @@ def setup():
6468
# Inputs
6569
# -------------------------------------------------------------------
6670

67-
# [ tag , initial, (lb,ub) , scaling , units ]
71+
# [ tag , initial, lb,ub) , scaling , units ]
6872
problem.inputs = np.array([
69-
[ 'wing_area' , 100 , ( 90. , 130. ) , 100. , Units.meter**2],
70-
[ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km],
73+
[ 'wing_area' , 100 , ( 90. , 130. ) , 100. , Units.meter**2],
74+
[ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km],
7175
])
7276

7377
# -------------------------------------------------------------------
@@ -137,19 +141,18 @@ def variable_sweep(problem):
137141
objective = outputs.objective
138142
constraints = outputs.constraint_val
139143
plt.figure(0)
140-
CS = plt.contourf(inputs[0,:],inputs[1,:], objective, 20, linewidths=2)
144+
CS = plt.contourf(inputs[0,:],inputs[1,:], objective, 20, linewidths=2,cmap='jet')
141145
cbar = plt.colorbar(CS)
142146

143147
cbar.ax.set_ylabel('fuel burn (kg)')
144-
CS_const = plt.contour(inputs[0,:],inputs[1,:], constraints[0,:,:])
148+
CS_const = plt.contour(inputs[0,:],inputs[1,:], constraints[0,:,:],cmap='jet')
145149
plt.clabel(CS_const, inline=1, fontsize=10)
146150
cbar = plt.colorbar(CS_const)
147151
cbar.ax.set_ylabel('fuel margin')
148152

149153
plt.xlabel('Wing Area (m^2)')
150154
plt.ylabel('Cruise Altitude (km)')
151155

152-
plt.legend(loc='upper left')
153156
plt.show(block=True)
154157

155158
return

Regional_Jet_Optimization/Procedure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,12 @@ def weight(nexus):
198198
vehicle=nexus.vehicle_configurations.base
199199

200200
# weight analysis
201-
weights = nexus.analyses.base.weights.evaluate()
202-
weights = nexus.analyses.cruise.weights.evaluate()
201+
weights = nexus.analyses.base.weights.evaluate(method="SUAVE")
202+
weights = nexus.analyses.cruise.weights.evaluate(method="SUAVE")
203203
vehicle.mass_properties.breakdown = weights
204-
weights = nexus.analyses.landing.weights.evaluate()
205-
weights = nexus.analyses.takeoff.weights.evaluate()
206-
weights = nexus.analyses.short_field_takeoff.weights.evaluate()
204+
weights = nexus.analyses.landing.weights.evaluate(method="SUAVE")
205+
weights = nexus.analyses.takeoff.weights.evaluate(method="SUAVE")
206+
weights = nexus.analyses.short_field_takeoff.weights.evaluate(method="SUAVE")
207207

208208
for config in nexus.vehicle_configurations:
209209
config.mass_properties.zero_fuel_center_of_gravity = vehicle.mass_properties.zero_fuel_center_of_gravity

tut_mission_B737.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
# covered in more detail in a separate tutorial. It does not size the turbofan geometry.
3737

3838

39-
# Python Imports
40-
import numpy as np
41-
import matplotlib.pyplot as plt
42-
4339
# ----------------------------------------------------------------------
4440
# Main
4541
# ----------------------------------------------------------------------
@@ -256,7 +252,7 @@ def vehicle_setup():
256252
wing.areas.reference = 124.862 * Units['meters**2']
257253
wing.twists.root = 4.0 * Units.degrees
258254
wing.twists.tip = 0.0 * Units.degrees
259-
wing.origin = [[13.61 * Units.meter, 0, -1.27 * Units.meter]]
255+
wing.origin = [[13.61, 0, -1.27]] * Units.meter
260256
wing.vertical = False
261257
wing.symmetric = True
262258
# The high lift flag controls aspects of maximum lift coefficient calculations
@@ -310,12 +306,12 @@ def vehicle_setup():
310306
wing.tag = 'horizontal_stabilizer'
311307

312308
wing.aspect_ratio = 6.16
313-
wing.sweeps.quarter_chord = 40 * Units.deg
309+
wing.sweeps.quarter_chord = 40.0 * Units.deg
314310
wing.thickness_to_chord = 0.08
315311
wing.taper = 0.2
316312
wing.spans.projected = 14.2 * Units.meter
317313
wing.chords.root = 4.7 * Units.meter
318-
wing.chords.tip = .955 * Units.meter
314+
wing.chords.tip = 0.955 * Units.meter
319315
wing.chords.mean_aerodynamic = 3.0 * Units.meter
320316
wing.areas.reference = 32.488 * Units['meters**2']
321317
wing.twists.root = 3.0 * Units.degrees
@@ -413,7 +409,7 @@ def vehicle_setup():
413409
turbofan.bypass_ratio = 5.4
414410
turbofan.engine_length = 2.71 * Units.meter
415411
turbofan.nacelle_diameter = 2.05 * Units.meter
416-
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]]
412+
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]] * Units.meter
417413

418414
# Approximate the wetted area
419415
turbofan.areas.wetted = 1.1*np.pi*turbofan.nacelle_diameter*turbofan.engine_length
@@ -565,19 +561,20 @@ def vehicle_setup():
565561
turbofan.append(fan)
566562

567563
# ------------------------------------------------------------------
568-
#Component 10 : thrust (to compute the thrust)
564+
# Component 11 - thrust (to compute the thrust)
565+
569566
thrust = SUAVE.Components.Energy.Processes.Thrust()
570567
thrust.tag ='compute_thrust'
571568

572569
# Design thrust is used to determine mass flow at full throttle
573570
thrust.total_design = 2*24000. * Units.N #Newtons
574-
575-
# Design sizing conditions are also used to determine mass flow
576-
altitude = 35000.0*Units.ft
577-
mach_number = 0.78
578571

579572
# Add to network
580573
turbofan.thrust = thrust
574+
575+
# Design sizing conditions are also used to determine mass flow
576+
altitude = 35000.0*Units.ft
577+
mach_number = 0.78
581578

582579
# Determine turbofan behavior at the design condition
583580
turbofan_sizing(turbofan,mach_number,altitude)

tut_payload_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def base_analysis(vehicle):
113113
# Aerodynamics Analysis
114114
aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
115115
aerodynamics.geometry = vehicle
116-
aerodynamics.settings.drag_coefficient_increment = 0.0050
116+
aerodynamics.settings.drag_coefficient_increment = 0.000
117117
analyses.append(aerodynamics)
118118

119119
# ------------------------------------------------------------------

0 commit comments

Comments
 (0)