Ejemplo n.º 1
0
# Liquid phase
for i, p in enumerate(ps):

    if p >= iapws1995.pc:
        continue

    # Get the bounding temperatures for this isobar
    Tmin = TMIN
    Tmax = Ts[i][0]

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

    # Get the density estimate
    rhoest = iapws1992.rhosat_liquid(T[-1])

    # Solve for the densities along the isobar, using the previous
    # result as the next estimate
    rho = []
    for T_ in T[::-1]:
        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)

    # Concatenate the arrays
    ss[i] = numpy.concatenate((s, ss[i]))
    Ts[i] = numpy.concatenate((T, Ts[i]))
Ejemplo n.º 2
0
    rhos.append(rho)
    ps.append(p)

# Liquid and solid phases
for i, T in enumerate(Ts):

    if iapws1995.Tt < T < iapws1995.Tc:  # Liquid

        # Get the minimum and maximum pressure
        pmin = iapws1992.psat(T)  # Liquid-vapor saturation pressure
        pmax = PMAX

        # Get the pressures and densities.  Calculate successive points
        # using the previous result as the next estimate.
        p = numpy.logspace(numpy.log10(pmin), numpy.log10(pmax), 100)
        rhoest = iapws1992.rhosat_liquid(T)
        rho = []
        for p_ in p:
            # 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)

        # Concatenate the arrays
        ps[i] = numpy.concatenate((ps[i], p))
        rhos[i] = numpy.concatenate((rhos[i], rho))

    elif T < iapws1995.Tt:  # Solid

        # Get the minimum and maximum pressure
        pmin = iapws2011.psubl_ice_Ih(T)