Moist Thermodynamics
Moist Thermodynamics
ClimateMachine.MoistThermodynamics — ModuleMoistThermodynamicsMoist 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 CLIMAParameters.jl. CLIMAParameters.jl defines several functions (e.g., many planet parameters). For example, to compute the mole-mass ratio:
using CLIMAParameters.Planet: molmass_ratio
using CLIMAParameters: AbstractEarthParameterSet
struct EarthParameterSet <: AbstractEarthParameterSet end
param_set = EarthParameterSet()
_molmass_ratio = molmass_ratio(param_set)Because these parameters are widely used throughout this module, param_set is an argument for many MoistThermodynamics functions.
Thermodynamic State Constructors
ClimateMachine.MoistThermodynamics.PhasePartition — TypePhasePartitionRepresents the mass fractions of the moist air mixture.
Constructors
PhasePartition(q_tot::Real[, q_liq::Real[, q_ice::Real]])
PhasePartition(ts::ThermodynamicState)See also PhasePartition_equil
Fields
tottotal specific humidity
liqliquid water specific humidity (default:
0)iceice specific humidity (default:
0)
ClimateMachine.MoistThermodynamics.PhasePartition_equil — FunctionPhasePartition_equil(param_set, T, ρ, q_tot)Partition the phases in equilibrium, returning a PhasePartition object using the liquid_fraction function where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air densityq_tottotal specific humidity
The residual q.tot - q.liq - q.ice is the vapor specific humidity.
ClimateMachine.MoistThermodynamics.ThermodynamicState — TypeThermodynamicState{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.
ClimateMachine.MoistThermodynamics.PhaseDry — TypePhaseDry{FT} <: ThermodynamicStateA dry thermodynamic state (q_tot = 0).
Constructors
PhaseDry(param_set, e_int, ρ)Fields
param_setparameter set, used to dispatch planet parameter function calls
e_intinternal energy
ρdensity of dry air
ClimateMachine.MoistThermodynamics.PhaseDry_given_pT — FunctionPhaseDry_given_pT(param_set, p, T)Constructs a PhaseDry thermodynamic state from:
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsppressureTtemperature
ClimateMachine.MoistThermodynamics.PhaseDry_given_ρT — FunctionPhaseDry_given_ρT(param_set, ρ, T)Constructs a PhaseDry thermodynamic state from:
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsρdensityTtemperature
ClimateMachine.MoistThermodynamics.PhaseEquil — TypePhaseEquil{FT} <: ThermodynamicStateA thermodynamic state assuming thermodynamic equilibrium (therefore, saturation adjustment may be needed).
Constructors
PhaseEquil(param_set, e_int, ρ, q_tot)Fields
param_setparameter set, used to dispatch planet parameter function calls
e_intinternal energy
ρdensity of air (potentially moist)
q_tottotal specific humidity
Ttemperature: computed via
saturation_adjustment
ClimateMachine.MoistThermodynamics.PhaseNonEquil — TypePhaseNonEquil{FT} <: ThermodynamicState
A thermodynamic state assuming thermodynamic non-equilibrium (therefore, temperature can be computed directly).
Constructors
PhaseNonEquil(param_set, e_int, q::PhasePartition, ρ)Fields
param_setparameter set, used to dispatch planet parameter function calls
e_intinternal energy
ρdensity of air (potentially moist)
qphase partition
ClimateMachine.MoistThermodynamics.TemperatureSHumEquil — FunctionTemperatureSHumEquil(param_set, T, ρ, q_tot)Constructs a PhaseEquil thermodynamic state from temperature.
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρdensityq_tottotal specific humidity
ClimateMachine.MoistThermodynamics.TemperatureSHumEquil_given_pressure — FunctionTemperatureSHumEquil_given_pressure(param_set, T, p, q_tot)Constructs a PhaseEquil thermodynamic state from temperature.
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureppressureq_tottotal specific humidity
ClimateMachine.MoistThermodynamics.LiquidIcePotTempSHumEquil — FunctionLiquidIcePotTempSHumEquil(param_set, θ_liq_ice, ρ, q_tot)Constructs a PhaseEquil thermodynamic state from:
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsθ_liq_iceliquid-ice potential temperatureρ(moist-)air densityq_tottotal specific humiditytemperature_toltemperature tolerance for saturation adjustmentmaxitermaximum iterations for saturation adjustment
ClimateMachine.MoistThermodynamics.LiquidIcePotTempSHumNonEquil — FunctionLiquidIcePotTempSHumNonEquil(param_set, θ_liq_ice, ρ, q_pt)Constructs a PhaseNonEquil thermodynamic state from:
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsθ_liq_iceliquid-ice potential temperatureρ(moist-)air densityq_ptphase partition
and, optionally
potential_temperature_tolpotential temperature for non-linear equation solvemaxitermaximum iterations for non-linear equation solve
ClimateMachine.MoistThermodynamics.LiquidIcePotTempSHumNonEquil_given_pressure — FunctionLiquidIcePotTempSHumNonEquil_given_pressure(param_set, θ_liq_ice, p, q_pt)Constructs a PhaseNonEquil thermodynamic state from:
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsθ_liq_iceliquid-ice potential temperatureppressureq_ptphase partition
Thermodynamic state methods
ClimateMachine.MoistThermodynamics.air_density — Functionair_density(param_set, T, p[, q::PhasePartition])The (moist-)air density from the equation of state (ideal gas law) where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTair temperatureppressure
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
air_density(ts::ThermodynamicState)The (moist-)air density, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.air_pressure — Functionair_pressure(param_set, T, ρ[, q::PhasePartition])The air pressure from the equation of state (ideal gas law) where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTair temperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
air_pressure(ts::ThermodynamicState)The air pressure from the equation of state (ideal gas law), given a thermodynamic state ts.
air_pressure(param_set, T::FT, T∞::FT, p∞::FT, ::DryAdiabaticProcess)The air pressure for an isentropic process, where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureT∞ambient temperaturep∞ambient pressure
ClimateMachine.MoistThermodynamics.air_temperature — Functionair_temperature(param_set, e_int, q::PhasePartition)The air temperature, where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailse_intinternal energy per unit mass
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
air_temperature(ts::ThermodynamicState)The air temperature, given a thermodynamic state ts.
air_temperature(param_set, p::FT, θ::FT, Φ::FT, ::DryAdiabaticProcess)The air temperature for an isentropic process, where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsppressureθpotential temperature
ClimateMachine.MoistThermodynamics.air_temperature_from_liquid_ice_pottemp — Functionair_temperature_from_liquid_ice_pottemp(param_set, θ_liq_ice, ρ, q::PhasePartition)The temperature given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsθ_liq_iceliquid-ice potential temperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
ClimateMachine.MoistThermodynamics.cp_m — Functioncp_m(param_set, [q::PhasePartition])The isobaric specific heat capacity of moist air given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more details
and, optionally
qPhasePartition. Without this argument, the results are for dry air.
cp_m(ts::ThermodynamicState)The isobaric specific heat capacity of moist air, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.cv_m — Functioncv_m(param_set, [q::PhasePartition])The isochoric specific heat capacity of moist air given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more details
and, optionally
qPhasePartition. Without this argument, the results are for dry air.
cv_m(ts::ThermodynamicState)The isochoric specific heat capacity of moist air, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.dry_pottemp — Functiondry_pottemp(param_set, T, ρ[, q::PhasePartition])The dry potential temperature where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
dry_pottemp(ts::ThermodynamicState)The dry potential temperature, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.exner — Functionexner(param_set, T, ρ[, q::PhasePartition)])The Exner function where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
exner(ts::ThermodynamicState)The Exner function, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.gas_constant_air — Functiongas_constant_air(param_set, [q::PhasePartition])The specific gas constant of moist air given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsqPhasePartition. Without this argument, the results are for dry air.
gas_constant_air(ts::ThermodynamicState)The specific gas constant of moist air given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.Ice — TypeIce <: PhaseAn ice phase, to dispatch over saturation_vapor_pressure and q_vap_saturation_generic.
ClimateMachine.MoistThermodynamics.internal_energy — Functioninternal_energy(param_set, T[, q::PhasePartition])The internal energy per unit mass, given a thermodynamic state ts or
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperature
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
internal_energy(ts::ThermodynamicState)The internal energy per unit mass, given a thermodynamic state ts.
internal_energy(ρ::FT, ρe::FT, ρu::AbstractVector{FT}, e_pot::FT)The internal energy per unit mass, given
ρ(moist-)air densityρetotal energy per unit volumeρumomentum vectore_potpotential energy (e.g., gravitational) per unit mass
ClimateMachine.MoistThermodynamics.internal_energy_sat — Functioninternal_energy_sat(param_set, T, ρ, q_tot)The internal energy per unit mass in thermodynamic equilibrium at saturation where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air densityq_tottotal specific humidity
internal_energy_sat(ts::ThermodynamicState)The internal energy per unit mass in thermodynamic equilibrium at saturation, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.latent_heat_fusion — Functionlatent_heat_fusion(param_set, T::FT) where {FT<:Real}The specific latent heat of fusion where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperature
latent_heat_fusion(ts::ThermodynamicState)The specific latent heat of fusion given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.latent_heat_sublim — Functionlatent_heat_sublim(param_set, T::FT) where {FT<:Real}The specific latent heat of sublimation where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperature
latent_heat_sublim(ts::ThermodynamicState)The specific latent heat of sublimation given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.latent_heat_vapor — Functionlatent_heat_vapor(param_set, T::FT) where {FT<:Real}The specific latent heat of vaporization where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperature
latent_heat_vapor(ts::ThermodynamicState)The specific latent heat of vaporization given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.Liquid — TypeLiquid <: PhaseA liquid phase, to dispatch over saturation_vapor_pressure and q_vap_saturation_generic.
ClimateMachine.MoistThermodynamics.liquid_fraction — Functionliquid_fraction(param_set, T[, q::PhasePartition])The fraction of condensate that is liquid where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureqPhasePartition
If q.liq or q.ice are nonzero, the liquid fraction is computed from them.
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_freeze.
liquid_fraction(ts::ThermodynamicState)The fraction of condensate that is liquid given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.liquid_ice_pottemp — Functionliquid_ice_pottemp(param_set, T, ρ, q::PhasePartition)The liquid-ice potential temperature where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
liquid_ice_pottemp(ts::ThermodynamicState)The liquid-ice potential temperature, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.liquid_ice_pottemp_sat — Functionliquid_ice_pottemp_sat(param_set, T, ρ[, q::PhasePartition])The saturated liquid ice potential temperature where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
liquid_ice_pottemp_sat(param_set, T, ρ, q_tot)The saturated liquid ice potential temperature where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air densityq_tottotal specific humidity
liquid_ice_pottemp_sat(ts::ThermodynamicState)The liquid potential temperature given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.gas_constants — Function(R_m, cp_m, cv_m, γ_m) = gas_constants(param_set, [q::PhasePartition])Wrapper to compute all gas constants at once, where optionally,
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsqPhasePartition. Without this argument, the results are for dry air.
The function returns a tuple of
R_mgas_constant_aircp_mcp_mcv_mcv_mγ_m = cp_m/cv_m
(R_m, cp_m, cv_m, γ_m) = gas_constants(ts::ThermodynamicState)Wrapper to compute all gas constants at once, given a thermodynamic state ts.
The function returns a tuple of
R_mgas_constant_aircp_mcp_mcv_mcv_mγ_m = cp_m/cv_m
ClimateMachine.MoistThermodynamics.saturation_adjustment — Functionsaturation_adjustment(param_set, e_int, ρ, q_tot)Compute the temperature that is consistent with
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailse_intinternal energyρ(moist-)air densityq_tottotal specific humiditytolabsolute tolerance for saturation adjustment iterations. Can be one of:SolutionTolerance()to stop when|x_2 - x_1| < tolResidualTolerance()to stop when|f(x)| < tol
maxitermaximum iterations for non-linear equation solve
by finding the root of
$e_int - internal_energy_sat(param_set, T, ρ, q_tot) = 0$
using Newtons method with analytic gradients.
See also saturation_adjustment.
ClimateMachine.MoistThermodynamics.saturation_excess — Functionsaturation_excess(param_set, T, ρ, q::PhasePartition)The saturation excess in equilibrium where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air densityqPhasePartition
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.
saturation_excess(ts::ThermodynamicState)Compute the saturation excess in equilibrium, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.q_vap_saturation — Functionq_vap_saturation(param_set, T, ρ[, q::PhasePartition])Compute the saturation specific humidity, given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
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(T) and the fraction of ice by the complement 1 - liquid_fraction(T).
q_vap_saturation(ts::ThermodynamicState)Compute the saturation specific humidity, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.q_vap_saturation_generic — Functionq_vap_saturation_generic(param_set, T, ρ[; phase=Liquid()])Compute the saturation specific humidity over a plane surface of condensate, given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
Liquid()indicating condensate is liquidIce()indicating condensate is ice
ClimateMachine.MoistThermodynamics.saturation_vapor_pressure — Functionsaturation_vapor_pressure(param_set, T, Liquid())Return the saturation vapor pressure over a plane liquid surface given
Ttemperatureparam_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailssaturationvaporpressure(param_set, T, Ice())
Return the saturation vapor pressure over a plane ice surface given
Ttemperatureparam_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailssaturationvaporpressure(paramset, T, LH0, Δ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.
ClimateMachine.MoistThermodynamics.soundspeed_air — Functionsoundspeed_air(param_set, T[, q::PhasePartition])The speed of sound in unstratified air, where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperature
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
soundspeed_air(ts::ThermodynamicState)The speed of sound in unstratified air given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.specific_volume — Functionspecific_volume(ts::ThermodynamicState)The (moist-)air specific volume, given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.total_energy — Functiontotal_energy(param_set, e_kin, e_pot, T[, q::PhasePartition])The total energy per unit mass, given
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailse_kinkinetic energy per unit masse_potpotential energy per unit massTtemperature
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
total_energy(e_kin, e_pot, ts::ThermodynamicState)The total energy per unit mass given a thermodynamic state ts.
ClimateMachine.MoistThermodynamics.virtual_pottemp — Functionvirtual_pottemp(param_set, T, ρ[, q::PhasePartition])The virtual temperature where
param_setanAbstractParameterSet, see theMoistThermodynamicsfor more detailsTtemperatureρ(moist-)air density
and, optionally,
qPhasePartition. Without this argument, the results are for dry air.
virtual_pottemp(ts::ThermodynamicState)The virtual potential temperature, given a thermodynamic state ts.