Exemplo n.º 1
0
def cotangent_fsolve_breakdown():
    ### Plots free energy per volume scaled by the tangent found from fsolve (used to determine approximately when fsolve stops working) ###
    previousSize = nR[0] - nL[0]
    count = 0

    for i in range(0, len(nL)):
        if (nR[i] - nL[i]) > 0.001: continue
        #if (nR[i]-nL[i]) < 0.0000001: break
        if True:
            #if previousSize - (nR[i]-nL[i]) > 0.0000001:
            x = plt.linspace(nL[i], nR[i], 4000)
            previousSize = nR[i] - nL[i]
            datatangent = SW.numH_dftot_dn(
                Tlist[i], nR[i]) * (x - nR[i]) + SW.ftot(Tlist[i], nR[i])
            #Tprev = Tlist[i]
            plt.figure()
            plt.title('ftot scaled  VS  n  @ T=%0.6f' % Tlist[i])
            plt.ylabel('Total free energy per volume')
            plt.xlabel('n')
            plt.plot(x, SW.ftot(Tlist[i], x) - datatangent, 'b')
            plt.plot(x, x - x, 'g')
            plt.plot(nL[i], 0, 'ko')
            plt.plot(nR[i], 0, 'ro')
            #plt.legend(loc='best')
            plt.savefig('cotangent-graphs/relativeH/graph%04d' % count)
            count += 1
            #print(nR[i]-nL[i])
            plt.close("all")
Exemplo n.º 2
0
    def plotstuff():
        global rgp
        global frgpinterp
        numdensity3 = plt.linspace(0.0001, .2, 1000)
        fload()
        ysw = []  # List for SnAFT SW fluid total free energy data
        yrgdiffsw = [
        ]  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy)
        savdiff = [
        ]  # List for difference between raw free energy difference and fitted data from savgo
        rgfittot = []  # List for fitted RG total free energy
        rg = []  # List for RG total free energy
        rgdiff = [
        ]  # List for difference between RG total free energy and the savgo fitted total free energy
        for i in range(0, len(numdensity3)):
            ysw.append(SW.ftot(temp, numdensity3[i]))
            yrgdiffsw.append(f_tot(numdensity3[i]) - ysw[i])

        savgo = savgol_filter(
            yrgdiffsw, 1, 0
        )  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
        # Use the arguments of (function,1,0) if you wish to not apply the filter

        for j in range(0, len(numdensity3)):
            # Builds the fitted RG total free energy (rgfittot)
            # Builds difference between raw free energy difference and fitted data from savgo
            # Not necessiary, I was just curious how much the savgo filter adjusted the data
            rgfittot.append(SW.ftot(temp, numdensity3[j]) + savgo[j])
            savdiff.append(yrgdiffsw[j] - savgo[j])
            rg.append(f_tot(numdensity3[j]))
            rgdiff.append(rgfittot[j] - rg[j])

        frgpinterp = interp1d(numdensity, rgfittot, kind='cubic')

        plt.figure()
        plt.title('savgo - rg')
        plt.ylabel('free energy')
        plt.xlabel('number density')
        #plt.xlim([0,0.11])
        #plt.ylim([-0.01,0.02])

        #plt.plot(numdensity3,savgo,color='red',linewidth=2)
        #plt.plot(numdensity3,sav,color='red',linewidth=2)

        #plt.plot(numdensity3,yrgdiffsw,color='green',linewidth=2)
        #plt.plot(numdensity3,savgo,color='red',linewidth=1)
        plt.plot(numdensity3, rgdiff, color='green', linewidth=1)
        yrgp = []
        dyrgp = []
        madyrgp = []
        for i in range(0, len(numdensity3)):
            yrgp.append(frgp_ext(numdensity3[i]))
            dyrgp.append(dfrgp_dn(numdensity3[i]))
            if numdensity3[i] < 0.085 and numdensity3[i] > 0.001:
                madyrgp.append(dyrgp[i])
        madyrgp = sum(madyrgp) / len(madyrgp)
        #print madyrgp
        cotangentGuess = []
        for i in range(0, len(numdensity3)):
            cotangentGuess.append(yrgp[i] - madyrgp * numdensity3[i])
Exemplo n.º 3
0
def plotF(T):
    plt.subplot(211)
    plt.plot(n * eta_conv, SW.f(T, n))
    plt.ylabel(r'$f$ (SW units)')
    plt.title('T=%0.2f' % T)

    plt.subplot(212)
    plt.plot(n * eta_conv, SW.df_dn(T, n))
    plt.ylabel(r'$\frac{df}{dn}$ (SW units)')
Exemplo n.º 4
0
def __main__():
    GPIO.setmode(GPIO.BCM)
    GLCD.PinsInit(20, 7, 8, 9, 18, 19, 10, 11, 12, 13, 14, 15, 16, 17)
    GLCD.GLCDInit()
    GLCD.GLCDDisplayClear()

    SW.PinsInit(21, 22, 23, 24, 25, 26, 27)
    SW.Start()

    roop = 10 * 60 * 60
    mode = 1
    try:
        while True:
            key = SW.GetKey()
            if key == "1":
                GLCD.GLCDDisplayClear()
                mode += 1
                if mode > 3:
                    mode = 1

            if mode == 1:
                if roop >= 10 * 60 * 60:
                    Weather.RequestAPI()
                    weather = Weather.GetWeather()
                    temp = Weather.GetTemp()
                    roop = 0

                GLCD.GLCDPuts(1, 0, "Date :")
                GLCD.GLCDPuts(5, 8,
                              datetime.datetime.now().strftime('%Y:%m:%d %A'))
                GLCD.GLCDPuts(1, 16, "Weather :")
                GLCD.GLCDPuts(10, 24, weather)
                GLCD.GLCDPuts(10, 32, "Temp : " + format(temp) + 'C')
                GLCD.GLCDPuts(
                    1, 40,
                    "Time : " + datetime.datetime.now().strftime('%H:%M:%S'))
                GLCD.GLCDPuts(1, 48, "Humidity    : " + AM2320.GetHum() + '%')
                GLCD.GLCDPuts(1, 56, "Temperature : " + AM2320.GetTemp() + 'C')

                roop += 1
            elif mode == 2:
                cal = calendar.month(datetime.datetime.now().year,
                                     datetime.datetime.now().month)
                cals = cal.split("\n")
                y = 0
                for c in cals:
                    GLCD.GLCDPuts(1, y, c)
                    y += 8

            elif mode == 3:
                GLCD.drowMashiro()

            time.sleep(0.1)
    except KeyboardInterrupt:
        SW.Stop()
        GLCD.GLCDDisplayClear()
        GPIO.cleanup()
Exemplo n.º 5
0
def plotF(T):
    plt.subplot(211)
    plt.plot(n*eta_conv,SW.f(T,n))
    plt.ylabel(r'$f$ (SW units)')
    plt.title('T=%0.2f'%T)

    plt.subplot(212)
    plt.plot(n*eta_conv,SW.df_dn(T,n))
    plt.ylabel(r'$\frac{df}{dn}$ (SW units)')
