def plot(covIndex): figR, ax = plt.subplots(nrows=1, ncols=2, figsize=(5,3.5)) figR.subplots_adjust(top=0.88,left=0.15,right=0.9,bottom=0.15, wspace=0.1) plotAx(ax[0], min0energy, covIndex, x0indexes) plotAx(ax[1], min1energy, covIndex, x1indexes) ax[0].plot(x, np.ones(len(x))*60, ":", color="gray") ax[0].annotate(r"", xy=(60,60), xytext=(65,max0energy), xycoords="data",arrowprops=dict(arrowstyle="-", edgecolor='gray')) ax[0].annotate(r"", xy=(58,0), xytext=(67,0), xycoords="data",arrowprops=dict(arrowstyle="-", edgecolor='gray')) # post ax[0].set_xlabel(r"$1/k_BT$")#, size=14) ax[1].set_xlabel(r"$1/k_BT$")#, size=14) ax[0].set_ylabel(r"Energy $(meV)$")#, size=14) ax[labelIndex].annotate(r"$\epsilon^{R}_\alpha=\omega^{R}_\alpha(E^k_\alpha+E^M_\alpha)$", xy=(0.25,0.3), xycoords="axes fraction") ax[1].yaxis.tick_right() #inf.smallerFont(ax[0], 14) #inf.smallerFont(ax[1], 14) ax[0].set_ylim(0, max0energy) ax[0].set_xlim(x0min, x0max) ax[1].set_ylim(0,60) ax[1].set_xlim(x1min, x1max) ax02 = mp.setY2TemperatureLabels(ax[0],kb, majors=majors0) ax12 = mp.setY2TemperatureLabels(ax[1],kb, majors=majors1) ax[0].legend(loc="best", prop={'size':9}) ax[1].legend(loc="best", prop={'size':9}) plt.savefig("plotResume/resume"+str(covIndex)+"_{:5f}".format(coverages[covIndex])+".svg") plt.close(figR)
def plotManyTotalRates(axarr, index, d, latSize, annotate=True): kb = 8.617332e-5 totalRateM, totalRateE, temperatures, coverages, totalRateH = d cm = plt.get_cmap('tab20c') if os.getcwd()[-4:] == "CuNi": color = [cm(0 / 20), cm(1 / 20), cm(2 / 20)] marker = ["o", "2", "^"] label = "Cu/Ni" else: color = [cm(4 / 20), cm(5 / 20), cm(6 / 20)] marker = ["d", "+", "s"] label = "Ni/Cu" axarr.plot(1 / kb / temperatures, totalRateE[index], "-", marker=marker[0], ms=7, label=label + r": $R_e = N_e/T$", color=color[0]) axarr.plot(1 / kb / temperatures, totalRateH[index], ":", marker=marker[2], ms=7, label=label + r": $R_d = N_d/T$", color=color[2], markerfacecolor="None") axarr.plot(1 / kb / temperatures, totalRateM[index], marker=marker[1], ms=7, ls="", label=label + r": $R_e' = \sum_{\alpha \in \{e\}} m_\alpha k_\alpha$", color=color[1]) if annotate: #axarr.annotate(r"$\epsilon^{R}_\alpha=\omega^{R}_\alpha(E^k_\alpha+E^M_\alpha)$", xy=(0.47,0.1), xycoords="axes fraction") axarr.annotate(r"$\theta =$" + str(np.round(coverages[index], 1)), xy=(0.1, 0.57), xycoords="axes fraction") axarr.set_ylabel("Total rate per site") axarr.set_xlabel(r"$1/k_BT$") mp.setY2TemperatureLabels(axarr, kb) else: axarr.plot(1 / kb / temperatures, np.ones(len(temperatures)) * coverages[index], "--", label=r"$R_a$" + " " + r"$(R = R_a + R_d)$", color=cm(9 / 20)) axarr.set_yscale("log") #axarr.set_ylim(3e-2,1e3) axarr.legend(loc="best", prop={'size': 8})
def flush(self, omegaSumTof): if not self.showPlot: return if self.one: self.axarr[1].legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) ax2 = mp.setY2TemperatureLabels(self.axarr[1], 8.617332e-5, majors=np.array( [25, 50, 75, 100, 200, 1000])) self.__smallerFont(ax2, 10) else: self.__smallerFont(self.axarr[0], 8) self.__smallerFont(self.axarr[1], 14) self.__putLabels() self.fig.savefig("../../../plot" + str(self.moment) + "_" + str(self.prod) + self.out) plt.close(self.fig)
except FileNotFoundError: pass os.getcwd() rate = 0 try: totalRate = getTotalRate() except ZeroDivisionError: totalRate = 0 print(f, totalRate[-1]) x.append(f) y.append(totalRate[-100]) os.chdir(workingPath) i += 1 p = inf.getInputParameters(glob.glob("*/output*")[0]) fig, ax = plt.subplots(1, 1, sharey=True, figsize=(5, 3.5)) fig.subplots_adjust(top=0.85, bottom=0.15, left=0.15, right=0.95, hspace=0.25, wspace=0.35) plot(x, y, p, ax, "total rate", "x") #labels=[r"$R_a$ (adsorption)", r"$R_d$ (desorption)", r"$R_r$ (reaction)", r"$R_h$ (diffusion)", "NO", "N2", "TOF"] #markers=["o", "+","x","1","s","d","h","v"] #for i in range(0,len(y2[0])): # plot(x, y2[:,i], p, ax, labels[i], markers[i+1]) mp.setY2TemperatureLabels(ax, kb) fig.savefig("totalRate.pdf") #, bbox_inches='tight')
def plotResume(self, concerted, covIndex, cov): #cm = plt.get_cmap('prism') x = list(reversed(1 / self.kb / concerted.temperatures)) if covIndex == 0: # save temporary data shape = np.shape(concerted.epsilon) np.savetxt("shape.txt", shape) np.savetxt("x_index.txt", x) np.savetxt( "epsilon.txt", concerted.epsilon.reshape(shape[0] * shape[1] * shape[2])) np.savetxt( "lastOmegas.txt", concerted.lastOmegas.reshape(shape[0] * shape[1] * shape[2])) np.savetxt("targetE.txt", concerted.tgt.reshape(shape[1] * shape[0])) np.savetxt("rcomptE.txt", concerted.rct.reshape(shape[1] * shape[0])) figR, ax = plt.subplots(1, figsize=(5, 3.5)) if concerted.total: rl = "R" else: rl = "TOF" figR.subplots_adjust(top=0.88, left=0.15, right=0.95, bottom=0.15) tgt = concerted.tgt[:, covIndex] rct = concerted.rct[:, covIndex] ax.plot(x, tgt * 1000, marker="o", label=r"$E^{" + rl + r"}_{app}$", color="red") ax.plot(x, rct * 1000, "--", label=r"$\sum \epsilon^{" + rl + r"}_\alpha$", color="green") for i, a in enumerate(range(concerted.minAlfa, concerted.maxAlfa - 1)): #if any(abs(concerted.epsilon[-1,::-1,i]) > 0.0001): # 0.1meV if any(concerted.omega[covIndex, :, i] > 0.01): #ax.plot(x, epsilon[-1,::-1,i], label=labelAlfa[a], color=cm(abs(i/20)), marker=markers[i%8]) ax.fill_between(x, concerted.lastOmegas[covIndex, :, i] * 1000, label=concerted.labelAlfa[a], color=self.cm(a % 20 / (19))) # ax2 = ax.twinx() # ax2.plot(x, err, label="Relative error") #ax.set_ylim(0,0.03) #ax.set_xlim(20,30) labels = [item for item in ax.get_xticklabels()] ax.plot(x, abs(np.array(tgt) - np.array(rct)) * 1000, label="Absolute error", color="black") if cov == 0.100002: maxIndex = np.argmax(abs(np.array(tgt) - np.array(rct))) print("Maximum error at 0.1:", max(abs(np.array(tgt) - np.array(rct)) * 1000), "at temperature", 1 / self.kb / x[maxIndex]) ax.legend(loc="best", prop={'size': 9}) #ax.set_xticklabels(labels) ax.set_xlabel(r"$1/k_BT$", size=14) ax.set_ylabel(r"Energy $(meV)$", size=14) #ax.set_yscale("log") #ax.set_xscale("log") ax2 = mp.setY2TemperatureLabels(ax, self.kb) inf.smallerFont(ax2, 12) ax.annotate(r"$\epsilon^{" + rl + r"}_\alpha=\omega^{" + rl + r"}_\alpha(E^k_\alpha+E^M_\alpha)$", xy=(0.2, 0.4), xycoords="axes fraction") inf.smallerFont(ax, 14) ax.set_ylim(1e-2, 100) #ax.set_xlim(30,510) #ax.set_yscale("log") plt.savefig("multiplicitiesResume" + concerted.ext + "{:5f}".format(cov) + self.out) #, bbox_inches='tight') ax.set_xlim(12, 30) ax.set_ylim(1e-1, 210) #ax.set_yscale("log") #ax2 = mp.setY2TemperatureLabels(ax,self.kb) plt.savefig("multiplicitiesResume" + concerted.ext + "{:5f}".format(cov) + "high" + self.out) #, bbox_inches='tight') plt.close(figR)