Пример #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)
def computeMavgAndOmega(fileNumber, p):
    d = info.readAverages()
    cove = d.getRecomputedCoverage()/p.sizI/p.sizJ
    Na = cove * p.sizI * p.sizJ
    matrix = np.loadtxt(fname="data"+str(fileNumber)+".txt", delimiter="\t")
    possiblesFromList = np.loadtxt(fname="possibleFromList"+str(fileNumber)+".txt")
    possiblesFromList = possiblesFromList[:,1:] # remove coverage
    time = np.array(matrix[:,1])
    length = len(time)
    hops = np.array(matrix[:,15])
    ratios = p.getRatios()
    Mavg = np.zeros(shape=(length,p.maxA))
    Mder = np.zeros(shape=(length,p.maxA))
    for i in range(0,p.maxA): # iterate alfa
        Mavg[:,i] = possiblesFromList[:,i]
        Mder[:,i] = fun.timeDerivative(Mavg[:,i], time)/(4*Na)
    hops = fun.timeDerivative(hops, time)/(4*Na)
    avgTotalHopRate3 = np.array(ratios.dot(np.transpose(Mder)))
    avgTotalHopRate1 = hops#/time
    # define omegas AgUc
    omega = np.zeros(shape=(length,p.maxA)) # [coverage, alfa]
    for i in range(0,length):
        omega[i,:] =  Mder[i,:] * ratios / avgTotalHopRate3[i]
    np.shape(omega)
    return Mder, omega, avgTotalHopRate1, avgTotalHopRate3
Пример #3
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)
Пример #4
0
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)
Пример #5
0
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")
Пример #6
0
    loglog(d.cove, sum, "3")

figure(1001)
i = 0
sum = np.zeros(len(Mij))
for j in range(3, -1, -1):
    loglog(d.cove, W[i] * np.sum(mu[:, i, j:4], axis=1))
    #for j in range(0,4):
    sum = sum + W[j] * mu[:, j, i]
    loglog(d.cove, sum, "3")

trash, Mij = inf.readDiscrete()
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)
i = 0
sum = np.zeros(len(Mij))
sumkj = np.zeros(len(Mij))
sumki = np.zeros(len(Mij))
figure(1002)
sumki = p.flux / (1 - d.cove) / p.sizI / p.sizJ * np.sum(Mij[:, :, i], axis=1)
for j in range(3, -1, -1):
    sumkj = np.sum(Mij[:, :, j], axis=1)
    fL = W[i] * mu[:, i, j] + p.flux / (1 - d.cove) / p.sizI / p.sizJ * sumkj
    loglog(d.cove, fL)
    sum = W[j] * mu[:, j, i]
    sumki = 0
    fR = sum + sumki
    loglog(d.cove, fR, "3")
def allSlopes(x, y):
    return fun.timeDerivative(np.log(y), x)
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")