Exemplo n.º 6
0
def cotangent_t0():
        plt.figure()
        plt.title('Helmholtz energy per volume  VS  ff  @ T=%0.4f'%Tlist[100])
        plt.ylabel('Helmholtz free energy per volume')
        plt.xlabel('filling fraction')
        plt.plot(xff,SW.ftot(Tlist[100],x),color='#f36118',linewidth=3)
        plt.plot(xff, SW.numH_dftot_dn(Tlist[100],nR[100])*(x-nR[100])+SW.ftot(Tlist[100],nR[100]),color='#00c0c0',linewidth=2)
        #plt.plot(nL[100],SW.ftot(Tlist[100],nL[100]),'ko')
        #plt.plot(nR[100],SW.ftot(Tlist[100],nR[100]),'ko')
        plt.plot(nL[100]*((4*np.pi*(SW.R)**3)/3),SW.ftot(Tlist[100],nL[100]),'ko')
        plt.plot(nR[100]*((4*np.pi*(SW.R)**3)/3),SW.ftot(Tlist[100],nR[100]),'ko')
        plt.savefig('figs/hfe_cotangent.pdf')
Exemplo n.º 7
0
def gfe3():
  x2=plt.linspace(1e-20,.2,40000)
  mu=SW.numH_dftot_dn(Tlist[100],x2)
  plt.figure()
  plt.title('Grand free energy per volume vs n@ T=%0.4f'%Tlist[100])
  plt.ylabel('Grand free energy per volume')
  plt.xlabel('number density (n)')  
  plt.plot(x2,SW.ftot(Tlist[100],x2)-mu*nR[100],color='#f36118')
  plt.plot(x2,x2-x2,'c')
  plt.plot(nL[100],0,'ko')
  plt.plot(nR[100],0,'ko')
  plt.show()
Exemplo n.º 8
0
def g(x):
    ### just a general function which includes conditions for finding the cotangent
    x1 = x[0]  # left guess "n"
    x2 = x[1]  # right guess "n"
    y1 = SW.ftot(T, x[0])  # f(x1)
    y2 = SW.ftot(T, x[1])  # f(x2)
    dy1 = SW.numH_dftot_dn(T, x[0])  # df_dx(x1)
    dy2 = SW.numH_dftot_dn(T, x[1])  # df_dx(x2)

    out = [(dy1 - dy2)]  # Condition 1: df_dx(x1) = df_dx(x2)
    out.append(dy1 - (
        (y2 - y1) /
        (x2 - x1)))  # Condition 2: df_dx(x1) = slope between the two positions
    return out
Exemplo n.º 9
0
def gfe4():
  x2=plt.linspace(1e-20,.13,90000)
  xmin2=((4*np.pi*(SW.R)**3)/3)*1e-20
  xmax2=((4*np.pi*(SW.R)**3)/3)*.13
  xff2 = plt.linspace(xmin2,xmax2,90000)
  thigh=100
  plt.figure()
  plt.title('Grand free energy per volume vs ff @ T=%0.4f'%Tlist[thigh])
  plt.ylabel('Grand free energy per volume')
  plt.xlabel('filling fraction')  
  plt.plot(xff2,SW.phi(Tlist[thigh],x2,nR[thigh]),color='#f36118',linewidth=3)
  #plt.axvline(nL[thigh])
  #plt.axvline(nR[thigh])
  #plt.axhline(SW.phi(Tlist[thigh],nR[thigh]))
  #plt.plot(x2,x2-x2,'c')
  plt.plot(nL[thigh]*((4*np.pi*(SW.R)**3)/3),SW.phi(Tlist[thigh],nL[thigh],nR[thigh]),'ko')
  plt.plot(nR[thigh]*((4*np.pi*(SW.R)**3)/3),SW.phi(Tlist[thigh],nR[thigh],nR[thigh]),'ko')
  plt.axhline(SW.phi(Tlist[thigh],nR[thigh],nR[thigh]),color='c',linewidth=2)
  print(Tlist[100])
  print(nL[100],nR[100])
  plt.savefig('figs/gfe_cotangent.pdf')

  plt.figure()
  plt.plot(xff2,SW.phi(Tlist[thigh],x2,nR[thigh]),color='#f36118',linewidth=3)
  plt.plot(nL[thigh]*((4*np.pi*(SW.R)**3)/3),SW.phi(Tlist[thigh],nL[thigh],nR[thigh]),'ko')
  plt.plot(nR[thigh]*((4*np.pi*(SW.R)**3)/3),SW.phi(Tlist[thigh],nR[thigh],nR[thigh]),'ko')
  plt.axhline(SW.phi(Tlist[thigh],nR[thigh],nR[thigh]),color='c',linewidth=2)
  plt.xlim(0,0.0003)
  plt.ylim(-.000014,0.000006)
  print(Tlist[100])
  print(nL[100],nR[100])
  plt.savefig('figs/gfe_insert_cotangent.pdf')
Exemplo n.º 10
0
def cotangent_t100():
        x2=plt.linspace(1e-20,.2,4000)
        plt.figure()
        plt.title('Helmholtz energy per volume  VS  ff  @ T=%0.4f'%Tlist[100])
        plt.ylabel('Helmholtz free energy per volume')
        plt.xlabel('filling fraction')
        plt.plot(x2,SW.ftot(Tlist[100],x2),color='#f36118',linewidth=3)
        plt.plot(x2, SW.numH_dftot_dn(Tlist[100],nR[100])*(x2-nR[100])+SW.ftot(Tlist[100],nR[100]),color='#00c0c0',linewidth=2)
        #plt.plot(nL[100],SW.ftot(Tlist[100],nL[100]),'ko')
        #plt.plot(nR[100],SW.ftot(Tlist[100],nR[100]),'ko')
        plt.plot(nL[100],SW.ftot(Tlist[100],nL[100]),'ko')
        plt.plot(nR[100],SW.ftot(Tlist[100],nR[100]),'ko')
        #plt.savefig('figs/hfe_cotangent.pdf')
        plt.show()
Exemplo n.º 11
0
def liq_vap_co_pvsT():
        pL=[]
        pR=[]
        pdiff=[]
        for i in range(0,len(nL)):
                pL.append(SW.findP(Tlist[i],nL[i]))
                pR.append(SW.findP(Tlist[i],nR[i]))
                pdiff.append(pL[i]-pR[i])
        plt.figure()
        plt.title('liquid-vapor coexistence '+r'$\lambda_{SW}=1.5$')
        plt.ylabel('pressure')
        plt.xlabel('temperature')
        plt.plot(Tlist,pL,color='#f36118',linewidth=8)
        plt.plot(Tlist,pR,'c',linewidth=3)
        plt.savefig('figs/liqVapCo_pvsT.pdf')
Exemplo n.º 12
0
def cotangent_t0():
    ### Total free energy per volume  VS  n  (with cotangent line shown) for the first temperature  ###
    plt.figure()
    plt.title('Total free energy per volume  VS  n  @ T=%0.4f' % Tlist[-1])
    plt.ylabel('Total free energy per volume')
    plt.xlabel('Number density (n)')
    plt.plot(x, SW.ftot(Tlist[-1], x), color='#f36118', linewidth=1)
    plt.plot(x,
             SW.numH_dftot_dn(Tlist[-1], nR[-1]) * (x - nR[-1]) +
             SW.ftot(Tlist[-1], nR[-1]),
             color='#00c0c0',
             linewidth=1)
    plt.plot(nL[-1], SW.ftot(Tlist[-1], nL[-1]), 'ko')
    plt.plot(nR[-1], SW.ftot(Tlist[0], nR[-1]), 'ko')
    #plt.legend(loc='best')
    plt.savefig('cotangent.pdf')
    plt.show()
