Skip to content

Commit

Permalink
small fixes for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
planes committed May 24, 2021
1 parent 501d74a commit 3b06f09
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 184 deletions.
2 changes: 1 addition & 1 deletion B737_AVL_Tutorial/tut_mission_B737_AVL.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def vehicle_setup():
wing.origin = [[13.61 * Units.meter, 0, -1.27 * Units.meter]]
wing.vertical = False
wing.symmetric = True
wing.high_lift = True
wing.high_lift = False
wing.dynamic_pressure_ratio = 1.0

# add to vehicle
Expand Down
4 changes: 2 additions & 2 deletions BWB_CFD/BWB.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from SUAVE.Core import Data, Units

from SUAVE.Input_Output.OpenVSP import write
from SUAVE.Input_Output.OpenVSP.get_vsp_areas import get_vsp_areas
from SUAVE.Input_Output.OpenVSP import get_vsp_measurements

from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
from SUAVE.Methods.Geometry.Two_Dimensional.Cross_Section.Propulsion import compute_turbofan_geometry
Expand Down Expand Up @@ -555,7 +555,7 @@ def simple_sizing(configs):
base.mass_properties.max_zero_fuel = 0.9 * base.mass_properties.max_takeoff

# Areas
wetted_areas = get_vsp_areas(base.tag)
wetted_areas = get_vsp_measurements(base.tag)

for wing in base.wings:
wing.areas.wetted = wetted_areas[wing.tag]
Expand Down
16 changes: 8 additions & 8 deletions Regional_Jet_Optimization/Optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,29 @@ def setup():
# Inputs
# -------------------------------------------------------------------

# [ tag , initial, (lb , ub) , scaling , units ]
# [ tag , initial, lb , ub , scaling , units ]
problem.inputs = np.array([
[ 'wing_area' , 92 , ( 50. , 130. ) , 100. , Units.meter**2],
[ 'cruise_altitude' , 8 , ( 6. , 12. ) , 10. , Units.km],
])
[ 'wing_area' , 92 , 50. , 130. , 100. , 1*Units.meter**2],
[ 'cruise_altitude' , 8 , 6. , 12. , 10. , 1*Units.km],
],dtype=object)

# -------------------------------------------------------------------
# Objective
# -------------------------------------------------------------------

# [ tag, scaling, units ]
problem.objective = np.array([
[ 'fuel_burn', 10000, Units.kg ]
])
[ 'fuel_burn', 10000, 1*Units.kg ]
],dtype=object)

# -------------------------------------------------------------------
# Constraints
# -------------------------------------------------------------------

# [ tag, sense, edge, scaling, units ]
problem.constraints = np.array([
[ 'design_range_fuel_margin' , '>', 0., 1E-1, Units.less], #fuel margin defined here as fuel
])
[ 'design_range_fuel_margin' , '>', 0., 1E-1, 1*Units.less], #fuel margin defined here as fuel
],dtype=object)

# -------------------------------------------------------------------
# Aliases
Expand Down
28 changes: 14 additions & 14 deletions Solar_UAV_Optimization/Optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,34 @@ def setup():

# [ tag , initial, [lb,ub], scaling, units ]
problem.inputs = np.array([
[ 'wing_area' , 0.5, ( 0.1, 1.5 ), 0.5, Units.meter ],
[ 'aspect_ratio' , 10.0, ( 5.0, 20.0 ), 10.0, Units.less ],
[ 'dynamic_pressure', 125.0, ( 1.0, 2000.0 ), 125.0, Units.pascals ],
[ 'solar_ratio' , 0.0, ( 0.0, 0.97), 1.0, Units.less ],
[ 'kv' , 800.0, ( 10.0, 10000.0 ), 800.0, Units['rpm/volt']],
])
[ 'wing_area' , 0.5, 0.1, 1.5 , 0.5, 1*Units.meter ],
[ 'aspect_ratio' , 10.0, 5.0, 20.0 , 10.0, 1*Units.less ],
[ 'dynamic_pressure', 125.0, 1.0, 2000.0 , 125.0, 1*Units.pascals ],
[ 'solar_ratio' , 0.0, 0.0, 0.97, 1.0, 1*Units.less ],
[ 'kv' , 800.0, 10.0, 10000.0 , 800.0, 1*Units['rpm/volt']],
],dtype=object)

# -------------------------------------------------------------------
# Objective
# -------------------------------------------------------------------

# [ tag, scaling, units ]
problem.objective = np.array([
[ 'Nothing', 1. , Units.kg],
])
[ 'Nothing', 1. , 1*Units.kg],
],dtype=object)

# -------------------------------------------------------------------
# Constraints
# -------------------------------------------------------------------

# [ tag, sense, edge, scaling, units ]
problem.constraints = np.array([
[ 'energy_constraint', '=', 0.0, 1.0, Units.less],
[ 'battery_mass' , '>', 0.0, 1.0, Units.kg ],
[ 'CL' , '>', 0.0, 1.0, Units.less],
[ 'Throttle_min' , '>', 0.0, 1.0, Units.less],
[ 'Throttle_max' , '>', 0.0, 1.0, Units.less],
])
[ 'energy_constraint', '=', 0.0, 1.0, 1*Units.less],
[ 'battery_mass' , '>', 0.0, 1.0, 1*Units.kg ],
[ 'CL' , '>', 0.0, 1.0, 1*Units.less],
[ 'Throttle_min' , '>', 0.0, 1.0, 1*Units.less],
[ 'Throttle_max' , '>', 0.0, 1.0, 1*Units.less],
],dtype=object)

# -------------------------------------------------------------------
# Aliases
Expand Down
168 changes: 9 additions & 159 deletions tut_payload_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
from SUAVE.Methods.Performance import payload_range
from SUAVE.Methods.Geometry.Two_Dimensional.Planform import wing_planform
from SUAVE.Plots.Mission_Plots import *

import numpy as np
import pylab as plt
Expand Down Expand Up @@ -720,166 +721,15 @@ def mission_setup(analyses):

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)
# Plot Flight Conditions
plot_flight_conditions(results, line_style)

# Plot Aerodynamic Coefficients
plot_aerodynamic_coefficients(results, line_style)

# Plot Altitude, sfc, vehicle weight
plot_altitude_sfc_weight(results, line_style)

# ------------------------------------------------------------------
# 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

Expand Down

0 comments on commit 3b06f09

Please sign in to comment.