Пример #1
0
import pylab as plt
import SW
import RG

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

n = plt.linspace(1e-8, 0.2, 10000)

### Low temp ###

T = 0.3
npart0 = 0.0462316928818
npart1 = 0.0776670124628

plt.figure()
plt.plot(n * eta_conv, RG.phi(T, n, npart0, 0), label='i=0')
plt.plot(n * eta_conv, RG.phi(T, n, npart1, 1), label='i=1')

plt.title('T = %0.2f' % T)
plt.ylabel(r'$\phi$')
plt.xlabel(r'$\eta$')
plt.ylim(-0.04, 0.1)
plt.xlim(0, 0.7)
plt.legend(loc=0)

plt.savefig('figs/phi-RG-lowT.pdf')

### High Temp ###

T = 1.32
npart0 = 0.0360850913603
Пример #2
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()
Пример #3
0
def plotphi(T, n, npart, i):
    plt.plot(n * RG.sigma ** 3 * np.pi / 6, RG.phi(T, n, npart, i))
    plt.ylabel(r"$\phi$")
    plt.xlabel(r"$\eta$")
Пример #4
0
import pylab as plt
import SW
import RG

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

n = plt.linspace(1e-8,0.2,10000)

### Low temp ###

T = 0.3
npart0 = 0.0462316928818
npart1 = 0.0776670124628

plt.figure()
plt.plot(n*eta_conv,RG.phi(T,n,npart0,0),label='i=0')
plt.plot(n*eta_conv,RG.phi(T,n,npart1,1),label='i=1')

plt.title('T = %0.2f'%T)
plt.ylabel(r'$\phi$')
plt.xlabel(r'$\eta$')
plt.ylim(-0.04,0.1)
plt.xlim(0,0.7)
plt.legend(loc=0)

plt.savefig('figs/phi-RG-lowT.pdf')

### High Temp ###

T = 1.32
npart0 = 0.0360850913603
Пример #5
0
def npart(iterations):
    # Initial conditions; dependent on you system

    T = 0.1
    nparticular = 0.08/(RG.sigma**3*np.pi/6) # using finite differences df_dn
    # nparticular = 0.155/(RG.sigma**3*np.pi/6) # using analytic df_nd

    # T = 0.68
    # nparticular = 0.0414/(RG.sigma**3*np.pi/6)

    N = 20 # For publication plots, make this bigger (40? 80? 100? You decide!)
    Tc = 1.33
    Tlow = T

    # Bounds of minimization.
    # Use range that works for many temperatures
    # Left (vapor)
    a_vap = 1e-10/(RG.sigma**3*np.pi/6)
    c_vap = nparticular
    # Right (liquid)
    a_liq = nparticular
    c_liq = 0.75/(RG.sigma**3*np.pi/6)
    ###############################

    # Open file for output
    fout = open('figs/npart_RG-i%d-out.dat'%iterations,'w')

    # label the columns of the output
    fout.write('#T     nvapor     nliquid       phi(nvap)        phi(nliq)         nparticular\n')#       phi_avg')
    sys.stdout.flush()

    # Do first temperature before the loop
    nvapor,phi_vapor = minmax_RG.minimize(RG.phi,T,a_vap,c_vap,nparticular,iterations)
    print 'initial nvap,phi_vap',nvapor,phi_vapor
    nliquid,phi_liquid = minmax_RG.minimize(RG.phi,T,a_liq,c_liq,nparticular,iterations)
    print 'initial nliq,phi_liq',nliquid,phi_liquid
    print 'initial npart',nparticular*(RG.sigma**3*np.pi/6)

    #while T < 1.4:
    for j in xrange(0,N+1):
        T = (Tc - Tlow)*(1 - ((N-j)/N)**4) + Tlow

        fout.flush()
        # Starting point for new nparticular is abscissa of max RG.phi with old nparticular
        nparticular = minmax_RG.maximize(RG.phi,T,nvapor, nliquid, nparticular,iterations)

        # I'm looking at the minima of RG.phi
        c_vap = nparticular
        a_liq = nparticular

        nvapor,phi_vapor = minmax_RG.minimize(RG.phi,T,c_vap,a_vap,nparticular,iterations)
        nliquid,phi_liquid = minmax_RG.minimize(RG.phi,T,a_liq,c_liq,nparticular,iterations)

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

        # Compare the two minima in RG.phi
        while np.fabs(phi_vapor - phi_liquid)/np.fabs(fnpart) > tol:

            delta_mu = (phi_liquid - phi_vapor)/(nliquid - nvapor)

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

            nparticular = minmax_RG.maximize(newphi,T,nvapor,nliquid,nparticular,iterations)

            fnpart = RG.phi(T, nparticular, nparticular, iterations)

            nvapor,phi_vapor = minmax_RG.minimize(RG.phi,T,a_vap,c_vap,nparticular,iterations)
            nliquid,phi_liquid = minmax_RG.minimize(RG.phi,T,a_liq,c_liq,nparticular,iterations)

        fout.write(str(T))
        fout.write('  ')
        fout.write(str(nvapor))
        fout.write('  ')
        fout.write(str(nliquid))
        fout.write('  ')
        fout.write(str(phi_vapor))
        fout.write('  ')
        fout.write(str(phi_liquid))
        fout.write('  ')
        fout.write(str(nparticular))
        fout.write('\n')
        sys.stdout.flush();
        print '   T, etaVap, etaLiq',T,nvapor/(RG.sigma**3*np.pi/6),nliquid/(RG.sigma**3*np.pi/6)
    fout.close()