Exemplo n.º 13
0
def plotPhi(T, npart):
    plt.plot(n * eta_conv, SW.phi(T, n, npart))
    plt.ylabel(r'$\phi$ /SW units')

    plt.xlabel(r'$\eta$')
    plt.title('SW; T = %0.2f ' % T)
    plt.xlim(0, 0.4)
    plt.ylim(-0.005, 0.015)
Exemplo n.º 14
0
def plotPhi(T,npart):
    plt.plot(n*eta_conv,SW.phi(T,n,npart))
    plt.ylabel(r'$\phi$ /SW units')

    plt.xlabel(r'$\eta$')
    plt.title('SW; T = %0.2f '%T)
    plt.xlim(0,0.4)
    plt.ylim(-0.005,0.015)
Exemplo n.º 15
0
def cotangent_tloop():
    ### Total free energy per volume  VS  n  (with cotangent line shown) for multiple temperatures, can use to make a gif later ###
    count = 0
    for i in range(0, len(Tlist)):
        if (i % 20 == 0):
            plt.figure()
            plt.title('Total free energy per volume  VS  n  @ T=%0.4f' %
                      Tlist[i])
            plt.ylabel('Total free energy per volume')
            plt.xlabel('Number density (n)')
            plt.ylim(-0.8, 1)
            plt.xlim(0, .18)
            plt.plot(x, SW.ftot(Tlist[i], x))
            plt.plot(
                x,
                SW.numH_dftot_dn(Tlist[i], nR[i]) * (x - nR[i]) +
                SW.ftot(Tlist[i], nR[i]))
            plt.plot(nL[i], SW.ftot(Tlist[i], nL[i]), 'ko')
            plt.plot(nR[i], SW.ftot(Tlist[i], nR[i]), 'ro')
            plt.savefig('cotangent_loop/cotangent%03d' % count)
            count += 1
Exemplo n.º 16
0
def plotphi(T, npart, nv=0, nl=0, phi_min=0, phi_max=0):
  n = plt.linspace(1e-8,0.2,20000)
  plt.figure()
  plt.plot(n*eta_conv,SW.phi(T,n,npart),'g-',label='SW')

  plt.title('T = %0.2f'%T)
  plt.ylabel(r'$\phi$')
  plt.xlabel(r'$n$')
  plt.ylim(-0.01,0.04)
  plt.xlim(0,0.45)
  #plt.legend(loc=0)

  if nv > 0 and nl > 0:
    # plot a line!
    phi_v = SW.phi(T, nv, npart)
    phi_l = SW.phi(T, nl, npart)
    free_energy_line = (n - nv)*phi_l/(nl - nv) + (n - nl)*phi_v/(nv - nl)
    plt.plot(n*eta_conv, free_energy_line, 'b-')

  if phi_min != 0 or phi_max != 0:
    plt.ylim(phi_min, phi_max)
Exemplo n.º 17
0
def plotphi(T, npart, nv=0, nl=0, phi_min=0, phi_max=0):
  n = plt.linspace(1e-8, 0.2, 20000)
  plt.figure()
  plt.plot(n*eta_conv, SW.phi(T, n, npart), 'g-', label='SW')

  plt.title('T = %0.2f'%T)
  plt.ylabel(r'$\phi$')
  plt.xlabel(r'$n$')
  plt.ylim(-0.01, 0.04)
  plt.xlim(0, 0.45)
  #plt.legend(loc=0)

  if nv > 0 and nl > 0:
    # plot a line!
    phi_v = SW.phi(T, nv, npart)
    phi_l = SW.phi(T, nl, npart)
    free_energy_line = (n - nv)*phi_l/(nl - nv) + (n - nl)*phi_v/(nv - nl)
    plt.plot(n*eta_conv, free_energy_line, 'b-')

  if phi_min != 0 or phi_max != 0:
    plt.ylim(phi_min, phi_max)
Exemplo n.º 18
0
def liq_vap_co_pvsT():
    ### Vapor - Liquid coexistence curve for pressure vs temperature ###
    pL = []
    pR = []
    pdiff = []
    for i in range(0, len(nL)):
        pL.append(SW.findP(Tlist[i], nL[i]))
        pR.append(SW.findP(Tlist[i], nR[i]))
        pdiff.append(pL[i] - pR[i])
    plt.figure()
    plt.title('Vapor - Liquid coexistence')
    plt.ylabel('Pressure')
    plt.xlabel('Temperature')
    plt.plot(Tlist, pL, color='#f36118', linewidth=5)
    plt.plot(Tlist, pR, 'c', linewidth=1)
    plt.savefig('liqVapCo_pvsT.pdf')

    plt.figure()
    plt.title('Pressure check')
    plt.ylabel('P')
    plt.xlabel('T')
    plt.plot(Tlist, pdiff, 'r')
    plt.savefig('liqVapCo_pvsT_diff.pdf')
Exemplo n.º 19
0
# npart 0.0400810433452
# nv 0.000922047538644
# nl 0.0894990434726

# T = 0.8005709375
# npart 0.0400859280435
# nv 0.000921779389983
# nl 0.0894968306258

### Annotate ###
n = plt.linspace(1e-8, 0.2, 20000)
T = 0.8

## Not equilib ##
plt.figure()
plt.plot(n * eta_conv, SW.phi(T, n, 0.035), 'g-', label='SW')

plt.title(r'$k_BT = $' + '%0.2f' % T + r'$\varepsilon$')
plt.ylabel(r'$\phi$')
plt.xlabel(r'$n$')
plt.ylim(-0.03, 0.02)
plt.xlim(0, 0.45)

plt.annotate('vapor',
             xy=(0.0050704, -0.000922852),
             xytext=(0.1, -0.01),
             arrowprops=dict(facecolor='black', width=2, headwidth=4,
                             frac=0.1))
plt.annotate('liquid',
             xy=(0.384147, -0.0203133),
             xytext=(0.37, 0.0),
Exemplo n.º 20
0
    numdensity3 = plt.linspace(0.0001,
                               max_fillingfraction_handled / (4 * np.pi / 3),
                               1000)
    finterp = fload(temp)
    ysw = []  # List for SnAFT SW fluid total free energy data
    yrgdiffsw = [
    ]  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy)
    savdiff = [
    ]  # List for difference between raw free energy difference and fitted data from savgo
    rgfittot = []  # List for fitted RG total free energy
    rg = []  # List for RG total free energy
    rgdiff = [
    ]  # List for difference between RG total free energy and the savgo fitted total free energy
    for i in range(0, len(numdensity3)):
        ysw.append(SW.ftot(temp, numdensity3[i]))
        yrgdiffsw.append(f_tot(numdensity3[i]) - ysw[i])

    savgo = savgol_filter(
        yrgdiffsw, 1, 0
    )  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
    # Use the arguments of (function,1,0) if you wish to not apply the filter

    for j in range(0, len(numdensity3)):
        # Builds the fitted RG total free energy (rgfittot)
        # Builds difference between raw free energy difference and fitted data from savgo
        # Not necessiary, I was just curious how much the savgo filter adjusted the data
        rgfittot.append(SW.ftot(temp, numdensity3[j]) + savgo[j])
        savdiff.append(yrgdiffsw[j] - savgo[j])
        rg.append(f_tot(numdensity3[j]))
        rgdiff.append(rgfittot[j] - rg[j])
