Physics utilities
This page is a work in progress. If you have any questions or notice any errors, please raise an issue.
Overview
This module provides small, self-contained thermodynamic and atmospheric utility functions that are shared across multiple process implementations. All functions are @inlined and scalar-valued; they are intended to be called from within kernel functions. Note that these functions are mostly intended for internal use within the Terrarium.jl codebase, and are therefore not exported as part of the public API. However, once can still access them via Terrarium.function_name if needed.
Some of the functionality here builds upon Thermodynamics.jl, which provides the basic thermodynamic building blocks, based on Rankine-Kirchhoff approximations. For a mathematical overview of these approximations, see here.
Saturation vapor pressure
The saturation vapor pressure $e_{\text{sat}}$ is computed using a wrapper around saturation_vapor_pressure from Thermodynamics.jl and is based on the integration of the Clausius-Clapeyron relation (see here for details).
Vapor pressure and humidity conversions
Specific humidity $q$ and vapor pressure $e$ conversions (including related variables like relative humidity) are handled by Thermodynamics.jl functions (or wrappers around these functions). Specifically:
- Transform $q$ to $e$ via
partial_pressure_vapor. - Transform $e$ to $q$ via
vapor_pressure_to_specific_humidity. With $\varepsilon = R_d / R_v$, the conversion is given by [24, Eq. (2.8)] using the total air pressure $p$:
\[\begin{equation} q = \frac{\varepsilon e}{p - e (1 - \varepsilon)} . \end{equation}\]
Partial pressures of trace gases
The partial pressures of O₂ and CO₂ are computed from total surface pressure and, for CO₂, the volumetric concentration in ppm:
\[\begin{align} p_{\text{O}_2} &= 0.209 \, p \\ p_{\text{CO}_2} &= C_{\text{CO}_2} \times 10^{-6} \times p \end{align}\]
Methods
Terrarium.seconds_per_day — Function
Return the number of seconds per day in the given number format.
Terrarium.seconds_per_hour — Function
Return the number of seconds per hour in the given number format.
Terrarium.saturation_vapor_pressure — Function
saturation_vapor_pressure(T)Saturation vapor pressure of an air parcel at the given temperature T in °C. By default, the saturation vapor pressure is computed over ice for T <= 0°C and over water for T > 0°C. Wrapper around saturation_vapor_pressure.
Terrarium.saturation_specific_humidity_vapor — Function
saturation_specific_humidity_vapor(c::ThermodynamicConstants, T, ρ)Saturation specific humidity at temperature T [°C] and density ρ [kg/m³]. Dispatches over ice for T <= 0°C and over liquid water otherwise. Wrapper around q_vap_saturation.
Terrarium.vapor_pressure_to_specific_humidity — Function
vapor_pressure_to_specific_humidity(c::ThermodynamicConstants, e, pr)Derives specific humidity from measured vapor pressure e [Pa] and air pressure pr [Pa].
Terrarium.relative_to_specific_humidity — Function
relative_to_specific_humidity(r_h, pr, T, c::ThermodynamicConstants)Derives specific humidity from measured relative humidity r_h [%], air pressure pr [Pa], air temperature T [°C], and physical constants c. Assumes saturation over ice for T <= 0°C and over liquid water otherwise. Wrapper around q_vap_from_RH.
Terrarium.partial_pressure_O2 — Function
partial_pressure_O2(pres)
Compute partial pressure of oxygen from surface pressure in Pa.
Terrarium.partial_pressure_CO2 — Function
partial_pressure_CO2(pres, conc_co2)
Compute partial pressure of CO2 from surface pressure and CO2 concentration in Pa.
References
- [24]
- W. J. Shuttleworth. Water Vapor in the Atmosphere. In: Terrestrial Hydrometeorology (John Wiley & Sons, Ltd, 2012); Chapter 2, pp. 14–24.