def computeMavgAndOmegaOverRuns(): p = info.getInputParameters() files = glob.glob("possibleDiscrete*") files.sort() matrix = np.loadtxt(fname="data0.txt", delimiter="\t") length = len(matrix) filesNumber = len(files) sumMavg = np.zeros(shape=(length,p.maxA)) # [coverage, alfa] sumOmega = np.zeros(shape=(length,p.maxA)) # [coverage, alfa] sumRate1 = np.zeros(length) sumRate3 = np.zeros(length) #iterating over runs for i in range(0,filesNumber): tmpMavg, tmpOmega, tmpRate1, tmpRate3 = computeMavgAndOmega(i, p) sumMavg = sumMavg + tmpMavg sumOmega = sumOmega + tmpOmega sumRate1 = sumRate1 + tmpRate1 sumRate3 = sumRate3 + tmpRate3 runMavg = sumMavg / filesNumber runOavg = sumOmega / filesNumber runR1avg = sumRate1 / filesNumber runR3avg = sumRate3 / filesNumber return runMavg, runOavg, runR1avg, runR3avg
def diffusivityDistance(binned, fig=0, ax=0, i=-1): p = inf.getInputParameters() if binned: d = inf.readBinnedAverages() else: d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ fig = plt.figure(num=33, figsize=(6, 5)) ax = plt.gca() x = cove cm = plt.get_cmap("Accent") alpha = 0.5 handles = [] hops = fun.timeDerivative(d.hops, d.time) / (4 * Na) lg, = ax.loglog( x, hops, label=r"$\frac{l^2}{2dN_a} \; \frac{d\langle N_h\rangle}{dt}$", marker="+", ls="", mew=1, markeredgecolor=cm(7 / 8), ms=7, alpha=alpha) handles.append(lg) Malpha = inf.readPossibleFromList() for l in range(0, 4): Malpha[l] = fun.timeDerivative(Malpha[l], d.time) individualHopsCalc = [] individualHopsCalc.append((Malpha[0] * ratios[0]) / (4 * Na)) individualHopsCalc.append((Malpha[1] * ratios[8]) / (4 * Na)) individualHopsCalc.append((Malpha[2] * ratios[15]) / (4 * Na)) individualHopsCalc.append((Malpha[3] * ratios[24]) / (4 * Na)) hopsCalc = np.sum(individualHopsCalc, axis=0) lgC, = plt.loglog(x, hopsCalc, "-", label="hops calc") # marker="*", ls="", mew=mew, markerfacecolor=cm(5/8), ms=5, alpha=alpha) lg, = plt.loglog(x, individualHopsCalc[0], "-", label="hops calc0") handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[1], "-", label="hops calc1") #, handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[2], "-", label="hops calc2") # handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[3], "-", label="hops calc3") # handles.append(lg) handles.append(lgC) ax.grid() ax.set_xlabel(r"$\theta$", size=16) #ax.set_ylim([1e-7,1e13]) ax.set_xlim([1e-5, 1e0]) ax.legend(loc="best", prop={'size': 6}) #ax.legend(handles=handles, loc=(0.46,0.3), numpoints=1, prop={'size':15}, markerscale=2) fig.savefig("../../../plot" + str(p.flux) + str(p.temp) + ".png") plt.close(33)
def computeMavgAndOmega(fileNumber, p): if p.calc == "catalysis": name = "dataAeAll" else: name = "dataAePossibleFromList" pTemp = inf.getInputParameters() ratios = pTemp.getRatiosTotal()[p.minA:p.maxA] possiblesFromList = np.loadtxt(fname=name+"{:03d}".format(fileNumber)+".txt") time = np.array(possiblesFromList[:p.mMsr,0]) possiblesFromList = possiblesFromList[:,1:] # remove time if p.maxA == 7: # for farkas TOF possiblesFromList[:,4] = possiblesFromList[:,22] possiblesFromList[:,5] = possiblesFromList[:,23] possiblesFromList[:,6] = possiblesFromList[:,24] ratios = p.getRatiosTotal() ratios[4] = ratios[22] ratios[5] = ratios[23] ratios[6] = ratios[24] ratios = ratios[0:7] Mavg = np.zeros(shape=(p.mMsr,p.maxA-p.minA)) for i,a in enumerate(range(p.minA,p.maxA)): # iterate alfa Mavg[:,i] = possiblesFromList[:p.mMsr,a]/time/p.sizI/p.sizJ totalRate = np.array(ratios.dot(np.transpose(Mavg))) # define omegas omega = np.zeros(shape=(p.mMsr,p.maxA-p.minA)) # [co2amount, alfa] for i in range(0,p.mMsr): omega[i,:] = Mavg[i,:] * ratios / totalRate[i] return Mavg, omega, totalRate, ratios
def computeMavgAndOmegaOverRuns(): p = inf.getInputParameters() files = glob.glob("dataAePossibleDiscrete*") files.sort() filesNumber = len(files) matrix = np.loadtxt(fname=files[0]) length = len(matrix) sumMavg = np.zeros(shape=(length, p.maxA)) # [time, alfa] sumOmega = np.zeros(shape=(length, p.maxA)) # [time, alfa] sumRate1 = np.zeros(length) sumRate2 = np.zeros(length) sumRate3 = np.zeros(length) #iterating over runs for i in range(0, filesNumber - 1): tmpMavg, tmpOmega, tmpRate1, tmpRate2, tmpRate3 = computeMavgAndOmega( i, p) sumMavg = sumMavg + tmpMavg sumOmega = sumOmega + tmpOmega sumRate1 = sumRate1 + tmpRate1 sumRate2 = sumRate2 + tmpRate2 sumRate3 = sumRate3 + tmpRate3 runMavg = sumMavg / filesNumber runOavg = sumOmega / filesNumber runR1avg = sumRate1 / filesNumber runR2avg = sumRate2 / filesNumber runR3avg = sumRate3 / filesNumber return runMavg, runOavg, runR1avg, runR2avg, runR3avg
def diffusivityDistance(binned, fig=0, ax=0, i=-1): p = inf.getInputParameters() if binned: d = inf.readBinnedAverages() else: d = inf.readAverages() cove = d.getRecomputedCoverage()/p.sizI/p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ fig = plt.figure(num=33, figsize=(6,5)) ax = plt.gca() x = list(range(0,len(d.time))) x = cove cm = plt.get_cmap("Accent") alpha = 0.5 mew = 0 diff = fun.timeDerivative(d.diff, d.time)/(4*Na) handles = [] #lg, = ax.loglog(x, d.diff/d.time/(4*Na), label=r"$\frac{1}{2dN_a} \; \frac{\langle R^2\rangle}{t}$", ls="-", color=cm(3/8), lw=2); handles.append(lg) lg, = ax.loglog(x, d.hops/d.time/(4*Na), label=r"$\frac{l^2}{2dN_a} \; \frac{\langle N_h\rangle}{t}$", marker="x", color=cm(4.1/8), ls="", solid_capstyle="round",lw=5); handles.append(lg) Malpha = inf.readPossibleFromList()#/d.time MalphaP = inf.readInstantaneous(False) for k in range(0,4): Malpha[k] = Malpha[k]/d.time label = r"$\theta_{"+str(k)+"}$" lg, = ax.loglog(x, fun.timeAverage(d.negs[k]/p.sizI/p.sizJ, d.time), label=label, ms=1, lw=2, ls="-", color=cm(k/8)); handles.append(lg) #lg, = plt.loglog(x, MalphaP[k]/d.negs[k], label=r"$m_"+str(k)+"$"); handles.append(lg) # Around 6, 2, 2, 0.1 individualHopsCalc = [] individualHopsCalc.append((Malpha[0]*ratios[0])/(4*Na)) individualHopsCalc.append((Malpha[1]*ratios[8])/(4*Na)) individualHopsCalc.append((Malpha[2]*ratios[15])/(4*Na)) individualHopsCalc.append((Malpha[3]*ratios[24])/(4*Na)) lg, = plt.loglog(x, individualHopsCalc[0], label="hops calc0") handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[1], label="hops calc1")#, handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[2], label="hops calc2")# handles.append(lg) lg, = plt.loglog(x, individualHopsCalc[3], label="hops calc3")# handles.append(lg) hopsCalc = np.sum(individualHopsCalc, axis=0) lgC, = plt.loglog(x, hopsCalc, label="hops calc") # marker="*", ls="", mew=mew, markerfacecolor=cm(5/8), ms=5, alpha=alpha) handles.append(lgC) ax.grid() ax.set_xlabel(r"$\theta$", size=16) #ax.set_ylim([1e-7,1e13]) ax.set_xlim([1e-5,1e0]) ax.legend(loc="best", prop={'size':6}) #ax.legend(handles=handles, loc=(0.46,0.3), numpoints=1, prop={'size':15}, markerscale=2) fig.savefig("../../../plot"+str(p.flux)+str(p.temp)+".png") plt.close(33)
def diffusivityDistance(): r_tt, temp, flux, L1, L2, maxN = i.getInputParameters() allData = [] filesN = glob.glob("data[0-9]*.txt") for i in range(0, len(filesN) - 1): fileName = "data" + str(i) + ".txt" allData.append(np.loadtxt(fname=fileName))
def getAvgProduction(): p = inf.getInputParameters() files = glob.glob("dataCatalysis*") filesNumber = len(files) production = np.zeros(3) for i in range(0,filesNumber): try: production += getOneProduction(i) except FileNotFoundError: filesNumber -= 1 production = production / filesNumber return production
def getAvgCoverages(): p = inf.getInputParameters() files = glob.glob("dataCatalysis*") filesNumber = len(files) coverages = np.zeros(4) for i in range(0, filesNumber): try: coverages += getOneCoverage(i) except FileNotFoundError: filesNumber -= 1 coverages = coverages / filesNumber coveragesWithEmpty = np.zeros(6) coveragesWithEmpty[0:4] = coverages coveragesWithEmpty[4] = 1 - (coverages[0] + coverages[2]) coveragesWithEmpty[5] = 1 - (coverages[1] + coverages[3]) return coveragesWithEmpty
def plot(): p = inf.getInputParameters() d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ x = cove fig, ax = plt.subplots(1, 1, sharey=True, figsize=(6, 5)) alpha = 0.5 Na = d.cove * p.sizI * p.sizJ diff = 1 / (4 * Na) * d.diff / d.time hops = 1 / (4 * Na) * d.hops / d.time diffCm = 1 / (4 * Na) * d.cmDf / d.time #/Na f = Na / d.negS**2 y = diffCm * f ax.plot(x, hops, "s", alpha=alpha) ax.plot(x, diff, "x", alpha=alpha) ax.plot(x, diffCm, "o", alpha=alpha) ax.plot(x, y, "d", alpha=alpha) ax.set_yscale("log") ax.set_xscale("log") fig.savefig("../../../cmDiff" + str(p.temp) + ".png")
def computeError(ax1=0, ax2=0, i=-1, t=150): p = inf.getInputParameters() d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ x = list(range(0, len(d.time))) x = cove cm1 = plt.get_cmap("coolwarm_r") cm2 = plt.get_cmap("coolwarm_r") alpha = 0.5 mew = 0 handles = [] ax1.loglog(x, d.diff / d.hops, label=str(t) + " K", ls="-", color=cm1(i / 21), lw=1) diff = fun.timeDerivative(d.diff, d.time) / (4 * Na) hops = fun.timeDerivative(d.hops, d.time) / (4 * Na) ax2.loglog(x, abs(diff / hops), label=str(t) + " K", ls="-", color=cm2(i / 21), lw=1) setUpPlot(ax1, p) ax1.set_ylabel(r"$f_T=\frac{\langle R^2 \rangle}{l^2\langle N_h \rangle}$") ax1.set_yscale("linear") ax1.set_ylim(0, 2) setUpPlot(ax2, p) ax2.set_ylabel( r"$\frac{\langle R^2\rangle / dt}{l^2d\langle N_h\rangle / dt}$") if p.calc == "basic": addColorBar(fig1, p, i)
from matplotlib.ticker import FixedFormatter import os import glob import numpy as np import multiplicitiesPlot as mp import multiplicitiesInfo as mi ########################################################## ########## Main function ##################### ########################################################## temperatures = inf.getTemperatures("float") temperatures = np.array([v for v in temperatures if v > 400 and v < 1560]) maxRanges = len(temperatures) kb = 8.6173324e-5 p = inf.getInputParameters(inf.getLastOutputFile("*")) print("Reference file is ", inf.getLastOutputFile("*")) maxCo2 = int(p.nCo2 / 10) total = False sp = False rAndM = False omegas = False sensibility = False tofSensibility = False kindOfSensibility = False ext = "" if len(sys.argv) > 1: total = "t" in sys.argv[1] sp = "p" in sys.argv[1] rAndM = "r" in sys.argv[1] omegas = "o" in sys.argv[1]
def diffusivityDistance(): p = inf.getInputParameters() d = inf.readAverages() # read all histograms filesN = glob.glob("histogram[0-9]*.txt") islandDistribution = [] for i in range(0, len(filesN)): fileName = "histogram" + str(i) + ".txt" islandDistribution.append(inf.readHistogram(fileName)) islB3 = np.mean([[np.count_nonzero(h[1:] > 2) for h in run] for run in islandDistribution], axis=0) cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() isld = fun.getOnlyAscending(d.isld) #Correct the simulated time: tp = np.zeros(len(d.time)) tp[0] = d.even[0] / (d.prob[0] + d.depo[0]) for j in range(1, len(d.prob)): tp[j] = tp[j - 1] + (d.even[j] - d.even[j - 1]) / (d.prob[j] + d.depo[j]) # Plot 2 plt.clf() x = list(range(0, len(d.time))) x = cove #time = tp cm = plt.get_cmap("Accent") plt.loglog(x, d.diff, label=r"$R^2 (\times \frac{1}{N_1 N_2})$", marker="s", ls="", mew=0, markerfacecolor=cm(0 / 8), alpha=0.8) plt.loglog(x, d.hops, label=r"$N_h l^2 (\times \frac{1}{N_1 N_2})$", marker="p", ls="", mew=0, markerfacecolor=cm(7 / 8), alpha=0.8) plt.loglog(x, fun.timeAverage(d.prob, d.time) * d.time, label=r"$\overline{R_{h}} \;\; l^2 t$") #coverages cm = plt.get_cmap("Set1") aneg = [] for k in range(0, 7): aneg.append(fun.timeAverage(d.negs[k], d.time)) if k < 4: label = r"$\overline{\theta}_" + str(k) + "$" plt.loglog(x, aneg[k] / p.sizI / p.sizJ, label=label) plt.loglog(x, (aneg[4] + aneg[5] + aneg[6]) / p.sizI / p.sizJ, label=r"$\overline{\theta}_{4+}$") acov = np.sum(aneg[:], axis=0) / p.sizI / p.sizJ plt.loglog(x, acov, "x", label=r"$\overline{\theta}$") plt.loglog(x, fun.thetaAverage(d.time, p.flux), label=r"$1-\frac{1-e^{-Ft}}{Ft}$", color=cm(0)) hopsCalc0 = (d.time * 6 * aneg[0] * ratios[0]) plt.loglog(x, hopsCalc0, label="hops calc0") hopsCalc = d.time * (6 * aneg[0] * ratios[0] + 2 * aneg[1] * ratios[8] + 2 * aneg[2] * ratios[15] + 0.1 * aneg[3] * ratios[24]) plt.loglog(x, hopsCalc, label="hops calc") ratios = inf.getRatio(p.temp, inf.getHexagonalEnergies()) cm = plt.get_cmap("Set3") plt.loglog(x, fun.timeAverage(islB3, d.time) / p.sizI / p.sizJ, ".", color=cm(3 / 12), label=r"$N_{isl}$", markerfacecolor="None") plt.subplots_adjust(left=0.12, bottom=0.1, right=0.7, top=0.9, wspace=0.2, hspace=0.2) plt.legend(numpoints=1, prop={'size': 8}, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plt.grid() plt.title("flux: {:.1e} temperature: {:d}".format(p.flux, int(p.temp))) plt.savefig("../../../plot2" + str(p.flux) + str(p.temp) + ".png")
os.chdir(runFolder[-1]) 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 diffusivityDistance(): p = info.getInputParameters() allData = [] filesN = glob.glob("data[0-9]*.txt") for i in range(0, len(filesN)): fileName = "data" + str(i) + ".txt" allData.append(np.loadtxt(fname=fileName, delimiter="\t")) # read all histograms islandDistribution = [] for i in range(0, len(filesN)): fileName = "histogram" + str(i) + ".txt" islandDistribution.append(info.readHistogram(fileName)) islB2 = np.mean([[np.count_nonzero(h[1:]) for h in run] for run in islandDistribution], axis=0) islB3 = np.mean([[np.count_nonzero(h[1:] > 2) for h in run] for run in islandDistribution], axis=0) islB4 = np.mean([[np.count_nonzero(h[1:] > 3) for h in run] for run in islandDistribution], axis=0) islB5 = np.mean([[np.count_nonzero(h[1:] > 4) for h in run] for run in islandDistribution], axis=0) cove = np.mean([i[:, 0] for i in allData], axis=0) time = np.mean([i[:, 1] for i in allData], axis=0) isld = np.mean([i[:, 3] for i in allData], axis=0) depo = np.mean([i[:, 4] for i in allData], axis=0) prob = np.mean([i[:, 5] for i in allData], axis=0) even = np.mean([i[:, 7] for i in allData], axis=0) hops = np.mean([i[:, 15] for i in allData], axis=0) diff = np.mean([i[:, 12] for i in allData], axis=0) neg0 = np.mean([i[:, 16] for i in allData], axis=0) neg1 = np.mean([i[:, 17] for i in allData], axis=0) neg2 = np.mean([i[:, 18] for i in allData], axis=0) neg3 = np.mean([i[:, 19] for i in allData], axis=0) if p.maxN == 6: neg4 = np.mean([i[:,20] for i in allData], axis=0) + \ np.mean([i[:,21] for i in allData], axis=0) + \ np.mean([i[:,22] for i in allData], axis=0) parti = np.mean([i[:, 0] * p.sizI * p.sizJ for i in allData], axis=0) #hops = even - parti+1 # Plot 2 plt.clf() x = time cm = plt.get_cmap("Accent") #plt.figure(num=None, figsize=(8,6)) plt.loglog(x, diff / p.sizI / p.sizJ, label=r"$R^2 (\times \frac{1}{N_1 N_2})$", marker="s", ls="", mew=0, markerfacecolor=cm(0 / 8), alpha=0.8) plt.loglog(x, hops / p.sizI / p.sizJ, label=r"$N_h l^2 (\times \frac{1}{N_1 N_2})$", marker="p", ls="", mew=0, markerfacecolor=cm(1 / 8), alpha=0.8) plt.loglog(x, diff / hops, ".", label=r"$\frac{R^2}{N_h l^2}$", marker="H", ls="", mew=0, markerfacecolor=cm(2 / 8), alpha=0.8) plt.loglog(x, diff / time / p.sizI / p.sizJ / p.r_tt, label=r"$\frac{R^2}{t} (\times \frac{1}{N_1 N_2 r_{tt}})$", marker="o", ls="", mew=0, markerfacecolor=cm(3 / 8), alpha=0.8) plt.loglog(x, hops / time / p.sizI / p.sizJ / p.r_tt, label=r"$\frac{N_h l^2}{t} (\times \frac{1}{N_1 N_2 r_{tt}})$", marker="D", ls="", mew=0, markerfacecolor=cm(4 / 8), alpha=0.8) plt.loglog(x, diff / (parti * time * p.r_tt), label=r"$\frac{R^2}{Nt} (\times \frac{1}{r_{tt}})$", marker=">", ls="", mew=0, markerfacecolor=cm(5 / 8), alpha=0.8) plt.loglog(x, hops / (parti * time * p.r_tt), label=r"$\frac{N_h l^2}{Nt} (\times \frac{1}{r_{tt}})$", marker="*", ls="", mew=0, markerfacecolor=cm(6 / 8), alpha=0.8) #coverages cm = plt.get_cmap("Set1") plt.loglog(x, neg0 / p.sizI / p.sizJ, label=r"$\theta_0$", color=cm(0 / 5), ls=(0, (1, 1))) plt.loglog(x, neg1 / p.sizI / p.sizJ, label=r"$\theta_1$", color=cm(1 / 5), ls=(0, (1, 1))) plt.loglog(x, neg2 / p.sizI / p.sizJ, label=r"$\theta_2$", color=cm(2 / 5), ls=(0, (1, 1))) plt.loglog(x, neg3 / p.sizI / p.sizJ, label=r"$\theta_3$", color=cm(3 / 5), ls=(0, (1, 1))) if p.maxN == 6: plt.loglog(x, neg4 / p.sizI / p.sizJ, label=r"$\theta_{4+}$", color=cm(4 / 5), ls=(0, (1, 1))) plt.loglog(x, isld / p.sizI / p.sizJ, label="number of islands", color=cm(5 / 5)) cm = plt.get_cmap("Set3") plt.loglog(x, fun.theta(time, p.flux), label=r"$1-e^{-Ft}$", color=cm(0)) plt.loglog(x, cove, ".", color=cm(3 / 12), label=r"$\theta$", markerfacecolor="None") plt.subplots_adjust(left=0.12, bottom=0.1, right=0.7, top=0.9, wspace=0.2, hspace=0.2) plt.legend(numpoints=1, prop={'size': 12}, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plt.grid() plt.title("flux: {:.1e} temperature: {:d}".format(p.flux, int(p.temp))) plt.savefig("plot" + str(p.flux) + str(p.temp) + ".png") return time, neg1
def diffusivityDistance(debug, smooth, smoothCalc, binned, readMultiplicities): p = inf.getInputParameters() if binned: d = inf.readBinnedAverages() else: d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ plt.clf() x = list(range(0, len(d.time))) x = cove cm = plt.get_cmap("Accent") alpha = 0.5 mew = 0 diff = fun.timeDerivative(d.diff, d.time) / (4 * Na) handles = [] if readMultiplicities: Malpha = inf.readInstantaneous() lg, = plt.loglog(x, Malpha[0] / d.negs[0], label=r"$\frac{m_0}{n_0}$") handles.append(lg) # Around 6 lg, = plt.loglog(x, Malpha[1] / d.negs[1], label=r"$\frac{m_1}{n_1}$") handles.append(lg) # Around 2 lg, = plt.loglog(x, Malpha[2] / d.negs[2], label=r"$\frac{m_2}{n_2}$") handles.append(lg) # Around 2 lg, = plt.loglog(x, Malpha[3] / d.negs[3], label=r"$\frac{m_3}{n_3}$") handles.append(lg) # Around 0.1 lgR, = plt.loglog(x, diff, label=r"$\frac{1}{2dN_a} \; \frac{d(R^2)}{dt}$", marker="s", ls="", mew=mew, markerfacecolor=cm(0 / 8), ms=8, alpha=alpha) hops = fun.timeDerivative(d.hops, d.time) / (4 * Na) lgN, = plt.loglog(x, hops, label=r"$\frac{l^2}{2dN_a} \; \frac{d(N_h)}{dt}$", marker="p", ls="", mew=mew, markerfacecolor=cm(7 / 8), ms=7, alpha=alpha) lgRh, = plt.loglog(x, d.prob / (4 * Na), label=r"$\frac{l^2}{2dN_a} R_{h} $", marker="o", ls="", mew=mew, markerfacecolor=cm(1 / 8), ms=5.5, alpha=alpha) #coverages cm1 = plt.get_cmap("Set1") lg, = plt.loglog(x, cove, label=r"$\theta$", color=cm1(1 / 9)) handles.append(lg) for k in range(0, 7): if k < 4: label = r"${n_" + str(k) + "}$" lg, = plt.loglog(x, d.negs[k] / p.sizI / p.sizJ, label=label, ms=1, marker=".", color=cm1((k + 2) / 9)) if smooth: ySmooth = np.exp(savgol_filter(np.log(d.negs[k]), 9, 1)) plt.loglog(x, ySmooth / p.sizI / p.sizJ, lw=2) d.negs[k] = ySmooth handles.append(lg) hopsCalc0 = (6 * d.negs[0] * ratios[0]) / (4 * Na) lgCAll = [] if debug: lgC0, = plt.loglog(x, hopsCalc0, "p-", label="hops calc0") lgCAll.append(lgC0) hopsCalc1 = (2 * d.negs[1] * ratios[8]) / (4 * Na) lgC1, = plt.loglog(x, hopsCalc1, "x-", label="hops calc1") #, lgCAll.append(lgC1) hopsCalc2 = (2 * d.negs[2] * ratios[15]) / (4 * Na) lgC2, = plt.loglog(x, hopsCalc2, "o-", label="hops calc2") # lgCAll.append(lgC2) hopsCalc3 = (0.1 * d.negs[3] * ratios[24]) / (4 * Na) lgC3, = plt.loglog(x, hopsCalc3, "*-", label="hops calc3") # lgCAll.append(lgC3) else: lgC0, = plt.loglog(x, hopsCalc0, label="hops calc0", marker="", ls=":", mew=mew, color=cm(8 / 8), ms=4, alpha=1) lgCAll.append(lgC0) if p.calc == "AgUc": hopsCalc = (6 * d.negs[0] * ratios[0] + 2 * d.negs[1] * ratios[8] + 2 * d.negs[2] * ratios[15] + 0.1 * d.negs[3] * ratios[24]) / (4 * Na) if smoothCalc: hopsCalc = np.exp(savgol_filter(np.log(hopsCalc), 9, 1)) lgC, = plt.loglog(x, hopsCalc, label="hops calc", marker="*", ls="", mew=mew, markerfacecolor=cm(5 / 8), ms=5, alpha=alpha) handles = [lgR, lgN, lgRh, lgC] + lgCAll + handles else: handles = [lgR, lgN, lgRh, lgC0] + handles plt.subplots_adjust(left=0.12, bottom=0.1, right=0.7, top=0.9, wspace=0.2, hspace=0.2) plt.legend(handles=handles, numpoints=1, prop={'size': 8}, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plt.grid() plt.title("flux: {:.1e} temperature: {:d} size {:d}x{:d} \n {}".format( p.flux, int(p.temp), p.sizI, p.sizJ, os.getcwd()), fontsize=10) plt.savefig("../../../plot" + str(p.flux) + str(p.temp) + ".png")
def diffusivityDistance(smooth, binned, fig=0, ax=0, i=-1): p = inf.getInputParameters() if binned: d = inf.readBinnedAverages() else: d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ innerFig = fig == 0 and ax == 0 if innerFig: fig = plt.figure(num=33, figsize=(5, 7)) ax = plt.gca() x = list(range(0, len(d.time))) x = cove cm = plt.get_cmap("Accent") alpha = 0.5 mew = 0 handles = [] lgE, = ax.loglog(x, d.diff / d.hops * 1e9, label="$f_T\cdot10^9$", marker="o", ms=1, ls="", mec=cm(3 / 20), mfc=cm(3 / 20), lw=2) lgR3, = ax.loglog(x, d.diff / d.time / (4 * Na), label=r"$g \; \frac{\langle R^2\rangle}{t}$", ls="-", color=cm(3 / 8), lw=5) lgN3, = ax.loglog(x, d.hops / d.time / (4 * Na), label=r"$gl^2 \; \frac{\langle N_h\rangle}{t}$", ls=":", color=cm(4.1 / 8), lw=4) lg, = ax.loglog(x, (np.sum(d.negs[0:7], axis=0)) / p.sizI / p.sizJ * 1e5, ms=1, lw=1, ls="-.", color="black", label=r"$\theta \cdot 10^5$") #, marker=markers[4]) markers = ["o", "s", "D", "^", "d", "h", "p", "o"] cm1 = plt.get_cmap("Set1") bbox_props = dict(boxstyle="round", fc="w", ec="1", alpha=0.7, pad=0.1) for k in range(0, 4): label = r"$\theta_" + str(k) + r"\cdot 10^4$" ax.loglog(x, d.negs[k] / p.sizI / p.sizJ * 1e5, label=label, ms=3, lw=1, ls="-", color=cm1(k / 8)) # marker=markers[k]) #ax.text(x[1],1e1,"text") index = np.where(d.negs[k] > 0)[0][2] ax.text(x[index], d.negs[k][index] / p.sizI / p.sizJ * 1e5, r"$\theta_{" + str(k) + r"}$", color=cm1(k / 8), bbox=bbox_props) index = np.where(d.negs[4] > 0)[0][2] ax.text(x[index], d.negs[4][index] / p.sizI / p.sizJ * 1e5, r"$\theta_{4+}$", color=cm1(7 / 8), bbox=bbox_props) ax.loglog(x, (d.negs[4] + d.negs[5] + d.negs[6]) / p.sizI / p.sizJ * 1e5, label=label, ms=1, lw=1, ls="-", color=cm1(7 / 8)) #, marker=markers[4]) if smooth: ySmooth = np.exp(savgol_filter(np.log(d.negs[k]), 9, 1)) ax.loglog(x, ySmooth / p.sizI / p.sizJ, lw=2) d.negs[k] = ySmooth handles.append(lg) isld = d.isld lg, = ax.loglog(x, isld / p.sizI / p.sizJ * 1e5, ls="--", lw=2, color=cm(6 / 8), label=r"$N_{isl}\cdot 10^5$", markerfacecolor="None") handles.append(lg) handles = [lgR3, lgN3, lgE] + handles #ax.grid() ax.set_xlabel(r"$\theta$", size=16) ax.set_ylim([1e-2, 1e13]) ax.set_xlim([1e-5, 1e0]) ax.yaxis.set_major_locator(LogLocator(100, [1e-2])) addFreeDiffusivity(ax, x, p) if innerFig: ax.legend(handles=handles, loc=(0.46, 0.3), numpoints=1, prop={'size': 15}, markerscale=2) #addSurface(p.temp) fig.savefig("../../../plot" + str(p.flux) + str(p.temp) + ".png") plt.close(33) else: addSurface(p.temp, ax) if i == 2: thetas = mlines.Line2D([], [], color='black', markersize=15, label=r"$\theta_{i} \cdot 10^5$" + "\n" + r"$i = 0,1,2,3,4+$") handles.append(thetas) ax.legend(handles=handles, loc=(1.05, .15), numpoints=4, prop={'size': 12}, markerscale=1, labelspacing=1, ncol=1, columnspacing=.7, borderpad=0.3) # -.15/1.03 if i > 2: xlim = (7e-1, 1) if i == 1: rect = Rectangle((7e-1, 1e1), 30, 1e6, facecolor="white", edgecolor=cm(8 / 8)) ax.add_patch(rect) if i == 2: rect = Rectangle((7e-1, 1e3), 30, 1e7, facecolor="white", edgecolor=cm(8 / 8)) ax.add_patch(rect) ax.annotate("", xy=(3e-2, 1e5), xytext=(6e-1, 1e5), arrowprops=dict(arrowstyle="->", connectionstyle="angle3", color=cm(8 / 8))) position = [0.1, 0.3, 0.06, 0.3] position[0:2] += ax.get_position().get_points().reshape(4)[0:2] newax = plt.gcf().add_axes(position, zorder=+100) newax.loglog(x, diff, label=r"$g \; \frac{d(R^2)}{dt}$", marker="s", ls="", mew=mew, markerfacecolor=cm(0 / 8), ms=8, alpha=alpha) newax.loglog(x, hops, label=r"$gl^2 \; \frac{d(N_h)}{dt}$", marker="+", ls="", mew=1, markeredgecolor=cm(7 / 8), ms=7, alpha=alpha) newax.loglog(x, d.diff / d.time / (4 * Na), label=r"new", color=cm(3 / 8), lw=2) newax.loglog(x, d.hops / d.time / (4 * Na), "--", label=r"new", color=cm(4.1 / 8), lw=1.8) newax.xaxis.set_major_formatter(plticker.NullFormatter()) newax.yaxis.set_major_formatter(plticker.NullFormatter()) arrow = dict(arrowstyle="-", connectionstyle="arc3", color=cm(8 / 8)) x1Big = 7e-1 if i == 1: ax.annotate("", xy=(x1Big, 1e1), arrowprops=arrow, xytext=(3e-3, 1.5e-1)) ax.annotate("", xy=(1, 1e1), arrowprops=arrow, xytext=(3.8e-1, 1.3e-1)) #ax.annotate("",xy=(1,1e6), arrowprops=arrow, # xytext=(3.8e-1,2e4)) ax.annotate("", xy=(x1Big, 1e6), arrowprops=arrow, xytext=(2.8e-3, 2e4)) newax.set_xlim(x1Big, 1) newax.set_ylim(1, 1e6) if i == 2: #ax.annotate("",xy=(x1Big,1e3), arrowprops=arrow, # xytext=(3e-3,1.5e-1)) #ax.annotate("",xy=(1,1e3), arrowprops=arrow, # xytext=(3.8e-1,1.3e-1)) #ax.annotate("",xy=(x1Big,1e7), arrowprops=arrow, # xytext=(2.8e-3,2e4)) newax.set_xlim(x1Big, 1) newax.set_ylim(1e3, 3e7)
def ratioplicity(ax): d = inf.readAverages() p = inf.getInputParameters() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ x = cove maxI = 7 maxJ = 7 maxK = 4 handles = [] Malpha, Mij = inf.readInstantaneous(False) Mij = Mij.reshape(len(Mij), 7, 7) #mAlpha, trash = inf.readDiscrete() trash, Mij = inf.readPossibles() m = [] Mij = Mij.reshape(len(Mij), 7, 7) for i in range(0, 7): for j in range(0, 7): Mij[:, i, j] = fun.timeDerivative(Mij[:, i, j], d.time) mij = np.zeros(len(Mij) * 49).reshape(len(Mij), 7, 7) for i in range(0, 4): m.append(Malpha[i] / d.negs[i]) label = r"$m_" + str(i) + "}$" lg, = plt.loglog(x, Malpha[i] / d.negs[i], label=label) handles.append(lg) # Around 6,2,2,0.1 #lg, = plt.loglog(x, m[i]/(mAlpha[i]/Malpha[i]), label=str(i)); handles.append(lg) # for i in range(0,7): # for j in range(0,7): # label=r"$m_{"+str(i)+str(j)+"}$" # lg, = plt.loglog(x, Mij[:,i,j]/d.negs[i], label=label); handles.append(lg) # Around 6,2,2,0.1 for i in range(0, maxI): for j in range(0, maxJ): #mij[:,i,j] = Mij[:,i,j]/(d.negs[i] + 1e-16) for coverage in range(0, len(Mij)): if d.negs[i][coverage] == 0: mij[coverage, i, j] = 0 else: mij[coverage, i, j] = Mij[coverage, i, j] / d.negs[i][coverage] label = r"$m_{" + str(i) + str(j) + "}$" #lg, = plt.loglog(x, mij[:,i,j], ls=":", label=label); handles.append(lg) # Around 6,2,2,0.1 #lg, = plt.loglog(x, mij[:,i,j], "o",label=r"$m_ij "+str(i)); handles.append(lg) #mij = fun.timeAverage(mij, d.time) ########################################################################################## ratios = p.getRatios().reshape(7, 7) numerator = np.zeros(len(Mij)) W = [] i = 0 j = 1 print(np.shape(mij)) print("kk", mij[:, 0, :]) W.append(compute(i, j, mij, ratios, maxK)) i = 1 j = 0 W.append(compute(i, j, mij, ratios, maxK)) i = 2 j = 1 W.append(compute(i, j, mij, ratios, maxK)) i = 3 j = 2 W.append(compute(i, j, mij, ratios, maxK)) ######################################################################################## cm1 = plt.get_cmap("Set1") bbox_props = dict(boxstyle="round", fc="w", ec="1", alpha=0.7, pad=0.1) ax.loglog(x, np.ones(len(x)), color="black") markers = ["x", "s", "o", "^", "h", "p", "d"] sum = d.negs[0] / cove / p.sizI / p.sizJ for k in range(0, 4): label = r"$\theta_" + str(k) + r"\cdot 10^4$" ax.loglog(x, d.negs[k] / cove / p.sizI / p.sizJ, label=label, ms=3, lw=1, ls="-", color=cm1(k / 8)) index = np.where(d.negs[k] > 0)[0][2] ax.text(x[index], d.negs[k][index] / cove[index] / p.sizI / p.sizJ, r"$W_{" + str(k) + r"}$", color=cm1(k / 8), bbox=bbox_props) sum += d.negs[k] / cove / p.sizI / p.sizJ #ax.loglog(x, sum, "x") for i in range(0, maxK): lg, = ax.loglog(x, W[i], ls="--", marker=markers[i], label="W temp" + str(i)) handles.append(lg) #ax.text(x[index],d.negs[k][index]/cove[index], r"$W_{"+str(k)+r"^\nu}$", color=cm1(k/8), bbox=bbox_props) #W = np.array(W) #print(np.shape(W)) #lg, = ax.loglog(x, np.sum(W, axis=0), "+", label="W sum"); handles.append(lg) plt.legend(handles=handles, loc="best")
def read(): p = inf.getInputParameters() d = inf.readAverages() return p, d
import traceback plt.title("$ R \propto d ( \\frac{s v_s}{r_g^2} )$") label = r'$\frac{s v_s}{r_g^2}$' plt.ylabel(label) label = r'R (total rate)' plt.xlabel(label) plt.grid(True) workingPath = os.getcwd() for f in i.getFluxes(): folder = "flux3.5e" + str(i) print(folder) try: p = i.getInputParameters(glob.glob(f + "/*/output*")[0]) os.chdir(f) temperatures = i.getTemperatures() meanValues = mk.getIslandDistribution(temperatures, False, False) except (OSError, IndexError): print("error changing to flux {}".format(f)) continue os.chdir(workingPath) vs = meanValues.getGrowthSlope() s = (0.3 * 400 * 400) / meanValues.getIslandsAmount() vg = meanValues.getGyradiusSlope() rtt = mk.getRtt(temperatures) d = fun.fractalD(rtt / p.flux) rg = meanValues.getLastGyradius() print(len(d), len(s), len(rg)) command = "d * ((s*vs)/rg**2)"
def diffusivityDistance(smooth, binned, fig=0, ax=0, i=-1): p = inf.getInputParameters() if binned: d = inf.readBinnedAverages() else: d = inf.readAverages() cove = d.getRecomputedCoverage() / p.sizI / p.sizJ ratios = p.getRatios() Na = cove * p.sizI * p.sizJ innerFig = fig == 0 and ax == 0 if innerFig: fig = plt.figure(num=33, figsize=(5, 7)) ax = plt.gca() x = list(range(0, len(d.time))) x = cove cm = plt.get_cmap("Accent") alpha = 0.5 mew = 0 handles = [] lgE, = ax.loglog(x, d.diff / d.hops * 1e7, label="$f_T\cdot10^7$", marker="o", ms=1, ls="", mec=cm(3 / 20), mfc=cm(3 / 20), lw=2) lgR3, = ax.loglog(x, d.diff / d.time / (4 * Na), label=r"$g \; \frac{\langle R^2\rangle}{t}$", ls="-", color=cm(3 / 8), lw=5) lgN3, = ax.loglog(x, d.hops / d.time / (4 * Na), label=r"$gl^2 \; \frac{\langle N_h\rangle}{t}$", ls=":", color=cm(4.1 / 8), lw=4) up = 1e4 lg, = ax.loglog(x, (np.sum(d.negs[0:7], axis=0)) / p.sizI / p.sizJ * up, ms=1, lw=1, ls="-.", color="black", label=r"$\theta \cdot 10^5$") #, marker=markers[4]) markers = ["o", "s", "D", "^", "d", "h", "p", "o"] cm1 = plt.get_cmap("Set1") bbox_props = dict(boxstyle="round", fc="w", ec="1", alpha=0.7, pad=0.1) for k in range(0, 4): label = r"$\theta_" + str(k) + r"\cdot 10^4$" ax.loglog(x, d.negs[k] / p.sizI / p.sizJ * up, label=label, ms=3, lw=1, ls="-", color=cm1(k / 8)) # marker=markers[k]) #ax.text(x[1],1e1,"text") index = np.where(d.negs[k] > 0)[0][2] ax.text(x[index], d.negs[k][index] / p.sizI / p.sizJ * up, r"$\theta_{" + str(k) + r"}$", color=cm1(k / 8), bbox=bbox_props) if smooth: ySmooth = np.exp(savgol_filter(np.log(d.negs[k]), 9, 1)) ax.loglog(x, ySmooth / p.sizI / p.sizJ, lw=2) d.negs[k] = ySmooth handles.append(lg) isld = d.isld lg, = ax.loglog(x, isld / p.sizI / p.sizJ * up, ls="--", lw=2, color=cm(6 / 8), label=r"$N_{isl}\cdot 10^4$", markerfacecolor="None") handles.append(lg) handles = [lgR3, lgN3, lgE] + handles #ax.grid() ax.set_xlabel(r"$\theta$", size=16) ax.set_ylim([1e-3, 5e10]) ax.set_xlim([1e-5, 1e0]) ax.yaxis.set_major_locator(LogLocator(100, [1e-2])) addFreeDiffusivity(ax, x, p) if innerFig: ax.legend(handles=handles, loc=(0.46, 0.3), numpoints=1, prop={'size': 15}, markerscale=2) fig.savefig("../../../plot" + str(p.flux) + str(p.temp) + ".png") plt.close(33) else: addSurface(p.temp, ax) if i == 2: thetas = mlines.Line2D([], [], color='black', markersize=15, label=r"$\theta_{i} \cdot 10^5$" + "\n" + r"$i = 0,1,2,3-4$") handles.append(thetas) ax.legend(handles=handles, loc=(1.05, .15), numpoints=4, prop={'size': 12}, markerscale=1, labelspacing=1, ncol=1, columnspacing=.7, borderpad=0.3)