1717import matplotlib .pyplot as plt
1818from SUAVE .Optimization import Nexus , carpet_plot
1919import SUAVE .Optimization .Package_Setups .scipy_setup as scipy_setup
20+ import VyPy
21+ import pyOpt
2022# ----------------------------------------------------------------------
2123# Run the whole thing
2224# ----------------------------------------------------------------------
2325def main ():
2426 problem = setup ()
25-
26- #output = problem.objective() #uncomment this line when using the default inputs
2727
28- '''
2928 #uncomment these lines when you want to start an optimization problem from a different initial guess
29+ '''
3030 inputs = [1.28, 1.38]
3131 scaling = problem.optimization_problem.inputs[:,3] #have to rescale inputs to start problem from here
3232 scaled_inputs = np.multiply(inputs,scaling)
3333 problem.optimization_problem.inputs[:,1] = scaled_inputs
3434 '''
35- #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
3635
37-
36+ #optimize
37+ #output = scipy_setup.SciPy_Solve(problem,solver='SLSQP')
38+ #print output
39+
3840
3941 #variable_sweep(problem) #uncomment this to view some contours of the problem
4042 print 'fuel burn=' , problem .summary .base_mission_fuelburn
4143 print 'fuel margin=' , problem .all_constraints ()
4244
43- Plot_Mission .plot_mission (problem . results )
45+ # Plot_Mission.plot_mission(problem)
4446
4547 return
4648
@@ -101,10 +103,24 @@ def setup():
101103 [ 'fuel_burn' , 'summary.base_mission_fuelburn' ],
102104 [ 'design_range_fuel_margin' , 'summary.max_zero_fuel_margin' ],
103105 ]
106+ '''
107+ #TASOPT imports
108+ from mission_B737_TASOPT import full_setup, mission_setup
109+
110+ configs, analyses = full_setup()
111+ nexus.vehicle_configurations = configs
112+ nexus.analyses = analyses
113+ nexus.mission = analyses.mission
114+ #nexus.mission = mission_setup(nexus.analyses)
115+ '''
116+
104117
105118 # -------------------------------------------------------------------
106119 # Vehicles
107120 # -------------------------------------------------------------------
121+
122+ #import Vehicle_TASOPT
123+ #nexus.vehicle_configurations = Vehicle_TASOPT.setup()
108124 nexus .vehicle_configurations = Vehicles .setup ()
109125
110126
@@ -119,7 +135,7 @@ def setup():
119135 # -------------------------------------------------------------------
120136 nexus .missions = Missions .setup (nexus .analyses )
121137
122-
138+
123139 # -------------------------------------------------------------------
124140 # Procedure
125141 # -------------------------------------------------------------------
@@ -129,11 +145,11 @@ def setup():
129145 # Summary
130146 # -------------------------------------------------------------------
131147 nexus .summary = Data ()
132-
148+ nexus . total_number_of_iterations = 0
133149 return nexus
134150
135151def variable_sweep (problem ):
136- number_of_points = 5
152+ number_of_points = 5
137153 outputs = carpet_plot (problem , number_of_points , 0 , 0 ) #run carpet plot, suppressing default plots
138154 inputs = outputs .inputs
139155 objective = outputs .objective
@@ -153,14 +169,23 @@ def variable_sweep(problem):
153169 plt .xlabel ('wing area (m^2)' )
154170 plt .ylabel ('cruise_altitude (km)' )
155171
156- '''
172+
173+ 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.
174+ 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. ]
175+
176+ 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.
177+
178+ 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. ]
179+
180+
181+
157182 #now plot optimization path (note that these data points were post-processed into a plottable format)
158- 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]
159- 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]
160- 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]
161- 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]
183+ # 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]
184+ #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]
185+ # 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]
186+ # 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]
162187
163-
188+ '''
164189 opt_1 = plt.plot(wing_1, alt_1, label='optimization path 1')
165190 init_1 = plt.plot(wing_1[0], alt_1[0], 'ko')
166191 final_1 = plt.plot(wing_1[-1], alt_1[-1], 'kx')
@@ -170,13 +195,13 @@ def variable_sweep(problem):
170195 final_2 = plt.plot(wing_2[-1], alt_2[-1], 'kx', label= 'final points')
171196 '''
172197 plt .legend (loc = 'upper left' )
173- plt .show ()
198+ plt .show (block = True )
174199
175200
176201
177202 return
178203
179-
204+
180205if __name__ == '__main__' :
181206 main ()
182207
0 commit comments