Exemplo n.º 1
0
def _(temperature):
    if temperature > constants.triple_point_water:
        return typ.e_eq_water_mk(temperature)
    elif temperature < (constants.triple_point_water - 23.0):
        return typ.e_eq_ice_mk(temperature)
    else:
        e_eq_ice = typ.e_eq_ice_mk(temperature)
        return (
            e_eq_ice +
            (typ.e_eq_water_mk(temperature) - typ.e_eq_ice_mk(temperature)) *
            ((temperature - constants.triple_point_water + 23) / 23)**2)
Exemplo n.º 2
0
    def test_e_eq_mixed_mk(self):
        """Test calculation of vapor pressure with respect to mixed phase."""
        assert np.allclose(physics.e_eq_ice_mk(240),
                           physics.e_eq_mixed_mk(240))

        assert np.allclose(physics.e_eq_water_mk(290),
                           physics.e_eq_mixed_mk(290))

        assert (physics.e_eq_ice_mk(263)
                < physics.e_eq_mixed_mk(263)
                < physics.e_eq_water_mk(263))
Exemplo n.º 3
0
def saturation_pressure(temperature):
    r"""Return equilibrium pressure of water with respect to the mixed-phase.

    The equilibrium pressure over water is taken for temperatures above the
    triple point :math:`T_t` the value over ice is taken for temperatures
    below :math:`T_t–23\,\mathrm{K}`.  For intermediate temperatures the
    equilibrium pressure is computed as a combination
    of the values over water and ice according to the IFS documentation:

    .. math::
        e_\mathrm{s} = \begin{cases}
            T > T_t, & e_\mathrm{liq} \\
            T < T_t - 23\,\mathrm{K}, & e_\mathrm{ice} \\
            else, & e_\mathrm{ice}
                + (e_\mathrm{liq} - e_\mathrm{ice})
                \cdot \left(\frac{T - T_t - 23}{23}\right)^2
        \end{cases}

    References:
        IFS Documentation – Cy45r1,
        Operational implementation 5 June 2018,
        Part IV: Physical Processes, Chapter 12, Eq. 12.13,
        https://www.ecmwf.int/node/18714

    Parameters:
        temperature (float or ndarray): Temperature [K].

    See also:
        :func:`~typhon.physics.e_eq_ice_mk`
            Equilibrium pressure of water over ice.
        :func:`~typhon.physics.e_eq_water_mk`
            Equilibrium pressure of water over liquid water.

    Returns:
        float or ndarray: Equilibrium pressure [Pa].
    """
    # Keep track of input type to match the return type.
    is_float_input = isinstance(temperature, Number)
    if is_float_input:
        # Convert float input to ndarray to allow indexing.
        temperature = np.asarray([temperature])

    e_eq_water = typ.e_eq_water_mk(temperature)
    e_eq_ice = typ.e_eq_ice_mk(temperature)

    is_water = temperature > constants.triple_point_water

    is_ice = temperature < (constants.triple_point_water - 23.)

    e_eq = (e_eq_ice + (e_eq_water - e_eq_ice) *
            ((temperature - constants.triple_point_water + 23) / 23)**2)
    e_eq[is_ice] = e_eq_ice[is_ice]
    e_eq[is_water] = e_eq_water[is_water]

    return float(e_eq) if is_float_input else e_eq
Exemplo n.º 4
0
 def test_e_eq_ice_mk(self):
     """Test calculation of equilibrium water vapor pressure over ice."""
     x = physics.e_eq_ice_mk(260)
     assert np.allclose(x, 195.81934571953161)