예제 #1
0
파일: hsat.py 프로젝트: tomduck/myiapws
# Saturated liquid and vapour above triple point
T1 = numpy.linspace(iapws1995.Tt, iapws1995.Tc, 300)
hsat_liquid1 = iapws1992.hsat_liquid(T1)
hsat_vapor1 = iapws1992.hsat_vapor(T1)

# Saturated ice (below triple point)
T2 = numpy.linspace(150, iapws1995.Tt, 300)
psubl = iapws2011.psubl_ice_Ih(T2)
hsat_ice2 = iapws2006.h(T2, psubl)

# Saturated vapour below triple point
rhoest = psubl / (iapws1995.R * T2)
# pylint: disable=cell-var-from-loop
rho = numpy.array([
    newton(lambda rho_: iapws1995.p(rho_, T_) - p_, rhoest_)
    for p_, T_, rhoest_ in zip(psubl, T2, rhoest)
])
hsat_vapor2 = iapws1995.h(rho, T2)

## Plotting ##

fig = pyplot.figure(figsize=[4, 2.8])
fig.set_tight_layout(True)

pyplot.plot(T1, hsat_liquid1 / 1e6, 'k-', linewidth=1)
pyplot.plot(T1, hsat_vapor1 / 1e6, 'k-', linewidth=1)
pyplot.plot(T1[-1], iapws1995.hc / 1e6, 'ko', markersize=4)
pyplot.plot(T2, hsat_ice2 / 1e6, 'k-', linewidth=1)
pyplot.plot(T2, hsat_vapor2 / 1e6, 'k-', linewidth=1)
예제 #2
0
파일: Ts.py 프로젝트: tomduck/myiapws
    # Get the bounding temperatures for this isobar
    Tmin = Tsat(p) if p < pc else TMIN
    Tmax = TMAX

    # Get the temperature series
    T = numpy.linspace(Tmin, Tmax, 300)

    # Estimate the minimum density
    rhoest = p/(iapws1995.R*Tmax)

    # Solve for the densities along the isobar, using the previous
    # result as the next estimate
    rho = []
    for T_ in T[::-1]:
        # pylint: disable=cell-var-from-loop, undefined-loop-variable
        rho.append(newton(lambda rho_: iapws1995.p(rho_, T_)-p, rhoest))
        rhoest = rho[-1]
    rho = numpy.array(rho)[::-1]

    # Get the entropies
    s = iapws1995.s(rho, T)

    # Save the arrays
    ss.append(s)
    Ts.append(T)

# Liquid phase
for i, p in enumerate(ps):

    if p >= iapws1995.pc:
        continue
예제 #3
0
# Parse command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument('-o', dest='path')
path = parser.parse_args().path

## Calculations ##

# Define a series of temperatures
Tl = numpy.linspace(273.16, 373.15, 200)

# Determine the density at normal pressure for this series of temperatures.
# Use the liquid saturation density for each temperature as an estimate.
# pylint: disable=cell-var-from-loop
rhoest = iapws1992.rhosat_liquid(Tl)
rhol = numpy.array([
    newton(lambda rho_: iapws1995.p(rho_, T_) - 101325, rhoest_)
    for rhoest_, T_ in zip(rhoest, Tl)
])

vl = 1 / rhol

# Ice (solid) temperatures and volumes
Ts = numpy.linspace(-25, 0, 100) + 273.15
vs = 1 / iapws2006.rho(Ts, 101325)

## Plotting ##

fig = pyplot.figure(figsize=[4, 2.8])
fig.set_tight_layout(True)

# Isobar
예제 #4
0
# Parse command-line arguments
parser = argparse.ArgumentParser()
parser.add_argument('-o', dest='path')
path = parser.parse_args().path


## Calculations ##

# Define a series of temperatures
T = numpy.linspace(273.2, 373.15, 100)

# Determine the density at normal pressure for this series of temperatures.
# Use the liquid saturation density for each temperature as a first estimate.
# pylint: disable=cell-var-from-loop
rhoest = iapws1992.rhosat_liquid(T)
rho = numpy.array([newton(lambda rho_: iapws1995.p(rho_, T_) - 101325, rhoest_)
                   for rhoest_, T_ in zip(rhoest, T)])

# Get the heat capacities for these densities
cp = iapws1995.cp(rho, T)


## Plotting ##

fig = pyplot.figure(figsize=[4, 2.8])
fig.set_tight_layout(True)

pyplot.plot(T-273.15, cp, 'k-', linewidth=1)
pyplot.xlabel(r'Temperature ($\mathrm{^{\circ}C}$)')
pyplot.ylabel(r'Heat Capacity (J/K/kg)')
예제 #5
0
파일: l.py 프로젝트: tomduck/myiapws
# Vaporization ----------

T1 = numpy.linspace(Tt, Tc, 300)
hsat_liquid1 = iapws1992.hsat_liquid(T1)
hsat_vapor1 = iapws1992.hsat_vapor(T1)
Lvap = hsat_vapor1 - hsat_liquid1

# Sublimation ----------

T2 = numpy.linspace(150, Tt, 300)
psubl = iapws2011.psubl_ice_Ih(T2)
hsat_ice2 = iapws2006.h(T2, psubl)

rhoest = psubl / (iapws1995.R * T2)
# pylint: disable=cell-var-from-loop
rho = numpy.array([newton(lambda rho_: iapws1995.p(rho_, T_) - p_, rhoest_) \
                   for p_, T_, rhoest_ in zip(psubl, T2, rhoest)])
hsat_vapor2 = iapws1995.h(rho, T2)

Lsub = hsat_vapor2 - hsat_ice2

# Fusion ----------

T3 = numpy.linspace(251.165, Tt, 300)
pmelt = iapws2011.pmelt_ice_Ih(T3)
hsat_ice3 = iapws2006.h(T3, pmelt)

# pylint: disable=cell-var-from-loop
rho = numpy.array([newton(lambda rho_: iapws1995.p(rho_, T_) - p_, 1000) \
                   for p_, T_ in zip(pmelt, T3)])
hsat_liquid3 = iapws1995.h(rho, T3)
예제 #6
0
파일: pv.py 프로젝트: tomduck/myiapws
Tc = iapws1995.Tc - 273.15  # C
Ts = numpy.array([-25, 0, 40, 100, 200, Tc, 1000, 2300]) + 273.15 # K
rhos = []
ps = []

# Determine the piecewise isotherms.  Obtain the gas/vapor segments first,
# followed by the liquid and solid segments.  We don't need to obtain data
# in the mixed phase region; the plateaus emerge when the segments are
# concatenated.

# Gas/vapor and supercritical fluid phases
for T in Ts:

    # Determine the minimum density.  Estimate it using the ideal gas law.
    # pylint: disable=cell-var-from-loop
    rhomin = newton(lambda rho_: iapws1995.p(rho_, T) - PMIN,
                    PMIN/(iapws1995.R*T))

    # Determine the maximum density. For Tt < T < Tc use the liquid-vapor
    # saturation density from IAPWS 1992; otherwise solve for it using an
    # estimate from the ideal gas law (the extra factor of 1.5 helps avoid
    # convergence problems around the critical density).
    if iapws1995.Tt < T < iapws1995.Tc:
        rhomax = iapws1992.rhosat_vapor(T)
    else:
        pmax = iapws2011.psubl_ice_Ih(T) if T < iapws1995.Tt else PMAX
        rhoest = pmax/(iapws1995.R*T)*1.5
        # pylint: disable=cell-var-from-loop
        rhomax = newton(lambda rho_: iapws1995.p(rho_, T) - pmax, rhoest)

    # Get the densities and pressures