Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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(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 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 * 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)