Exemplo n.º 21
0
    # I'm looking at the minima of SW.phi
    c_vap = nparticular
    a_liq = nparticular

    nvapor,phi_vapor = minmax.minimize(SW.phi,T,c_vap,a_vap,nparticular)
    nliquid,phi_liquid = minmax.minimize(SW.phi,T,a_liq,c_liq,nparticular)

    if abs(T - 0.8) < 0.05:
        print "\n\nT =", T
        print 'npart', nparticular
        print 'nv', nvapor
        print 'nl', nliquid

    tol = 1e-5
    fnpart = SW.phi(T, nparticular, nparticular)

    # Compare the two minima in SW.phi
    while np.fabs(phi_vapor - phi_liquid)/np.fabs(fnpart - phi_vapor) > tol:
        delta_mu = (phi_liquid - phi_vapor)/(nliquid - nvapor)
        def newphi(T, n, npart):
            return SW.phi(T, n, npart) - delta_mu*n
        nparticular = minmax.maximize(newphi,T,nvapor,nliquid,nparticular)
        fnpart = SW.phi(T, nparticular, nparticular)

        nvapor,phi_vapor = minmax.minimize(SW.phi,T,a_vap,c_vap,nparticular)
        nliquid,phi_liquid = minmax.minimize(SW.phi,T,a_liq,c_liq,nparticular)
        if abs(T - 0.8) < 0.05:
            print "\nT =", T
            print 'npart', nparticular
            print 'nv', nvapor
Exemplo n.º 22
0
def plotstuff():
        numdensity3 = plt.linspace(0.0001,.2,1000)
        f01_load()
        f02_load()
        f03_load()
        f04_load()
        f05_load()
        ysw=[]
        yrg0=[]
        yrg1=[]
        yrg2=[]
        yrg3=[]
        yrg4=[]
        yrg5=[]
        print (f02interp(0.1))
        for i in range(0,len(numdensity3)):
                ysw.append(SW.ftot(temp,numdensity3[i]))
                yrg0.append(f00_tot(numdensity3[i]))
                yrg1.append(f01_tot(numdensity3[i])-ysw[i])
                yrg2.append(f02_tot(numdensity3[i])-ysw[i])
                yrg3.append(f03_tot(numdensity3[i])-ysw[i])
                yrg4.append(f04_tot(numdensity3[i])-ysw[i])
                yrg5.append(f05_tot(numdensity3[i])-ysw[i])
                


        plt.figure()
        plt.title('free energy difference')
        plt.ylabel('free energy difference')
        plt.xlabel('number density')
        #plt.plot(numdensity,ysw,color='r',linewidth=6)
        #plt.plot(numdensity,yrg0,'b-',linewidth=3)
        plt.plot(numdensity3,yrg1,'g--',linewidth=2)
        plt.plot(numdensity3,yrg2,'r--',linewidth=2)
        plt.plot(numdensity3,yrg3,color='k',linewidth=2)
        plt.plot(numdensity3,yrg4,color='b',linewidth=2)
        plt.plot(numdensity3,yrg5,color='g',linewidth=2)
        #plt.show()
        
        plt.savefig('figs_diff/RG_difference_26_33_T%.3f.png'%temp)
        plt.close()


        yrg0=[]
        yrg1=[]
        yrg2=[]
        yrg3=[]
        yrg4=[]
        yrg5=[]

        for i in range(0,len(numdensity3)):
                #ysw.append(SW.ftot(temp,numdensity3[i]))
                yrg0.append(f00_tot(numdensity3[i]))
                yrg1.append(f01_tot(numdensity3[i]))
                yrg2.append(f02_tot(numdensity3[i]))
                yrg3.append(f03_tot(numdensity3[i]))
                yrg4.append(f04_tot(numdensity3[i]))
                yrg5.append(f05_tot(numdensity3[i]))

        plt.figure()
        plt.title('free energy difference')
        plt.ylabel('free energy difference')
        plt.xlabel('number density')
        #plt.plot(numdensity,ysw,color='r',linewidth=6)
        #plt.plot(numdensity3,yrg0,'r',linewidth=2)
        #plt.plot(numdensity3,yrg1,'g--',linewidth=2)
        #plt.plot(numdensity3,yrg2,'r--',linewidth=2)
        #plt.plot(numdensity3,yrg3,color='b',linewidth=2)
        #plt.plot(numdensity3,yrg4,color='g',linewidth=2)
        plt.plot(numdensity3,yrg5,color='g',linewidth=1)
        #plt.show()
        plt.savefig('RG_FREE.pdf')
Exemplo n.º 23
0
def plotstuff():
    numdensity3 = plt.linspace(0.0001, .2, 1000)
    f01_load()
    f02_load()
    f03_load()
    f04_load()
    f05_load()
    ysw = []
    yrg0 = []
    yrg1 = []
    yrg2 = []
    yrg3 = []
    yrg4 = []
    yrg5 = []
    print(f02interp(0.1))
    for i in range(0, len(numdensity3)):
        ysw.append(SW.ftot(temp, numdensity3[i]))
        yrg0.append(f00_tot(numdensity3[i]))
        yrg1.append(f01_tot(numdensity3[i]) - ysw[i])
        yrg2.append(f02_tot(numdensity3[i]) - ysw[i])
        yrg3.append(f03_tot(numdensity3[i]) - ysw[i])
        yrg4.append(f04_tot(numdensity3[i]) - ysw[i])
        yrg5.append(f05_tot(numdensity3[i]) - ysw[i])

    plt.figure()
    plt.title('free energy difference')
    plt.ylabel('free energy difference')
    plt.xlabel('number density')
    #plt.plot(numdensity,ysw,color='r',linewidth=6)
    #plt.plot(numdensity,yrg0,'b-',linewidth=3)
    plt.plot(numdensity3, yrg1, 'g--', linewidth=2)
    plt.plot(numdensity3, yrg2, 'r--', linewidth=2)
    plt.plot(numdensity3, yrg3, color='k', linewidth=2)
    plt.plot(numdensity3, yrg4, color='b', linewidth=2)
    plt.plot(numdensity3, yrg5, color='g', linewidth=2)
    #plt.show()

    plt.savefig('figs_diff/RG_difference_26_33_T%.3f.png' % temp)
    plt.close()

    yrg0 = []
    yrg1 = []
    yrg2 = []
    yrg3 = []
    yrg4 = []
    yrg5 = []

    for i in range(0, len(numdensity3)):
        #ysw.append(SW.ftot(temp,numdensity3[i]))
        yrg0.append(f00_tot(numdensity3[i]))
        yrg1.append(f01_tot(numdensity3[i]))
        yrg2.append(f02_tot(numdensity3[i]))
        yrg3.append(f03_tot(numdensity3[i]))
        yrg4.append(f04_tot(numdensity3[i]))
        yrg5.append(f05_tot(numdensity3[i]))

    plt.figure()
    plt.title('free energy difference')
    plt.ylabel('free energy difference')
    plt.xlabel('number density')
    #plt.plot(numdensity,ysw,color='r',linewidth=6)
    #plt.plot(numdensity3,yrg0,'r',linewidth=2)
    #plt.plot(numdensity3,yrg1,'g--',linewidth=2)
    #plt.plot(numdensity3,yrg2,'r--',linewidth=2)
    #plt.plot(numdensity3,yrg3,color='b',linewidth=2)
    #plt.plot(numdensity3,yrg4,color='g',linewidth=2)
    plt.plot(numdensity3, yrg5, color='g', linewidth=1)
    #plt.show()
    plt.savefig('RG_FREE.pdf')
