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, cmap='jet') cbar = plt.colorbar(CS) cbar.ax.set_ylabel('fuel burn (kg)') CS_const = plt.contour(inputs[0, :], inputs[1, :], constraints[0, :, :], cmap='jet') 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)') plt.show(block=True) return
def variable_sweep(problem, color_label, bar_label, xlabel, ylabel, title): 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, cmap='hot') cbar = plt.colorbar(CS) cbar.ax.set_ylabel(color_label) # cbar.ax.set_ylabel('fuel burn (kg)') if bar_label != "unknown": 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') cbar.ax.set_ylabel(bar_label) # plt.xlabel('wing area (m^2)') plt.xlabel(xlabel) plt.ylabel(ylabel) # plt.ylabel('cruise_speed (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.savefig(title + ".eps") plt.show() return
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)') plt.legend(loc='upper left') plt.show(block=True) return
def variable_sweep(problem): from matplotlib import rcParams rcParams['font.family'] = 'times new roman' # rcParams['font.times-new-roman'] = ['times new roman'] 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[-1, :, :], cmap=plt.get_cmap('hot')) plt.clabel(CS_const, inline=1, fontsize=12, family='times new roman') cbar = plt.colorbar(CS_const) # plt.FontProperties(family='times new roman', style='italic', size=12) cbar.ax.set_ylabel('BOW (kg)') # font = matplotlib.font_manager.FontProperties(family='times new roman', style='italic', size=12) # CS_const.font_manager.FontProperties.set_family(family='times new roman') plt.xlabel('Wing Area (m^2)') plt.ylabel('Aspect Ratio (-)') plt.legend(loc='upper left') # plt.show(block=True) plt.show() number_of_points = 5 outputs = carpet_plot( problem, number_of_points, 0, 0, sweep_index_0=1, sweep_index_1=3) # 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[-1, :, :], cmap=plt.get_cmap('hot')) plt.clabel(CS_const, inline=1, fontsize=10) cbar = plt.colorbar(CS_const) cbar.ax.set_ylabel('BOW (kg)') plt.xlabel('AR (-)') plt.ylabel('Sweep Angle (Deg)') plt.legend(loc='upper left') plt.show() number_of_points = 5 outputs = carpet_plot( problem, number_of_points, 0, 0, sweep_index_0=2, sweep_index_1=3) # 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[-1, :, :], cmap=plt.get_cmap('hot')) plt.clabel(CS_const, inline=1, fontsize=10) cbar = plt.colorbar(CS_const) cbar.ax.set_ylabel('BOW (kg)') plt.xlabel('t/c (-)') plt.ylabel('Sweep Angle (Deg)') plt.legend(loc='upper left') plt.show(block=True) return
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)') 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] ''' 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(block=True) return
def variable_sweep(problem): number_of_points=2 outputs=carpet_plot(problem, number_of_points, plot_obj = 0, plot_const = 0) #run carpet plot, suppressing default plots return outputs
def variable_sweep(problem): number_of_points=2 #run carpet plot, suppressing default plots outputs=carpet_plot(problem, number_of_points, plot_obj = 0, plot_const = 0) return outputs