Пример #6
0
 def newphi(T, n, npart, i):
     return RG.phi(T, n, npart, i) - delta_mu*n
Пример #7
0
for i in xrange(0, N + 1):
    T = (Tc - Tlow) * (1 - ((N - i) / N) ** 4) + Tlow

    fout.flush()
    # Starting point for new nparticular is abscissa of max RG.phi with old nparticular
    nparticular = minmax_RG.maximize(RG.phi, T, nvapor, nliquid, nparticular, i)

    # I'm looking at the minima of RG.phi
    c_vap = nparticular
    a_liq = nparticular

    nvapor, phi_vapor = minmax_RG.minimize(RG.phi, T, c_vap, a_vap, nparticular, i)
    nliquid, phi_liquid = minmax_RG.minimize(RG.phi, T, a_liq, c_liq, nparticular, i)

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

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

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

        nparticular = minmax_RG.maximize(newphi, T, nvapor, nliquid, nparticular, i)
        fnpart = RG.phi(T, nparticular, nparticular, i)

        nvapor, phi_vapor = minmax_RG.minimize(RG.phi, T, a_vap, c_vap, nparticular, i)
        nliquid, phi_liquid = minmax_RG.minimize(RG.phi, T, a_liq, c_liq, nparticular, i)

    fout.write(str(T))
Пример #8
0
def plotphi_old(T, n, npart, i, label):
    plt.plot(n * eta_conv, RG1.phi(T, n, npart, i), label=label)
Пример #9
0
def npart(iterations):
    # Initial conditions; dependent on you system

    T = 0.1
    nparticular = 0.08 / (RG.sigma**3 * np.pi / 6
                          )  # using finite differences df_dn
    # nparticular = 0.155/(RG.sigma**3*np.pi/6) # using analytic df_nd

    # T = 0.68
    # nparticular = 0.0414/(RG.sigma**3*np.pi/6)

    N = 20  # For publication plots, make this bigger (40? 80? 100? You decide!)
    Tc = 1.33
    Tlow = T

    # Bounds of minimization.
    # Use range that works for many temperatures
    # Left (vapor)
    a_vap = 1e-10 / (RG.sigma**3 * np.pi / 6)
    c_vap = nparticular
    # Right (liquid)
    a_liq = nparticular
    c_liq = 0.75 / (RG.sigma**3 * np.pi / 6)
    ###############################

    # Open file for output
    fout = open('figs/npart_RG-i%d-out.dat' % iterations, 'w')

    # label the columns of the output
    fout.write(
        '#T     nvapor     nliquid       phi(nvap)        phi(nliq)         nparticular\n'
    )  #       phi_avg')
    sys.stdout.flush()

    # Do first temperature before the loop
    nvapor, phi_vapor = minmax_RG.minimize(RG.phi, T, a_vap, c_vap,
                                           nparticular, iterations)
    print 'initial nvap,phi_vap', nvapor, phi_vapor
    nliquid, phi_liquid = minmax_RG.minimize(RG.phi, T, a_liq, c_liq,
                                             nparticular, iterations)
    print 'initial nliq,phi_liq', nliquid, phi_liquid
    print 'initial npart', nparticular * (RG.sigma**3 * np.pi / 6)

    #while T < 1.4:
    for j in xrange(0, N + 1):
        T = (Tc - Tlow) * (1 - ((N - j) / N)**4) + Tlow

        fout.flush()
        # Starting point for new nparticular is abscissa of max RG.phi with old nparticular
        nparticular = minmax_RG.maximize(RG.phi, T, nvapor, nliquid,
                                         nparticular, iterations)

        # I'm looking at the minima of RG.phi
        c_vap = nparticular
        a_liq = nparticular

        nvapor, phi_vapor = minmax_RG.minimize(RG.phi, T, c_vap, a_vap,
                                               nparticular, iterations)
        nliquid, phi_liquid = minmax_RG.minimize(RG.phi, T, a_liq, c_liq,
                                                 nparticular, iterations)

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

        # Compare the two minima in RG.phi
        while np.fabs(phi_vapor - phi_liquid) / np.fabs(fnpart) > tol:

            delta_mu = (phi_liquid - phi_vapor) / (nliquid - nvapor)

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

            nparticular = minmax_RG.maximize(newphi, T, nvapor, nliquid,
                                             nparticular, iterations)

            fnpart = RG.phi(T, nparticular, nparticular, iterations)

            nvapor, phi_vapor = minmax_RG.minimize(RG.phi, T, a_vap, c_vap,
                                                   nparticular, iterations)
            nliquid, phi_liquid = minmax_RG.minimize(RG.phi, T, a_liq, c_liq,
                                                     nparticular, iterations)

        fout.write(str(T))
        fout.write('  ')
        fout.write(str(nvapor))
        fout.write('  ')
        fout.write(str(nliquid))
        fout.write('  ')
        fout.write(str(phi_vapor))
        fout.write('  ')
        fout.write(str(phi_liquid))
        fout.write('  ')
        fout.write(str(nparticular))
        fout.write('\n')
        sys.stdout.flush()
        print '   T, etaVap, etaLiq', T, nvapor / (
            RG.sigma**3 * np.pi / 6), nliquid / (RG.sigma**3 * np.pi / 6)
    fout.close()
Пример #10
0
 def newphi(T, n, npart, i):
     return RG.phi(T, n, npart, i) - delta_mu * n
Пример #11
0
def plotphi_old(T,n,npart,i,label):
  plt.plot(n*eta_conv,RG1.phi(T,n,npart,i),label=label)