From cf8d501a0ba26dde5ccb951fc8ccd15875b2e77b Mon Sep 17 00:00:00 2001 From: Racheal Erhard Date: Wed, 23 Dec 2020 22:48:01 -0800 Subject: [PATCH] Updated tutorial scripts --- Regional_Jet_Optimization/Optimize.py | 22 +++++++++++----------- Regional_Jet_Optimization/Procedure.py | 4 ++-- Solar_UAV_Optimization/Vehicles.py | 4 ++-- tut_solar_uav.py | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Regional_Jet_Optimization/Optimize.py b/Regional_Jet_Optimization/Optimize.py index ce401b3..73d0baf 100644 --- a/Regional_Jet_Optimization/Optimize.py +++ b/Regional_Jet_Optimization/Optimize.py @@ -23,22 +23,22 @@ # Run the whole thing # ---------------------------------------------------------------------- def main(): + import time + t = time.time() + problem = setup() ## 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) + # Uncomment for the first optimization + output = scipy_setup.SciPy_Solve(problem,solver='SLSQP') + print (output) + t_elapsed = time.time() - t ## Uncomment these lines when you want to start an optimization problem from a different initial guess #inputs = [1.28, 1.38] #scaling = problem.optimization_problem.inputs[:,3] #have to rescale inputs to start problem from here @@ -70,8 +70,8 @@ def setup(): # [ 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' , 90 , ( 90. , 130. ) , 100. , Units.meter**2], + [ 'cruise_altitude' , 10 , ( 9 , 14. ) , 10. , Units.km], ]) # ------------------------------------------------------------------- diff --git a/Regional_Jet_Optimization/Procedure.py b/Regional_Jet_Optimization/Procedure.py index 9ed2cd8..0c0d925 100644 --- a/Regional_Jet_Optimization/Procedure.py +++ b/Regional_Jet_Optimization/Procedure.py @@ -253,11 +253,11 @@ def post_process(nexus): # Fuel margin and base fuel calculations operating_empty = vehicle.mass_properties.operating_empty - payload = vehicle.mass_properties.breakdown.payload + payload = vehicle.mass_properties.breakdown.payload_breakdown design_landing_weight = results.base.segments[-1].conditions.weights.total_mass[-1] design_takeoff_weight = vehicle.mass_properties.takeoff max_takeoff_weight = nexus.vehicle_configurations.takeoff.mass_properties.max_takeoff - zero_fuel_weight = payload+operating_empty + zero_fuel_weight = vehicle.mass_properties.breakdown.zero_fuel_weight summary.max_zero_fuel_margin = (design_landing_weight - zero_fuel_weight)/zero_fuel_weight summary.base_mission_fuelburn = design_takeoff_weight - results.base.segments['descent_3'].conditions.weights.total_mass[-1] diff --git a/Solar_UAV_Optimization/Vehicles.py b/Solar_UAV_Optimization/Vehicles.py index 6f5aa6e..f64bca8 100644 --- a/Solar_UAV_Optimization/Vehicles.py +++ b/Solar_UAV_Optimization/Vehicles.py @@ -171,12 +171,12 @@ def base_setup(): esc.efficiency = 0.95 # Gundlach for brushless motors net.esc = esc - # Component 5 the Propeller + # Component 4 the Propeller prop = SUAVE.Components.Energy.Converters.Propeller_Lo_Fid() prop.propulsive_efficiency = 0.825 net.propeller = prop - # Component 4 the Motor + # Component 5 the Motor motor = SUAVE.Components.Energy.Converters.Motor_Lo_Fid() motor.speed_constant = 800. * Units['rpm/volt'] # RPM/volt is standard motor = size_from_kv(motor) diff --git a/tut_solar_uav.py b/tut_solar_uav.py index e788214..07f91dc 100644 --- a/tut_solar_uav.py +++ b/tut_solar_uav.py @@ -242,7 +242,7 @@ def vehicle_setup(): motor.no_load_current = 4.5 * Units.ampere motor.speed_constant = 120. * Units['rpm'] # RPM/volt converted to (rad/s)/volt motor.propeller_radius = prop.tip_radius - motor.propeller_Cp = prop.power_coefficient + motor.propeller_Cp = prop.design_power_coefficient motor.gear_ratio = 12. # Gear ratio motor.gearbox_efficiency = .98 # Gear box efficiency motor.expected_current = 160. # Expected current @@ -396,7 +396,7 @@ def mission_setup(analyses,vehicle): base_segment.process.iterate.unknowns.network = vehicle.propulsors.solar.unpack_unknowns base_segment.process.iterate.residuals.network = vehicle.propulsors.solar.residuals base_segment.process.iterate.initials.initialize_battery = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery - base_segment.state.unknowns.propeller_power_coefficient = vehicle.propulsors.solar.propeller.power_coefficient * ones_row(1)/15. + base_segment.state.unknowns.propeller_power_coefficient = vehicle.propulsors.solar.propeller.design_power_coefficient * ones_row(1)/15. base_segment.state.residuals.network = 0. * ones_row(1) # ------------------------------------------------------------------