Skip to content

Commit

Permalink
many tutorials fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
planes committed Nov 9, 2021
1 parent e60deee commit 835bbc5
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 30 deletions.
7 changes: 2 additions & 5 deletions B737_AVL_Tutorial/tut_mission_B737_AVL.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,15 @@ def base_analysis(vehicle):
# ------------------------------------------------------------------
# Aerodynamics Analysis
aerodynamics = SUAVE.Analyses.Aerodynamics.AVL()
#aerodynamics.process.compute.lift.inviscid.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
aerodynamics.process.compute.lift.inviscid.settings.filenames.avl_bin_name = '/Users/emiliobotero/Research/avl3.35'
aerodynamics.process.compute.lift.inviscid.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
#aerodynamics.process.compute.lift.inviscid.settings.spanwise_vortex_density = 3
aerodynamics.geometry = vehicle
analyses.append(aerodynamics)

# ------------------------------------------------------------------
# Stability Analysis
stability = SUAVE.Analyses.Stability.AVL()
#stability.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
stability.settings.filenames.avl_bin_name = '/Users/emiliobotero/Research/avl3.35'

stability.settings.filenames.avl_bin_name = 'CHANGE ME TO YOUR DIRECTORY'
#stability.settings.spanwise_vortex_density = 3
stability.geometry = vehicle
analyses.append(stability)
Expand Down
2 changes: 1 addition & 1 deletion Solar_UAV_Optimization/Analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def base(vehicle):
# Energy
# ------------------------------------------------------------------
energy = SUAVE.Analyses.Energy.Energy()
energy.network = vehicle.propulsors
energy.network = vehicle.networks
analyses.append(energy)

# ------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Solar_UAV_Optimization/Missions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def mission(analyses,vehicle):
segment.charge_ratio = 1.0
segment.latitude = 37.4
segment.longitude = -122.15
segment.battery_energy = vehicle.base.networks.solar_low_fidelity.battery.max_energy
segment.state.conditions.frames.wind.body_rotations[:,2] = 125.* Units.degrees

mission.append_segment(segment)
Expand Down
6 changes: 3 additions & 3 deletions Solar_UAV_Optimization/Optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def setup():
[ 'wing_area' ,['vehicle_configurations.*.wings.main_wing.areas.reference',
'vehicle_configurations.base.reference_area'] ],
[ 'aspect_ratio' , 'vehicle_configurations.*.wings.main_wing.aspect_ratio' ],
[ 'kv' , 'vehicle_configurations.*.propulsors.solar_low_fidelity.motor.speed_constant' ],
[ 'battery_mass' , 'vehicle_configurations.base.propulsors.solar_low_fidelity.battery.mass_properties.mass'],
[ 'solar_ratio' , 'vehicle_configurations.*.propulsors.solar_low_fidelity.solar_panel.ratio' ],
[ 'kv' , 'vehicle_configurations.*.networks.solar_low_fidelity.motor.speed_constant' ],
[ 'battery_mass' , 'vehicle_configurations.base.networks.solar_low_fidelity.battery.mass_properties.mass'],
[ 'solar_ratio' , 'vehicle_configurations.*.networks.solar_low_fidelity.solar_panel.ratio' ],
[ 'dynamic_pressure' , 'missions.mission.segments.cruise.dynamic_pressure' ],
[ 'Nothing' , 'summary.nothing' ],
[ 'energy_constraint', 'summary.energy_constraint' ],
Expand Down
2 changes: 1 addition & 1 deletion Solar_UAV_Optimization/Plot_Mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def plot_mission(results,line_style='bo-'):
plot_solar_flux(results)

# Plot Aircraft Electronics
plot_electronic_conditions(results)
plot_battery_pack_conditions(results)

return

Expand Down
23 changes: 11 additions & 12 deletions Solar_UAV_Optimization/Procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from SUAVE.Core import Units
from SUAVE.Analyses.Process import Process
from SUAVE.Methods.Power.Battery.Sizing import initialize_from_mass
from SUAVE.Methods.Power.Battery import append_initial_battery_conditions
from SUAVE.Methods.Propulsion.electric_motor_sizing import size_from_kv

# ----------------------------------------------------------------------
Expand Down Expand Up @@ -97,14 +98,14 @@ def simple_sizing(nexus):

