From ba3c378ce7fe88a108b8e98a3f9afedbce214bd2 Mon Sep 17 00:00:00 2001 From: jmvegh Date: Fri, 23 Sep 2016 16:19:43 -0700 Subject: [PATCH 1/9] updated for new data structure, getting it ready for surrogate optimization --- Regional_Jet_Optimization/Optimize.py | 62 ++++-- .../Optimize_Surrogate.py | 198 ++++++++++++++++++ Regional_Jet_Optimization/Plot_Mission.py | 10 +- Regional_Jet_Optimization/Procedure.py | 27 ++- 4 files changed, 263 insertions(+), 34 deletions(-) create mode 100644 Regional_Jet_Optimization/Optimize_Surrogate.py diff --git a/Regional_Jet_Optimization/Optimize.py b/Regional_Jet_Optimization/Optimize.py index 4a68c02..7ecbbcd 100644 --- a/Regional_Jet_Optimization/Optimize.py +++ b/Regional_Jet_Optimization/Optimize.py @@ -17,30 +17,33 @@ import matplotlib.pyplot as plt from SUAVE.Optimization import Nexus, carpet_plot import SUAVE.Optimization.Package_Setups.scipy_setup as scipy_setup +from SUAVE.Optimization.Surrogate_Optimization import Surrogate_Optimization +import VyPy +import pyOpt # ---------------------------------------------------------------------- # Run the whole thing # ---------------------------------------------------------------------- def main(): problem = setup() - - #output = problem.objective() #uncomment this line when using the default inputs - ''' #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 scaled_inputs = np.multiply(inputs,scaling) problem.optimization_problem.inputs[:,1] = scaled_inputs ''' - #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP') + + #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP') + #print output - #variable_sweep(problem) #uncomment this to view some contours of the problem + variable_sweep(problem) #uncomment this to view some contours of the problem print 'fuel burn=', problem.summary.base_mission_fuelburn print 'fuel margin=', problem.all_constraints() - Plot_Mission.plot_mission(problem.results) + #Plot_Mission.plot_mission(problem) return @@ -101,11 +104,25 @@ def setup(): [ 'fuel_burn' , 'summary.base_mission_fuelburn' ], [ 'design_range_fuel_margin' , 'summary.max_zero_fuel_margin' ], ] + ''' + #TASOPT imports + from mission_B737_TASOPT import full_setup, mission_setup + + configs, analyses = full_setup() + nexus.vehicle_configurations = configs + nexus.analyses = analyses + nexus.mission = analyses.mission + #nexus.mission = mission_setup(nexus.analyses) + ''' + # ------------------------------------------------------------------- # Vehicles # ------------------------------------------------------------------- - nexus.vehicle_configurations = Vehicles.setup() + + import Vehicle_TASOPT + nexus.vehicle_configurations = Vehicle_TASOPT.setup() + #nexus.vehicle_configurations = Vehicles.setup() # ------------------------------------------------------------------- @@ -119,7 +136,7 @@ def setup(): # ------------------------------------------------------------------- nexus.missions = Missions.setup(nexus.analyses) - + # ------------------------------------------------------------------- # Procedure # ------------------------------------------------------------------- @@ -129,11 +146,11 @@ def setup(): # Summary # ------------------------------------------------------------------- nexus.summary = Data() - + nexus.total_number_of_iterations = 0 return nexus def variable_sweep(problem): - number_of_points=5 + number_of_points=20 outputs=carpet_plot(problem, number_of_points, 0, 0) #run carpet plot, suppressing default plots inputs =outputs.inputs objective=outputs.objective @@ -153,14 +170,23 @@ def variable_sweep(problem): plt.xlabel('wing area (m^2)') plt.ylabel('cruise_altitude (km)') - ''' + + wing_1 = np.array([ 0.95, 0.9500000149011611, 0.95, 0.95, 0.9500000149011611, 0.95, 0.95, 0.9500000149011611, 0.95, 1.0830895945429801, 1.0830896094441413, 1.0830895945429801, 1.0830895945429801, 1.0830896094441413, 1.0830895945429801, 1.0830895945429801, 1.0830896094441413, 1.0830895945429801, 1.021757391325076, 1.0217574062262371, 1.021757391325076, 1.021757391325076, 1.0217574062262371, 1.021757391325076, 1.021757391325076, 1.0217574062262371, 1.021757391325076, 0.923430766276824, 0.9234307811779852, 0.923430766276824, 0.923430766276824, 0.9234307811779852, 0.923430766276824, 0.923430766276824, 0.9234307811779852, 0.923430766276824, 0.9458241453484385, 0.9458241602495997, 0.9458241453484385, 0.9458241453484385, 0.9458241602495997, 0.9458241453484385, 0.9458241453484385, 0.9458241602495997, 0.9458241453484385, 0.943053052966747, 0.9430530678679082, 0.943053052966747, 0.943053052966747, 0.9430530678679082, 0.943053052966747, 0.943053052966747, 0.9430530678679082, 0.943053052966747, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1000000000000001, 1.1000000000000001, 1.1000000000000001, 1.1000000000000001, 1.1000000000000001, 1.2, 1.2, 1.2, 1.2, 1.2, 1.3, 1.3, 1.3, 1.3, 1.3, 0.94305305 ])*100. + alt_1 = [11. , 11. , 11.00000015, 11. , 11. , 11.00000015, 11. , 11. , 11.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 9. , 9.00000015, 9. , 10.25 , 11.5 , 12.75 , 14. , 9. , 10.25 , 11.5 , 12.75 , 14. , 9. , 10.25 , 11.5 , 12.75 , 14. , 9. , 10.25 , 11.5 , 12.75 , 14. , 9. , 10.25 , 11.5 , 12.75 , 14. , 9. ] + + wing_2 = np.array([1.28, 1.2800000149011612, 1.28, 1.28, 1.2800000149011612, 1.28, 1.28, 1.2800000149011612, 1.28, 1.3, 1.3000000149011612, 1.3, 1.3, 1.3000000149011612, 1.3, 1.3, 1.3000000149011612, 1.3, 1.2512983213829585, 1.2512983362841197, 1.2512983213829585, 1.2512983213829585, 1.2512983362841197, 1.2512983213829585, 1.2512983213829585, 1.2512983362841197, 1.2512983213829585, 1.2027018036450188, 1.20270181854618, 1.2027018036450188, 1.2027018036450188, 1.20270181854618, 1.2027018036450188, 1.2027018036450188, 1.20270181854618, 1.2027018036450188, 0.9696195074510734, 0.9696195223522346, 0.9696195074510734, 0.9696195074510734, 0.9696195223522346, 0.9696195074510734, 0.9696195074510734, 0.9696195223522346, 0.9696195074510734, 0.9356100057984995, 0.9356100206996607, 0.9356100057984995, 0.9356100057984995, 0.9356100206996607, 0.9356100057984995, 0.9356100057984995, 0.9356100206996607, 0.9356100057984995, 0.9442290521247874, 0.9442290670259486, 0.9442290521247874, 0.9442290521247874, 0.9442290670259486, 0.9442290521247874, 0.9442290521247874, 0.9442290670259486, 0.9442290521247874, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 0.90000000000000002, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1000000000000001, 1.1000000000000001, 0.94422905 ])* 100. + + alt_2 = [ 13.8 , 13.8 , 13.80000015 , 13.8 , 13.8 , 13.80000015 , 13.8 , 13.8, 13.80000015 , 10.86578142 , 10.86578142, 10.86578157 , 10.86578142 , 10.86578142 , 10.86578157 , 10.86578142, 10.86578142 , 10.86578157 , 9. , 9. , 9.00000015 , 9., 9., 9.00000015 , 9. , 9. , 9.00000015 , 9.26299784 , 9.26299784 , 9.26299799 , 9.26299784 , 9.26299784 , 9.26299799 , 9.26299784 , 9.26299784 , 9.26299799 , 9.21358943 , 9.21358943 , 9.21358957 , 9.21358943 , 9.21358943 , 9.21358957 , 9.21358943 , 9.21358943 , 9.21358957 , 9. , 9., 9.00000015 , 9., 9. , 9.00000015 , 9., 9. , 9.00000015 , 9. , 9., 9.00000015 , 9. , 9. , 9.00000015 , 9. , 9., 9.00000015 , 9. , 10.25 , 11.5 , 12.75, 14., 9.,10.25 , 11.5 , 12.75 , 14. , 9. , 10.25 , 9. ] + + + #now plot optimization path (note that these data points were post-processed into a plottable format) - wing_1 = [95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.2149828] - alt_1 = [11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.52829047] - wing_2 = [128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891] - alt_2 = [13.8, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334] + #wing_1 = [95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.2149828] + #alt_1 = [11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.52829047] + #wing_2 = [128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891] + #alt_2 = [13.8, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334] - + ''' opt_1 = plt.plot(wing_1, alt_1, label='optimization path 1') init_1 = plt.plot(wing_1[0], alt_1[0], 'ko') final_1 = plt.plot(wing_1[-1], alt_1[-1], 'kx') @@ -170,13 +196,13 @@ def variable_sweep(problem): final_2 = plt.plot(wing_2[-1], alt_2[-1], 'kx', label= 'final points') ''' plt.legend(loc='upper left') - plt.show() + plt.show(block=True) return - + if __name__ == '__main__': main() diff --git a/Regional_Jet_Optimization/Optimize_Surrogate.py b/Regional_Jet_Optimization/Optimize_Surrogate.py new file mode 100644 index 0000000..8b166ec --- /dev/null +++ b/Regional_Jet_Optimization/Optimize_Surrogate.py @@ -0,0 +1,198 @@ +# Optimize.py +# Created: Feb 2016, M. Vegh +# Modified: + +# ---------------------------------------------------------------------- +# Imports +# ---------------------------------------------------------------------- + +import SUAVE +from SUAVE.Core import Units, Data +import numpy as np +import Vehicles +import Analyses +import Missions +import Procedure +import Plot_Mission +import matplotlib.pyplot as plt +from SUAVE.Optimization import Nexus, carpet_plot +import SUAVE.Optimization.Package_Setups.scipy_setup as scipy_setup +from SUAVE.Optimization.Surrogate_Optimization import Surrogate_Optimization +import VyPy +import pyOpt +# ---------------------------------------------------------------------- +# Run the whole thing +# ---------------------------------------------------------------------- +def main(): + problem = setup() + number_of_points = 10 + build_surrogate(problem, number_of_points) + output = problem.objective() #uncomment this line when using the default inputs + + ''' + #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 + scaled_inputs = np.multiply(inputs,scaling) + problem.optimization_problem.inputs[:,1] = scaled_inputs + ''' + #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP') + + + + #variable_sweep(problem) #uncomment this to view some contours of the problem + print 'fuel burn=', problem.summary.base_mission_fuelburn + print 'fuel margin=', problem.all_constraints() + + Plot_Mission.plot_mission(problem) + + return + + + +# ---------------------------------------------------------------------- +# Inputs, Objective, & Constraints +# ---------------------------------------------------------------------- + +def setup(): + + nexus = Nexus() + problem = Data() + nexus.optimization_problem = problem + + # ------------------------------------------------------------------- + # Inputs + # ------------------------------------------------------------------- + + # [ tag , initial, (lb,ub) , scaling , units ] + problem.inputs = np.array([ + [ 'wing_area' , 95 , ( 90. , 130. ) , 100. , Units.meter**2], + [ 'cruise_altitude' , 11 , ( 9 , 14. ) , 10. , Units.km], + ]) + + + + # ------------------------------------------------------------------- + # Objective + # ------------------------------------------------------------------- + + # throw an error if the user isn't specific about wildcards + # [ tag, scaling, units ] + problem.objective = np.array([ + [ 'fuel_burn', 10000, Units.kg ] + ]) + + + # ------------------------------------------------------------------- + # 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 + ]) + + # ------------------------------------------------------------------- + # Aliases + # ------------------------------------------------------------------- + + # [ 'alias' , ['data.path1.name','data.path2.name'] ] + + problem.aliases = [ + [ 'wing_area' , ['vehicle_configurations.*.wings.main_wing.areas.reference', + 'vehicle_configurations.*.reference_area' ]], + [ 'cruise_altitude' , 'missions.base.segments.climb_5.altitude_end' ], + [ 'fuel_burn' , 'summary.base_mission_fuelburn' ], + [ 'design_range_fuel_margin' , 'summary.max_zero_fuel_margin' ], + ] + + # ------------------------------------------------------------------- + # Vehicles + # ------------------------------------------------------------------- + nexus.vehicle_configurations = Vehicles.setup() + + + # ------------------------------------------------------------------- + # Analyses + # ------------------------------------------------------------------- + nexus.analyses = Analyses.setup(nexus.vehicle_configurations) + + + # ------------------------------------------------------------------- + # Missions + # ------------------------------------------------------------------- + nexus.missions = Missions.setup(nexus.analyses) + + + # ------------------------------------------------------------------- + # Procedure + # ------------------------------------------------------------------- + nexus.procedure = Procedure.setup() + + # ------------------------------------------------------------------- + # Summary + # ------------------------------------------------------------------- + nexus.summary = Data() + nexus.total_number_of_iterations = 0 + return nexus + +def variable_sweep(problem): + number_of_points=5 + outputs=carpet_plot(problem, number_of_points, 0, 0) #run carpet plot, suppressing default plots + inputs =outputs.inputs + objective=outputs.objective + constraints=outputs.constraint_val + plt.figure(0) + CS = plt.contourf(inputs[0,:],inputs[1,:], objective, 20, linewidths=2) + cbar = plt.colorbar(CS) + + cbar.ax.set_ylabel('fuel burn (kg)') + CS_const=plt.contour(inputs[0,:],inputs[1,:], constraints[0,:,:]) + 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)') + + ''' + #now plot optimization path (note that these data points were post-processed into a plottable format) + wing_1 = [95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 95 , 95.00000149 , 95 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 106.674165 , 106.6741665 , 106.674165 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 105.6274294 , 105.6274309 , 105.6274294 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 106.9084316 , 106.9084331 , 106.9084316 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 110.520489 , 110.5204905 , 110.520489 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 113.2166831 , 113.2166845 , 113.2166831 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.1649262 , 114.1649277 , 114.1649262 , 114.2149828] + alt_1 = [11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 11.0 , 11.0 , 11.000000149011612, 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 9.540665954351425 , 9.540665954351425 , 9.540666103363037 , 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.023015652305284, 10.023015652305284, 10.023015801316896, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.190994033521863, 10.190994033521863, 10.190994182533474, 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.440582829327589, 10.440582829327589, 10.4405829783392 , 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.536514606250261, 10.536514606250261, 10.536514755261873, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.535957839878783, 10.535957839878783, 10.535957988890395, 10.52829047] + wing_2 = [128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 128 , 128.0000015, 128 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 130 , 130.0000015, 130 , 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 122.9564124, 122.9564139, 122.9564124, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.5744347, 116.5744362, 116.5744347, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891, 116.3530891, 116.3530906, 116.3530891] + alt_2 = [13.8, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 13.799999999999999, 13.799999999999999, 13.80000014901161, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.302562430674953, 11.302562430674953, 11.302562579686565, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.158808932491421, 11.158808932491421, 11.158809081503033, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.412913394878741, 11.412913394878741, 11.412913543890353, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334, 11.402627869388722, 11.402627869388722, 11.402628018400334] + + + opt_1 = plt.plot(wing_1, alt_1, label='optimization path 1') + init_1 = plt.plot(wing_1[0], alt_1[0], 'ko') + final_1 = plt.plot(wing_1[-1], alt_1[-1], 'kx') + + opt_2 = plt.plot(wing_2, alt_2, 'k--', label='optimization path 2') + init_2 = plt.plot(wing_2[0], alt_2[0], 'ko', label= 'initial points') + final_2 = plt.plot(wing_2[-1], alt_2[-1], 'kx', label= 'final points') + ''' + plt.legend(loc='upper left') + plt.show() + + + + return +def build_surrogate(problem, number_of_points): + + surrogate_optimization = Surrogate_Optimization() #create surrogate optimization_problem + surrogate_optimization.sample_plan = VyPy.sampling.lhc_uniform + surrogate_optimization.optimizer = pyOpt.pySNOPT.SNOPT() + surrogate_optimization.problem = problem + surrogate_optimization.number_of_points = number_of_points + surrogate_optimization.surrogate_model = 'GPR' + surrogate_optimization.optimization_filename = 'results.txt' + surrogate_optimization.build_surrogate() + output, surrogate_problem = surrogate_optimization.iterative_optimization() + + +if __name__ == '__main__': + main() + + diff --git a/Regional_Jet_Optimization/Plot_Mission.py b/Regional_Jet_Optimization/Plot_Mission.py index a47a9e4..dd32283 100644 --- a/Regional_Jet_Optimization/Plot_Mission.py +++ b/Regional_Jet_Optimization/Plot_Mission.py @@ -16,8 +16,8 @@ # Plot Mission # ---------------------------------------------------------------------- -def plot_mission(results,line_style='bo-'): - +def plot_mission(nexus,line_style='bo-'): + results=nexus.results axis_font = {'fontname':'Arial', 'size':'14'} @@ -51,7 +51,7 @@ def plot_mission(results,line_style='bo-'): axes.set_xlabel('Time (min)',axis_font) axes.set_ylabel('AOA (deg)',axis_font) axes.grid(True) - + # ------------------------------------------------------------------ # Aerodynamics 2 # ------------------------------------------------------------------ @@ -121,8 +121,8 @@ def plot_mission(results,line_style='bo-'): - - plt.show() + + plt.show(block=True) return diff --git a/Regional_Jet_Optimization/Procedure.py b/Regional_Jet_Optimization/Procedure.py index da8b2c7..e2082f5 100644 --- a/Regional_Jet_Optimization/Procedure.py +++ b/Regional_Jet_Optimization/Procedure.py @@ -17,7 +17,7 @@ from SUAVE.Methods.Center_of_Gravity.compute_component_centers_of_gravity import compute_component_centers_of_gravity from SUAVE.Methods.Center_of_Gravity.compute_aircraft_center_of_gravity import compute_aircraft_center_of_gravity from SUAVE.Methods.Aerodynamics.Fidelity_Zero.Lift.compute_max_lift_coeff import compute_max_lift_coeff - +from SUAVE.Optimization.write_optimization_outputs import write_optimization_outputs # ---------------------------------------------------------------------- # Setup @@ -30,7 +30,7 @@ def setup(): # ------------------------------------------------------------------ # size the base config - procedure = Data() + procedure = Process() procedure.simple_sizing = simple_sizing # find the weights @@ -128,7 +128,8 @@ def simple_sizing(nexus): conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics() #assign conditions in form for propulsor sizing conditions.freestream = freestream - + print 'altitude = ', altitude/Units.km + print 'conditions.freestream = ', conditions.freestream for config in configs: @@ -146,7 +147,7 @@ def simple_sizing(nexus): fuselage = config.fuselages['fuselage'] fuselage.differential_pressure = diff_pressure - turbofan_sizing(config.propulsors['turbofan'], mach_number, altitude) + turbofan_sizing(config.propulsors['turbofan'], mach_number = mach_number, altitude = altitude) compute_turbofan_geometry(config.propulsors['turbofan'], conditions) # diff the new data config.store_diff() @@ -258,11 +259,11 @@ def finalize(nexus): def post_process(nexus): # Unpack data - vehicle = nexus.vehicle_configurations.base - results = nexus.results - summary = nexus.summary - missions = nexus.missions - + vehicle = nexus.vehicle_configurations.base + results = nexus.results + summary = nexus.summary + missions = nexus.missions + nexus.total_number_of_iterations +=1 # Static stability calculations CMA = -10. for segment in results.base.segments.values(): @@ -309,8 +310,11 @@ def post_process(nexus): lh = vehicle.wings.horizontal_stabilizer.origin[0] + vehicle.wings.horizontal_stabilizer.aerodynamic_center[0] - vehicle.mass_properties.center_of_gravity[0] lv = vehicle.wings.vertical_stabilizer.origin[0] + vehicle.wings.vertical_stabilizer.aerodynamic_center[0] - vehicle.mass_properties.center_of_gravity[0] - ''' + #when you run want to output results to a file + filename = 'results.txt' + write_optimization_outputs(nexus, filename) + ''' unscaled_inputs = nexus.optimization_problem.inputs[:,1] #use optimization problem inputs here input_scaling = nexus.optimization_problem.inputs[:,3] scaled_inputs = unscaled_inputs/input_scaling @@ -319,7 +323,8 @@ def post_process(nexus): for value in unscaled_inputs: problem_inputs.append(value) file=open('results.txt' , 'ab') - + file.write('iteration = ') + file.write(str(nexus.iteration_number)) file.write('fuel weight = ') file.write(str( summary.base_mission_fuelburn)) From 060e1eb697725325a3c51068d8c5bcd9c94be2c4 Mon Sep 17 00:00:00 2001 From: jmvegh Date: Fri, 23 Sep 2016 16:24:46 -0700 Subject: [PATCH 2/9] changed imports so it runs --- Regional_Jet_Optimization/Optimize.py | 6 +++--- Regional_Jet_Optimization/Procedure.py | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Regional_Jet_Optimization/Optimize.py b/Regional_Jet_Optimization/Optimize.py index 7ecbbcd..c4a323d 100644 --- a/Regional_Jet_Optimization/Optimize.py +++ b/Regional_Jet_Optimization/Optimize.py @@ -120,9 +120,9 @@ def setup(): # Vehicles # ------------------------------------------------------------------- - import Vehicle_TASOPT - nexus.vehicle_configurations = Vehicle_TASOPT.setup() - #nexus.vehicle_configurations = Vehicles.setup() + #import Vehicle_TASOPT + #nexus.vehicle_configurations = Vehicle_TASOPT.setup() + nexus.vehicle_configurations = Vehicles.setup() # ------------------------------------------------------------------- diff --git a/Regional_Jet_Optimization/Procedure.py b/Regional_Jet_Optimization/Procedure.py index e2082f5..60d2549 100644 --- a/Regional_Jet_Optimization/Procedure.py +++ b/Regional_Jet_Optimization/Procedure.py @@ -128,8 +128,6 @@ def simple_sizing(nexus): conditions = SUAVE.Analyses.Mission.Segments.Conditions.Aerodynamics() #assign conditions in form for propulsor sizing conditions.freestream = freestream - print 'altitude = ', altitude/Units.km - print 'conditions.freestream = ', conditions.freestream for config in configs: From f4d2660601ad0f74a4499753e649958e7c96ffd4 Mon Sep 17 00:00:00 2001 From: jmvegh Date: Mon, 26 Sep 2016 15:19:24 -0700 Subject: [PATCH 3/9] fixed sweep definition in the tutorial --- Regional_Jet_Optimization/Optimize.py | 8 +++--- Regional_Jet_Optimization/Procedure.py | 37 ++++++++++++++------------ Regional_Jet_Optimization/Vehicles.py | 6 ++--- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Regional_Jet_Optimization/Optimize.py b/Regional_Jet_Optimization/Optimize.py index c4a323d..5929d11 100644 --- a/Regional_Jet_Optimization/Optimize.py +++ b/Regional_Jet_Optimization/Optimize.py @@ -34,12 +34,12 @@ def main(): problem.optimization_problem.inputs[:,1] = scaled_inputs ''' - + #optimize #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP') #print output - + - variable_sweep(problem) #uncomment this to view some contours of the problem + #variable_sweep(problem) #uncomment this to view some contours of the problem print 'fuel burn=', problem.summary.base_mission_fuelburn print 'fuel margin=', problem.all_constraints() @@ -150,7 +150,7 @@ def setup(): return nexus def variable_sweep(problem): - number_of_points=20 + number_of_points = 5 outputs=carpet_plot(problem, number_of_points, 0, 0) #run carpet plot, suppressing default plots inputs =outputs.inputs objective=outputs.objective diff --git a/Regional_Jet_Optimization/Procedure.py b/Regional_Jet_Optimization/Procedure.py index 60d2549..485a637 100644 --- a/Regional_Jet_Optimization/Procedure.py +++ b/Regional_Jet_Optimization/Procedure.py @@ -104,7 +104,7 @@ def design_mission(nexus): def simple_sizing(nexus): configs=nexus.vehicle_configurations base=configs.base - + #find conditions air_speed = nexus.missions.base.segments['cruise'].air_speed altitude = nexus.missions.base.segments['climb_5'].altitude_end @@ -163,10 +163,11 @@ def simple_sizing(nexus): # Landing CL_max altitude = nexus.missions.base.segments[-1].altitude_end atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976() - p, T, rho, a, mu = atmosphere.compute_values(altitude) + freestream_landing = atmosphere.compute_values(0.) + #p, T, rho, a, mu = atmosphere.compute_values(0.) landing_conditions.freestream.velocity = nexus.missions.base.segments['descent_3'].air_speed - landing_conditions.freestream.density = rho - landing_conditions.freestream.dynamic_viscosity = mu/rho + landing_conditions.freestream.density = freestream_landing.density + landing_conditions.freestream.dynamic_viscosity = freestream_landing.dynamic_viscosity CL_max_landing,CDi = compute_max_lift_coeff(landing,landing_conditions) landing.maximum_lift_coefficient = CL_max_landing # diff the new data @@ -178,11 +179,12 @@ def simple_sizing(nexus): takeoff_conditions = Data() takeoff_conditions.freestream = Data() altitude = nexus.missions.base.airport.altitude - atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976() - p, T, rho, a, mu = atmosphere.compute_values(altitude) + freestream_takeoff = atmosphere.compute_values(altitude) + + #p, T, rho, a, mu = atmosphere.compute_values(altitude) takeoff_conditions.freestream.velocity = nexus.missions.base.segments.climb_1.air_speed - takeoff_conditions.freestream.density = rho - takeoff_conditions.freestream.dynamic_viscosity = mu/rho + takeoff_conditions.freestream.density = freestream_takeoff.density + takeoff_conditions.freestream.dynamic_viscosity = freestream_takeoff.dynamic_viscosity max_CL_takeoff,CDi = compute_max_lift_coeff(takeoff,takeoff_conditions) takeoff.maximum_lift_coefficient = max_CL_takeoff @@ -193,13 +195,7 @@ def simple_sizing(nexus): #Base config CL_max base = nexus.vehicle_configurations.base base_conditions = Data() - base_conditions.freestream = Data() - altitude = nexus.missions.base.airport.altitude - atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976() - p, T, rho, a, mu = atmosphere.compute_values(altitude) - base_conditions.freestream.velocity = nexus.missions.base.segments.climb_1.air_speed - base_conditions.freestream.density = rho - base_conditions.freestream.dynamic_viscosity = mu/rho + base_conditions.freestream = takeoff_conditions.freestream max_CL_base,CDi = compute_max_lift_coeff(base,base_conditions) base.maximum_lift_coefficient = max_CL_base base.store_diff() @@ -225,6 +221,7 @@ def weight(nexus): weights = nexus.analyses.cruise.weights.evaluate() + 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() @@ -235,6 +232,7 @@ def weight(nexus): #config.mass_properties.max_zero_fuel = empty_weight+passenger_weight config.mass_properties.zero_fuel_center_of_gravity = vehicle.mass_properties.zero_fuel_center_of_gravity config.fuel = vehicle.fuel + return nexus @@ -257,7 +255,13 @@ def finalize(nexus): def post_process(nexus): # Unpack data - vehicle = nexus.vehicle_configurations.base + vehicle = nexus.vehicle_configurations.base + + ''' + print 'base.mass_properties.takeoff = ', vehicle.mass_properties.takeoff + print 'takeoff.mass_properties.takeoff = ', nexus.vehicle_configurations.takeoff.mass_properties.takeoff + print 'vehicle.mass_properties.empty = ', vehicle.mass_properties.operating_empty + ''' results = nexus.results summary = nexus.summary missions = nexus.missions @@ -284,7 +288,6 @@ def post_process(nexus): summary.max_throttle = max_throttle # Fuel margin and base fuel calculations - operating_empty = vehicle.mass_properties.operating_empty payload = vehicle.passenger_weights.mass_properties.mass design_landing_weight = results.base.segments[-1].conditions.weights.total_mass[-1] diff --git a/Regional_Jet_Optimization/Vehicles.py b/Regional_Jet_Optimization/Vehicles.py index 985e101..9c4c38c 100644 --- a/Regional_Jet_Optimization/Vehicles.py +++ b/Regional_Jet_Optimization/Vehicles.py @@ -66,7 +66,7 @@ def base_setup(): wing.tag = 'main_wing' wing.aspect_ratio = 8.4 - wing.sweep = 23.0 * Units.deg + wing.sweeps.quarter_chord = 23.0 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.28 wing.span_efficiency = 1.0 @@ -108,7 +108,7 @@ def base_setup(): wing.tag = 'horizontal_stabilizer' wing.aspect_ratio = 5.5 - wing.sweep = 34.5 * Units.deg + wing.sweeps.quarter_chord = 34.5 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.11 wing.span_efficiency = 0.9 @@ -146,7 +146,7 @@ def base_setup(): wing.tag = 'vertical_stabilizer' wing.aspect_ratio = 1.7 # - wing.sweep = 35 * Units.deg + wing.sweeps.quarter_chord = 35 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.31 wing.span_efficiency = 0.9 From b8e734b504bab1ed035d0ed35ce573d27a4175f5 Mon Sep 17 00:00:00 2001 From: Emilio Botero Date: Sun, 8 Jan 2017 23:05:15 -0800 Subject: [PATCH 4/9] updating prior tutorials --- Regional_Jet_Optimization/Optimize.py | 1 - Regional_Jet_Optimization/Procedure.py | 12 +-- Solar_UAV_Optimization/Missions.py | 12 +-- Solar_UAV_Optimization/Optimize.py | 2 +- Solar_UAV_Optimization/Vehicles.py | 40 +++++----- tut_concorde.py | 2 +- tut_lithium_air_jet_sizing.py | 20 +++-- tut_mission_B737.py | 106 +++++++++++++------------ tut_payload_range.py | 6 +- tut_solar_uav.py | 69 ++++++++++------ 10 files changed, 146 insertions(+), 124 deletions(-) diff --git a/Regional_Jet_Optimization/Optimize.py b/Regional_Jet_Optimization/Optimize.py index 5929d11..5096275 100644 --- a/Regional_Jet_Optimization/Optimize.py +++ b/Regional_Jet_Optimization/Optimize.py @@ -17,7 +17,6 @@ import matplotlib.pyplot as plt from SUAVE.Optimization import Nexus, carpet_plot import SUAVE.Optimization.Package_Setups.scipy_setup as scipy_setup -from SUAVE.Optimization.Surrogate_Optimization import Surrogate_Optimization import VyPy import pyOpt # ---------------------------------------------------------------------- diff --git a/Regional_Jet_Optimization/Procedure.py b/Regional_Jet_Optimization/Procedure.py index 485a637..4c4fed4 100644 --- a/Regional_Jet_Optimization/Procedure.py +++ b/Regional_Jet_Optimization/Procedure.py @@ -147,8 +147,7 @@ def simple_sizing(nexus): turbofan_sizing(config.propulsors['turbofan'], mach_number = mach_number, altitude = altitude) compute_turbofan_geometry(config.propulsors['turbofan'], conditions) - # diff the new data - config.store_diff() + # ------------------------------------------------------------------ # Landing Configuration @@ -170,9 +169,6 @@ def simple_sizing(nexus): landing_conditions.freestream.dynamic_viscosity = freestream_landing.dynamic_viscosity CL_max_landing,CDi = compute_max_lift_coeff(landing,landing_conditions) landing.maximum_lift_coefficient = CL_max_landing - # diff the new data - landing.store_diff() - #Takeoff CL_max takeoff = nexus.vehicle_configurations.takeoff @@ -188,18 +184,12 @@ def simple_sizing(nexus): max_CL_takeoff,CDi = compute_max_lift_coeff(takeoff,takeoff_conditions) takeoff.maximum_lift_coefficient = max_CL_takeoff - takeoff.store_diff() - - - #Base config CL_max base = nexus.vehicle_configurations.base base_conditions = Data() base_conditions.freestream = takeoff_conditions.freestream max_CL_base,CDi = compute_max_lift_coeff(base,base_conditions) base.maximum_lift_coefficient = max_CL_base - base.store_diff() - # done! return nexus diff --git a/Solar_UAV_Optimization/Missions.py b/Solar_UAV_Optimization/Missions.py index 4fe7995..2c04a95 100644 --- a/Solar_UAV_Optimization/Missions.py +++ b/Solar_UAV_Optimization/Missions.py @@ -17,15 +17,15 @@ # Define the Mission # ---------------------------------------------------------------------- -def setup(analyses): +def setup(analyses,vehicle): # the mission container missions = SUAVE.Analyses.Mission.Mission.Container() - missions.mission = mission(analyses) + missions.mission = mission(analyses,vehicle) return missions -def mission(analyses): +def mission(analyses,vehicle): # ------------------------------------------------------------------ # Initialize the Mission @@ -41,8 +41,8 @@ def mission(analyses): Segments = SUAVE.Analyses.Mission.Segments # base segment - base_segment = Segments.Segment() - base_segment.process.iterate.initials.initialize_battery = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery + base_segment = Segments.Segment() + base_segment.process.iterate.initials.initialize_battery = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery # ------------------------------------------------------------------ # Cruise Segment: Constant Dynamic Pressure, Constant Altitude @@ -57,7 +57,7 @@ def mission(analyses): # segment attributes segment.state.numerics.number_control_points = 50 segment.dynamic_pressure = 115.0 * Units.pascals - segment.start_time = time.strptime("Tue, Jun 21 11:00:00 2016", "%a, %b %d %H:%M:%S %Y",) + segment.start_time = time.strptime("Tue, Jun 21 11:00:00 2017", "%a, %b %d %H:%M:%S %Y",) segment.altitude = 1000.0 * Units.feet segment.distance = 1000.0 * Units.km segment.charge_ratio = 1.0 diff --git a/Solar_UAV_Optimization/Optimize.py b/Solar_UAV_Optimization/Optimize.py index aab7b1f..7847a22 100644 --- a/Solar_UAV_Optimization/Optimize.py +++ b/Solar_UAV_Optimization/Optimize.py @@ -110,7 +110,7 @@ def setup(): # ------------------------------------------------------------------- # Missions # ------------------------------------------------------------------- - nexus.missions = Missions.setup(nexus.analyses) + nexus.missions = Missions.setup(nexus.analyses,nexus.vehicle_configurations) # ------------------------------------------------------------------- # Procedure diff --git a/Solar_UAV_Optimization/Vehicles.py b/Solar_UAV_Optimization/Vehicles.py index ab115ed..542a615 100644 --- a/Solar_UAV_Optimization/Vehicles.py +++ b/Solar_UAV_Optimization/Vehicles.py @@ -58,7 +58,7 @@ def base_setup(): wing.areas.reference = vehicle.reference_area wing.spans.projected = 40.0 wing.aspect_ratio = (wing.spans.projected**2)/wing.areas.reference - wing.sweep = 0.0 * Units.deg + wing.sweeps.quarter_chord = 0.0 * Units.deg wing.symmetric = True wing.thickness_to_chord = 0.12 wing.taper = 1.0 @@ -89,18 +89,18 @@ def base_setup(): wing = SUAVE.Components.Wings.Wing() wing.tag = 'horizontal_stabilizer' - wing.aspect_ratio = 10. - wing.sweep = 0 * Units.deg - wing.thickness_to_chord = 0.12 - wing.taper = 1.0 - wing.span_efficiency = 0.95 - wing.areas.reference = vehicle.reference_area * .15 - wing.areas.wetted = 2.0 * wing.areas.reference - wing.areas.exposed = 0.8 * wing.areas.wetted - wing.areas.affected = 0.6 * wing.areas.wetted - wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) - wing.twists.root = 0.0 * Units.degrees - wing.twists.tip = 0.0 * Units.degrees + wing.aspect_ratio = 10. + wing.sweeps.quarter_chord = 0 * Units.deg + wing.thickness_to_chord = 0.12 + wing.taper = 1.0 + wing.span_efficiency = 0.95 + wing.areas.reference = vehicle.reference_area * .15 + wing.areas.wetted = 2.0 * wing.areas.reference + wing.areas.exposed = 0.8 * wing.areas.wetted + wing.areas.affected = 0.6 * wing.areas.wetted + wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) + wing.twists.root = 0.0 * Units.degrees + wing.twists.tip = 0.0 * Units.degrees wing.vertical = False wing.symmetric = True @@ -122,13 +122,13 @@ def base_setup(): wing = SUAVE.Components.Wings.Wing() wing.tag = 'vertical_stabilizer' - wing.aspect_ratio = 10. - wing.sweep = 0 * Units.deg - wing.thickness_to_chord = 0.12 - wing.taper = 1.0 - wing.span_efficiency = 0.97 - wing.areas.reference = vehicle.reference_area * 0.1 - wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) + wing.aspect_ratio = 10. + wing.sweeps.quarter_chord = 0 * Units.deg + wing.thickness_to_chord = 0.12 + wing.taper = 1.0 + wing.span_efficiency = 0.97 + wing.areas.reference = vehicle.reference_area * 0.1 + wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) wing.chords.root = wing.areas.reference/wing.spans.projected wing.chords.tip = wing.areas.reference/wing.spans.projected diff --git a/tut_concorde.py b/tut_concorde.py index ad47527..806603a 100644 --- a/tut_concorde.py +++ b/tut_concorde.py @@ -160,7 +160,7 @@ def vehicle_setup(): # ------------------------------------------------------------------ vehicle = SUAVE.Vehicle() - vehicle.tag = 'AS2' + vehicle.tag = 'Concorde' # ------------------------------------------------------------------ diff --git a/tut_lithium_air_jet_sizing.py b/tut_lithium_air_jet_sizing.py index 37272e6..13b8f99 100644 --- a/tut_lithium_air_jet_sizing.py +++ b/tut_lithium_air_jet_sizing.py @@ -265,7 +265,7 @@ def vehicle_setup(cruise_altitude): wing.tag = 'main_wing' wing.aspect_ratio = 8.3 - wing.sweep = 0.002 * Units.deg + wing.sweeps.quarter_chord = 0.002 * Units.deg wing.thickness_to_chord = 0.105 wing.taper = 0.28 wing.span_efficiency = 1.0 @@ -303,7 +303,7 @@ def vehicle_setup(cruise_altitude): wing.tag = 'horizontal_stabilizer' wing.aspect_ratio = 5.5 - wing.sweep = 0.002 * Units.deg + wing.sweeps.quarter_chord = 0.002 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.11 wing.span_efficiency = 0.9 @@ -341,7 +341,7 @@ def vehicle_setup(cruise_altitude): wing.tag = 'vertical_stabilizer' wing.aspect_ratio = 1.7 # - wing.sweep = 0.001 * Units.deg + wing.sweeps.quarter_chord = 0.001 * Units.deg wing.thickness_to_chord = 0.12 wing.taper = 0.10 wing.span_efficiency = 0.9 @@ -415,9 +415,19 @@ def vehicle_setup(cruise_altitude): # ------------------------------------------------------------------ atm = SUAVE.Analyses.Atmospheric.US_Standard_1976() - p1, T1, rho1, a1, mu1 = atm.compute_values(0.) - p2, T2, rho2, a2, mu2 = atm.compute_values(cruise_altitude) + conditions1 = atm.compute_values(0.) + conditions2 = atm.compute_values(cruise_altitude) + p1 = conditions1.pressure + p2 = conditions2.pressure + T1 = conditions1.temperature + T2 = conditions2.temperature + rho1 = conditions1.density + rho2 = conditions2.density + a1 = conditions1.speed_of_sound + a2 = conditions2.speed_of_sound + mu1 = conditions1.dynamic_viscosity + mu2 = conditions2.dynamic_viscosity mach_number = .729 #Create Energy Network diff --git a/tut_mission_B737.py b/tut_mission_B737.py index 5f1441c..93e8fe7 100644 --- a/tut_mission_B737.py +++ b/tut_mission_B737.py @@ -1,7 +1,7 @@ # tut_mission_B737.py # # Created: Aug 2014, SUAVE Team -# Modified: Jun 2015, SUAVE Team +# Modified: Jan 2017, SUAVE Team """ setup file for a mission with a 737 """ @@ -20,7 +20,7 @@ import copy, time from SUAVE.Core import ( -Data, Container, Data_Exception, Data_Warning, +Data, Container ) from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing @@ -187,7 +187,7 @@ def vehicle_setup(): # ------------------------------------------------------------------ vehicle = SUAVE.Vehicle() - vehicle.tag = 'Boeing_737800' + vehicle.tag = 'Boeing_737_800' # ------------------------------------------------------------------ @@ -218,25 +218,26 @@ def vehicle_setup(): wing = SUAVE.Components.Wings.Main_Wing() wing.tag = 'main_wing' - wing.aspect_ratio = 10.18 - wing.sweep = 25 * Units.deg - wing.thickness_to_chord = 0.1 - wing.taper = 0.16 + wing.aspect_ratio = 10.18 # Not set + wing.thickness_to_chord = 0.1 # Not set + wing.taper = 0.782/7.7760 wing.span_efficiency = 0.9 - wing.spans.projected = 35.66 + wing.spans.projected = 34.32 - wing.chords.root = 6.81 - wing.chords.tip = 1.09 - wing.chords.mean_aerodynamic = 4.235 + wing.chords.root = 7.760 * Units.meter + wing.chords.tip = 0.782 * Units.meter + wing.chords.mean_aerodynamic = 4.235 * Units.meter - wing.areas.reference = 124.862 + wing.areas.reference = 124.862 # Not set + wing.sweeps.quarter_chord = 25. * Units.degrees wing.twists.root = 4.0 * Units.degrees - wing.twists.tip = -4.0 * Units.degrees + wing.twists.tip = 0.0 * Units.degrees + wing.dihedral = 2.5 * Units.degrees - wing.origin = [20,0,0] - wing.aerodynamic_center = [3,0,0] + wing.origin = [13.61,0,-1.27] + wing.aerodynamic_center = [0,0,0] wing.vertical = False wing.symmetric = True @@ -255,30 +256,32 @@ def vehicle_setup(): wing = SUAVE.Components.Wings.Wing() wing.tag = 'horizontal_stabilizer' - wing.aspect_ratio = 6.16 - wing.sweep = 30 * Units.deg - wing.thickness_to_chord = 0.08 - wing.taper = 0.4 + wing.aspect_ratio = 6.16 # Not set + wing.thickness_to_chord = 0.08 # Not set + wing.taper = 0.955/4.70 wing.span_efficiency = 0.9 - wing.spans.projected = 14.146 + wing.spans.projected = 14.2 + + wing.chords.root = 4.70 + wing.chords.tip = 0.955 + wing.chords.mean_aerodynamic = 2.5 - wing.chords.root = 3.28 - wing.chords.tip = 1.31 - wing.chords.mean_aerodynamic = 8.0 + wing.areas.reference = 42.65 - wing.areas.reference = 32.488 + wing.twists.root = 0.0 * Units.degrees # Not set + wing.twists.tip = 0.0 * Units.degrees # Not set - wing.twists.root = 3.0 * Units.degrees - wing.twists.tip = 3.0 * Units.degrees + wing.sweeps.quarter_chord = 40.0 * Units.degrees - wing.origin = [50,0,0] - wing.aerodynamic_center = [2,0,0] + wing.origin = [32.83,0,1.14] + wing.aerodynamic_center = [0,0,0] + wing.dihedral = 8.63 * Units.degrees wing.vertical = False wing.symmetric = True - wing.dynamic_pressure_ratio = 0.9 + wing.dynamic_pressure_ratio = 0.9 # add to vehicle vehicle.append_component(wing) @@ -292,24 +295,24 @@ def vehicle_setup(): wing.tag = 'vertical_stabilizer' wing.aspect_ratio = 1.91 - wing.sweep = 25 * Units.deg + wing.sweep = 25. * Units.deg wing.thickness_to_chord = 0.08 wing.taper = 0.25 wing.span_efficiency = 0.9 - wing.spans.projected = 7.877 + wing.spans.projected = 7.77 - wing.chords.root = 6.60 - wing.chords.tip = 1.65 - wing.chords.mean_aerodynamic = 8.0 + wing.chords.root = 8.19 + wing.chords.tip = 0.95 + wing.chords.mean_aerodynamic = 4.0 - wing.areas.reference = 32.488 + wing.areas.reference = 27.316 wing.twists.root = 0.0 * Units.degrees wing.twists.tip = 0.0 * Units.degrees - wing.origin = [50,0,0] - wing.aerodynamic_center = [2,0,0] + wing.origin = [28.79,0,1.54] + wing.aerodynamic_center = [0,0,0] wing.vertical = True wing.symmetric = False @@ -331,31 +334,32 @@ def vehicle_setup(): fuselage.seats_abreast = 6 fuselage.seat_pitch = 1 - fuselage.fineness.nose = 1.6 - fuselage.fineness.tail = 2. + fuselage.fineness.nose = 1.57 + fuselage.fineness.tail = 3.2 - fuselage.lengths.nose = 6.4 - fuselage.lengths.tail = 8.0 + fuselage.lengths.nose = 8.0 + fuselage.lengths.tail = 12. fuselage.lengths.cabin = 28.85 fuselage.lengths.total = 38.02 fuselage.lengths.fore_space = 6. fuselage.lengths.aft_space = 5. - fuselage.width = 3.74 + fuselage.width = 3.76 - fuselage.heights.maximum = 3.74 - fuselage.heights.at_quarter_length = 3.74 - fuselage.heights.at_three_quarters_length = 3.74 - fuselage.heights.at_wing_root_quarter_chord = 3.74 + fuselage.heights.maximum = 3.76 + fuselage.heights.at_quarter_length = 3.76 + fuselage.heights.at_three_quarters_length = 3.65 + fuselage.heights.at_wing_root_quarter_chord = 3.76 fuselage.areas.side_projected = 142.1948 fuselage.areas.wetted = 446.718 fuselage.areas.front_projected = 12.57 - fuselage.effective_diameter = 3.74 #4.0 + fuselage.effective_diameter = 3.76 fuselage.differential_pressure = 5.0e4 * Units.pascal # Maximum differential pressure + # add to vehicle vehicle.append_component(fuselage) @@ -371,8 +375,9 @@ def vehicle_setup(): # setup turbofan.number_of_engines = 2.0 turbofan.bypass_ratio = 5.4 - turbofan.engine_length = 2.71 - turbofan.nacelle_diameter = 2.05 + turbofan.engine_length = 4.1 + turbofan.nacelle_diameter = 0.85 + turbofan.origin = [[13.72, 4.86,-1.9],[13.72, -4.86,-1.9]] # working fluid turbofan.working_fluid = SUAVE.Attributes.Gases.Air() @@ -565,6 +570,7 @@ def vehicle_setup(): return vehicle + # ---------------------------------------------------------------------- # Define the Configurations # --------------------------------------------------------------------- @@ -664,7 +670,7 @@ def plot_mission(results,line_style='bo-'): axes = fig.add_subplot(2,1,2) axes.plot( time , eta , line_style ) axes.set_xlabel('Time (min)',axis_font) - axes.set_ylabel('eta',axis_font) + axes.set_ylabel('Throttle',axis_font) axes.grid(True) plt.savefig("B737_engine.pdf") diff --git a/tut_payload_range.py b/tut_payload_range.py index 674e0af..1423cd8 100644 --- a/tut_payload_range.py +++ b/tut_payload_range.py @@ -198,7 +198,7 @@ def vehicle_setup(): wing.tag = 'main_wing' wing.aspect_ratio = 8.4 - wing.sweep = 22.0 * Units.deg + wing.sweeps.quarter_chord = 22.0 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.16 wing.span_efficiency = 1.0 @@ -236,7 +236,7 @@ def vehicle_setup(): wing.tag = 'horizontal_stabilizer' wing.aspect_ratio = 5.5 - wing.sweep = 34.5 * Units.deg + wing.sweeps.quarter_chord = 34.5 * Units.deg wing.thickness_to_chord = 0.11 wing.taper = 0.11 wing.span_efficiency = 0.9 @@ -274,7 +274,7 @@ def vehicle_setup(): wing.tag = 'vertical_stabilizer' wing.aspect_ratio = 1.7 # - wing.sweep = 25 * Units.deg + wing.sweeps.quarter_chord = 25 * Units.deg wing.thickness_to_chord = 0.12 wing.taper = 0.10 wing.span_efficiency = 0.9 diff --git a/tut_solar_uav.py b/tut_solar_uav.py index 5462ceb..e12ebf6 100644 --- a/tut_solar_uav.py +++ b/tut_solar_uav.py @@ -1,8 +1,7 @@ # tut_solar_UAV.py # # Created: Jul 2014, E. Botero -# Modified: Jun 2015, E. Botero -# Apr 2016, E. Botero +# Modified: Jan 2017, E. Botero #---------------------------------------------------------------------- # Imports @@ -11,7 +10,7 @@ from SUAVE.Core import Units from SUAVE.Core import ( -Data, Container, Data_Exception, Data_Warning, +Data, Container ) import numpy as np @@ -107,7 +106,7 @@ def vehicle_setup(): wing.areas.reference = vehicle.reference_area wing.spans.projected = 40.0 wing.aspect_ratio = (wing.spans.projected**2)/wing.areas.reference - wing.sweep = 0.0 * Units.deg + wing.sweeps.quarter_chord = 0.0 * Units.deg wing.symmetric = True wing.thickness_to_chord = 0.12 wing.taper = 1.0 @@ -138,18 +137,18 @@ def vehicle_setup(): wing = SUAVE.Components.Wings.Wing() wing.tag = 'horizontal_stabilizer' - wing.aspect_ratio = 20. - wing.sweep = 0 * Units.deg - wing.thickness_to_chord = 0.12 - wing.taper = 1.0 - wing.span_efficiency = 0.95 - wing.areas.reference = vehicle.reference_area * .15 - wing.areas.wetted = 2.0 * wing.areas.reference - wing.areas.exposed = 0.8 * wing.areas.wetted - wing.areas.affected = 0.6 * wing.areas.wetted - wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) - wing.twists.root = 0.0 * Units.degrees - wing.twists.tip = 0.0 * Units.degrees + wing.aspect_ratio = 20. + wing.sweeps.quarter_chord = 0 * Units.deg + wing.thickness_to_chord = 0.12 + wing.taper = 1.0 + wing.span_efficiency = 0.95 + wing.areas.reference = vehicle.reference_area * .15 + wing.areas.wetted = 2.0 * wing.areas.reference + wing.areas.exposed = 0.8 * wing.areas.wetted + wing.areas.affected = 0.6 * wing.areas.wetted + wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) + wing.twists.root = 0.0 * Units.degrees + wing.twists.tip = 0.0 * Units.degrees wing.vertical = False wing.symmetric = True @@ -172,13 +171,13 @@ def vehicle_setup(): wing.tag = 'vertical_stabilizer' - wing.aspect_ratio = 20. - wing.sweep = 0 * Units.deg - wing.thickness_to_chord = 0.12 - wing.taper = 1.0 - wing.span_efficiency = 0.97 - wing.areas.reference = vehicle.reference_area * 0.1 - wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) + wing.aspect_ratio = 20. + wing.sweeps.quarter_chord = 0 * Units.deg + wing.thickness_to_chord = 0.12 + wing.taper = 1.0 + wing.span_efficiency = 0.97 + wing.areas.reference = vehicle.reference_area * 0.1 + wing.spans.projected = np.sqrt(wing.aspect_ratio*wing.areas.reference) wing.chords.root = wing.areas.reference/wing.spans.projected wing.chords.tip = wing.areas.reference/wing.spans.projected @@ -281,7 +280,7 @@ def vehicle_setup(): #Component 9 the system logic controller and MPPT logic = SUAVE.Components.Energy.Distributors.Solar_Logic() - logic.system_voltage = 100.0 + logic.system_voltage = 40.0 logic.MPPT_efficiency = 0.95 net.solar_logic = logic @@ -404,8 +403,12 @@ def mission_setup(analyses,vehicle): # base segment base_segment = Segments.Segment() + ones_row = base_segment.state.ones_row + base_segment.process.iterate.unknowns.network = vehicle.propulsors.network.unpack_unknowns + base_segment.process.iterate.residuals.network = vehicle.propulsors.network.residuals base_segment.process.iterate.initials.initialize_battery = SUAVE.Methods.Missions.Segments.Common.Energy.initialize_battery - base_segment.process.iterate.conditions.planet_position = SUAVE.Methods.skip + base_segment.state.unknowns.propeller_power_coefficient = vehicle.propulsors.network.propeller.prop_attributes.Cp * ones_row(1)/15. + base_segment.state.residuals.network = 0. * ones_row(1) # ------------------------------------------------------------------ # Cruise Segment: constant speed, constant altitude @@ -419,7 +422,7 @@ def mission_setup(analyses,vehicle): # segment attributes segment.state.numerics.number_control_points = 64 - segment.start_time = time.strptime("Tue, Jun 21 11:30:00 2015", "%a, %b %d %H:%M:%S %Y",) + segment.start_time = time.strptime("Tue, Jun 21 11:30:00 2017", "%a, %b %d %H:%M:%S %Y",) segment.altitude = 15.0 * Units.km segment.mach = 0.12 segment.distance = 3050.0 * Units.km @@ -499,12 +502,16 @@ def plot_mission(results): axes.plot( time , Lift , 'bo-' ) axes.set_xlabel('Time (min)') axes.set_ylabel('Lift (N)') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,2) axes.plot( time , Drag , 'bo-' ) axes.set_xlabel('Time (min)') axes.set_ylabel('Drag (N)') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,3) @@ -532,12 +539,16 @@ def plot_mission(results): axes.plot( time , CLift , 'bo-' ) axes.set_xlabel('Time (min)') axes.set_ylabel('CL') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,2) axes.plot( time , CDrag , 'bo-' ) axes.set_xlabel('Time (min)') axes.set_ylabel('CD') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,3) @@ -685,17 +696,23 @@ def plot_mission(results): axes = fig.add_subplot(3,1,1) axes.plot( time , aoa , 'bo-' ) axes.set_ylabel('Angle of Attack (deg)') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,2) axes.plot( time , altitude , 'bo-' ) axes.set_ylabel('Altitude (km)') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) axes = fig.add_subplot(3,1,3) axes.plot( time , mach, 'bo-' ) axes.set_xlabel('Time (min)') axes.set_ylabel('Mach Number (-)') + axes.get_yaxis().get_major_formatter().set_scientific(False) + axes.get_yaxis().get_major_formatter().set_useOffset(False) axes.grid(True) # ------------------------------------------------------------------ From b2fea76e6d5388be3bd5d32415db27982db62f26 Mon Sep 17 00:00:00 2001 From: Emilio Botero Date: Mon, 9 Jan 2017 14:59:10 -0800 Subject: [PATCH 5/9] incomplete BWB --- BWB_CFD/BWB.py | 940 ++++++++++++++++++++++++++++++++++++++++++ BWB_CFD/base_data.txt | 13 + 2 files changed, 953 insertions(+) create mode 100644 BWB_CFD/BWB.py create mode 100644 BWB_CFD/base_data.txt diff --git a/BWB_CFD/BWB.py b/BWB_CFD/BWB.py new file mode 100644 index 0000000..8642a32 --- /dev/null +++ b/BWB_CFD/BWB.py @@ -0,0 +1,940 @@ +# BWB.py +# +# Created: Jan 2017, E. Botero +# Modified: + +# ---------------------------------------------------------------------- +# Imports +# ---------------------------------------------------------------------- + +import SUAVE + +import numpy as np +import pylab as plt + +from SUAVE.Core import Data, Container, Units + +from SUAVE.Plugins.OpenVSP import write +from SUAVE.Plugins.OpenVSP.get_vsp_areas import get_vsp_areas + +from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing +from SUAVE.Methods.Geometry.Two_Dimensional.Cross_Section.Propulsion import compute_turbofan_geometry + +# ---------------------------------------------------------------------- +# Main +# ---------------------------------------------------------------------- + +def main(): + + configs, analyses = full_setup() + + simple_sizing(configs) + + configs.finalize() + analyses.finalize() + + # weight analysis + weights = analyses.configs.base.weights + + # mission analysis + mission = analyses.missions.base + results = mission.evaluate() + + # plt the old results + plot_mission(results) + + return + +# ---------------------------------------------------------------------- +# Analysis Setup +# ---------------------------------------------------------------------- + +def full_setup(): + + # vehicle data + vehicle = vehicle_setup() + configs = configs_setup(vehicle) + + # vehicle analyses + configs_analyses = analyses_setup(configs) + + # mission analyses + mission = mission_setup(configs_analyses) + missions_analyses = missions_setup(mission) + + analyses = SUAVE.Analyses.Analysis.Container() + analyses.configs = configs_analyses + analyses.missions = missions_analyses + + return configs, analyses + +# ---------------------------------------------------------------------- +# Define the Vehicle Analyses +# ---------------------------------------------------------------------- + +def analyses_setup(configs): + + analyses = SUAVE.Analyses.Analysis.Container() + + # build a base analysis for each config + for tag,config in configs.items(): + analysis = base_analysis(config) + analyses[tag] = analysis + + return analyses + +def base_analysis(vehicle): + + # ------------------------------------------------------------------ + # Initialize the Analyses + # ------------------------------------------------------------------ + analyses = SUAVE.Analyses.Vehicle() + + # ------------------------------------------------------------------ + # Basic Geometry Relations + sizing = SUAVE.Analyses.Sizing.Sizing() + sizing.features.vehicle = vehicle + analyses.append(sizing) + + # ------------------------------------------------------------------ + # Weights + weights = SUAVE.Analyses.Weights.Weights() + weights.vehicle = vehicle + analyses.append(weights) + + # ------------------------------------------------------------------ + # Aerodynamics Analysis + aerodynamics = SUAVE.Analyses.Aerodynamics.SU2_Euler() + aerodynamics.geometry = vehicle + + #aerodynamics.process.compute.lift.inviscid.settings.parallel = True + #aerodynamics.process.compute.lift.inviscid.settings.processors = 12 + + aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) + aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg + aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' + + aerodynamics.settings.drag_coefficient_increment = 0.0000 + analyses.append(aerodynamics) + + # ------------------------------------------------------------------ + # Energy + energy= SUAVE.Analyses.Energy.Energy() + energy.network = vehicle.propulsors + analyses.append(energy) + + # ------------------------------------------------------------------ + # Planet Analysis + planet = SUAVE.Analyses.Planets.Planet() + analyses.append(planet) + + # ------------------------------------------------------------------ + # Atmosphere Analysis + atmosphere = SUAVE.Analyses.Atmospheric.US_Standard_1976() + atmosphere.features.planet = planet.features + analyses.append(atmosphere) + + # done! + return analyses + +# ---------------------------------------------------------------------- +# Define the Vehicle +# ---------------------------------------------------------------------- + +def vehicle_setup(): + + # ------------------------------------------------------------------ + # Initialize the Vehicle + # ------------------------------------------------------------------ + + vehicle = SUAVE.Vehicle() + vehicle.tag = 'Boeing_BWB_450' + + + # ------------------------------------------------------------------ + # Vehicle-level Properties + # ------------------------------------------------------------------ + + # mass properties + vehicle.mass_properties.max_takeoff = 823000. * Units.lb + vehicle.mass_properties.takeoff = 823000. * Units.lb + vehicle.mass_properties.max_zero_fuel = 0.9 * vehicle.mass_properties.max_takeoff + vehicle.mass_properties.cargo = 00. * Units.kilogram + + # envelope properties + vehicle.envelope.ultimate_load = 2.5 + vehicle.envelope.limit_load = 1.5 + + # basic parameters + vehicle.reference_area = 15680. * Units.feet**2 + vehicle.passengers = 450. + vehicle.systems.control = "fully powered" + vehicle.systems.accessories = "medium range" + + + # ------------------------------------------------------------------ + # Main Wing + # ------------------------------------------------------------------ + + wing = SUAVE.Components.Wings.Main_Wing() + wing.tag = 'main_wing' + + wing.aspect_ratio = 289.**2 / (7840. * 2) + wing.thickness_to_chord = 0.15 + wing.taper = 0.0138 + wing.span_efficiency = 0.95 + + wing.spans.projected = 289.0 * Units.feet + + wing.chords.root = 145.0 * Units.feet + wing.chords.tip = 3.5 * Units.feet + wing.chords.mean_aerodynamic = 86. * Units.feet + + wing.areas.reference = 15680. * Units.feet**2 + wing.sweeps.quarter_chord = 33. * Units.degrees + + wing.twists.root = 0.0 * Units.degrees + wing.twists.tip = 0.0 * Units.degrees + wing.dihedral = 2.5 * Units.degrees + + wing.origin = [0.,0.,0] + wing.aerodynamic_center = [0,0,0] + + wing.vertical = False + wing.symmetric = True + wing.high_lift = True + + wing.dynamic_pressure_ratio = 1.0 + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_1' + segment.percent_span_location = 0.0 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 1. + segment.dihedral_outboard = 0. * Units.degrees + segment.sweeps.quarter_chord = 30.0 * Units.degrees + segment.thickness_to_chord = 0.165 + segment.vsp_mesh = Data() + segment.vsp_mesh.inner_radius = 4. + segment.vsp_mesh.outer_radius = 4. + segment.vsp_mesh.inner_length = .14 + segment.vsp_mesh.outer_length = .14 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_2' + segment.percent_span_location = 0.052 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.921 + segment.dihedral_outboard = 0. * Units.degrees + segment.sweeps.quarter_chord = 52.5 * Units.degrees + segment.thickness_to_chord = 0.167 + segment.vsp_mesh = Data() + segment.vsp_mesh.inner_radius = 4. + segment.vsp_mesh.outer_radius = 4. + segment.vsp_mesh.inner_length = .14 + segment.vsp_mesh.outer_length = .14 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_3' + segment.percent_span_location = 0.138 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.76 + segment.dihedral_outboard = 1.85 * Units.degrees + segment.sweeps.quarter_chord = 36.9 * Units.degrees + segment.thickness_to_chord = 0.171 + segment.vsp_mesh = Data() + segment.vsp_mesh.inner_radius = 4. + segment.vsp_mesh.outer_radius = 4. + segment.vsp_mesh.inner_length = .14 + segment.vsp_mesh.outer_length = .14 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_4' + segment.percent_span_location = 0.221 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.624 + segment.dihedral_outboard = 1.85 * Units.degrees + segment.sweeps.quarter_chord = 30.4 * Units.degrees + segment.thickness_to_chord = 0.175 + segment.vsp_mesh = Data() + segment.vsp_mesh.inner_radius = 4. + segment.vsp_mesh.outer_radius = 2.8 + segment.vsp_mesh.inner_length = .14 + segment.vsp_mesh.outer_length = .14 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_5' + segment.percent_span_location = 0.457 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.313 + segment.dihedral_outboard = 1.85 * Units.degrees + segment.sweeps.quarter_chord = 30.85 * Units.degrees + segment.thickness_to_chord = 0.118 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_6' + segment.percent_span_location = 0.568 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.197 + segment.dihedral_outboard = 1.85 * Units.degrees + segment.sweeps.quarter_chord = 34.3 * Units.degrees + segment.thickness_to_chord = 0.10 + wing.Segments.append(segment) + + segment = SUAVE.Components.Wings.Segment() + segment.tag = 'section_7' + segment.percent_span_location = 0.97 + segment.twist = 0. * Units.deg + segment.root_chord_percent = 0.086 + segment.dihedral_outboard = 73. * Units.degrees + segment.sweeps.quarter_chord = 55. * Units.degrees + segment.thickness_to_chord = 0.10 + wing.Segments.append(segment) + + # add to vehicle + vehicle.append_component(wing) + + # ------------------------------------------------------------------ + # Turbofan Network + # ------------------------------------------------------------------ + + #instantiate the gas turbine network + + turbofan = SUAVE.Components.Energy.Networks.Turbofan() + turbofan.tag = 'turbofan1' + + # setup + turbofan.number_of_engines = 3.0 + turbofan.bypass_ratio = 8.1 + turbofan.engine_length = 289. * Units.inches + turbofan.nacelle_diameter = 3.96 * Units.meters + #turbofan.cooling_ratio = 1.0 + turbofan.origin = [[133.0 *Units.feet, 25.0*Units.feet, 6.5*Units.feet],[145.0 *Units.feet, 0.0*Units.feet, 6.5*Units.feet],[133.0 *Units.feet, -25.0*Units.feet, 6.5*Units.feet]] + + # working fluid + turbofan.working_fluid = SUAVE.Attributes.Gases.Air() + + # ------------------------------------------------------------------ + # Component 1 - Ram + + # to convert freestream static to stagnation quantities + + # instantiate + ram = SUAVE.Components.Energy.Converters.Ram() + ram.tag = 'ram' + + # add to the network + turbofan.append(ram) + + # ------------------------------------------------------------------ + # Component 2 - Inlet Nozzle + + # instantiate + inlet_nozzle = SUAVE.Components.Energy.Converters.Compression_Nozzle() + inlet_nozzle.tag = 'inlet_nozzle' + + # setup + inlet_nozzle.polytropic_efficiency = 1.0 + inlet_nozzle.pressure_ratio = 1.0 + + # add to network + turbofan.append(inlet_nozzle) + + # ------------------------------------------------------------------ + # Component 3 - Low Pressure Compressor + + # instantiate + compressor = SUAVE.Components.Energy.Converters.Compressor() + compressor.tag = 'low_pressure_compressor' + + # setup + compressor.polytropic_efficiency = 0.91 + compressor.pressure_ratio = 1.1 + + # add to network + turbofan.append(compressor) + + # ------------------------------------------------------------------ + # Component 4 - High Pressure Compressor + + # instantiate + compressor = SUAVE.Components.Energy.Converters.Compressor() + compressor.tag = 'high_pressure_compressor' + + # setup + compressor.polytropic_efficiency = 0.91 + compressor.pressure_ratio = 23.0 + #compressor.hub_to_tip_ratio = 0.325 + + # add to network + turbofan.append(compressor) + + # ------------------------------------------------------------------ + # Component 5 - Low Pressure Turbine + + # instantiate + turbine = SUAVE.Components.Energy.Converters.Turbine() + turbine.tag='low_pressure_turbine' + + # setup + turbine.mechanical_efficiency = 0.99 + turbine.polytropic_efficiency = 0.93 + + # add to network + turbofan.append(turbine) + + # ------------------------------------------------------------------ + # Component 6 - High Pressure Turbine + + # instantiate + turbine = SUAVE.Components.Energy.Converters.Turbine() + turbine.tag='high_pressure_turbine' + + # setup + turbine.mechanical_efficiency = 0.99 + turbine.polytropic_efficiency = 0.93 + + # add to network + turbofan.append(turbine) + + # ------------------------------------------------------------------ + # Component 7 - Combustor + + # instantiate + combustor = SUAVE.Components.Energy.Converters.Combustor() + combustor.tag = 'combustor' + + # setup + combustor.efficiency = 1.0 + combustor.alphac = 1.0 + combustor.turbine_inlet_temperature = 1592. * Units.kelvin + combustor.pressure_ratio = 0.95 + combustor.fuel_data = SUAVE.Attributes.Propellants.Jet_A() + + # add to network + turbofan.append(combustor) + + # ------------------------------------------------------------------ + # Component 8 - Core Nozzle + + # instantiate + nozzle = SUAVE.Components.Energy.Converters.Expansion_Nozzle() + nozzle.tag = 'core_nozzle' + + # setup + nozzle.polytropic_efficiency = 0.95 + nozzle.pressure_ratio = 0.99 + + # add to network + turbofan.append(nozzle) + + # ------------------------------------------------------------------ + # Component 9 - Fan Nozzle + + # instantiate + nozzle = SUAVE.Components.Energy.Converters.Expansion_Nozzle() + nozzle.tag = 'fan_nozzle' + + # setup + nozzle.polytropic_efficiency = 0.95 + nozzle.pressure_ratio = 0.99 + + # add to network + turbofan.append(nozzle) + + # ------------------------------------------------------------------ + # Component 10 - Fan + + # instantiate + fan = SUAVE.Components.Energy.Converters.Fan() + fan.tag = 'fan' + + # setup + fan.polytropic_efficiency = 0.93 + fan.pressure_ratio = 1.58 + #fan.hub_to_tip_ratio = 0.325 + + # add to network + turbofan.append(fan) + + # ------------------------------------------------------------------ + #Component 10 : thrust (to compute the thrust) + thrust = SUAVE.Components.Energy.Processes.Thrust() + thrust.tag ='compute_thrust' + + #total design thrust (includes all the engines) + thrust.total_design = 3.0*512000 * Units.N + thrust.bypass_ratio = 8.4 + + #design sizing conditions + altitude = 0. * Units.km + mach_number = 0.01 + isa_deviation = 0. + + # add to network + turbofan.thrust = thrust + + #size the turbofan + turbofan_sizing(turbofan,mach_number,altitude) + + #computing the engine length and diameter + compute_turbofan_geometry(turbofan,None) + + vehicle.append_component(turbofan) + + + # ------------------------------------------------------------------ + # Vehicle Definition Complete + # ------------------------------------------------------------------ + + return vehicle + + +# ---------------------------------------------------------------------- +# Define the Configurations +# --------------------------------------------------------------------- + +def configs_setup(vehicle): + + # ------------------------------------------------------------------ + # Initialize Configurations + # ------------------------------------------------------------------ + + configs = SUAVE.Components.Configs.Config.Container() + + base_config = SUAVE.Components.Configs.Config(vehicle) + base_config.tag = 'base' + configs.append(base_config) + + write(vehicle,base_config.tag) + + + # done! + return configs + +# ---------------------------------------------------------------------- +# Sizing for the Vehicle Configs +# ---------------------------------------------------------------------- + +# ---------------------------------------------------------------------- +# Plot Mission +# ---------------------------------------------------------------------- + +def plot_mission(results,line_style='bo-'): + + axis_font = {'fontname':'Arial', 'size':'14'} + + # ------------------------------------------------------------------ + # Aerodynamics + # ------------------------------------------------------------------ + + + fig = plt.figure("Aerodynamic Forces",figsize=(8,6)) + 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] / Units.lbf + Thrust = segment.conditions.frames.body.thrust_force_vector[:,0] / Units.lbf + eta = segment.conditions.propulsion.throttle[:,0] + mdot = segment.conditions.weights.vehicle_mass_rate[:,0] + thrust = segment.conditions.frames.body.thrust_force_vector[:,0] + sfc = 3600. * mdot / 0.1019715 / thrust + + + axes = fig.add_subplot(2,1,1) + axes.plot( time , Thrust , line_style ) + axes.set_ylabel('Thrust (lbf)',axis_font) + axes.grid(True) + + axes = fig.add_subplot(2,1,2) + axes.plot( time , eta , line_style ) + axes.set_xlabel('Time (min)',axis_font) + axes.set_ylabel('Throttle',axis_font) + axes.grid(True) + + + + # ------------------------------------------------------------------ + # Aerodynamics 2 + # ------------------------------------------------------------------ + fig = plt.figure("Aerodynamic Coefficients",figsize=(8,10)) + 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] + aoa = segment.conditions.aerodynamics.angle_of_attack[:,0] / Units.deg + l_d = CLift/CDrag + + + axes = fig.add_subplot(3,1,1) + axes.plot( time , CLift , line_style ) + axes.set_ylabel('Lift Coefficient',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,2) + axes.plot( time , l_d , line_style ) + axes.set_ylabel('L/D',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,3) + axes.plot( time , aoa , 'ro-' ) + axes.set_xlabel('Time (min)',axis_font) + axes.set_ylabel('AOA (deg)',axis_font) + axes.grid(True) + + # ------------------------------------------------------------------ + # Aerodynamics 2 + # ------------------------------------------------------------------ + fig = plt.figure("Drag Components",figsize=(8,10)) + 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 parasite' ) + axes.plot( time , cdi , 'bo-', label='CD induced' ) + axes.plot( time , cdc , 'go-', label='CD compressibility' ) + axes.plot( time , cdm , 'yo-', label='CD miscellaneous' ) + axes.plot( time , cd , 'ro-', label='CD total' ) + 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) + + # ------------------------------------------------------------------ + # Altitude, sfc, vehicle weight + # ------------------------------------------------------------------ + + fig = plt.figure("Altitude_sfc_weight",figsize=(8,10)) + 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] + aoa = segment.conditions.aerodynamics.angle_of_attack[:,0] / Units.deg + l_d = CLift/CDrag + mass = segment.conditions.weights.total_mass[:,0] / Units.lb + altitude = segment.conditions.freestream.altitude[:,0] / Units.ft + mdot = segment.conditions.weights.vehicle_mass_rate[:,0] + thrust = segment.conditions.frames.body.thrust_force_vector[:,0] + sfc = 3600. * mdot / 0.1019715 / thrust + + axes = fig.add_subplot(3,1,1) + axes.plot( time , altitude , line_style ) + axes.set_ylabel('Altitude (ft)',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,3) + axes.plot( time , sfc , line_style ) + axes.set_xlabel('Time (min)',axis_font) + axes.set_ylabel('sfc (lb/lbf-hr)',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,2) + axes.plot( time , mass , 'ro-' ) + axes.set_ylabel('Weight (lb)',axis_font) + axes.grid(True) + + # ------------------------------------------------------------------ + # Aerodynamics 2 + # ------------------------------------------------------------------ + fig = plt.figure("Velocities",figsize=(8,10)) + 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] / Units.lbf + Thrust = segment.conditions.frames.body.thrust_force_vector[:,0] / Units.lbf + eta = segment.conditions.propulsion.throttle[:,0] + mdot = segment.conditions.weights.vehicle_mass_rate[:,0] + thrust = segment.conditions.frames.body.thrust_force_vector[:,0] + sfc = 3600. * mdot / 0.1019715 / thrust + velocity = segment.conditions.freestream.velocity[:,0] + pressure = segment.conditions.freestream.pressure[:,0] + density = segment.conditions.freestream.density[:,0] + EAS = velocity * np.sqrt(density/1.225) + mach = segment.conditions.freestream.mach_number[:,0] + + + axes = fig.add_subplot(3,1,1) + axes.plot( time , velocity / Units.kts, line_style ) + axes.set_ylabel('velocity (kts)',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,2) + axes.plot( time , EAS / Units.kts, line_style ) + axes.set_xlabel('Time (min)',axis_font) + axes.set_ylabel('Equivalent Airspeed',axis_font) + axes.grid(True) + + axes = fig.add_subplot(3,1,3) + axes.plot( time , mach , line_style ) + axes.set_xlabel('Time (min)',axis_font) + axes.set_ylabel('Mach',axis_font) + axes.grid(True) + + return + +def simple_sizing(configs): + + base = configs.base + base.pull_base() + + # zero fuel weight + base.mass_properties.max_zero_fuel = 0.9 * base.mass_properties.max_takeoff + + ## wing areas + #for wing in base.wings: + #wing.areas.wetted = 2.0 * wing.areas.reference + #wing.areas.exposed = 0.8 * wing.areas.wetted + #wing.areas.affected = 0.6 * wing.areas.wetted + + # Areas + wetted_areas = get_vsp_areas(base.tag) + + for wing in base.wings: + wing.areas.wetted = wetted_areas[wing.tag] + wing.areas.exposed = wetted_areas[wing.tag] + wing.areas.affected = 0.6 * wing.areas.wetted + + # diff the new data + base.store_diff() + + # done! + return + +# ---------------------------------------------------------------------- +# Define the Mission +# ---------------------------------------------------------------------- + +def mission_setup(analyses): + + # ------------------------------------------------------------------ + # Initialize the Mission + # ------------------------------------------------------------------ + + mission = SUAVE.Analyses.Mission.Sequential_Segments() + mission.tag = 'the_mission' + + #airport + airport = SUAVE.Attributes.Airports.Airport() + airport.altitude = 0.0 * Units.ft + airport.delta_isa = 0.0 + airport.atmosphere = SUAVE.Attributes.Atmospheres.Earth.US_Standard_1976() + mission.airport = airport + + # unpack Segments module + Segments = SUAVE.Analyses.Mission.Segments + + # base segment + base_segment = Segments.Segment() + + # ------------------------------------------------------------------ + # First Climb Segment: constant Mach, constant segment angle + # ------------------------------------------------------------------ + + segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "climb_1" + + segment.analyses.extend( analyses.base ) + + ones_row = segment.state.ones_row + segment.state.unknowns.body_angle = ones_row(1) * 3. * Units.deg + + segment.altitude_start = 0.0 * Units.km + segment.altitude_end = 3.0 * Units.km + segment.air_speed = 125.0 * Units['m/s'] + segment.climb_rate = 6.0 * Units['m/s'] + + # add to misison + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Second Climb Segment: constant Speed, constant segment angle + # ------------------------------------------------------------------ + + segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "climb_2" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 8.0 * Units.km + segment.air_speed = 190.0 * Units['m/s'] + segment.climb_rate = 6.0 * Units['m/s'] + + # add to mission + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Third Climb Segment: constant Mach, constant segment angle + # ------------------------------------------------------------------ + + segment = Segments.Climb.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "climb_3" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 35000 * Units.feet + segment.air_speed = 226.0 * Units['m/s'] + segment.climb_rate = 3.0 * Units['m/s'] + + # add to mission + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Cruise Segment: constant speed, constant altitude + # ------------------------------------------------------------------ + + segment = Segments.Cruise.Constant_Mach_Constant_Altitude(base_segment) + segment.tag = "cruise" + + segment.analyses.extend( analyses.base ) + + segment.mach = 0.78 + segment.distance = 6500 * Units.nautical_mile + + # add to mission + mission.append_segment(segment) + + +# ------------------------------------------------------------------ +# First Descent Segment: consant speed, constant segment rate +# ------------------------------------------------------------------ + + segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "descent_1" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 8.0 * Units.km + segment.air_speed = 220.0 * Units['m/s'] + segment.descent_rate = 4.5 * Units['m/s'] + + # add to mission + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Second Descent Segment: consant speed, constant segment rate + # ------------------------------------------------------------------ + + segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "descent_2" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 6.0 * Units.km + segment.air_speed = 195.0 * Units['m/s'] + segment.descent_rate = 5.0 * Units['m/s'] + + # add to mission + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Third Descent Segment: consant speed, constant segment rate + # ------------------------------------------------------------------ + + segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "descent_3" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 4.0 * Units.km + segment.air_speed = 170.0 * Units['m/s'] + segment.descent_rate = 5.0 * Units['m/s'] + + # add to mission + mission.append_segment(segment) + + + # ------------------------------------------------------------------ + # Fourth Descent Segment: consant speed, constant segment rate + # ------------------------------------------------------------------ + + segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "descent_4" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 2.0 * Units.km + segment.air_speed = 150.0 * Units['m/s'] + segment.descent_rate = 5.0 * Units['m/s'] + + + # add to mission + mission.append_segment(segment) + + + + # ------------------------------------------------------------------ + # Fifth Descent Segment: consant speed, constant segment rate + # ------------------------------------------------------------------ + + segment = Segments.Descent.Constant_Speed_Constant_Rate(base_segment) + segment.tag = "descent_5" + + segment.analyses.extend( analyses.base ) + + segment.altitude_end = 0.0 * Units.km + segment.air_speed = 145.0 * Units['m/s'] + segment.descent_rate = 3.0 * Units['m/s'] + + + # append to mission + mission.append_segment(segment) + + # ------------------------------------------------------------------ + # Mission definition complete + # ------------------------------------------------------------------ + + return mission + +def missions_setup(base_mission): + + # the mission container + missions = SUAVE.Analyses.Mission.Mission.Container() + + # ------------------------------------------------------------------ + # Base Mission + # ------------------------------------------------------------------ + + missions.base = base_mission + + + # done! + return missions + +if __name__ == '__main__': + main() + plt.show() + diff --git a/BWB_CFD/base_data.txt b/BWB_CFD/base_data.txt new file mode 100644 index 0000000..67fc169 --- /dev/null +++ b/BWB_CFD/base_data.txt @@ -0,0 +1,13 @@ +# AoA Mach CL CD +0.00000000 0.30000000 0.00357426 0.00198925 +0.00000000 0.50000000 0.00385438 0.00262971 +0.00000000 0.70000000 0.00471753 0.00444076 +0.00000000 0.85000000 0.00856885 0.01859320 +0.05235988 0.30000000 0.20620500 0.00821743 +0.05235988 0.50000000 0.21761550 0.01013710 +0.05235988 0.70000000 0.24444750 0.01578280 +0.05235988 0.85000000 0.29654400 0.05575920 +0.10471976 0.30000000 0.40600150 0.02727500 +0.10471976 0.50000000 0.42532150 0.03379330 +0.10471976 0.70000000 0.46278650 0.05568500 +0.10471976 0.85000000 0.51038000 0.13394200 From 5b01e3dff2834dc56edc81d70d77353446b6c7c9 Mon Sep 17 00:00:00 2001 From: Emilio Botero Date: Tue, 10 Jan 2017 15:31:44 -0800 Subject: [PATCH 6/9] updates to bwb --- BWB_CFD/BWB.py | 48 ++++++++++++++++++++++----------------------- tut_mission_B737.py | 6 +++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/BWB_CFD/BWB.py b/BWB_CFD/BWB.py index 8642a32..4bb1b11 100644 --- a/BWB_CFD/BWB.py +++ b/BWB_CFD/BWB.py @@ -14,8 +14,8 @@ from SUAVE.Core import Data, Container, Units -from SUAVE.Plugins.OpenVSP import write -from SUAVE.Plugins.OpenVSP.get_vsp_areas import get_vsp_areas +from SUAVE.Input_Output.OpenVSP import write +from SUAVE.Input_Output.OpenVSP.get_vsp_areas import get_vsp_areas from SUAVE.Methods.Propulsion.turbofan_sizing import turbofan_sizing from SUAVE.Methods.Geometry.Two_Dimensional.Cross_Section.Propulsion import compute_turbofan_geometry @@ -112,7 +112,7 @@ def base_analysis(vehicle): aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg - aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' + #aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' aerodynamics.settings.drag_coefficient_increment = 0.0000 analyses.append(aerodynamics) @@ -212,13 +212,13 @@ def vehicle_setup(): segment.twist = 0. * Units.deg segment.root_chord_percent = 1. segment.dihedral_outboard = 0. * Units.degrees - segment.sweeps.quarter_chord = 30.0 * Units.degrees + segment.sweeps.quarter_chord = 40.0 * Units.degrees segment.thickness_to_chord = 0.165 - segment.vsp_mesh = Data() - segment.vsp_mesh.inner_radius = 4. - segment.vsp_mesh.outer_radius = 4. - segment.vsp_mesh.inner_length = .14 - segment.vsp_mesh.outer_length = .14 + #segment.vsp_mesh = Data() + #segment.vsp_mesh.inner_radius = 4. + #segment.vsp_mesh.outer_radius = 4. + #segment.vsp_mesh.inner_length = .14 + #segment.vsp_mesh.outer_length = .14 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -229,11 +229,11 @@ def vehicle_setup(): segment.dihedral_outboard = 0. * Units.degrees segment.sweeps.quarter_chord = 52.5 * Units.degrees segment.thickness_to_chord = 0.167 - segment.vsp_mesh = Data() - segment.vsp_mesh.inner_radius = 4. - segment.vsp_mesh.outer_radius = 4. - segment.vsp_mesh.inner_length = .14 - segment.vsp_mesh.outer_length = .14 + #segment.vsp_mesh = Data() + #segment.vsp_mesh.inner_radius = 4. + #segment.vsp_mesh.outer_radius = 4. + #segment.vsp_mesh.inner_length = .14 + #segment.vsp_mesh.outer_length = .14 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -244,11 +244,11 @@ def vehicle_setup(): segment.dihedral_outboard = 1.85 * Units.degrees segment.sweeps.quarter_chord = 36.9 * Units.degrees segment.thickness_to_chord = 0.171 - segment.vsp_mesh = Data() - segment.vsp_mesh.inner_radius = 4. - segment.vsp_mesh.outer_radius = 4. - segment.vsp_mesh.inner_length = .14 - segment.vsp_mesh.outer_length = .14 + #segment.vsp_mesh = Data() + #segment.vsp_mesh.inner_radius = 4. + #segment.vsp_mesh.outer_radius = 4. + #segment.vsp_mesh.inner_length = .14 + #segment.vsp_mesh.outer_length = .14 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -259,11 +259,11 @@ def vehicle_setup(): segment.dihedral_outboard = 1.85 * Units.degrees segment.sweeps.quarter_chord = 30.4 * Units.degrees segment.thickness_to_chord = 0.175 - segment.vsp_mesh = Data() - segment.vsp_mesh.inner_radius = 4. - segment.vsp_mesh.outer_radius = 2.8 - segment.vsp_mesh.inner_length = .14 - segment.vsp_mesh.outer_length = .14 + #segment.vsp_mesh = Data() + #segment.vsp_mesh.inner_radius = 4. + #segment.vsp_mesh.outer_radius = 2.8 + #segment.vsp_mesh.inner_length = .14 + #segment.vsp_mesh.outer_length = .14 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() diff --git a/tut_mission_B737.py b/tut_mission_B737.py index 93e8fe7..89ea5fa 100644 --- a/tut_mission_B737.py +++ b/tut_mission_B737.py @@ -220,7 +220,7 @@ def vehicle_setup(): wing.aspect_ratio = 10.18 # Not set wing.thickness_to_chord = 0.1 # Not set - wing.taper = 0.782/7.7760 + wing.taper = 0.1 wing.span_efficiency = 0.9 wing.spans.projected = 34.32 @@ -258,7 +258,7 @@ def vehicle_setup(): wing.aspect_ratio = 6.16 # Not set wing.thickness_to_chord = 0.08 # Not set - wing.taper = 0.955/4.70 + wing.taper = 0.2 wing.span_efficiency = 0.9 wing.spans.projected = 14.2 @@ -295,7 +295,7 @@ def vehicle_setup(): wing.tag = 'vertical_stabilizer' wing.aspect_ratio = 1.91 - wing.sweep = 25. * Units.deg + wing.sweep.quarter_chord = 25. * Units.deg wing.thickness_to_chord = 0.08 wing.taper = 0.25 wing.span_efficiency = 0.9 From 272442b181119897a2b97ea472059932be8eb356 Mon Sep 17 00:00:00 2001 From: Tim MacDonald Date: Tue, 10 Jan 2017 17:04:12 -0800 Subject: [PATCH 7/9] mesh working --- BWB_CFD/BWB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BWB_CFD/BWB.py b/BWB_CFD/BWB.py index 4bb1b11..a748c28 100644 --- a/BWB_CFD/BWB.py +++ b/BWB_CFD/BWB.py @@ -112,7 +112,7 @@ def base_analysis(vehicle): aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg - #aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' + aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' aerodynamics.settings.drag_coefficient_increment = 0.0000 analyses.append(aerodynamics) @@ -212,7 +212,7 @@ def vehicle_setup(): segment.twist = 0. * Units.deg segment.root_chord_percent = 1. segment.dihedral_outboard = 0. * Units.degrees - segment.sweeps.quarter_chord = 40.0 * Units.degrees + segment.sweeps.quarter_chord = 30.0 * Units.degrees segment.thickness_to_chord = 0.165 #segment.vsp_mesh = Data() #segment.vsp_mesh.inner_radius = 4. From d90d41e57c0c61cbc924db33bed81a625e1c1eba Mon Sep 17 00:00:00 2001 From: timdmacdo Date: Tue, 10 Jan 2017 17:18:36 -0800 Subject: [PATCH 8/9] moved vsp mesh settings --- BWB_CFD/BWB.py | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/BWB_CFD/BWB.py b/BWB_CFD/BWB.py index a748c28..c1b7463 100644 --- a/BWB_CFD/BWB.py +++ b/BWB_CFD/BWB.py @@ -106,13 +106,37 @@ def base_analysis(vehicle): # Aerodynamics Analysis aerodynamics = SUAVE.Analyses.Aerodynamics.SU2_Euler() aerodynamics.geometry = vehicle - + + aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh = Data() + aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.inner_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.outer_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.inner_length = .14 + aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.outer_length = .14 + + aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh = Data() + aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.inner_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.outer_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.inner_length = .14 + aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.outer_length = .14 + + aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh = Data() + aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.inner_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.outer_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.inner_length = .14 + aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.outer_length = .14 + + aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh = Data() + aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.inner_radius = 4. + aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.outer_radius = 2.8 + aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.inner_length = .14 + aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.outer_length = .14 + #aerodynamics.process.compute.lift.inviscid.settings.parallel = True #aerodynamics.process.compute.lift.inviscid.settings.processors = 12 aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg - aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' + #aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' aerodynamics.settings.drag_coefficient_increment = 0.0000 analyses.append(aerodynamics) @@ -213,12 +237,7 @@ def vehicle_setup(): segment.root_chord_percent = 1. segment.dihedral_outboard = 0. * Units.degrees segment.sweeps.quarter_chord = 30.0 * Units.degrees - segment.thickness_to_chord = 0.165 - #segment.vsp_mesh = Data() - #segment.vsp_mesh.inner_radius = 4. - #segment.vsp_mesh.outer_radius = 4. - #segment.vsp_mesh.inner_length = .14 - #segment.vsp_mesh.outer_length = .14 + segment.thickness_to_chord = 0.165 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -228,12 +247,7 @@ def vehicle_setup(): segment.root_chord_percent = 0.921 segment.dihedral_outboard = 0. * Units.degrees segment.sweeps.quarter_chord = 52.5 * Units.degrees - segment.thickness_to_chord = 0.167 - #segment.vsp_mesh = Data() - #segment.vsp_mesh.inner_radius = 4. - #segment.vsp_mesh.outer_radius = 4. - #segment.vsp_mesh.inner_length = .14 - #segment.vsp_mesh.outer_length = .14 + segment.thickness_to_chord = 0.167 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -243,12 +257,7 @@ def vehicle_setup(): segment.root_chord_percent = 0.76 segment.dihedral_outboard = 1.85 * Units.degrees segment.sweeps.quarter_chord = 36.9 * Units.degrees - segment.thickness_to_chord = 0.171 - #segment.vsp_mesh = Data() - #segment.vsp_mesh.inner_radius = 4. - #segment.vsp_mesh.outer_radius = 4. - #segment.vsp_mesh.inner_length = .14 - #segment.vsp_mesh.outer_length = .14 + segment.thickness_to_chord = 0.171 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() @@ -259,11 +268,6 @@ def vehicle_setup(): segment.dihedral_outboard = 1.85 * Units.degrees segment.sweeps.quarter_chord = 30.4 * Units.degrees segment.thickness_to_chord = 0.175 - #segment.vsp_mesh = Data() - #segment.vsp_mesh.inner_radius = 4. - #segment.vsp_mesh.outer_radius = 2.8 - #segment.vsp_mesh.inner_length = .14 - #segment.vsp_mesh.outer_length = .14 wing.Segments.append(segment) segment = SUAVE.Components.Wings.Segment() From 4232b424478a169f63a910963a44d6f7c0a0ef37 Mon Sep 17 00:00:00 2001 From: Emilio Botero Date: Wed, 11 Jan 2017 07:57:57 -0800 Subject: [PATCH 9/9] clean up bwb --- BWB_CFD/BWB.py | 59 +++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/BWB_CFD/BWB.py b/BWB_CFD/BWB.py index c1b7463..abfe7f1 100644 --- a/BWB_CFD/BWB.py +++ b/BWB_CFD/BWB.py @@ -107,38 +107,39 @@ def base_analysis(vehicle): aerodynamics = SUAVE.Analyses.Aerodynamics.SU2_Euler() aerodynamics.geometry = vehicle - aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh = Data() - aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.inner_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.outer_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.inner_length = .14 - aerodynamics.geometry.wings.main_wing.Segments.section_1.vsp_mesh.outer_length = .14 - - aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh = Data() - aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.inner_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.outer_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.inner_length = .14 - aerodynamics.geometry.wings.main_wing.Segments.section_2.vsp_mesh.outer_length = .14 - - aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh = Data() - aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.inner_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.outer_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.inner_length = .14 - aerodynamics.geometry.wings.main_wing.Segments.section_3.vsp_mesh.outer_length = .14 - - aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh = Data() - aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.inner_radius = 4. - aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.outer_radius = 2.8 - aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.inner_length = .14 - aerodynamics.geometry.wings.main_wing.Segments.section_4.vsp_mesh.outer_length = .14 - #aerodynamics.process.compute.lift.inviscid.settings.parallel = True - #aerodynamics.process.compute.lift.inviscid.settings.processors = 12 - - aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) - aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg + #aerodynamics.process.compute.lift.inviscid.settings.processors = 12 #aerodynamics.process.compute.lift.inviscid.training_file = 'base_data.txt' - aerodynamics.settings.drag_coefficient_increment = 0.0000 + + aerodynamics.process.compute.lift.inviscid.training.Mach = np.array([.3, .5, .7, .85]) + aerodynamics.process.compute.lift.inviscid.training.angle_of_attack = np.array([0.,3.,6.]) * Units.deg + + wing_segments = vehicle.wings.main_wing.Segments + wing_segments.section_1.vsp_mesh = Data() + wing_segments.section_1.vsp_mesh.inner_radius = 4. + wing_segments.section_1.vsp_mesh.outer_radius = 4. + wing_segments.section_1.vsp_mesh.inner_length = .14 + wing_segments.section_1.vsp_mesh.outer_length = .14 + + wing_segments.section_2.vsp_mesh = Data() + wing_segments.section_2.vsp_mesh.inner_radius = 4. + wing_segments.section_2.vsp_mesh.outer_radius = 4. + wing_segments.section_2.vsp_mesh.inner_length = .14 + wing_segments.section_2.vsp_mesh.outer_length = .14 + + wing_segments.section_3.vsp_mesh = Data() + wing_segments.section_3.vsp_mesh.inner_radius = 4. + wing_segments.section_3.vsp_mesh.outer_radius = 4. + wing_segments.section_3.vsp_mesh.inner_length = .14 + wing_segments.section_3.vsp_mesh.outer_length = .14 + + wing_segments.section_4.vsp_mesh = Data() + wing_segments.section_4.vsp_mesh.inner_radius = 4. + wing_segments.section_4.vsp_mesh.outer_radius = 2.8 + wing_segments.section_4.vsp_mesh.inner_length = .14 + wing_segments.section_4.vsp_mesh.outer_length = .14 + analyses.append(aerodynamics) # ------------------------------------------------------------------