Skip to content

Commit

Permalink
Updating tutorial scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rachealerhard committed Dec 23, 2020
1 parent dbc8e40 commit e1425b0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
23 changes: 13 additions & 10 deletions Regional_Jet_Optimization/Optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ def main():

## Base Input Values
#output = problem.objective()
import time
t = time.time()

## Uncomment to view contours of the design space
#variable_sweep(problem)
# Uncomment to view contours of the design space
variable_sweep(problem)

t_elapsed = time.time() - t

## Uncomment for the first optimization
output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
print (output)
#output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
#print (output)

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

# [ tag , initial, (lb,ub) , scaling , units ]
# [ tag , initial, lb,ub) , scaling , units ]
problem.inputs = np.array([
[ 'wing_area' , 100 , ( 90. , 130. ) , 100. , Units.meter**2],
[ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km],
[ 'wing_area' , 100 , ( 90. , 130. ) , 100. , Units.meter**2],
[ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km],
])

# -------------------------------------------------------------------
Expand Down Expand Up @@ -137,19 +141,18 @@ def variable_sweep(problem):
objective = outputs.objective
constraints = outputs.constraint_val
plt.figure(0)
CS = plt.contourf(inputs[0,:],inputs[1,:], objective, 20, linewidths=2)
CS = plt.contourf(inputs[0,:],inputs[1,:], objective, 20, linewidths=2,cmap='jet')
cbar = plt.colorbar(CS)

cbar.ax.set_ylabel('fuel burn (kg)')
CS_const = plt.contour(inputs[0,:],inputs[1,:], constraints[0,:,:])
CS_const = plt.contour(inputs[0,:],inputs[1,:], constraints[0,:,:],cmap='jet')
plt.clabel(CS_const, inline=1, fontsize=10)
cbar = plt.colorbar(CS_const)
cbar.ax.set_ylabel('fuel margin')

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

plt.legend(loc='upper left')
plt.show(block=True)

return
Expand Down
10 changes: 5 additions & 5 deletions Regional_Jet_Optimization/Procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ def weight(nexus):
vehicle=nexus.vehicle_configurations.base

# weight analysis
weights = nexus.analyses.base.weights.evaluate()
weights = nexus.analyses.cruise.weights.evaluate()
weights = nexus.analyses.base.weights.evaluate(method="SUAVE")
weights = nexus.analyses.cruise.weights.evaluate(method="SUAVE")
vehicle.mass_properties.breakdown = weights
weights = nexus.analyses.landing.weights.evaluate()
weights = nexus.analyses.takeoff.weights.evaluate()
weights = nexus.analyses.short_field_takeoff.weights.evaluate()
weights = nexus.analyses.landing.weights.evaluate(method="SUAVE")
weights = nexus.analyses.takeoff.weights.evaluate(method="SUAVE")
weights = nexus.analyses.short_field_takeoff.weights.evaluate(method="SUAVE")

for config in nexus.vehicle_configurations:
config.mass_properties.zero_fuel_center_of_gravity = vehicle.mass_properties.zero_fuel_center_of_gravity
Expand Down
23 changes: 10 additions & 13 deletions tut_mission_B737.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
# covered in more detail in a separate tutorial. It does not size the turbofan geometry.


# Python Imports
import numpy as np
import matplotlib.pyplot as plt

# ----------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -256,7 +252,7 @@ def vehicle_setup():
wing.areas.reference = 124.862 * Units['meters**2']
wing.twists.root = 4.0 * Units.degrees
wing.twists.tip = 0.0 * Units.degrees
wing.origin = [[13.61 * Units.meter, 0, -1.27 * Units.meter]]
wing.origin = [[13.61, 0, -1.27]] * Units.meter
wing.vertical = False
wing.symmetric = True
# The high lift flag controls aspects of maximum lift coefficient calculations
Expand Down Expand Up @@ -310,12 +306,12 @@ def vehicle_setup():
wing.tag = 'horizontal_stabilizer'

wing.aspect_ratio = 6.16
wing.sweeps.quarter_chord = 40 * Units.deg
wing.sweeps.quarter_chord = 40.0 * Units.deg
wing.thickness_to_chord = 0.08
wing.taper = 0.2
wing.spans.projected = 14.2 * Units.meter
wing.chords.root = 4.7 * Units.meter
wing.chords.tip = .955 * Units.meter
wing.chords.tip = 0.955 * Units.meter
wing.chords.mean_aerodynamic = 3.0 * Units.meter
wing.areas.reference = 32.488 * Units['meters**2']
wing.twists.root = 3.0 * Units.degrees
Expand Down Expand Up @@ -413,7 +409,7 @@ def vehicle_setup():
turbofan.bypass_ratio = 5.4
turbofan.engine_length = 2.71 * Units.meter
turbofan.nacelle_diameter = 2.05 * Units.meter
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]]
turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]] * Units.meter

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

# ------------------------------------------------------------------
#Component 10 : thrust (to compute the thrust)
# Component 11 - thrust (to compute the thrust)

thrust = SUAVE.Components.Energy.Processes.Thrust()
thrust.tag ='compute_thrust'

# Design thrust is used to determine mass flow at full throttle
thrust.total_design = 2*24000. * Units.N #Newtons

# Design sizing conditions are also used to determine mass flow
altitude = 35000.0*Units.ft
mach_number = 0.78

# Add to network
turbofan.thrust = thrust

# Design sizing conditions are also used to determine mass flow
altitude = 35000.0*Units.ft
mach_number = 0.78

# Determine turbofan behavior at the design condition
turbofan_sizing(turbofan,mach_number,altitude)
Expand Down
2 changes: 1 addition & 1 deletion tut_payload_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def base_analysis(vehicle):
# Aerodynamics Analysis
aerodynamics = SUAVE.Analyses.Aerodynamics.Fidelity_Zero()
aerodynamics.geometry = vehicle
aerodynamics.settings.drag_coefficient_increment = 0.0050
aerodynamics.settings.drag_coefficient_increment = 0.000
analyses.append(aerodynamics)

# ------------------------------------------------------------------
Expand Down

0 comments on commit e1425b0

Please sign in to comment.