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.
Saturation vapor pressure
The saturation vapor pressure $e_{\text{sat}}$ is computed using the August-Roche-Magnus empirical formula (Alduchov and Eskridge, 1997):
\[\begin{equation} e_{\text{sat}}(T) = a_1 \exp\!\left(\frac{a_2 T}{T + a_3}\right) \end{equation}\]
where $T$ is temperature in °C and the coefficients differ for liquid water ($T \geq 0$°C) and ice ($T < 0$°C):
| Phase | $a_1$ (Pa) | $a_2$ | $a_3$ (°C) |
|---|---|---|---|
| Liquid water ($T \geq 0$°C) | 611.0 | 17.62 | 243.12 |
| Ice ($T < 0$°C) | 611.0 | 22.46 | 272.62 |
Vapor pressure and humidity conversions
Specific humidity $q$ and vapor pressure $e$ are related through the molecular weight ratio $\varepsilon = M_v / M_d \approx 0.622$ and the total atmospheric pressure $p$:
\[\begin{equation} q = \frac{\varepsilon \, e}{p} \end{equation}\]
The inverse conversion (vapor pressure from specific humidity) accounts for the partial pressure of dry air:
\[\begin{equation} e = \frac{q \, p}{\varepsilon + (1 - \varepsilon) q} \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, a₁, a₂, a₃)August-Roche-Magnus equation for saturation vapor pressure at temperature T with empirical coefficients a₁, a₂, and a₃.
saturation_vapor_pressure(T, Ts=T)Saturation vapor pressure at the given temperature T, accounting for both frozen (T < 0°C) and unfrozen conditions.
Coefficients taken from Alduchov and Eskridge (1997).
Terrarium.vapor_pressure_to_specific_humidity — Function
vapor_pressure_to_specific_humidity(e, p, ε)Convert the vapor pressure e to specific humidity at the given pressure p based on the molecular weight ratio ε.
Terrarium.relative_to_specific_humidity — Function
relative_to_specific_humidity(r_h, pr, Tair)Derives specific humidity from measured relative humidity, air pressure, and air temperature.
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.