Skip to content
This documentation describes version 4.0.0, which is not released yet. The current version on PyPI is 3.3.0 and does not carry everything described here.

fluids.gas

An ideal gas from the two numbers a gas table prints.

A table of gases prints a ratio of specific heats and a molar mass, and those two close the ideal-gas state completely:

so a caller who has a gas that is not air or water can still have a Fluid for it, computed rather than typed.

Hopkins (2007) Table A1, PDF page 634 (printed p. 607), prints both columns for six gases at 20 degC and 1,013 x 10^5 Pa, as its own footnote states. Against it, the speeds land within 0,5 m/s for all six and the densities within 0,002 kg/m3 for the four light ones. Carbon dioxide comes out 0,7 % light and sulphur hexafluoride 2 % light.

That shortfall is not an error in the arithmetic, it is the compressibility factor: a real gas has rho = p M / (Z R T), so the ideal density is Z times the real one and the fraction missing is 1 - Z. It grows with the molecule, and SF6, a heavy one whose attraction is not negligible at room conditions, is exactly the gas a demonstration reaches for. The model says so in IDEAL_GAS_VALIDITY rather than pretending otherwise.

Viscosity, thermal conductivity and the Prandtl number are transport properties. Nothing in the ideal-gas closure determines them, so the returned fluid does not carry them and reading one raises FluidPropertyUnavailable naming the model, which is what every other fluid here does with a quantity its model did not fix.

Auto-generated from the source docstrings by scripts/generate_api_docs.py (make api-docs). Do not edit by hand.

ideal_gas(
*,
temperature_c: float,
heat_capacity_ratio: float,
molar_mass_kg_mol: float,
static_pressure_pa: float | None = None,
) -> Fluid

A gas at one state, from its ratio of specific heats and molar mass.

and , the two ideal-gas relations, which is all a table that prints gamma and M supports. See the module docstring for how far that goes and what it leaves out.

Parameters

NameDescription
temperature_cTemperature t, in degrees Celsius (above absolute zero).
heat_capacity_ratioRatio of specific heats gamma (> 1). It is 1,67 for a monatomic gas, about 1,4 for a diatomic one and lower for a polyatomic one, and it is above 1 for every gas, because gamma is c_p/c_v and c_p - c_v is the gas constant.
molar_mass_kg_molMolar mass M, in kg/mol (> 0). The tables print kg/mol, so 0,028 95 for dry air and not 28,95.
static_pressure_paStatic pressure p, in pascals (> 0). When omitted, one standard atmosphere is assumed and a FluidAssumptionWarning says so, because the density is proportional to it.

Returns: The Fluid at that state, carrying a density, a speed of sound and the ratio of specific heats it was given.

Raises

ExceptionWhen
ValueErrorfor a non-positive input or a temperature at or below absolute zero.

Constant (str).

IDEAL_GAS_VALIDITY = "ideal gas: exact for a dilute gas and within about 1 % of a printed table for the light gases at room conditions. The density comes out light by 1 - Z, the compressibility factor's distance from unity, and that grows with the molecule: carbon dioxide is 0,7 % light and sulphur hexafluoride 2 % against Hopkins Table A1, where the speeds still land within 0,5 m/s."

Constant (float).

MOLAR_GAS_CONSTANT = 8.31446261815324