optmat.gas.mixture_eos#
The density of a gas mixture at a pressure and temperature (OEP 4, section 7.4).
A mixture’s equation of state is chosen per mixture, by the evidence for its pairs:
multi-fluid: CoolProp’s multi-fluid Helmholtz model of the mixture, where every pair has a binary model fitted to data of that pair. It reduces to each pure fluid’s equation at \(x_s = 1\). It is
qualifiedonly where every pair passed the comparison with the measured cross second virials and mixture densities (data/gas/mixture_pairs.toml).virial: the fallback of section 4.2, each species’ own equation at its partial density plus the curated cross second virial coefficients,
\[p(\rho, T) = \sum_s p_s(x_s\rho, T) + RT\rho^2\sum_{s \ne t} x_s x_t B_{st}(T).\]It preserves the composition, \(N_s = x_s N\) exactly, and holds while \(|\rho\sum_{s\ne t}x_s x_t B_{st}| \le 10^{-2}\). It is
qualifiedwhere every pair’s fallback passed the same comparison with the measured densities.partial-density: the same with every unknown cross coefficient zero: the composition-preserving form of the partial-pressure rule,
provisional, which warns when it is built.
The densities follow the CODATA convention of optmat.gas.eos: N = p / (Z k_B
T) with the equation’s dimensionless Z.
Module Attributes
The curated pairs of the mixture equations of state. |
|
The density methods, in the order the default is chosen. |
|
The bound on |
Functions
|
Return the equation of state of a gas mixture (OEP 4, sections 4.2 and 7.4). |
Classes
|
The equation of state of a gas mixture of fixed composition (OEP 4). |
|
One unlike pair of a mixture equation of state. |
- optmat.gas.mixture_eos.METHODS: Final = ('multi-fluid', 'virial', 'partial-density')#
The density methods, in the order the default is chosen.
- class optmat.gas.mixture_eos.MixtureEquationOfState(material, composition, method, qualified, pairs, constituents, backend, temperature_range, *, status='user', status_reason='', modified=(), base='')[source]#
Bases:
IdentifiedThe equation of state of a gas mixture of fixed composition (OEP 4).
- Attributes:
- materialstr
The composition’s name, or its species and fractions.
- compositiontuple of tuple
(species, mole fraction), in the order given, summing to one.- methodstr
One of
METHODS.- qualifiedbool
Whether the method holds for this mixture by the evidence of section 7.4.
- pairstuple of PairDensity
Every unlike pair.
- constituentstuple of EquationOfState
Each species’ own equation of state, in the order of
composition.- backendstr
CoolProp’s version.
- temperature_rangetuple of float
The temperatures every constituent’s equation covers, K, and for the fallback every cross coefficient’s measured temperatures.
- statusstr
validatedwherequalified, elseprovisional.
- compressibility(state)[source]#
Return the mixture’s compressibility factor
Z = p / (N k_B T).- Parameters:
- stateState
Pressure and temperature.
- Returns:
- float
Dimensionless.
- constituents: tuple[EquationOfState, ...]#
- property molar_mass: float#
The composition’s molar mass, kg/mol.
The constituents’ equation-of-state molar masses (
molar_mass) weighted by their mole fractions, for every method. For dry air it is the mean of its composition, not the pseudo-pure air ofair_equation_of_state()(TC-832).- Returns:
- float
The molar mass, kg/mol.
Examples
>>> mixture_equation_of_state({"Ar": 1.0}).molar_mass 0.039948
- number_density(state)[source]#
Return the mixture’s total number density at a state.
- Parameters:
- stateState
Pressure and temperature.
- Returns:
- float
The total number density, m^-3.
- Raises:
- StateError
Outside the constituents’ temperatures, or where the mixture (or, for the fallback, a constituent at its partial density) is not a gas.
- Warns:
- ModelRangeWarning
Where the fallback is beyond its truncation bound.
Examples
>>> from optmat.conditions import State >>> eos = mixture_equation_of_state({"He": 0.5, "Ne": 0.5}) >>> eos.method 'virial' >>> f"{eos.number_density(State(pressure=1e6, temperature=294.0)):.6e}" '2.451570e+26'
- pairs: tuple[PairDensity, ...]#
- partial_densities(state)[source]#
Return each species’ number density,
x_s N.- Parameters:
- stateState
Pressure and temperature.
- Returns:
- dict
Species to m^-3, the keys
MixtureOpticstakes.
- pressure(number_density, temperature)[source]#
Return the pressure at total number densities and temperatures.
- Parameters:
- number_densityarray_like or float
Total number density, m^-3, > 0.
- temperaturearray_like or float
K; broadcast against
number_density.
- Returns:
- numpy.ndarray
Pa.
- Raises:
- StateError
At a non-positive density, or where the mixture is not a gas.
Examples
>>> eos = mixture_equation_of_state({"He": 0.5, "Ne": 0.5}) >>> f"{float(eos.pressure(2.451570e26, 294.0)) / 1e6:.6f}" '1.000000'
- second_virial(temperature)[source]#
Return the mixture’s second virial coefficient, the method’s own.
- Parameters:
- temperaturefloat
- Returns:
- float
B_mix, m^3/mol: the multi-fluid model’s at zero density, or the fallback’ssum_s x_s^2 B_ss + sum_{s != t} x_s x_t B_st.
- property species: tuple[str, ...]#
The species, in the order of
composition.- Returns:
- tuple of str
The species.
- optmat.gas.mixture_eos.PAIRS_FILE: Final = PosixPath('/home/docs/checkouts/optmat/checkouts/7/src/optmat/data/gas/mixture_pairs.toml')#
The curated pairs of the mixture equations of state.
- class optmat.gas.mixture_eos.PairDensity(species, partner, model, kind, curated, qualified, cross_virial, reason, fallback_qualified=False, fallback_reason='', prefer_multi_fluid=False)[source]#
Bases:
objectOne unlike pair of a mixture equation of state.
- Attributes:
- species, partnerstr
The pair, in sorted order.
- modelstr
CoolProp’s reference key of the pair’s binary model, or empty where it has none.
- kindstr
fitted,placeholder(every reducing parameter one and no departure function: not fitted to data of the pair) ornone.- curatedbool
Whether the pair is in
mixture_pairs.toml.- qualifiedbool
Whether its multi-fluid model passed the comparison with the measured data.
- cross_virialstr
The curated cross (or excess) second virial dataset, or empty.
- reasonstr
The comparison’s result, or why the pair is what it is.
- fallback_qualifiedbool
Whether the fallback (method
virial) passed the same comparison with the measured mixture densities, within its truncation bound.- fallback_reasonstr
That comparison’s result.
- prefer_multi_fluidbool
Whether the author chose the multi-fluid model as this pair’s default even though it is not qualified (dry air’s pairs, TC-796).
- optmat.gas.mixture_eos.TRUNCATION_BOUND: Final = 0.01#
The bound on
|rho sum_{s != t} x_s x_t B_st|within which the fallback holds.
- optmat.gas.mixture_eos.mixture_equation_of_state(composition, *, method=None)[source]#
Return the equation of state of a gas mixture (OEP 4, sections 4.2 and 7.4).
- Parameters:
- compositionMapping or str
Species to mole fraction, summing to one, or a named composition (
"dry air (N2, O2, Ar)").- methodstr, optional
One of
METHODS; by default the first the mixture’s pairs qualify for, elsepartial-density.
- Returns:
- MixtureEquationOfState
The equation, with its method, qualification and pairs.
- Raises:
- OptmatError
For an invalid composition or a method the pairs cannot support.
- StateError
For a species without an equation of state (ozone).
- Warns:
- ModelRangeWarning
When the equation is provisional.
Examples
>>> eos = mixture_equation_of_state({"Ar": 1.0}) >>> eos.method, eos.qualified ('multi-fluid', True)