Thermodynamics

Thermodynamics.ThermodynamicsModule
Thermodynamics

Moist thermodynamic functions, e.g., for air pressure (atmosphere equation of state), latent heats of phase transitions, saturation vapor pressures, and saturation specific humidities.

AbstractParameterSet's

Many functions defined in this module rely on ClimaParams.jl. ClimaParams.jl defines several functions (e.g., many planet parameters). For example, to compute the mole-mass ratio:

import ClimaParams as CP
import Thermodynamics.Parameters as TP
FT = Float64
param_set = TP.ThermodynamicsParameters(FT)
_molmass_ratio = TP.molmass_ratio(param_set)

Because these parameters are widely used throughout this module, param_set is an argument for many Thermodynamics functions.

Numerical methods for saturation adjustment

Saturation adjustment function are designed to accept

  • sat_adjust_method a type used to dispatch which numerical method to use

and a function to return an instance of the numerical method. For example:

  • sa_numerical_method_ρpq returns an instance of the numerical method. One of these functions must be defined for the particular numerical method and the particular formulation (ρ-p-q_tot in this case).

The currently supported numerical methods, in RootSolvers.jl, are:

  • NewtonsMethod uses Newton method with analytic gradients
  • NewtonsMethodAD uses Newton method with autodiff
  • SecantMethod uses Secant method
  • RegulaFalsiMethod uses Regula-Falsi method
source

Thermodynamics Parameters

Thermodynamics.Parameters.ThermodynamicsParametersType
ThermodynamicsParameters

Parameters for Thermodynamics.jl.

Example

import ClimaParams as CP
import Thermodynamics.Parameters as TP

FT = Float64;
param_set = TP.ThermodynamicsParameters(FT)

# Alternatively:
toml_dict = CP.create_toml_dict(FT)
param_set = TP.ThermodynamicsParameters(toml_dict)
source

Thermodynamic State Constructors

Thermodynamics.PhasePartitionType
PhasePartition

Represents the mass fractions of the moist air mixture.

Constructors

PhasePartition(q_tot::Real[, q_liq::Real[, q_ice::Real]])
PhasePartition(param_set::APS, ts::ThermodynamicState)

See also PhasePartition_equil

Fields

  • tot: total specific humidity

  • liq: liquid water specific humidity (default: 0)

  • ice: ice specific humidity (default: 0)

source
Thermodynamics.ThermodynamicStateType
ThermodynamicState{FT}

A thermodynamic state, which can be initialized for various thermodynamic formulations (via its sub-types). All ThermodynamicState's have access to functions to compute all other thermodynamic properties.

source
Thermodynamics.PhaseDryType
PhaseDry{FT} <: AbstractPhaseDry

A dry thermodynamic state (q_tot = 0).

Constructors

PhaseDry(param_set, e_int, ρ)

Fields

  • e_int: internal energy

  • ρ: density of dry air

source
Thermodynamics.PhaseEquilType
PhaseEquil{FT} <: AbstractPhaseEquil

A thermodynamic state assuming thermodynamic equilibrium (therefore, saturation adjustment may be needed).

Constructors

PhaseEquil(param_set, ρ, e_int, q_tot)

Fields

  • ρ: density of air (potentially moist)

  • p: air pressure

  • e_int: internal energy

  • q_tot: total specific humidity

  • T: temperature: computed via saturation_adjustment