# Size solar panel area
wing_area = vec.reference_area
spanel = vec.propulsors.solar_low_fidelity.solar_panel
spanel = vec.networks.solar_low_fidelity.solar_panel
sratio = spanel.ratio
solar_area = wing_area*sratio
spanel.area = solar_area
spanel.mass_properties.mass = solar_area*(0.60 * Units.kg)

# Resize the motor
motor = vec.propulsors.solar_low_fidelity.motor
motor = vec.networks.solar_low_fidelity.motor
motor = size_from_kv(motor)

# diff the new data
Expand All @@ -123,23 +124,21 @@ def weights_battery(nexus):
config.weights.evaluate()

vec = nexus.vehicle_configurations.base
payload = vec.propulsors.solar_low_fidelity.payload.mass_properties.mass
msolar = vec.propulsors.solar_low_fidelity.solar_panel.mass_properties.mass
payload = vec.networks.solar_low_fidelity.payload.mass_properties.mass
msolar = vec.networks.solar_low_fidelity.solar_panel.mass_properties.mass
MTOW = vec.mass_properties.max_takeoff
empty = vec.weight_breakdown.empty
mmotor = vec.propulsors.solar_low_fidelity.motor.mass_properties.mass
mmotor = vec.networks.solar_low_fidelity.motor.mass_properties.mass
segment = nexus.missions.mission.segments.cruise

# Calculate battery mass
batmass = MTOW - empty - payload - msolar -mmotor
bat = vec.propulsors.solar_low_fidelity.battery
bat = vec.networks.solar_low_fidelity.battery
initialize_from_mass(bat,batmass)
vec.propulsors.solar_low_fidelity.battery.mass_properties.mass = batmass
vec.networks.solar_low_fidelity.battery.mass_properties.mass = batmass

# Set Battery Charge
maxcharge = nexus.vehicle_configurations.base.propulsors.solar_low_fidelity.battery.max_energy
charge = maxcharge

nexus.missions.mission.segments.cruise.battery_energy = charge
append_initial_battery_conditions(segment, bat)

return nexus

Expand All @@ -165,7 +164,7 @@ def post_process(nexus):
res = nexus.results.mission.segments.cruise.conditions

# Final Energy
maxcharge = vec.propulsors.solar_low_fidelity.battery.max_energy
maxcharge = vec.networks.solar_low_fidelity.battery.max_energy

# Energy constraints, the battery doesn't go to zero anywhere, using a P norm
p = 8.
Expand Down
14 changes: 10 additions & 4 deletions Solar_UAV_Optimization/Vehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ def base_setup():

# add to vehicle
vehicle.append_component(wing)

# ------------------------------------------------------------------
# Nacelle
# ------------------------------------------------------------------
nacelle = SUAVE.Components.Nacelles.Nacelle()
nacelle.diameter = 0.05 * Units.meters
nacelle.length = 0.01 * Units.meters
nacelle.tag = 'nacelle'
nacelle.areas.wetted = nacelle.length *(2*np.pi*nacelle.diameter/2.)
vehicle.append_component(nacelle)

#------------------------------------------------------------------
# Propulsor
Expand All @@ -149,10 +159,6 @@ def base_setup():
# build network
net = Solar_Low_Fidelity()
net.number_of_engines = 1.
net.nacelle_diameter = 0.05
net.areas = Data()
net.areas.wetted = 0.01*(2*np.pi*0.01/2)
net.engine_length = 0.01

# Component 1 the Sun
sun = SUAVE.Components.Energy.Processes.Solar_Radiation()
Expand Down
4 changes: 2 additions & 2 deletions tut_payload_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# ----------------------------------------------------------------------

import SUAVE
#if not SUAVE.__version__=='2.5.0':
#assert('These tutorials only work with the SUAVE 2.5.0 release')
if not SUAVE.__version__=='2.5.0':
assert('These tutorials only work with the SUAVE 2.5.0 release')
from SUAVE.Core import Units, Data
from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing
from SUAVE.Methods.Performance import payload_range
Expand Down
4 changes: 2 additions & 2 deletions tut_solar_uav.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# Imports
# ----------------------------------------------------------------------
import SUAVE
#if not SUAVE.__version__=='2.5.0':
#assert('These tutorials only work with the SUAVE 2.5.0 release')
if not SUAVE.__version__=='2.5.0':
assert('These tutorials only work with the SUAVE 2.5.0 release')
from SUAVE.Core import Units

import numpy as np
Expand Down

0 comments on commit 835bbc5

Please sign in to comment.