Exemplo n.º 24
0
def SW_Finfinity(n):
    T = 1.0e8
    return SW.fhs(T, n) / T
Exemplo n.º 25
0
colors = ['ro', 'go', 'bo', 'rx', 'gx', 'bx']
plt.figure()
size = 15.0
for i in range(0, len(allFinfinity)):
    plt.plot(allFinfinity[i][0],
             allFinfinity[i][1],
             colors[i % len(colors)],
             label="L=%f" % allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("dataF-saftF")
plt.legend(loc='best')
plt.savefig("deltaF.pdf")
plt.close()

colors = ['ro', 'go', 'bo', 'rx', 'gx', 'bx']
plt.figure()
size = 15.0
for i in range(0, len(allFinfinity)):  #ms=size*(0.7)**i
    plt.plot(allFinfinityPercent[i][0],
             allFinfinityPercent[i][1],
             colors[i % len(colors)],
             label="L=%f" % allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("(dataF-saftF)/dataF*100.0")
plt.legend(loc='best')
plt.savefig("deltaFpercent.pdf")
plt.close()

print SW.fhs(0, 0.1)
print SW.fhs(0, 0.2)
Exemplo n.º 26
0
			allFinfinityPercent.append([[],[]])
			for i in range(0,len(dataFreeEnergy)):
				allFinfinityPercent[-1][0].append(ffData[i])
				allFinfinityPercent[-1][1].append(dataFreeEnergy[i])
			
###############--------------all ww=1.5  T=infinity  dataF-saftF------##
colors=['ro','go','bo','rx','gx','bx']
plt.figure()
size=15.0
for i in range(0,len(allFinfinity)):
	plt.plot(allFinfinity[i][0],allFinfinity[i][1],colors[i%len(colors)],label="L=%f"%allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("dataF-saftF")
plt.legend(loc='best')
plt.savefig("deltaF.pdf")
plt.close()

colors=['ro','go','bo','rx','gx','bx']
plt.figure()
size=15.0
for i in range(0,len(allFinfinity)):#ms=size*(0.7)**i
	plt.plot(allFinfinityPercent[i][0],allFinfinityPercent[i][1],colors[i%len(colors)],label="L=%f"%allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("(dataF-saftF)/dataF*100.0")
plt.legend(loc='best')
plt.savefig("deltaFpercent.pdf")
plt.close()

print SW.fhs(0,0.1)
print SW.fhs(0,0.2)
Exemplo n.º 27
0
    def plotstuff():
        global rgp
        global frgpinterp
        numdensity3 = plt.linspace(0.0001, max_fillingfraction_handled / (4 * np.pi / 3), 1000)
        fload()
        ysw = []  # List for SnAFT SW fluid total free energy data
        yrgdiffsw = []  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy)
        savdiff = []  # List for difference between raw free energy difference and fitted data from savgo
        rgfittot = []  # List for fitted RG total free energy
        rg = []  # List for RG total free energy
        rgdiff = []  # List for difference between RG total free energy and the savgo fitted total free energy
        for i in range(0, len(numdensity3)):
            ysw.append(SW.ftot(temp, numdensity3[i]))
            yrgdiffsw.append(f_tot(numdensity3[i]) - ysw[i])

        savgo = savgol_filter(
            yrgdiffsw, 1, 0
        )  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
        # Use the arguments of (function,1,0) if you wish to not apply the filter

        for j in range(0, len(numdensity3)):
            # Builds the fitted RG total free energy (rgfittot)
            # Builds difference between raw free energy difference and fitted data from savgo
            # Not necessiary, I was just curious how much the savgo filter adjusted the data
            rgfittot.append(SW.ftot(temp, numdensity3[j]) + savgo[j])
            savdiff.append(yrgdiffsw[j] - savgo[j])
            rg.append(f_tot(numdensity3[j]))
            rgdiff.append(rgfittot[j] - rg[j])

        frgpinterp = interp1d(numdensity, rgfittot, kind="cubic")

        yrgp = []
        dyrgp = []
        madyrgp = []
        for i in range(0, len(numdensity3)):
            yrgp.append(frgp_ext(numdensity3[i]))
            dyrgp.append(dfrgp_dn(numdensity3[i]))
            if numdensity3[i] < 0.085 and numdensity3[i] > 0.001:
                madyrgp.append(dyrgp[i])
        madyrgp = sum(madyrgp) / len(madyrgp)
        mu = SW.numH_dftot_dn(T[p], numdensity3)
        mu2 = SW.numH_dftot_dn(T[p], nR1[p])
        mu3 = dfrgp_dn(nL1[p])
        mu4 = dfrgp_dn(nR1[p])
        # print madyrgp
        cotangentGuess = []
        for i in range(0, len(numdensity3)):
            cotangentGuess.append(yrgp[i] - madyrgp * numdensity3[i])

        gfe = []
        for i in range(0, len(numdensity3)):
            gfe.append(yrgp[i] - mu4 * numdensity3[i])

        ##                gfergp=[]
        ##                for i in range(0,len(numdensity3)):
        ##                        gfergp.append(yrgp[i]-mu3*numdensity3[i])

        swgfe = []
        for i in range(0, len(numdensity3)):
            swgfe.append(ysw[i] - mu2 * numdensity3[i])

        ##                plt.plot(numdensity3,cotangentGuess)
        plt.plot(numdensity3, swgfe, color="b", linewidth=2)
        plt.plot(numdensity3, gfe, color="#f36118", linewidth=2)
        ##                plt.plot(numdensity3,gfergp,color='c',linewidth=2)
        ##                plt.plot(numdensity3,gfergp,color='g',linewidth=2)
        plt.plot(nL1[p], gfe[p], "ko")
        plt.plot(nR1[p], gfe[p], "ko")
        ##                plt.axhline(SW.phi(T[p],nR1[p],nR1[p]),color='c',linewidth=2)
        plt.axhline(gfe[p], color="r", linewidth=2)
        plt.title("GFE per volume  VS  n  @ T=%0.16g" % T[p])
        plt.ylabel("grand free energy per volume")
        plt.xlabel("Number density (n)")

        plt.xlim(0, nR1[p] + 0.05)
        plt.ylim(gfe[p] - 0.01, 0.0075)
        ##                plt.show()
        plt.savefig("meeting/20july2016/f05/gfe_T%.16g.png" % T[p])
        plt.close()
Exemplo n.º 28
0
 def newphi(T, n, npart):
     return SW.phi(T, n, npart) - delta_mu*n
Exemplo n.º 29
0
			allFinfinityPercent.append([[], []])
			for i in range(0, len(dataFreeEnergy)):
				allFinfinityPercent[-1][0].append(ffData[i])
				allFinfinityPercent[-1][1].append(dataFreeEnergy[i])
			
###############--------------all ww=1.5  T=infinity  dataF-saftF------##
colors=['ro', 'go', 'bo', 'rx', 'gx', 'bx']
plt.figure()
size=15.0
for i in range(0, len(allFinfinity)):
	plt.plot(allFinfinity[i][0], allFinfinity[i][1], colors[i%len(colors)], label="L=%f"%allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("dataF-saftF")
plt.legend(loc='best')
plt.savefig("deltaF.pdf")
plt.close()

colors=['ro', 'go', 'bo', 'rx', 'gx', 'bx']
plt.figure()
size=15.0
for i in range(0, len(allFinfinity)):#ms=size*(0.7)**i
	plt.plot(allFinfinityPercent[i][0], allFinfinityPercent[i][1], colors[i%len(colors)], label="L=%f"%allCellLength[i])
plt.xlabel("filling fraction")
plt.ylabel("(dataF-saftF)/dataF*100.0")
plt.legend(loc='best')
plt.savefig("deltaFpercent.pdf")
plt.close()

print(SW.fhs(0, 0.1))
print(SW.fhs(0, 0.2))
Exemplo n.º 30
0
# npart 0.0400810433452
# nv 0.000922047538644
# nl 0.0894990434726

# T = 0.8005709375
# npart 0.0400859280435
# nv 0.000921779389983
# nl 0.0894968306258

### Annotate ###
n = plt.linspace(1e-8,0.2,20000)
T = 0.8

## Not equilib ##
plt.figure()
plt.plot(n*eta_conv,SW.phi(T,n,0.035),'g-',label='SW')

plt.title(r'$k_BT = $'+'%0.2f'%T+r'$\varepsilon$')
plt.ylabel(r'$\phi$')
plt.xlabel(r'$n$')
plt.ylim(-0.03,0.02)
plt.xlim(0,0.45)

plt.annotate('vapor',xy=(0.0050704,-0.000922852),xytext=(0.1,-0.01),arrowprops=dict(facecolor='black',width=2,headwidth=4,frac=0.1))
plt.annotate('liquid',xy=(0.384147, -0.0203133),xytext=(0.37,0.0),arrowprops=dict(facecolor='black',width=2,headwidth=4,frac=0.1))
plt.savefig('figs/SW-phi-lowT-vapor-liquid-annotation.pdf')

## Equilib ##
plt.figure()
plt.plot(n*eta_conv,SW.phi(T,n,0.0400859271143),'g-',label='SW')
Exemplo n.º 31
0
def SW_Fexc(T, n):
    #return SW.fhs(T,n)
    #return SW.fdisp(T,n)
    return SW.fdisp(T, n) + SW.fhs(T, n)
Exemplo n.º 32
0
def plotPhi(T,npart):
    plt.plot(n*eta_conv,SW.phi(T,n,npart))
    plt.ylabel(r'$\phi$ (SW units)')

    plt.xlabel(r'$\eta$')
    plt.title('T = %0.2f '%T + r'n$_{part}$' +' = %0.2f'%npart)
Exemplo n.º 33
0
    def plotstuff():
        global rgp
        global frgpinterp
        numdensity3 = plt.linspace(
            0.0001, max_fillingfraction_handled / (4 * np.pi / 3), 1000)
        fload()
        ysw = []  # List for SnAFT SW fluid total free energy data
        yrgdiffsw = [
        ]  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy)
        savdiff = [
        ]  # List for difference between raw free energy difference and fitted data from savgo
        rgfittot = []  # List for fitted RG total free energy
        rg = []  # List for RG total free energy
        rgdiff = [
        ]  # List for difference between RG total free energy and the savgo fitted total free energy
        for i in range(0, len(numdensity3)):
            ysw.append(SW.ftot(temp, numdensity3[i]))
            yrgdiffsw.append(f_tot(numdensity3[i]) - ysw[i])

        savgo = savgol_filter(
            yrgdiffsw, 1, 0
        )  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
        # Use the arguments of (function,1,0) if you wish to not apply the filter

        for j in range(0, len(numdensity3)):
            # Builds the fitted RG total free energy (rgfittot)
            # Builds difference between raw free energy difference and fitted data from savgo
            # Not necessiary, I was just curious how much the savgo filter adjusted the data
            rgfittot.append(SW.ftot(temp, numdensity3[j]) + savgo[j])
            savdiff.append(yrgdiffsw[j] - savgo[j])
            rg.append(f_tot(numdensity3[j]))
            rgdiff.append(rgfittot[j] - rg[j])

        frgpinterp = interp1d(numdensity, rgfittot, kind='cubic')

        yrgp = []
        dyrgp = []
        madyrgp = []
        for i in range(0, len(numdensity3)):
            yrgp.append(frgp_ext(numdensity3[i]))
            dyrgp.append(dfrgp_dn(numdensity3[i]))
            if numdensity3[i] < 0.085 and numdensity3[i] > 0.001:
                madyrgp.append(dyrgp[i])
        madyrgp = sum(madyrgp) / len(madyrgp)
        mu = SW.numH_dftot_dn(T[p], numdensity3)
        mu2 = SW.numH_dftot_dn(T[p], nR1[p])
        mu3 = dfrgp_dn(nL1[p])
        mu4 = dfrgp_dn(nR1[p])
        #print madyrgp
        cotangentGuess = []
        for i in range(0, len(numdensity3)):
            cotangentGuess.append(yrgp[i] - madyrgp * numdensity3[i])

        gfe = []
        for i in range(0, len(numdensity3)):
            gfe.append(yrgp[i] - mu4 * numdensity3[i])

##                gfergp=[]
##                for i in range(0,len(numdensity3)):
##                        gfergp.append(yrgp[i]-mu3*numdensity3[i])

        swgfe = []
        for i in range(0, len(numdensity3)):
            swgfe.append(ysw[i] - mu2 * numdensity3[i])

##                plt.plot(numdensity3,cotangentGuess)
        plt.plot(numdensity3, swgfe, color='b', linewidth=2)
        plt.plot(numdensity3, gfe, color='#f36118', linewidth=2)
        ##                plt.plot(numdensity3,gfergp,color='c',linewidth=2)
        ##                plt.plot(numdensity3,gfergp,color='g',linewidth=2)
        plt.plot(nL1[p], gfe[p], 'ko')
        plt.plot(nR1[p], gfe[p], 'ko')
        ##                plt.axhline(SW.phi(T[p],nR1[p],nR1[p]),color='c',linewidth=2)
        plt.axhline(gfe[p], color='r', linewidth=2)
        plt.title('GFE per volume  VS  n  @ T=%0.16g' % T[p])
        plt.ylabel('grand free energy per volume')
        plt.xlabel('Number density (n)')

        plt.xlim(0, nR1[p] + 0.05)
        plt.ylim(gfe[p] - 0.01, 0.0075)
        ##                plt.show()
        plt.savefig('meeting/20july2016/f05/gfe_T%.16g.png' % T[p])
        plt.close()
Exemplo n.º 34
0
    R = 2**512
    R2p = (R * R) % p
    R2q = (R * R) % q
    R = 2**1024
    R2_1024 = (R * R) % N

    print "R2_p         = ", hex(R2p)  # 1024-bits
    print "R2_q         = ", hex(R2q)  # 1024-bits
    print "R2_1024      = ", hex(R2_1024)  # 1024-bits

    #####################################################

    print "\n--- Execute RSA (For verification)"

    # Encrypt
    Ct1 = SW.MontExp_1024(M, e, N)  # 1024-bit exponentiation
    print "Ciphertext   = ", hex(Ct1)  # 512-bits

    # Decrypt
    Pt1 = SW.MontExp_1024(Ct1, d, N)  # 1024-bit exponentiation
    print "Plaintext    = ", hex(Pt1)  # 512-bits

    #####################################################

    print "\n--- Execute CRT RSA"

    #### Encrypt

    # Exponentiation, in Software
    Ct2 = SW.MontExp_1024(M, e,
                          N)  # 1024-bit SW based montgomery exponentiation
Exemplo n.º 35
0
from __future__ import division
import SW
import RG

T = 5
n = 0.02

print '    SW; T = %d; n = %0.2f; f = %0.4f'%(T,n,SW.f(T,n))
print '\n'

for i in range (2):
    print '    RG; i = %d; T = %d; n = %0.2f; f = %0.4f'%(i,T,n,RG.ftot(T,n,i))
Exemplo n.º 36
0
 def newphi(T, n, npart):
     return SW.phi(T, n, npart) - delta_mu * n
Exemplo n.º 37
0
    portfolios_csv_path = os.path.join(script_dir, 'data/r_xq_portfolios.csv')
    XueQiuFetchPortfoliosJob.XueQiuFetchPortfoliosJob(
        xq, portfolios_csv_path).run()

    holdings_csv_path = os.path.join(
        script_dir, 'data/r_xq_holdings_{}.csv'.format(today_str))
    portfolios = xq.get_portfolios_from_csv(portfolios_csv_path)
    XueQiuFetchHoldingsJob.XueQiuFetchHoldingsJob(xq, holdings_csv_path,
                                                  portfolios['code']).run()

    watches_csv_path = os.path.join(script_dir, 'data/r_xq_watches.csv')
    XueQiuFetchWatchesJob.XueQiuFetchWatchesJob(xq, watches_csv_path).run()

if generate_sw and not only_local_file:
    sw = SW.SW()
    succeed, reason = sw.init()
    if not succeed:
        raise Exception("sw init failed: " + reason)

    SWDownloadFilesJob.SWDownloadFilesJob(sw,
                                          sw_files,
                                          data_file_path=os.path.join(
                                              script_dir, 'data/')).run()

if generate_zz:
    if not only_local_file:
        df = pd.read_csv(os.path.join(script_dir, 'data/r_stocks.csv'))

        StocksDownloadFilesJob.StocksDownloadFilesJob(
            df['code'].str.split('.').str.get(0),
Exemplo n.º 38
0
    print "A                = ", hex(A)  # 1027-bits
    print "B                = ", hex(B)  # 1027-bits
    print "A - B            = ", hex(C)  # 1028-bits

#####################################################

if operation == 3:

    print "Test Vector for Windoed Montgomery Multiplication\n"

    M = helpers.getModulus(1024)
    A = helpers.getRandomInt(1024) % M
    B = helpers.getRandomInt(1024) % M

    C = SW.MontMul(A, B, M)
    # D = HW.MontMul(A, B, M)
    D = HW.MontMul_2bW(A, B, M)

    e = (C - D)

    print "A                = ", hex(A)  # 1024-bits
    print "B                = ", hex(B)  # 1024-bits
    print "M                = ", hex(M)  # 1024-bits
    print "(A*B*R^-1) mod M = ", hex(C)  # 1024-bits
    print "(A*B*R^-1) mod M = ", hex(D)  # 1024-bits
    print "error            = ", hex(e)

#####################################################

if operation == 4:
Exemplo n.º 39
0
    # I'm looking at the minima of SW.phi
    c_vap = nparticular
    a_liq = nparticular

    nvapor, phi_vapor = minmax.minimize(SW.phi, T, c_vap, a_vap, nparticular)
    nliquid, phi_liquid = minmax.minimize(SW.phi, T, a_liq, c_liq, nparticular)

    if abs(T - 0.8) < 0.05:
        print "\n\nT =", T
        print 'npart', nparticular
        print 'nv', nvapor
        print 'nl', nliquid

    tol = 1e-5
    fnpart = SW.phi(T, nparticular, nparticular)

    # Compare the two minima in SW.phi
    while np.fabs(phi_vapor - phi_liquid) / np.fabs(fnpart - phi_vapor) > tol:
        delta_mu = (phi_liquid - phi_vapor) / (nliquid - nvapor)

        def newphi(T, n, npart):
            return SW.phi(T, n, npart) - delta_mu * n

        nparticular = minmax.maximize(newphi, T, nvapor, nliquid, nparticular)
        fnpart = SW.phi(T, nparticular, nparticular)

        nvapor, phi_vapor = minmax.minimize(SW.phi, T, a_vap, c_vap,
                                            nparticular)
        nliquid, phi_liquid = minmax.minimize(SW.phi, T, a_liq, c_liq,
                                              nparticular)
Exemplo n.º 40
0
Wifi.Connect()
LED.On2() #Activating led for indication

#sending number on seven segment
SSD.SendNumber(Number)

#Main loop
while 1:
    #indication if number of locations reached zero 
    if(Number==0):
        LED.On1()
    else:
        LED.Off1() 
    
    #checking mode of operation
    mode = SW.GetToggleValue()
    
    #Manual mode
    if mode==1:
        #initializing 3 interrupts
        INT.Init(Inc_ISR, Dec_ISR, Res_ISR)
        print('Manual')
        #establishing connection with server
        message = Server.listen()
        
        #taking action according to message recieved from server
        if(message.lower()=='inc'):
            Number+=1
        if(message.lower()=='dec'):
            Number-=1
        if(message.lower()=='res'):
Exemplo n.º 41
0
def SW_Fexc(T,n):
	#return SW.fhs(T,n)
	#return SW.fdisp(T,n)
	return SW.fdisp(T,n)+SW.fhs(T,n)
Exemplo n.º 42
0
def SW_Finfinity(n):
	T=1.0e8
	return SW.fhs(T,n)/T
Exemplo n.º 43
0
            dn = 1e-6*n
            return (frgp_ext(n + dn) - frgp_ext(n - dn))/(2*dn)




        numdensity3 = plt.linspace(0.0001,max_fillingfraction_handled/(4*np.pi/3),1000)
        finterp = fload(temp)
        ysw=[]  # List for SnAFT SW fluid total free energy data
        yrgdiffsw=[]  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy)
        savdiff=[]  # List for difference between raw free energy difference and fitted data from savgo
        rgfittot=[]  # List for fitted RG total free energy
        rg=[]  # List for RG total free energy
        rgdiff = []  # List for difference between RG total free energy and the savgo fitted total free energy
        for i in range(0,len(numdensity3)):
                ysw.append(SW.ftot(temp,numdensity3[i]))
                yrgdiffsw.append(f_tot(numdensity3[i])-ysw[i])

        savgo = savgol_filter(yrgdiffsw,1,0)  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
        # Use the arguments of (function,1,0) if you wish to not apply the filter

        for j in range(0,len(numdensity3)):
                # Builds the fitted RG total free energy (rgfittot)
                # Builds difference between raw free energy difference and fitted data from savgo
                # Not necessiary, I was just curious how much the savgo filter adjusted the data
                rgfittot.append(SW.ftot(temp,numdensity3[j])+savgo[j])
                savdiff.append(yrgdiffsw[j]-savgo[j])
                rg.append(f_tot(numdensity3[j]))
                rgdiff.append(rgfittot[j]-rg[j])

        frgpinterp = interp1d(numdensity,rgfittot,kind='cubic')
Exemplo n.º 44
0
import matplotlib, sys
if 'show' not in sys.argv:
  matplotlib.use('Agg')
import pylab
import SW
import RG

eta_conv = SW.sigma**3*pylab.pi/6

n = pylab.linspace(0,0.2,10000)
T = 0.3
npart = 0.0462316928818


pylab.plot(n*eta_conv,SW.phi(T,n,npart),'g-',label='SW')
pylab.plot(n*eta_conv,RG.phi(T,n,npart,0),'r-',label='SW+RG; i=0')
pylab.plot(n*eta_conv,RG.phi(T,n,npart,1),'b--',label='SW+RG; i=1')

# pylab.plot(n*eta_conv,SW.f(T,n),'g-',label='SW')
# pylab.plot(n*eta_conv,RG.ftot(T,n,0),'r--',label='SW+RG; i=0')
# pylab.plot(n*eta_conv,RG.ftot(T,n,1),'b--',label='SW+RG; i=1')

pylab.title('T = %0.2f'%T)
pylab.ylabel(r'$\phi$')
# pylab.ylabel(r'$f$')
pylab.xlabel(r'$\eta$')
pylab.legend(loc=0)

pylab.savefig('figs/SW-RG-compare.pdf')
pylab.show()
Exemplo n.º 45
0
    def __init__(self, station_num):
        self.ebreak = False
        self.station_num = station_num
        #self.station_num["ebreak"][0] = 1
        self.index = {}
        self.index["lw"] = 0
        self.index["sw"] = self.index["lw"] + self.station_num["lw"][0]
        self.index["jmp"] = self.index["sw"] + self.station_num["sw"][0]
        #self.index["jalr"] = self.index["sw"] + self.station_num["sw"]
        #self.index["ret"] = self.index["sw"] + self.station_num["sw"]
        self.index["beq"] = self.index["jmp"] + self.station_num["jmp"][0]
        self.index["add"] = self.index["beq"] + self.station_num["beq"][0]
        #self.index["sub"] = self.index["beq"] + self.station_num["beq"]
        #self.index["addi"] = self.index["beq"] + self.station_num["beq"]
        self.index["nand"] = self.index["add"] + self.station_num["add"][0]
        self.index["mult"] = self.index["nand"] + self.station_num["nand"][0]
        self.index["ebreak"] = self.index["mult"] + self.station_num["mult"][0]

        self.used = {}
        self.used["lw"] = 0
        self.used["sw"] = 0
        self.used["jmp"] = 0
        self.used["beq"] = 0
        self.used["add"] = 0
        self.used["nand"] = 0
        self.used["mult"] = 0
        self.used["ebreak"] = 0

        self.cycle = {}
        self.cycle["lw"] = 0
        self.cycle["sw"] = 0
        self.cycle["jmp"] = 0
        self.cycle["beq"] = 0
        self.cycle["add"] = 0
        self.cycle["nand"] = 0
        self.cycle["mult"] = 0
        self.cycle["ebreak"] = 0

        self.station = []

        for i in range(self.station_num["lw"][0]):
            station_entry = {}
            station_entry["name"] = "lw" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = LW(station_num["lw"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["sw"][0]):
            station_entry = {}
            station_entry["name"] = "sw" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = SW(station_num["sw"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["jmp"][0]):
            station_entry = {}
            station_entry["name"] = "jmp" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = JMP(station_num["jmp"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["beq"][0]):
            station_entry = {}
            station_entry["name"] = "beq" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = BEQ(
                station_num["beq"][1])  #TODO change the 1 to be variable
            self.station.append(station_entry)

        for i in range(self.station_num["add"][0]):
            station_entry = {}
            station_entry["name"] = "add" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = Adders(station_num["add"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["nand"][0]):
            station_entry = {}
            station_entry["name"] = "nand" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = NAND(station_num["nand"][1])
            self.station.append(station_entry)

        for i in range(self.station_num["mult"][0]):
            station_entry = {}
            station_entry["name"] = "mult" + str(i)
            station_entry["busy"] = False
            station_entry["op"] = "init"
            station_entry["Vj"] = 0
            station_entry["Vk"] = 0
            station_entry["Qj"] = -1
            station_entry["Qk"] = -1
            station_entry["dest"] = 0
            station_entry["A"] = 0
            station_entry["status"] = "init"
            station_entry["funct_unit"] = Multipliers(station_num["mult"][1])
            self.station.append(station_entry)

        station_entry = {}
        station_entry["name"] = "ebreak"
        station_entry["busy"] = False
        station_entry["op"] = "init"
        station_entry["Vj"] = 0
        station_entry["Vk"] = 0
        station_entry["Qj"] = -1
        station_entry["Qk"] = -1
        station_entry["dest"] = 0
        station_entry["A"] = 0
        station_entry["status"] = "init"
        station_entry["funct_unit"] = None
        self.station.append(station_entry)
Exemplo n.º 46
0
        def plotstuff():
                global rgp
                global frgpinterp
                numdensity3 = plt.linspace(0.0001,.2,1000)
                fload()
                ysw=[]  # List for SnAFT SW fluid total free energy data
                yrgdiffsw=[]  # List for fitted free energy difference (total RG free energy - total SnAFT SW free energy) 
                savdiff=[]  # List for difference between raw free energy difference and fitted data from savgo
                rgfittot=[]  # List for fitted RG total free energy
                rg=[]  # List for RG total free energy
                rgdiff = []  # List for difference between RG total free energy and the savgo fitted total free energy
                for i in range(0,len(numdensity3)):
                        ysw.append(SW.ftot(temp,numdensity3[i]))
                        yrgdiffsw.append(f_tot(numdensity3[i])-ysw[i]) 
 
    

                savgo = savgol_filter(yrgdiffsw,1,0)  #  Uses Savitzky Golay filter from scipy package to fit data (gets rid of noise)
                # Use the arguments of (function,1,0) if you wish to not apply the filter

                for j in range(0,len(numdensity3)):
                        # Builds the fitted RG total free energy (rgfittot)                
                        # Builds difference between raw free energy difference and fitted data from savgo
                        # Not necessiary, I was just curious how much the savgo filter adjusted the data
                        rgfittot.append(SW.ftot(temp,numdensity3[j])+savgo[j])
                        savdiff.append(yrgdiffsw[j]-savgo[j])
                        rg.append(f_tot(numdensity3[j]))
                        rgdiff.append(rgfittot[j]-rg[j])

                
                frgpinterp = interp1d(numdensity,rgfittot,kind='cubic')
              
                plt.figure()
                plt.title('savgo - rg')
                plt.ylabel('free energy')
                plt.xlabel('number density')
                #plt.xlim([0,0.11])
                #plt.ylim([-0.01,0.02])


        
                #plt.plot(numdensity3,savgo,color='red',linewidth=2)
                #plt.plot(numdensity3,sav,color='red',linewidth=2)
        
        
                #plt.plot(numdensity3,yrgdiffsw,color='green',linewidth=2)
                #plt.plot(numdensity3,savgo,color='red',linewidth=1)
                plt.plot(numdensity3,rgdiff,color='green',linewidth=1)
                yrgp = []
                dyrgp = []
                madyrgp = []
                for i in range(0,len(numdensity3)):
                        yrgp.append(frgp_ext(numdensity3[i]))
                        dyrgp.append(dfrgp_dn(numdensity3[i]))
                        if numdensity3[i] < 0.085 and numdensity3[i]>0.001:
                                madyrgp.append(dyrgp[i])
                madyrgp = sum(madyrgp)/len(madyrgp)
                #print madyrgp
                cotangentGuess = []
                for i in range(0,len(numdensity3)):
                        cotangentGuess.append(yrgp[i]-madyrgp*numdensity3[i])