Thermodynamics
Thermodynamics.Thermodynamics
— ModuleThermodynamics
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 gradientsNewtonsMethodAD
uses Newton method with autodiffSecantMethod
uses Secant methodRegulaFalsiMethod
uses Regula-Falsi method
Thermodynamics Parameters
Thermodynamics.Parameters.ThermodynamicsParameters
— TypeThermodynamicsParameters
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)
Thermodynamic State Constructors
Thermodynamics.PhasePartition
— TypePhasePartition
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 humidityliq
: liquid water specific humidity (default:0
)ice
: ice specific humidity (default:0
)
Thermodynamics.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.
Thermodynamics.PhaseDry
— TypePhaseDry{FT} <: AbstractPhaseDry
A dry thermodynamic state (q_tot = 0
).
Constructors
PhaseDry(param_set, e_int, ρ)
Fields
e_int
: internal energyρ
: density of dry air
Thermodynamics.PhaseDry_ρe
— FunctionPhaseDry_ρe(param_set, ρ, e_int)
A dry thermodynamic state (q_tot = 0
) from
param_set
anThermodynamicsParameters
for more detailsρ
e_int
internal energy
Thermodynamics.PhaseDry_pT
— FunctionPhaseDry_pT(param_set, p, T)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureT
temperature
Thermodynamics.PhaseDry_pθ
— FunctionPhaseDry_pθ(param_set, p, θ_dry)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureθ_dry
dry potential temperature
Thermodynamics.PhaseDry_pe
— FunctionPhaseDry_pe(param_set, p, e_int)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressuree_int
internal energy
Thermodynamics.PhaseDry_ph
— FunctionPhaseDry_ph(param_set, p, h)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureh
specific enthalpy
Thermodynamics.PhaseDry_ρθ
— FunctionPhaseDry_ρθ(param_set, ρ, θ_dry)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityθ_dry
dry potential temperature
Thermodynamics.PhaseDry_ρT
— FunctionPhaseDry_ρT(param_set, ρ, T)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityT
temperature
Thermodynamics.PhaseDry_ρp
— FunctionPhaseDry_ρp(param_set, ρ, p)
Constructs a PhaseDry
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityp
pressure
Thermodynamics.PhaseEquil
— TypePhaseEquil{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 pressuree_int
: internal energyq_tot
: total specific humidityT
: temperature: computed viasaturation_adjustment
Thermodynamics.PhaseEquil_ρeq
— FunctionPhaseEquil_ρeq(param_set, ρ, e_int, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])
Moist thermodynamic phase, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densitye_int
internal energyq_tot
total specific humidity
and, optionally
maxiter
maximum iterations for saturation adjustmentrelative_temperature_tol
relative temperature tolerance for saturation adjustmentsat_adjust_method
the numerical method to use. See theThermodynamics
for options.T_guess
initial guess for temperature in saturation adjustment
Thermodynamics.PhaseEquil_ρTq
— FunctionPhaseEquil_ρTq(param_set, ρ, T, q_tot)
Constructs a PhaseEquil
thermodynamic state from temperature.
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityT
temperatureq_tot
total specific humidity
Thermodynamics.PhaseEquil_pTq
— FunctionPhaseEquil_pTq(param_set, p, T, q_tot)
Constructs a PhaseEquil
thermodynamic state from temperature.
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureT
temperatureq_tot
total specific humidity
Thermodynamics.PhaseEquil_pθq
— FunctionPhaseEquil_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
anAbstractParameterSet
, see theThermodynamics
for more detailsp
air pressureθ_liq_ice
liquid-ice potential temperatureq_tot
total specific humidityrelative_temperature_tol
relative temperature tolerance for saturation adjustmentmaxiter
maximum iterations for saturation adjustmentsat_adjust_method
the numerical method to use.T_guess
initial guess for temperature in saturation adjustment
Thermodynamics.PhaseEquil_peq
— FunctionPhaseEquil_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
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressuree_int
temperatureq_tot
total specific humidityT_guess
initial guess for temperature in saturation adjustment
Thermodynamics.PhaseEquil_phq
— FunctionPhaseEquil_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
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureh
specific enthalpyq_tot
total specific humidityT_guess
initial guess for temperature in saturation adjustment
Thermodynamics.PhaseEquil_ρθq
— FunctionPhaseEquil_ρθq(param_set, ρ, θ_liq_ice, q_tot[, maxiter, relative_temperature_tol, sat_adjust_method, T_guess])
Constructs a PhaseEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
(moist-)air densityθ_liq_ice
liquid-ice potential temperatureq_tot
total specific humidityrelative_temperature_tol
relative temperature tolerance for saturation adjustmentmaxiter
maximum iterations for saturation adjustmentT_guess
initial guess for temperature in saturation adjustment
Thermodynamics.PhaseEquil_ρpq
— FunctionPhaseEquil_ρ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
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityp
pressureq_tot
total specific humidityperform_sat_adjust
Bool indicating to perform saturation adjustmentmaxiter
maximum number of iterations to perform in saturation adjustmentsat_adjust_method
the numerical method to use. See theThermodynamics
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)
Thermodynamics.PhaseNonEquil
— Type 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
Thermodynamics.PhaseNonEquil_ρTq
— FunctionPhaseNonEquil_ρTq(param_set, ρ, T, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
(moist-)air densityT
temperatureq_pt
phase partition
Thermodynamics.PhaseNonEquil_pTq
— FunctionPhaseNonEquil_pTq(param_set, p, T, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureT
air temperatureq_pt
phase partition
Thermodynamics.PhaseNonEquil_ρθq
— FunctionPhaseNonEquil_ρθq(param_set, ρ, θ_liq_ice, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
(moist-)air densityθ_liq_ice
liquid-ice potential temperatureq_pt
phase partition
and, optionally
relative_temperature_tol
potential temperature for non-linear equation solvemaxiter
maximum iterations for non-linear equation solve
Thermodynamics.PhaseNonEquil_pθq
— FunctionPhaseNonEquil_pθq(param_set, p, θ_liq_ice, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureθ_liq_ice
liquid-ice potential temperatureq_pt
phase partition
Thermodynamics.PhaseNonEquil_peq
— FunctionPhaseNonEquil_peq(param_set, p, e_int, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressuree_int
internal energyq_pt
phase partition
Thermodynamics.PhaseNonEquil_phq
— FunctionPhaseNonEquil_phq(param_set, p, e_int, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureh
specific enthalpyq_pt
phase partition
Thermodynamics.PhaseNonEquil_ρpq
— FunctionPhaseNonEquil_ρpq(param_set, ρ, p, q_pt)
Constructs a PhaseNonEquil
thermodynamic state from:
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsρ
densityp
pressureq_pt
phase partition
Types
Thermodynamics.Ice
— TypeIce <: Phase
An ice phase, to dispatch over saturation_vapor_pressure
and q_vap_saturation_generic
.
Thermodynamics.Liquid
— TypeLiquid <: Phase
A liquid phase, to dispatch over saturation_vapor_pressure
and q_vap_saturation_generic
.
Thermodynamic state methods
Thermodynamics.air_density
— Functionair_density(param_set, T, p[, q::PhasePartition])
The (moist-)air density from the equation of state (ideal gas law) where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
air temperaturep
pressure
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
air_density(param_set::APS, ts::ThermodynamicState)
The (moist-)air density, given a thermodynamic state ts
.
Thermodynamics.air_pressure
— Functionair_pressure(param_set, T, ρ[, q::PhasePartition])
The air pressure from the equation of state (ideal gas law) where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
air temperatureρ
(moist-)air density
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
air_pressure(param_set::APS, 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_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureT∞
ambient temperaturep∞
ambient pressure
Thermodynamics.air_temperature
— Functionair_temperature(param_set, e_int, q::PhasePartition)
The air temperature, where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailse_int
internal energy per unit mass
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
air_temperature(param_set::APS, 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_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureθ
potential temperature
Thermodynamics.condensate
— Functioncondensate(q::PhasePartition{FT})
condensate(param_set::APS, ts::ThermodynamicState)
Condensate of the phase partition.
Thermodynamics.cp_m
— Functioncp_m(param_set, q::PhasePartition)
The isobaric specific heat capacity of moist air given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsq
PhasePartition
.
cp_m(param_set::APS, ts::ThermodynamicState)
The isobaric specific heat capacity of moist air, given a thermodynamic state ts
.
Thermodynamics.cv_m
— Functioncv_m(param_set, q::PhasePartition)
The isochoric specific heat capacity of moist air given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsq
PhasePartition
.
cv_m(param_set::APS, ts::ThermodynamicState)
The isochoric specific heat capacity of moist air, given a thermodynamic state ts
.
Thermodynamics.dry_pottemp
— Functiondry_pottemp(param_set, T, ρ[, q::PhasePartition, cpm])
The dry potential temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air density
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
dry_pottemp(param_set::APS, ts::ThermodynamicState)
The dry potential temperature, given a thermodynamic state ts
.
Thermodynamics.exner
— Functionexner(param_set, T, ρ[, q::PhasePartition)])
The Exner function where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air density
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
exner(param_set::APS, ts::ThermodynamicState)
The Exner function, given a thermodynamic state ts
.
Thermodynamics.gas_constant_air
— Functiongas_constant_air(param_set, [q::PhasePartition])
The specific gas constant of moist air given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsq
PhasePartition
. Without this argument, the results are for dry air.
gas_constant_air(param_set::APS, ts::ThermodynamicState)
The specific gas constant of moist air given a thermodynamic state ts
.
Thermodynamics.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_set
anAbstractParameterSet
, see theThermodynamics
for more detailsq
PhasePartition
.
The function returns a tuple of
R_m
gas_constant_air
cp_m
cp_m
cv_m
cv_m
γ_m = cp_m/cv_m
(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
R_m
gas_constant_air
cp_m
cp_m
cv_m
cv_m
γ_m = cp_m/cv_m
Thermodynamics.has_condensate
— Functionhas_condensate(q::PhasePartition{FT})
has_condensate(param_set::APS, ts::ThermodynamicState)
Bool indicating if condensate exists in the phase partition
Thermodynamics.ice_specific_humidity
— Functionice_specific_humidity(param_set::APS, ts::ThermodynamicState)
ice_specific_humidity(q::PhasePartition)
Ice specific humidity given
ts
a thermodynamic state
or
q
aPhasePartition
Thermodynamics.internal_energy
— Functioninternal_energy(param_set, T[, q::PhasePartition])
The internal energy per unit mass, given a thermodynamic state ts
or
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
internal_energy(param_set::APS, 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ρe
total energy per unit volumeρu
momentum vectore_pot
potential energy (e.g., gravitational) per unit mass
Thermodynamics.internal_energy_dry
— Functioninternal_energy_dry(param_set, T)
The dry air internal energy
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
internal_energy_dry(param_set::APS, ts::ThermodynamicState)
The the dry air internal energy, given a thermodynamic state ts
.
Thermodynamics.internal_energy_vapor
— Functioninternal_energy_vapor(param_set, T)
The water vapor internal energy
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
internal_energy_vapor(param_set::APS, ts::ThermodynamicState)
The the water vapor internal energy, given a thermodynamic state ts
.
Thermodynamics.internal_energy_liquid
— Functioninternal_energy_liquid(param_set, T)
The liquid water internal energy
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
internal_energy_liquid(param_set::APS, ts::ThermodynamicState)
The the liquid water internal energy, given a thermodynamic state ts
.
Thermodynamics.internal_energy_ice
— Functioninternal_energy_ice(param_set, T)
The ice internal energy
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
internal_energy_ice(param_set::APS, ts::ThermodynamicState)
The the ice internal energy, given a thermodynamic state ts
.
Thermodynamics.internal_energy_sat
— Functioninternal_energy_sat(param_set, T, ρ, q_tot, phase_type)
The internal energy per unit mass in thermodynamic equilibrium at saturation where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air densityq_tot
total specific humidityphase_type
a thermodynamic state type
internal_energy_sat(param_set::APS, ts::ThermodynamicState)
The internal energy per unit mass in thermodynamic equilibrium at saturation, given a thermodynamic state ts
.
Thermodynamics.latent_heat_fusion
— Functionlatent_heat_fusion(param_set, T::FT) where {FT<:Real}
The specific latent heat of fusion where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
latent_heat_fusion(param_set::APS, ts::ThermodynamicState)
The specific latent heat of fusion given a thermodynamic state ts
.
Thermodynamics.latent_heat_liq_ice
— Functionlatent_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
anAbstractParameterSet
, see theThermodynamics
for more detailsq
PhasePartition
. Without this argument, the results are for dry air.
Thermodynamics.latent_heat_sublim
— Functionlatent_heat_sublim(param_set, T::FT) where {FT<:Real}
The specific latent heat of sublimation where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
latent_heat_sublim(param_set::APS, ts::ThermodynamicState)
The specific latent heat of sublimation given a thermodynamic state ts
.
Thermodynamics.latent_heat_vapor
— Functionlatent_heat_vapor(param_set, T::FT) where {FT<:Real}
The specific latent heat of vaporization where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
latent_heat_vapor(param_set::APS, ts::ThermodynamicState)
The specific latent heat of vaporization given a thermodynamic state ts
.
Thermodynamics.liquid_fraction
— Functionliquid_fraction(param_set, T, phase_type[, q])
The fraction of condensate that is liquid where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsphase_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
.
liquid_fraction(param_set::APS, ts::ThermodynamicState)
The fraction of condensate that is liquid given a thermodynamic state ts
.
Thermodynamics.liquid_ice_pottemp
— Functionliquid_ice_pottemp(param_set, T, ρ[, q::PhasePartition, cpm])
The liquid-ice potential temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air density
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
liquid_ice_pottemp(param_set::APS, ts::ThermodynamicState)
The liquid-ice potential temperature, given a thermodynamic state ts
.
Thermodynamics.liquid_ice_pottemp_sat
— Functionliquid_ice_pottemp_sat(param_set, T, ρ, phase_type[, q::PhasePartition, cpm])
The saturated liquid ice potential temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air densityphase_type
a thermodynamic state type
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
liquid_ice_pottemp_sat(param_set, T, ρ, phase_type, q_tot)
The saturated liquid ice potential temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air densityphase_type
a thermodynamic state typeq_tot
total specific humidity
liquid_ice_pottemp_sat(param_set::APS, ts::ThermodynamicState)
The liquid potential temperature given a thermodynamic state ts
.
Thermodynamics.liquid_specific_humidity
— Functionliquid_specific_humidity(param_set::APS, ts::ThermodynamicState)
liquid_specific_humidity(q::PhasePartition)
Liquid specific humidity given
ts
a thermodynamic state
or
q
aPhasePartition
Thermodynamics.mixing_ratios
— Functionmixing_ratios(q::PhasePartition)
Mixing ratios
r.tot
total mixing ratior.liq
liquid mixing ratior.ice
ice mixing ratio
given a phase partition, q
.
mixing_ratios(param_set::APS, ts::ThermodynamicState)
Mixing ratios stored, in a phase partition, for
- total specific humidity
- liquid specific humidity
- ice specific humidity
Thermodynamics.vol_vapor_mixing_ratio
— Functionvol_vapor_mixing_ratio(param_set, q::PhasePartition)
Volume mixing ratio of water vapor given a parameter set param_set
and a phase partition, q
.
Thermodynamics.moist_static_energy
— Functionmoist_static_energy(param_set, ts, e_pot)
Moist static energy, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsts
a thermodynamic statee_pot
potential energy (e.g., gravitational) per unit mass
Thermodynamics.virtual_dry_static_energy
— Functionvirtual_dry_static_energy(param_set, ts, e_pot)
Virtual dry static energy, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsts
a thermodynamic statee_pot
gravitational potential energy per unit mass
Thermodynamics.q_vap_saturation
— Functionq_vap_saturation(param_set, T, ρ, phase_type[, q::PhasePartition])
Compute the saturation specific humidity, given
param_set
: anAbstractParameterSet
, see theThermodynamics
for more detailsT
: temperatureρ
: air densityphase_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)
.
q_vap_saturation(param_set::APS, ts::ThermodynamicState)
Compute the saturation specific humidity, given a thermodynamic state ts
.
Thermodynamics.q_vap_saturation_liquid
— Functionq_vap_saturation_liquid(param_set::APS, ts::ThermodynamicState)
Compute the saturation specific humidity over liquid, given a thermodynamic state ts
.
Thermodynamics.q_vap_saturation_ice
— Functionq_vap_saturation_ice(param_set::APS, ts::ThermodynamicState)
Compute the saturation specific humidity over ice, given a thermodynamic state ts
.
Thermodynamics.relative_humidity
— Functionrelative_humidity(param_set, T, p, phase_type, q::PhasePartition)
The relative humidity (clipped between 0 and 1), given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressurephase_type
a thermodynamic state type
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
relative_humidity(param_set::APS, ts::ThermodynamicState)
The relative humidity, given a thermodynamic state ts
.
Thermodynamics.saturated
— Functionsaturated(param_set::APS, ts::ThermodynamicState)
Boolean indicating if thermodynamic state is saturated.
Thermodynamics.saturation_adjustment
— Functionsaturation_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 theThermodynamics
for options.param_set
anAbstractParameterSet
, see theThermodynamics
for more detailse_int
internal energyρ
(moist-)air densityq_tot
total specific humidityphase_type
a thermodynamic state typemaxiter
maximum iterations for non-linear equation solverelative_temperature_tol
relative temperature toleranceT_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
.
Thermodynamics.saturation_excess
— Functionsaturation_excess(param_set, T, ρ, phase_type, q::PhasePartition)
The saturation excess in equilibrium where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air densityphase_type
a thermodynamic state typeq
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.
saturation_excess(param_set::APS, ts::ThermodynamicState)
Compute the saturation excess in equilibrium, given a thermodynamic state ts
.
Thermodynamics.saturation_vapor_pressure
— Functionsaturation_vapor_pressure(param_set, T, Liquid())
Return the saturation vapor pressure over a plane liquid surface given
T
temperatureparam_set
anAbstractParameterSet
, see theThermodynamics
for more detailssaturation_vapor_pressure(param_set, T, Ice())
Return the saturation vapor pressure over a plane ice surface given
T
temperatureparam_set
anAbstractParameterSet
, see theThermodynamics
for more detailssaturation_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
.
Thermodynamics.soundspeed_air
— Functionsoundspeed_air(param_set, T[, q::PhasePartition])
The speed of sound in unstratified air, where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
soundspeed_air(param_set::APS, ts::ThermodynamicState)
The speed of sound in unstratified air given a thermodynamic state ts
.
Thermodynamics.specific_enthalpy
— Functionspecific_enthalpy(e_int, R_m, T)
Specific enthalpy, given
e_int
internal specific energyR_m
gas_constant_air
T
air temperature
specific_enthalpy(param_set, ts)
Specific enthalpy, given a thermodynamic state ts
.
specific_enthalpy(param_set, T[, q::PhasePartition])
The specific_enthalpy per unit mass, given a thermodynamic state ts
or
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
Thermodynamics.specific_volume
— Functionspecific_volume(param_set::APS, ts::ThermodynamicState)
The (moist-)air specific volume, given a thermodynamic state ts
.
Thermodynamics.supersaturation
— Functionsupersaturation(param_set, q, ρ, T, Liquid())
supersaturation(param_set, q, ρ, T, Ice())
supersaturation(ts, Ice())
supersaturation(ts, Liquid())
param_set
- abstract set with earth parametersq
- phase partitionρ
- air density,T
- air temperatureLiquid()
,Ice()
- liquid or ice phase to dispatch over.ts
thermodynamic state
Returns supersaturation (pv/pv_sat -1) over water or ice.
Thermodynamics.total_energy
— Functiontotal_energy(param_set, e_kin, e_pot, T[, q::PhasePartition])
The total energy per unit mass, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailse_kin
kinetic energy per unit masse_pot
potential energy per unit massT
temperature
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
total_energy(param_set::APS, ts::ThermodynamicState, e_kin, e_pot)
The total energy per unit mass given a thermodynamic state ts
.
Thermodynamics.total_specific_enthalpy
— Functiontotal_specific_enthalpy(e_tot, R_m, T)
Total specific enthalpy, given
e_tot
total specific energyR_m
gas_constant_air
T
air temperature
total_specific_enthalpy(param_set, ts, e_tot::Real)
Total specific enthalpy, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsts
a thermodynamic statee_tot
total specific energy
Thermodynamics.total_specific_humidity
— Functiontotal_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
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperaturep
pressurerelative_humidity
relative humidity (can exceed 1 when there is super saturation/condensate)
Thermodynamics.vapor_specific_humidity
— Functionvapor_specific_humidity(q::PhasePartition{FT})
The vapor specific humidity, given a PhasePartition
q
.
Thermodynamics.virtual_pottemp
— Functionvirtual_pottemp(param_set, T, ρ[, q::PhasePartition])
The virtual potential temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air density
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
virtual_pottemp(param_set::APS, ts::ThermodynamicState)
The virtual potential temperature, given a thermodynamic state ts
.
Thermodynamics.virtual_temperature
— Functionvirtual_temperature(param_set, T[, q::PhasePartition])
The virtual temperature where
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperature
and, optionally,
q
PhasePartition
. Without this argument, the results are for dry air.
virtual_temperature(param_set::APS, ts::ThermodynamicState)
The virtual temperature, given a thermodynamic state ts
.
Thermodynamics.specific_entropy
— Functionspecific_entropy(param_set, p, T, q)
specific_entropy(param_set, ts)
Specific entropy, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsp
pressureT
temperatureq
phase partition
following equations (29)-(33) of [1].
Internal methods
Thermodynamics.shum_to_mixing_ratio
— Functionshum_to_mixing_ratio(q, q_tot)
Mixing ratio, from specific humidity
q
specific humidityq_tot
total specific humidity
Thermodynamics.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_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
Thermodynamics.q_vap_saturation_from_pressure
— Functionq_vap_saturation_from_pressure(param_set, q_tot, p, T, phase_type)
Compute the saturation specific humidity, given
param_set
anAbstractParameterSet
, see theThermodynamics
for more detailsq_tot
total water specific humidity,p
air pressure,T
air tempearturephase_type
a thermodynamic state type
Thermodynamics.PhasePartition_equil
— FunctionPhasePartition_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
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperatureρ
(moist-)air densityq_tot
total specific humidityphase_type
a thermodynamic state typep_vap_sat
saturation vapor pressureλ
liquid fraction
The residual q.tot - q.liq - q.ice
is the vapor specific humidity.
Thermodynamics.PhasePartition_equil_given_p
— FunctionPhasePartition_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
anAbstractParameterSet
, see theThermodynamics
for more detailsT
temperaturep
air pressureq_tot
total specific humidityphase_type
a thermodynamic state type
The residual q.tot - q.liq - q.ice
is the vapor specific humidity.
Dispatch types
Thermodynamics.DryAdiabaticProcess
— TypeDryAdiabaticProcess
For dispatching to isentropic formulas
Temperature Profiles
Thermodynamics.TemperatureProfiles.IsothermalProfile
— FunctionIsothermalProfile(param_set, T_virt)
IsothermalProfile(param_set, ::Type{FT<:Real})
A uniform virtual temperature profile, which is implemented as a special case of DecayingTemperatureProfile
.
Thermodynamics.TemperatureProfiles.TemperatureProfile
— TypeTemperatureProfile
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).
Thermodynamics.TemperatureProfiles.DryAdiabaticProfile
— TypeDryAdiabaticProfile{FT} <: TemperatureProfile{FT}
A temperature profile that has uniform dry potential temperature θ
Fields
T_surface
: Surface temperature (K)T_min_ref
: Minimum temperature (K)
Thermodynamics.TemperatureProfiles.DecayingTemperatureProfile
— TypeDecayingTemperatureProfile{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)
Tested profiles
Thermodynamics.TestedProfiles
— ModuleTestedProfiles
Tested thermodynamic profiles
This module contains functions to compute all of the thermodynamic states that Thermodynamics is tested with in runtests.jl
Data collection
Thermodynamics.DataCollection
— ModuleDataCollection
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()
This data collection was designed for unthreaded single processor runs, and may not work correctly for threaded / multi-processor runs.