source
Thermodynamics.PhaseEquil_ρeqFunction
PhaseEquil_ρeq(param_set, ρ, e_int, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Moist thermodynamic phase, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ρ density
  • e_int internal energy
  • q_tot total specific humidity

and, optionally

  • maxiter maximum iterations for saturation adjustment
  • relative_temperature_tol relative temperature tolerance for saturation adjustment
  • sat_adjust_method the numerical method to use. See the Thermodynamics for options.
  • T_guess initial guess for temperature in saturation adjustment
source
Thermodynamics.PhaseEquil_pθqFunction
PhaseEquil_pθq(param_set, θ_liq_ice, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Constructs a PhaseEquil thermodynamic state from:

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p air pressure
  • θ_liq_ice liquid-ice potential temperature
  • q_tot total specific humidity
  • relative_temperature_tol relative temperature tolerance for saturation adjustment
  • maxiter maximum iterations for saturation adjustment
  • sat_adjust_method the numerical method to use.
  • T_guess initial guess for temperature in saturation adjustment
source
Thermodynamics.PhaseEquil_peqFunction
PhaseEquil_peq(param_set, p, e_int, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Constructs a PhaseEquil thermodynamic state from temperature.

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p pressure
  • e_int temperature
  • q_tot total specific humidity
  • T_guess initial guess for temperature in saturation adjustment
source
Thermodynamics.PhaseEquil_phqFunction
PhaseEquil_phq(param_set, p, h, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Constructs a PhaseEquil thermodynamic state from temperature.

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p pressure
  • h specific enthalpy
  • q_tot total specific humidity
  • T_guess initial guess for temperature in saturation adjustment
source
Thermodynamics.PhaseEquil_ρθqFunction
PhaseEquil_ρθq(param_set, ρ, θ_liq_ice, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])

Constructs a PhaseEquil thermodynamic state from:

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ρ (moist-)air density
  • θ_liq_ice liquid-ice potential temperature
  • q_tot total specific humidity
  • relative_temperature_tol relative temperature tolerance for saturation adjustment
  • maxiter maximum iterations for saturation adjustment
  • T_guess initial guess for temperature in saturation adjustment
source
Thermodynamics.PhaseEquil_ρpqFunction
PhaseEquil_ρpq(param_set, ρ, p, q_tot[, perform_sat_adjust=true, maxiter, sat_adjust_method, T_guess])

Constructs a PhaseEquil thermodynamic state from temperature.

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ρ density
  • p pressure
  • q_tot total specific humidity
  • perform_sat_adjust Bool indicating to perform saturation adjustment
  • maxiter maximum number of iterations to perform in saturation adjustment
  • sat_adjust_method the numerical method to use. See the Thermodynamics for options.
  • T_guess initial guess for temperature in saturation adjustment

TODO: change input argument order: performsatadjust is unique to this constructor, so it should be last. (breaking change)

source
Thermodynamics.PhaseNonEquilType
 PhaseNonEquil{FT} <: ThermodynamicState

A thermodynamic state assuming thermodynamic non-equilibrium (therefore, temperature can be computed directly).

Constructors

PhaseNonEquil(param_set, e_int, q::PhasePartition, ρ)

Fields

  • e_int: internal energy

  • ρ: density of air (potentially moist)

  • q: phase partition

source
Thermodynamics.PhaseNonEquil_ρθqFunction
PhaseNonEquil_ρθq(param_set, ρ, θ_liq_ice, q_pt)

Constructs a PhaseNonEquil thermodynamic state from:

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ρ (moist-)air density
  • θ_liq_ice liquid-ice potential temperature
  • q_pt phase partition

and, optionally

  • relative_temperature_tol potential temperature for non-linear equation solve
  • maxiter maximum iterations for non-linear equation solve
source

Types

Thermodynamic state methods

Thermodynamics.air_densityFunction
air_density(param_set, T, p[, q::PhasePartition])

The (moist-)air density from the equation of state (ideal gas law) where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T air temperature
  • p pressure

and, optionally,

source
air_density(param_set::APS, ts::ThermodynamicState)

The (moist-)air density, given a thermodynamic state ts.

source
Thermodynamics.air_pressureFunction
air_pressure(param_set, T, ρ[, q::PhasePartition])

The air pressure from the equation of state (ideal gas law) where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T air temperature
  • ρ (moist-)air density

and, optionally,

source
air_pressure(param_set::APS, ts::ThermodynamicState)

The air pressure from the equation of state (ideal gas law), given a thermodynamic state ts.

source
air_pressure(param_set, T::FT, T∞::FT, p∞::FT, ::DryAdiabaticProcess)

The air pressure for an isentropic process, where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • T∞ ambient temperature
  • p∞ ambient pressure
source
Thermodynamics.air_temperatureFunction
air_temperature(param_set, e_int, q::PhasePartition)

The air temperature, where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • e_int internal energy per unit mass

and, optionally,

source
air_temperature(param_set::APS, ts::ThermodynamicState)

The air temperature, given a thermodynamic state ts.

source
air_temperature(param_set, p::FT, θ::FT, Φ::FT, ::DryAdiabaticProcess)

The air temperature for an isentropic process, where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p pressure
  • θ potential temperature
source
Thermodynamics.condensateFunction
condensate(q::PhasePartition{FT})
condensate(param_set::APS, ts::ThermodynamicState)

Condensate of the phase partition.

source
Thermodynamics.cp_mFunction
cp_m(param_set, q::PhasePartition)

The isobaric specific heat capacity of moist air given

source
cp_m(param_set::APS, ts::ThermodynamicState)

The isobaric specific heat capacity of moist air, given a thermodynamic state ts.

source
Thermodynamics.cv_mFunction
cv_m(param_set, q::PhasePartition)

The isochoric specific heat capacity of moist air given

source
cv_m(param_set::APS, ts::ThermodynamicState)

The isochoric specific heat capacity of moist air, given a thermodynamic state ts.

source
Thermodynamics.dry_pottempFunction
dry_pottemp(param_set, T, ρ[, q::PhasePartition, cpm])

The dry potential temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density

and, optionally,

source
dry_pottemp(param_set::APS, ts::ThermodynamicState)

The dry potential temperature, given a thermodynamic state ts.

source
Thermodynamics.exnerFunction
exner(param_set, T, ρ[, q::PhasePartition)])

The Exner function where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density

and, optionally,

source
exner(param_set::APS, ts::ThermodynamicState)

The Exner function, given a thermodynamic state ts.

source
Thermodynamics.gas_constant_airFunction
gas_constant_air(param_set, [q::PhasePartition])

The specific gas constant of moist air given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • q PhasePartition. Without this argument, the results are for dry air.
source
gas_constant_air(param_set::APS, ts::ThermodynamicState)

The specific gas constant of moist air given a thermodynamic state ts.

source
Thermodynamics.gas_constantsFunction
(R_m, cp_m, cv_m, γ_m) = gas_constants(param_set, q::PhasePartition)

Wrapper to compute all gas constants at once, where optionally,

The function returns a tuple of

source
(R_m, cp_m, cv_m, γ_m) = gas_constants(param_set::APS, ts::ThermodynamicState)

Wrapper to compute all gas constants at once, given a thermodynamic state ts.

The function returns a tuple of

source
Thermodynamics.has_condensateFunction
has_condensate(q::PhasePartition{FT})
has_condensate(param_set::APS, ts::ThermodynamicState)

Bool indicating if condensate exists in the phase partition

source
Thermodynamics.ice_specific_humidityFunction
ice_specific_humidity(param_set::APS, ts::ThermodynamicState)
ice_specific_humidity(q::PhasePartition)

Ice specific humidity given

  • ts a thermodynamic state

or

  • q a PhasePartition
source
Thermodynamics.internal_energyFunction
internal_energy(param_set, T[, q::PhasePartition])

The internal energy per unit mass, given a thermodynamic state ts or

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature

and, optionally,

source
internal_energy(param_set::APS, ts::ThermodynamicState)

The internal energy per unit mass, given a thermodynamic state ts.

source
internal_energy(ρ::FT, ρe::FT, ρu::AbstractVector{FT}, e_pot::FT)

The internal energy per unit mass, given

  • ρ (moist-)air density
  • ρe total energy per unit volume
  • ρu momentum vector
  • e_pot potential energy (e.g., gravitational) per unit mass
source
Thermodynamics.internal_energy_dryFunction
internal_energy_dry(param_set, T)

The dry air internal energy

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
internal_energy_dry(param_set::APS, ts::ThermodynamicState)

The the dry air internal energy, given a thermodynamic state ts.

source
Thermodynamics.internal_energy_vaporFunction
internal_energy_vapor(param_set, T)

The water vapor internal energy

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
internal_energy_vapor(param_set::APS, ts::ThermodynamicState)

The the water vapor internal energy, given a thermodynamic state ts.

source
Thermodynamics.internal_energy_liquidFunction
internal_energy_liquid(param_set, T)

The liquid water internal energy

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
internal_energy_liquid(param_set::APS, ts::ThermodynamicState)

The the liquid water internal energy, given a thermodynamic state ts.

source
Thermodynamics.internal_energy_iceFunction
internal_energy_ice(param_set, T)

The ice internal energy

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
internal_energy_ice(param_set::APS, ts::ThermodynamicState)

The the ice internal energy, given a thermodynamic state ts.

source
Thermodynamics.internal_energy_satFunction
internal_energy_sat(param_set, T, ρ, q_tot, phase_type)

The internal energy per unit mass in thermodynamic equilibrium at saturation where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density
  • q_tot total specific humidity
  • phase_type a thermodynamic state type
source
internal_energy_sat(param_set::APS, ts::ThermodynamicState)

The internal energy per unit mass in thermodynamic equilibrium at saturation, given a thermodynamic state ts.

source
Thermodynamics.latent_heat_fusionFunction
latent_heat_fusion(param_set, T::FT) where {FT<:Real}

The specific latent heat of fusion where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
latent_heat_fusion(param_set::APS, ts::ThermodynamicState)

The specific latent heat of fusion given a thermodynamic state ts.

source
Thermodynamics.latent_heat_liq_iceFunction
latent_heat_liq_ice(param_set, q::PhasePartition{FT})

Effective latent heat of condensate (weighted sum of liquid and ice), with specific latent heat evaluated at reference temperature T_0 given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • q PhasePartition. Without this argument, the results are for dry air.
source
Thermodynamics.latent_heat_sublimFunction
latent_heat_sublim(param_set, T::FT) where {FT<:Real}

The specific latent heat of sublimation where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
latent_heat_sublim(param_set::APS, ts::ThermodynamicState)

The specific latent heat of sublimation given a thermodynamic state ts.

source
Thermodynamics.latent_heat_vaporFunction
latent_heat_vapor(param_set, T::FT) where {FT<:Real}

The specific latent heat of vaporization where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
source
latent_heat_vapor(param_set::APS, ts::ThermodynamicState)

The specific latent heat of vaporization given a thermodynamic state ts.

source
Thermodynamics.liquid_fractionFunction
liquid_fraction(param_set, T, phase_type[, q])

The fraction of condensate that is liquid where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • phase_type a thermodynamic state type

PhaseNonEquil behavior

If q.liq or q.ice are nonzero, the liquid fraction is computed from them.

ThermodynamicState

Otherwise, phase equilibrium is assumed so that the fraction of liquid is a function that is 1 above T_freeze and goes to zero below T_icenuc.

source
liquid_fraction(param_set::APS, ts::ThermodynamicState)

The fraction of condensate that is liquid given a thermodynamic state ts.

source
Thermodynamics.liquid_ice_pottempFunction
liquid_ice_pottemp(param_set, T, ρ[, q::PhasePartition, cpm])

The liquid-ice potential temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density

and, optionally,

source
liquid_ice_pottemp(param_set::APS, ts::ThermodynamicState)

The liquid-ice potential temperature, given a thermodynamic state ts.

source
Thermodynamics.liquid_ice_pottemp_satFunction
liquid_ice_pottemp_sat(param_set, T, ρ, phase_type[, q::PhasePartition, cpm])

The saturated liquid ice potential temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density
  • phase_type a thermodynamic state type

and, optionally,

source
liquid_ice_pottemp_sat(param_set, T, ρ, phase_type, q_tot)

The saturated liquid ice potential temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density
  • phase_type a thermodynamic state type
  • q_tot total specific humidity
source
liquid_ice_pottemp_sat(param_set::APS, ts::ThermodynamicState)

The liquid potential temperature given a thermodynamic state ts.

source
Thermodynamics.liquid_specific_humidityFunction
liquid_specific_humidity(param_set::APS, ts::ThermodynamicState)
liquid_specific_humidity(q::PhasePartition)

Liquid specific humidity given

  • ts a thermodynamic state

or

  • q a PhasePartition
source
Thermodynamics.mixing_ratiosFunction
mixing_ratios(q::PhasePartition)

Mixing ratios

  • r.tot total mixing ratio
  • r.liq liquid mixing ratio
  • r.ice ice mixing ratio

given a phase partition, q.

source
mixing_ratios(param_set::APS, ts::ThermodynamicState)

Mixing ratios stored, in a phase partition, for

  • total specific humidity
  • liquid specific humidity
  • ice specific humidity
source
Thermodynamics.moist_static_energyFunction
moist_static_energy(param_set, ts, e_pot)

Moist static energy, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ts a thermodynamic state
  • e_pot potential energy (e.g., gravitational) per unit mass
source
Thermodynamics.q_vap_saturationFunction
q_vap_saturation(param_set, T, ρ, phase_type[, q::PhasePartition])

Compute the saturation specific humidity, given

  • param_set: an AbstractParameterSet, see the Thermodynamics for more details
  • T: temperature
  • ρ: air density
  • phase_type: a thermodynamic state type
  • (optional) q: PhasePartition

If the PhasePartition q is given, the saturation specific humidity is that of a mixture of liquid and ice, computed in a thermodynamically consistent way from the weighted sum of the latent heats of the respective phase transitions (Pressel et al., JAMES, 2015). That is, the saturation vapor pressure and from it the saturation specific humidity are computed from a weighted mean of the latent heats of vaporization and sublimation, with the weights given by the fractions of condensates q.liq/(q.liq + q.ice) and q.ice/(q.liq + q.ice) that are liquid and ice, respectively.

If the PhasePartition q is not given, or has zero liquid and ice specific humidities, the saturation specific humidity is that over a mixture of liquid and ice, with the fraction of liquid given by temperature dependent liquid_fraction(param_set, T, phase_type) and the fraction of ice by the complement 1 - liquid_fraction(param_set, T, phase_type).

source
q_vap_saturation(param_set::APS, ts::ThermodynamicState)

Compute the saturation specific humidity, given a thermodynamic state ts.

source
Thermodynamics.relative_humidityFunction
relative_humidity(param_set, T, p, phase_type, q::PhasePartition)

The relative humidity, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p pressure
  • phase_type a thermodynamic state type

and, optionally,

source
relative_humidity(param_set::APS, ts::ThermodynamicState)

The relative humidity, given a thermodynamic state ts.

source
Thermodynamics.saturation_adjustmentFunction
saturation_adjustment(
    sat_adjust_method,
    param_set,
    e_int,
    ρ,
    q_tot,
    phase_type,
    maxiter,
    relative_temperature_tol,
    T_guess,
)

Compute the temperature that is consistent with

  • sat_adjust_method the numerical method to use. See the Thermodynamics for options.
  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • e_int internal energy
  • ρ (moist-)air density
  • q_tot total specific humidity
  • phase_type a thermodynamic state type
  • maxiter maximum iterations for non-linear equation solve
  • relative_temperature_tol relative temperature tolerance
  • T_guess initial temperature guess

by finding the root of

e_int - internal_energy_sat(param_set, T, ρ, q_tot, phase_type) = 0

using the given numerical method sat_adjust_method.

See also saturation_adjustment.

source
Thermodynamics.saturation_excessFunction
saturation_excess(param_set, T, ρ, phase_type, q::PhasePartition)

The saturation excess in equilibrium where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density
  • phase_type a thermodynamic state type
  • q PhasePartition

The saturation excess is the difference between the total specific humidity q.tot and the saturation specific humidity in equilibrium, and it is defined to be nonzero only if this difference is positive.

source
saturation_excess(param_set::APS, ts::ThermodynamicState)

Compute the saturation excess in equilibrium, given a thermodynamic state ts.

source
Thermodynamics.saturation_vapor_pressureFunction
saturation_vapor_pressure(param_set, T, Liquid())

Return the saturation vapor pressure over a plane liquid surface given

  • T temperature

  • param_set an AbstractParameterSet, see the Thermodynamics for more details

    saturation_vapor_pressure(param_set, T, Ice())

Return the saturation vapor pressure over a plane ice surface given

  • T temperature

  • param_set an AbstractParameterSet, see the Thermodynamics for more details

    saturation_vapor_pressure(param_set, T, LH_0, Δcp)

Compute the saturation vapor pressure over a plane surface by integration of the Clausius-Clapeyron relation.

The Clausius-Clapeyron relation

`dlog(p_v_sat)/dT = [LH_0 + Δcp * (T-T_0)]/(R_v*T^2)`

is integrated from the triple point temperature T_triple, using Kirchhoff's relation

`L = LH_0 + Δcp * (T - T_0)`

for the specific latent heat L with constant isobaric specific heats of the phases. The linear dependence of the specific latent heat on temperature T allows analytic integration of the Clausius-Clapeyron relation to obtain the saturation vapor pressure p_v_sat as a function of the triple point pressure press_triple.

source
Thermodynamics.soundspeed_airFunction
soundspeed_air(param_set, T[, q::PhasePartition])

The speed of sound in unstratified air, where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature

and, optionally,

source
soundspeed_air(param_set::APS, ts::ThermodynamicState)

The speed of sound in unstratified air given a thermodynamic state ts.

source
Thermodynamics.specific_enthalpyFunction
specific_enthalpy(e_int, R_m, T)

Specific enthalpy, given

source
specific_enthalpy(param_set, ts)

Specific enthalpy, given a thermodynamic state ts.

source
specific_enthalpy(param_set, T[, q::PhasePartition])

The specific_enthalpy per unit mass, given a thermodynamic state ts or

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature

and, optionally,

source
Thermodynamics.supersaturationFunction
supersaturation(param_set, q, ρ, T, Liquid())
supersaturation(param_set, q, ρ, T, Ice())
supersaturation(ts, Ice())
supersaturation(ts, Liquid())
  • param_set - abstract set with earth parameters
  • q - phase partition
  • ρ - air density,
  • T - air temperature
  • Liquid(), Ice() - liquid or ice phase to dispatch over.
  • ts thermodynamic state

Returns supersaturation (pv/pv_sat -1) over water or ice.

source
Thermodynamics.total_energyFunction
total_energy(param_set, e_kin, e_pot, T[, q::PhasePartition])

The total energy per unit mass, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • e_kin kinetic energy per unit mass
  • e_pot potential energy per unit mass
  • T temperature

and, optionally,

source
total_energy(param_set::APS, ts::ThermodynamicState, e_kin, e_pot)

The total energy per unit mass given a thermodynamic state ts.

source
Thermodynamics.total_specific_enthalpyFunction
total_specific_enthalpy(e_tot, R_m, T)

Total specific enthalpy, given

source
total_specific_enthalpy(param_set, ts, e_tot::Real)

Total specific enthalpy, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • ts a thermodynamic state
  • e_tot total specific energy
source
Thermodynamics.total_specific_humidityFunction
total_specific_humidity(param_set::APS, ts::ThermodynamicState)
total_specific_humidity(param_set, T, p, relative_humidity)

Total specific humidity given

  • ts a thermodynamic state

or

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • p pressure
  • relative_humidity relative humidity (can exceed 1 when there is super saturation/condensate)
source
Thermodynamics.virtual_pottempFunction
virtual_pottemp(param_set, T, ρ[, q::PhasePartition])

The virtual potential temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density

and, optionally,

source
virtual_pottemp(param_set::APS, ts::ThermodynamicState)

The virtual potential temperature, given a thermodynamic state ts.

source
Thermodynamics.virtual_temperatureFunction
virtual_temperature(param_set, T[, q::PhasePartition])

The virtual temperature where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature

and, optionally,

source
virtual_temperature(param_set::APS, ts::ThermodynamicState)

The virtual temperature, given a thermodynamic state ts.

source
Thermodynamics.specific_entropyFunction
specific_entropy(param_set, p, T, q)
specific_entropy(param_set, ts)

Specific entropy, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • p pressure
  • T temperature
  • q phase partition

following equations (29)-(33) of [1].

source

Internal methods

Thermodynamics.q_vap_saturation_genericFunction
q_vap_saturation_generic(param_set, T, ρ[, phase=Liquid()])

Compute the saturation specific humidity over a plane surface of condensate, given

- `param_set`: an `AbstractParameterSet`, see the [`Thermodynamics`](@ref) for more details
- `T`: temperature
- `ρ`: air density
- (optional) `Liquid()`: indicating condensate is liquid
- (optional) `Ice()`: indicating condensate is ice
source
Thermodynamics.q_vap_saturation_from_pressureFunction
q_vap_saturation_from_pressure(param_set, q_tot, p, T, phase_type)

Compute the saturation specific humidity, given

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • q_tot total water specific humidity,
  • p air pressure,
  • T air tempearture
  • phase_type a thermodynamic state type
source
Thermodynamics.PhasePartition_equilFunction
PhasePartition_equil(param_set, T, ρ, q_tot, phase_type)
PhasePartition_equil(param_set, T, ρ, q_tot, p_vap_sat, λ)

Partition the phases in equilibrium, returning a PhasePartition object using the liquid_fraction function where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • ρ (moist-)air density
  • q_tot total specific humidity
  • phase_type a thermodynamic state type
  • p_vap_sat saturation vapor pressure
  • λ liquid fraction

The residual q.tot - q.liq - q.ice is the vapor specific humidity.

source
Thermodynamics.PhasePartition_equil_given_pFunction
PhasePartition_equil_given_p(param_set, T, p, q_tot, phase_type)

Partition the phases in equilibrium, returning a PhasePartition object using the liquid_fraction function where

  • param_set an AbstractParameterSet, see the Thermodynamics for more details
  • T temperature
  • p air pressure
  • q_tot total specific humidity
  • phase_type a thermodynamic state type

The residual q.tot - q.liq - q.ice is the vapor specific humidity.

source

Dispatch types

Temperature Profiles

Thermodynamics.TemperatureProfiles.TemperatureProfileType
TemperatureProfile

Specifies the temperature or virtual temperature profile for a reference state.

Instances of this type are required to be callable objects with the following signature

T,p = (::TemperatureProfile)(param_set::APS, z::FT) where {FT}

where T is the temperature or virtual temperature (in K), and p is the pressure (in Pa).

source
Thermodynamics.TemperatureProfiles.DecayingTemperatureProfileType
DecayingTemperatureProfile{F} <: TemperatureProfile{FT}

A virtual temperature profile that decays smoothly with height z, from T_virt_surf to T_min_ref over a height scale H_t. The default height scale H_t is the density scale height evaluated with T_virt_surf.

\[T_{\text{v}}(z) = \max(T_{\text{v, sfc}} − (T_{\text{v, sfc}} - T_{\text{v, min}}) \tanh(z/H_{\text{t}})\]

Fields

  • T_virt_surf: Virtual temperature at surface (K)

  • T_min_ref: Minimum virtual temperature at the top of the atmosphere (K)

  • H_t: Height scale over which virtual temperature drops (m)

source

Tested profiles

Thermodynamics.TestedProfilesModule
TestedProfiles

Tested thermodynamic profiles

This module contains functions to compute all of the thermodynamic states that Thermodynamics is tested with in runtests.jl

source

Data collection

Thermodynamics.DataCollectionModule
DataCollection

This module is designed to help judge the accuracy and performance for a particular formulation, tolerance, and or solver configuration, by providing tools to collect various statistics when Thermodynamic saturation_adjustment is called.

Example:

import Thermodynamics as TD
import RootSolvers as RS

function do_work()
    # Calls TD.PhaseEquil_ρeq()..., possibly many times
end

TD.solution_type() = RS.VerboseSolution()
do_work()
TD.DataCollection.print_summary()
Warn

This data collection was designed for unthreaded single processor runs, and may not work correctly for threaded / multi-processor runs.

source