def plotLilienthalPolar(self): h = 0. c_a = [x / 10.0 for x in range(-1, 18, 1)] c_w = list(map(self.calcC_WFromC_A, c_a)) plt.figure("Lilienthalpolare") #p1 = plt.plot(c_w_guess, c_a_guess, '-') p2 = plt.plot(c_w, c_a, '-', linewidth=c.LINE_WIDTH) p3 = plt.plot(2. * self.C_W0, self.calcC_aFromC_w(2. * self.C_W0), 'o', label="$2 C_{W0}$", markersize=12) p4 = plt.plot(self.C_W0, 0, 'o', label="$C_{W0}$", markersize=12) plt.ylabel("Auftriebsbeiwert $C_A$") plt.xlabel("Widerstandsbeiwert $C_W$") #plt.legend(loc=4) axes = plt.gca() axes.set_xlim([0, 1.1 * max(c_w)]) axes.set_ylim([-0.6, 2.]) plt.legend(loc=4) generalUtils.pltCosmetics() plt.show() plt.close('all')
def plotOnlyComp(Rvec, Vvec, diffMeshCost, limitCost, hybDegMesh, path, propType): fig = plt.figure(figsize=(16,4)) ax = host_subplot(111) plotCompare(fig, ax, Rvec, Vvec, diffMeshCost, limitCost, hybDegMesh) generalUtils.pltCosmetics(multiPlot=False) plt.subplots_adjust(left=0.04, bottom=0.08, right=1.2, top=0.95, wspace=None, hspace=None) plt.savefig(path + "_" + propType + "_comp.png", format='png', dpi=400) #plt.show() plt.close('all')
def plotEps(self): h = 0. m = 900. u_g = range(20, 90, 2) eps = list( map(self.calcE, m * np.ones(len(u_g)), h * np.ones(len(u_g)), u_g)) plt.figure(r"Gleitzahl") pG = plt.plot(u_g, eps, '-', linewidth=c.LINE_WIDTH) plt.ylabel(r"Gleitzahl $\epsilon$") plt.xlabel(r"Fluggeschwindigkeit $TAS$ in m/s") #plt.legend(pG, ['Gleitzahl'], loc=4) generalUtils.pltCosmetics() plt.show() plt.close('all')
def plotWeights(self, MOTOR_FILE, add, dens, skipLast=0): csv = generalUtils.readCsv(MOTOR_FILE) P = csv[:, 1] m = csv[:, 2] name = generalUtils.readStrForNaN(MOTOR_FILE, 0, csv[:, 0]) Plin = 1.1 * max(P) mlin = add + (1.1 * max(P) / (dens / 1000)) plt.plot([0, Plin], [add, mlin], linewidth=c.LINE_WIDTH) if (skipLast > 0): Pav = np.sum(P[:-skipLast]) / (len(P) - skipLast) mav = (np.sum(m[:-skipLast]) / (len(m) - skipLast)) - add else: Pav = np.sum(P) / len(P) mav = (np.sum(m) / len(m)) - add print("Ration [kW/gk]: " + str(1000 * Pav / mav)) #PlinAv = 1.1 * max(P) #mlinAv = 0 + (1.1 * max(P) / (Pav/mav)) #plt.plot([0, PlinAv], [add, mlinAv]) plt.plot(P, m, 'o', markersize=10) plt.xlim([0, 1.1 * max(P)]) plt.ylim([0, 1.1 * max(m)]) plt.xlabel("Leistung $P$ in kW") plt.ylabel("Masse $m$ in kg") for i in range(0, len(name), 1): xAdd = 10 yAdd = -6 if (i % 2 == 1): xAdd = -10 yAdd = 6 if (len(name[i]) > 0): if (name[i][0] != '-'): plt.annotate(name[i], xy=(P[i], m[i]), xycoords="data", xytext=(P[i] + xAdd, m[i] + yAdd), textcoords="data", va="top", ha="center", fontsize=14, bbox=dict(boxstyle="round", fc="w"), arrowprops=dict(arrowstyle="->", linewidth=2)) generalUtils.pltCosmetics() plt.draw() plt.show()
def plotSpeedPolar(self): plt.figure("Geschwindigkeitspolare") h = 0. m = 900. c_a = [x / 100.0 for x in range(14, 260, 1)] u_g = list( map(self.calcU_g, m * np.ones(len(c_a)), h * np.ones(len(c_a)), c_a)) w_g = list( map(self.calcW_g, m * np.ones(len(c_a)), h * np.ones(len(c_a)), c_a)) #plt.plot(self.polar[:,0], self.polar[:,1], '-') plt.plot([0, 3 * c.E_MAX], [0, 3], '--', linewidth=c.LINE_WIDTH) plt.plot(u_g, w_g, '-', linewidth=c.LINE_WIDTH) C_W0 = self.calcC_W0() V_W_min = plt.plot(self.calcU_g_W_min(m, h), self.calcW_g(m, h, self.calcC_aFromC_w(2. * C_W0)), 'o', label="$V_{MW}$", markersize=12) plt.plot( self.calcU_g_dH_min(m, h), self.calcU_g_dH_min(m, h) * math.sin(math.atan(self.calcEps(m, h, self.calcU_g_dH_min(m, h)))), 'o', label="$V_{w_{g, min}}$", markersize=12) #plt.plot(c.V_E_MAX, c.V_E_MAX / c.E_MAX, 'o', markersize=12) plt.grid(True) plt.gca().invert_yaxis() plt.ylabel("Vertikalfluggeschwindigkeit $w_g$ in m/s") plt.xlabel("Horizontalfluggeschwindigkeit $u_g$ in m/s") plt.legend(loc=3) generalUtils.pltCosmetics() plt.show() plt.close('all')
def plotDiffMap(Rvec, Vvec, diffMeshFuel, diffMeshElec, diffMeshCost, limitFuel, limitElec, limitCost, hybDegMesh, path, propType): Vvec = list(Vvec) Vvec.append(max(Vvec) + Vvec[1] - Vvec[0]) Vvec = np.array(Vvec) Vvec = np.add(Vvec, (Vvec[0] - Vvec[1]) / 2) diffMeshFuel = np.ma.masked_invalid(diffMeshFuel) diffMeshElec = np.ma.masked_invalid(diffMeshElec) diffMeshCost = np.ma.masked_invalid(diffMeshCost) fig = plt.figure(figsize=(13,9)) ax = host_subplot(311) ax.set_title("Brennstoffverbrauch") #ax.set_ylabel("Fluggeschwindigkeit in m/s") plt.ylim([min(Vvec), max(Vvec)]) plt.xlim([min(Rvec), max(Rvec)]) ax.set_xlabel("") ax.set_xticklabels([]) cm = generalUtils.custom_div_cmap(numcolors=256, mincol='#FFFFFF', maxcol='#DD0000', midcol='#00CC00') cm.set_bad(color = '#000000', alpha = 1.) bunt = ax.pcolormesh(Rvec, Vvec, diffMeshFuel, vmin=limitFuel[0], vmax=limitFuel[1], cmap=cm)#, norm=LogNorm(vmin=FF.min(), vmax=FF.max()), cmap=cmap) cbar = fig.colorbar(bunt) cbar.set_label(r"Brennstoff $B$ in $\frac{\mathrm{l}}{100\mathrm{km}}$") ax = host_subplot(312) ax.set_title("Stromverbrauch") ax.set_xlabel("") ax.set_xticklabels([]) cm = generalUtils.custom_div_cmap(numcolors=256, mincol='#FFFFFF', maxcol='#DD0000', midcol='#00CC00') cm.set_bad(color = '#000000', alpha = 1.) bunt = ax.pcolormesh(Rvec, Vvec, diffMeshElec, vmin=limitElec[0], vmax=limitElec[1], cmap=cm)#, norm=LogNorm(vmin=FF.min(), vmax=FF.max()), cmap=cmap) cbar = fig.colorbar(bunt) cbar.set_label(r"Strom $E_{Bat.}$ in $\frac{\mathrm{kWh}}{100\mathrm{km}}$") ax.set_ylabel(r"Fluggeschwindigkeit $v$ in m/s") plt.ylim([min(Vvec), max(Vvec)]) plt.xlim([min(Rvec), max(Rvec)]) ax = host_subplot(313) ax.set_title("Energie") # cm = generalUtils.custom_div_cmap(numcolors=256, mincol='#00CC00', maxcol='#FF0000', midcol='#FFFFFF') # cm.set_bad(color = '#000000', alpha = 1.) # # bunt = ax.pcolormesh(Rvec, Vvec, diffMeshCost, vmin=limitCost[0], vmax=limitCost[1], cmap=cm)#, norm=LogNorm(vmin=FF.min(), vmax=FF.max()), cmap=cmap) # cbar = fig.colorbar(bunt) # cbar.set_label("Kosten in % von Konv.") # # #ax.set_ylabel("Fluggeschwindigkeit in m/s") # plt.ylim([min(Vvec), max(Vvec)]) # plt.xlim([min(Rvec), max(Rvec)]) # ax.set_xlabel("Reichweite in km") plotCompare(fig, ax, Rvec, Vvec, diffMeshCost, limitCost, hybDegMesh) generalUtils.pltCosmetics() plt.savefig(path + "_" + propType + "_overview_energy.png", format='png', dpi=400) #plt.show() plt.close('all') plotOnlyComp(Rvec, Vvec, diffMeshCost, limitCost, hybDegMesh, path, propType)
def plotEfficiencyMap(ice, flight=None, fileName=None, showPlot=True, propType=c.COMB): fig, ax = plt.subplots(figsize=(11,7)) fig.canvas.set_window_title('sfcMap') p_e = np.array(range(0, 1810000, 10000)) N = np.array(range(1200,5810,10)) FF = np.zeros([len(p_e), len(N)]) for iPe in range(0, len(p_e), 1): for iN in range(0, len(N), 1): if(ice.getMaxP_e(N[iN]) >= p_e[iPe]): FF[iPe, iN] = ice.getFuelFlow(N[iN], p_e[iPe]) else: FF[iPe, iN] = FF.max() p_e = np.divide(p_e, 100000) cmap = generalUtils.custom_div_cmap(numcolors=30, mincol='#008000', maxcol='#DD0000', midcol='#FFFF00') bunt = ax.pcolormesh(N, p_e, FF, norm=LogNorm(vmin=FF.min(), vmax=FF.max()), cmap=cmap) cbar = fig.colorbar(bunt) uniq = np.unique(ice.FF) uniq = uniq[::4] cbar.set_ticks(uniq) cbar.set_ticklabels(uniq.astype(int)) cbar.set_label("spez. Kraftstoffverbrauch $sfc$ in g/kWh") ax.set_ylabel("Mitteldruck $p_e$ in bar") ax.set_xlabel("Drehzahl $N$ in 1/min") #plt.xlim([min(N), max(N)]) ax.plot(ice.Nmax, np.divide(ice.p_emax, 100000), 'r--', linewidth=3.0) Nmax, p_emax = ice.getMaxOpPoint() p_emax = p_emax / 100000 ax.annotate(r'$\mathbf{P_{max}}$', xy=(Nmax, p_emax), xycoords="data", xytext=(Nmax - 400, p_emax + 2), textcoords="data", va="top", ha="center", fontsize=20, bbox=dict(boxstyle="round", fc="w"), arrowprops=dict(arrowstyle="->")) p_e_opt = ice.p_e_opt / 100000 ax.annotate(r'$\mathbf{P_{opt}}$', xy=(ice.N_opt, p_e_opt), xycoords="data", xytext=(ice.N_opt - 800, p_e_opt + 1), textcoords="data", va="top", ha="center", fontsize=20, bbox=dict(boxstyle="round", fc="w"), arrowprops=dict(arrowstyle="->")) #ax.plot(ice.N_opt, ice.p_e_opt, 'o') #ax.plot(Nmax, p_emax, 'o') #stimmt NUR fuer Konventionell!!! #if(propType == c.COMB): if(False): tas = 40. h = 1000. if(flight != None): tas = sum(flight.tas) / float(len(flight.tas)) h = sum(flight.H) / float(len(flight.H)) prop = Propeller() N_prop = [] p_e_prop = [] p_e_prop_min = [] p_e_prop_max = [] for iN in range(0, len(N), 1): for iPe in range(0, len(p_e), 1): Pshaft = ice.p_e_to_M(100000 * p_e[iPe]) * N2omega(N[iN]) Nprop = ice.NiceToNprop(N[iN]) J = prop.calcJ(tas, Nprop) Cp = prop.calcCp(h, Nprop, Pshaft) if (not ((Cp < 2 or Cp > 22) or (J < 0.2 or J > 2.2)) and (Nprop <= c.PROP_MAX_N)): p_e_prop.append(p_e[iPe]) if(len(p_e_prop) > 0): p_e_prop_min.append(min(p_e_prop)) p_e_prop_max.append(max(p_e_prop)) else: p_e_prop_min.append(min(p_e)) p_e_prop_max.append(min(p_e)) N_prop.append(N[iN]) #N_prop = [] p_e_prop = [] ax.fill_between(N_prop, min(p_e) * np.ones(len(p_e_prop_min)), p_e_prop_min, facecolor="#000000", alpha=.25, label="prop") ax.fill_between(N_prop, p_e_prop_max, max(p_e) * np.ones(len(p_e_prop_max)), facecolor="#000000", alpha=.25, label="prop") if(flight != None): P = flight.Pice Nice = flight.Nice M = np.divide(P, list(map(N2omega, Nice))) p_e_ice = list(map(ice.M_to_p_e, M)) p_e_ice = np.divide(p_e_ice, 100000) p_e_ice = [round(x, 1) for x in p_e_ice] Nice = [round(x/50, 0)*50 for x in Nice] vecLen = len(Nice) Nx_vec = [] p_ex_vec = [] while(len(Nice) > 0): Nx = Nice[0] p_ex = p_e_ice[0] dens, Nice, p_e_ice = countApperance(Nice, p_e_ice, Nx, p_ex) ax.plot(Nx, p_ex, "o", ms=min(max(60 * dens / vecLen, 5), 30), color="black") Nx_vec.append(Nx) p_ex_vec.append(p_ex) ax.set_xlim([min(min(N), min(Nx_vec)), max(max(N), max(Nx_vec))]) ax.set_ylim([min(min(p_e), min(p_ex_vec)), max(max(p_e), max(p_ex_vec))]) else: ax.set_xlim([min(N), max(N)]) stepWidth = max(int(int(ice.Pmax) / 10), 1) P = range(0, int(ice.Pmax) + stepWidth, stepWidth) N = list(map(ice.calcNIce, P)) omega = list(map(N2omega, N)) M = np.divide(P, omega) p_e = list(map(ice.M_to_p_e, M)) p_e = np.divide(p_e, 100000) ax.plot(N, p_e, 'k-', alpha=0.6)#, linewidth=3.0) generalUtils.pltCosmetics() #plt.draw() if(fileName != None): fig.savefig(fileName + ".png", format='png', dpi=400) if(showPlot): plt.show() plt.close('all')
def plotHybrid(propulsionType, mission, flights, P_increment, saveFile=True, verbose=True, maxs={}): Pice, fuel, mto, Cbat, Pmax = getResVectors(flights) hybDeg = [] for f in flights: hybDeg.append(calcHybridDegree(f.config)) #Pice = np.divide(Pice, 1000.) optConfig = findBestConfig(flights) if (len(optConfig) > 0): hybDegOpt = calcHybridDegree(optConfig) ini = Ini(mission.NAME) fuelComb = float(ini.get(c.COMB, "fuel")) PoptComb = float(ini.get(c.COMB, "popt")) PoptComb = PoptComb / 1000. PmaxComb = float(ini.get(c.COMB, "pmax")) m_pl = c.M_PL if (ini.keyExists("general", "mpl")): m_pl = float(ini.get("general", "mpl")) #plt.figure(mission + " - " + propulsionType) host = host_subplot(111, axes_class=AA.Axes) #plt.subplots_adjust(right=0.75) par1 = host.twinx() par2 = host.twinx() new_fixed_axis = par2.get_grid_helper().new_fixed_axis par2.axis["right"] = new_fixed_axis(loc="right", axes=par2, offset=(60, 0)) par2.axis["right"].toggle(all=True) host.set_xlabel("Hybridisierungsgrad") host.set_xlim([-0.05, 1.05]) #host.axes.set_xlim([min(flight.t), max(flight.t)]) host.set_ylabel("Brennstoff in l") yMax = max(fuel) if ("fuel" in maxs): host.set_ylim([0, 1.1 * maxs["fuel"]]) yMax = maxs["fuel"] par1.set_ylabel("Abflugmasse in kg") #par1.axes.set_ylim([0, 1.1 * max(mto)]) par1.set_ylim([(c.M_STRUCT + m_pl), c.MTOM]) par2.set_ylabel("Batteriekappazität in kWh") if ("bat" in maxs): par2.axes.set_ylim([0, 1.1 * (maxs["bat"] / 1000.)]) host.invert_xaxis() p1, = host.plot(hybDeg, fuel, "o", label="$B$") p2, = par1.plot(hybDeg, mto, "o", label="$m_{TO}$") p3, = par2.plot(hybDeg, np.divide(Cbat, 1000.), "o", label="$C_{Bat}$") if (len(optConfig) > 0): p1_2 = host.plot([hybDegOpt, hybDegOpt], [0, 1.1 * max(fuel)], "b-") host.annotate("min", xy=(hybDegOpt, float(yMax) / 2.), xycoords="data", va="center", ha="center", bbox=dict(boxstyle="round", fc="w", alpha=0.5)) host.axis["left"].label.set_color(p1.get_color()) par1.axis["right"].label.set_color(p2.get_color()) par2.axis["right"].label.set_color(p3.get_color()) #plt.legend() host.legend(loc='upper center', bbox_to_anchor=(0.5, 1.22), ncol=3) generalUtils.pltCosmetics() font = {'size': 16} rc('font', **font) host.locator_params(nbins=7) plt.subplots_adjust(left=0.12, bottom=0.13, right=0.74, top=0.8, wspace=None, hspace=None) #font = {'size' : 14} #rc('font', **font) plt.draw() if (saveFile): plt.savefig(mission.getResultsPath() + "optiMap_" + mission.NAME + "_" + propulsionType + ".png", format='png', dpi=400) if (verbose): plt.show() plt.close('all') plotMass = True if (plotMass): komponents = ["ICE", "Gen", "Umr2", "B", "EMot", "Umr", "Bat"] colors = { "ICE": "FF0000", "Umr": "4FFF4F", "EMot": "00A100", "Bat": "00A6FF", "Gen": "FF7300", "Umr2": "FFBB00", "B": "D1D1D1" } #fig = plt.figure() ax = host_subplot(111) m_pl = flights[0].config["mpl"] valuesOld = list(np.ones(len(flights)) * (c.M_STRUCT + m_pl)) add = 0 plots = [] legendKeys = [] #for key, _ in iter(flights[0].mass.items()): # for key, _ in iter(sorted(flights[0].mass.items())): # values = [] # for i in range(0, len(flights), 1): # add = valuesOld[i] # values.append(flights[i].mass[key] + add) # # ax.fill_between(hybDeg, valuesOld, values, facecolor="#" + colors[key], alpha=.7, label=key) # plots.append(Rectangle((0, 0), 1, 1, color="#" + colors[key])) # legendKeys.append(key) # valuesOld = values for i in range(0, len(komponents), 1): key = komponents[i] if (key in flights[0].mass): values = [] for i in range(0, len(flights), 1): add = valuesOld[i] values.append(flights[i].mass[key] + add) ax.fill_between(hybDeg, valuesOld, values, facecolor="#" + colors[key], alpha=.7, label="$m_{" + key + "}$") plots.append(Rectangle((0, 0), 1, 1, color="#" + colors[key])) legendKeys.append("$m_{" + key + "}$") valuesOld = values #fuel... values = np.multiply(fuel, c.DENS_FUEL) values = np.add(values, valuesOld) ax.fill_between(hybDeg, valuesOld, values, facecolor="#" + colors["B"], alpha=.7, label="B") plots.append(Rectangle((0, 0), 1, 1, color="#" + colors["B"])) legendKeys.append("$m_{B}$") plt.xlim([min(hybDeg), max(hybDeg)]) plt.ylim([(c.M_STRUCT + m_pl), c.MTOM]) plt.legend(plots, legendKeys, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) generalUtils.pltCosmetics() ax.locator_params(nbins=7) plt.subplots_adjust(left=0.14, bottom=0.13, right=0.73, top=0.95, wspace=None, hspace=None) plt.xlabel("Hybridisierungsgrad") ax.set_xlim([-0.05, 1.05]) plt.ylabel("Masse $m$ in kg") ax.invert_xaxis() if (len(optConfig) > 0): plt.plot([hybDegOpt, hybDegOpt], [(c.M_STRUCT + m_pl), c.MTOM], "b-") plt.annotate("$m_{B_{min}}$", xy=(hybDegOpt, (c.MTOM + (c.M_STRUCT + m_pl))), xycoords="data", color="b", va="center", ha="center", bbox=dict(boxstyle="round", fc="w", alpha=0.5)) #draw konv. Mass p = Plane(mission, propulsionType=c.COMB, config={ "pmax": PmaxComb, "fuel": fuelComb, "mpl": m_pl }) massComb = p.calcActWeight() plt.plot([min(min(hybDeg), PoptComb), max(max(hybDeg), PoptComb)], [massComb, massComb], "k-") plt.plot([PoptComb], [massComb], "o", label="Masse konv.") plt.draw() if (saveFile): plt.savefig(mission.getResultsPath() + "mass_" + mission.NAME + "_" + propulsionType + ".png", format='png', dpi=400) if (verbose): plt.show() plt.close('all') plotCost = True if (plotCost): host = host_subplot(111, axes_class=AA.Axes) PriceFuel = np.multiply(fuel, c.PRICE_FUEL) usedElec = [] for f in flights: usedElec.append((f.SoC[0] - f.SoC[-1]) * f.config["cbat"] / 1000) PriceElec = np.multiply(usedElec, c.PRICE_ELEC) PriceTotal = list(np.add(PriceFuel, PriceElec)) host.plot([min(hybDeg), max(hybDeg)], [fuelComb * c.PRICE_FUEL, fuelComb * c.PRICE_FUEL], "k-", label="konv.") host.plot(hybDeg, PriceFuel, ".-", label="Brennst.") host.plot(hybDeg, PriceElec, ".-", label="Strom") host.plot(hybDeg, PriceTotal, ".-", label="Summe") #host.plot([PoptComb], [fuelComb * c.PRICE_FUEL], "o", label="Sprit konv.") plt.legend(loc=4) minIndex = PriceTotal.index([min(PriceTotal)]) host.plot([hybDeg[minIndex], hybDeg[minIndex]], [0, max(PriceTotal)], "k-") #max(PriceTotal) * 2. / 3. plt.xlabel("Hybridisierungsgrad") plt.xlim([-0.05, 1.05]) plt.ylabel("Flugkosten in Euro") yMax = max(PriceTotal) if ("price" in maxs): host.set_ylim([0, 1.1 * maxs["price"]]) yMax = maxs["price"] host.invert_xaxis() host.annotate("min", xy=(hybDeg[minIndex], yMax), xycoords="data", va="center", ha="center", bbox=dict(boxstyle="round", fc="w", alpha=0.5)) if (len(optConfig) > 0): plt.plot([hybDegOpt, hybDegOpt], [0, yMax], "b-") #max(PriceTotal) / 3. plt.annotate("$m_{F_{min}}$", xy=(hybDegOpt, float(yMax) / 10.), color="b", xycoords="data", va="center", ha="center", bbox=dict(boxstyle="round", fc="w", alpha=0.5)) ax.locator_params(nbins=7) generalUtils.pltCosmetics() plt.draw() if (saveFile): plt.savefig(mission.getResultsPath() + "costs_" + mission.NAME + "_" + propulsionType + ".png", format='png', dpi=400) if (verbose): plt.show() plt.close('all') plotBarChart = True if (plotBarChart): ax = host_subplot(111) ax2 = ax.twinx() hDLimit = max(hybDeg) #fls = [] hDs = [] eE = [] eF = [] #test = [] #actP = 0. minF = flights[0] maxF = flights[0] #P_increment = P_increment * 2 barWidth = 0.02 for f in flights: P = int(round(f.config["pice"])) #hD = 1 - (f.config["pice"] / f.config["pmax"]) hD = calcHybridDegree(f.config) #if(hD <= hDLimit): if (P % P_increment == 0): #fls.append(f) hDs.append(hD) e = (f.SoC[0] - f.SoC[-1]) * f.config["cbat"] / 1000 eE.append(e) fuel = f.config["fuel"] eF.append(fuel) hDLimit -= 0.1 #test.append(f.config["pice"]) #lastF = f if (hD < calcHybridDegree(minF.config)): minF = f if (hD > calcHybridDegree(maxF.config)): maxF = f #letzten und ersten überschreiben mit min, bzw. max hD-Lösung if (len(hDs) > 0): hDs[0] = calcHybridDegree(maxF.config) e = (maxF.SoC[0] - maxF.SoC[-1]) * maxF.config["cbat"] / 1000 eE[0] = e fuel = maxF.config["fuel"] eF[0] = fuel hDLimit -= 0.1 hDs[-1] = calcHybridDegree(minF.config) e = (minF.SoC[0] - minF.SoC[-1]) * minF.config["cbat"] / 1000 eE[-1] = e fuel = minF.config["fuel"] eF[-1] = fuel hDLimit -= 0.1 else: f = flights[-1] hDs.append(calcHybridDegree(f.config)) e = (f.SoC[0] - f.SoC[-1]) * f.config["cbat"] / 1000 eE.append(e) fuel = f.config["fuel"] eF.append(fuel) p1 = ax.bar(np.add(hDs, barWidth / 2.), np.multiply(eF, c.ENERGY_FUEL_L), barWidth, color='#FFBB61', label="$E_{chem.}$", zorder=2) p2 = ax.bar(np.add(hDs, barWidth / 2.), eE, barWidth, color='#7BFF00', bottom=np.multiply(eF, c.ENERGY_FUEL_L), label="$E_{elekr.}$", zorder=2) p3 = ax2.bar(np.subtract(hDs, barWidth / 2.), np.multiply(eF, c.PRICE_FUEL), barWidth, color='#BD0000', label="$K_{chem.}$", zorder=2) p4 = ax2.bar(np.subtract(hDs, barWidth / 2.), np.multiply(eE, c.PRICE_ELEC), barWidth, color='#008C10', bottom=np.multiply(eF, c.PRICE_FUEL), label="$K_{elekr.}$", zorder=2) eComb = fuelComb * c.ENERGY_FUEL_L p5 = ax.plot([-0.05, 1.05], [eComb, eComb], "k-", label="konv.", zorder=1) kComb = fuelComb * c.PRICE_FUEL p5 = ax2.plot([-0.05, 1.05], [kComb, kComb], "k--", zorder=1) #label="$K_{konv.}$", ax.set_xlim([-0.05, 1.05]) quotE = maxs["energy"] / eComb quotK = maxs["price"] / kComb quot = max(quotE, quotK) * 1.05 ax.set_ylim([0., quot * eComb]) ax2.set_ylim([0., quot * kComb]) #ax.set_ylim([0., maxs["energy"] * 1.05]) #ax2.set_ylim([0., maxs["price"] * 1.05]) plt.xlabel("Hybridisierungsgrad") ax.set_ylabel("Energie $E$ in kWh") ax2.set_ylabel("Betriebskosten $K$ in Euro") ax.invert_xaxis() ax.locator_params(nbins=7) plt.legend(bbox_to_anchor=(1.2, 1), loc=2, borderaxespad=0.) generalUtils.pltCosmetics() #right=0.67 plt.subplots_adjust(left=0.12, bottom=0.13, right=0.64, top=0.95, wspace=None, hspace=None) #plt.show() plt.draw() if (saveFile): plt.savefig(mission.getResultsPath() + "energyCosts_" + mission.NAME + "_" + propulsionType + ".png", format='png', dpi=400) if (verbose): plt.show() plt.close('all')
def plotFevBand(self): fig, ax = plt.subplots(figsize=(10, 6)) ax.grid(True) SFCfakt = 0.01 im = plt.imread('../data/ICE/FEV-Streuband_merc_bg.png') implot = plt.imshow(im, extent=[0, 6, 200 * SFCfakt, 300 * SFCfakt]) #------- efficiency ------- FEV_FILE = 'data/ICE/FEV-Efficiency.data' fev = generalUtils.read1dAmeFile(FEV_FILE) fev_V_h = fev[:, 0] fev_V_h = np.multiply(fev_V_h, 1000.) fev_sfc = fev[:, 1] f_fev = inter.interp1d(fev_V_h, fev_sfc, kind='cubic') fev_sfc = np.divide(fev_sfc, 1. / SFCfakt) #f_fev = inter.interp1d(fev_V_h, fev_sfc, kind='cubic') plt.plot(fev_V_h, fev_sfc, linewidth=3) #rotax914 V_h_R914 = 1.2112 # plt.plot([V_h_R914], [239 * SFCfakt], "ro", markersize=10) # ax.annotate(r'Rotax 914', xy=(V_h_R914 + 0, (239 + 0) * SFCfakt), xycoords="data", # xytext=(V_h_R914 + 1, (239 + 25) * SFCfakt), textcoords="data", # va="top", ha="center", fontsize=16, # bbox=dict(boxstyle="round", fc="w"), # arrowprops=dict(facecolor='black', shrink=0.05)) #plt.gca().invert_yaxis() plt.xlabel("Hubraum $h_v$ in l") plt.ylabel("min. spez. Brennstoffverbrauch $sfc$ in g/kWh") ax.axes.set_ylim([0 * SFCfakt, 450 * SFCfakt]) plt.draw() # labels = [item.get_text() for item in ax.get_yticklabels()] # newLabel = [] # for i in range(0, len(labels), 1): # if(labels[i] != ''): # lab = float(labels[i]) # lab = (lab / SFCfakt)/1000 # newLabel.append(str(lab)) # else: # newLabel.append(labels[i]) #'0', '50', '100', '150', newLabel = [ '0', '50', '100', '150', '200', '250', '300', '350', '400', '450' ] ax.set_yticklabels(newLabel) hub = [0.29, 0.57, 0.86, 0.95, 1.211] #hub = np.multiply(hub, 10) eta = [0.250, 0.291, 0.323, 0.331, 0.346] sfc = np.multiply(eta, c.ED_FUEL) sfc = np.divide(1000., sfc) sfc = np.divide(sfc, 1. / SFCfakt) plt.plot(hub[0], sfc[0], "o", label="Variante 1", markersize=15) plt.plot(hub[1], sfc[1], "o", label="Variante 2", markersize=15) plt.plot(hub[2], sfc[2], "o", label="Variante 3", markersize=15) plt.plot(hub[3], sfc[3], "o", label="Variante 4", markersize=15) plt.plot(hub[4], sfc[4], "o", label="Rotax 914", markersize=15) # 1 / (float(FFmin * eff) * c.ED_FUEL / 1000) h = [0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 2.] #plt.plot(h, np.divide(f_fev(h), 1./SFCfakt), "o") #print(str(f_fev(0.29))) #plt.xlim([0, 2]) #ax.axes.set_ylim([200 * SFCfakt, 400 * SFCfakt]) generalUtils.pltCosmetics() plt.legend(loc=4) plt.show()