solprop.physdata.equation_of_state#

Gas number density and pressure from the equation of state.

Number densities are optmat’s real-gas equations of state (SEP 3): CoolProp’s Helmholtz-energy equations through optmat.gas.eos, adapted by OptmatGas, whose exact inverse gives the pressure. An ideal-gas expression is available for comparison; the two agree to better than 1e-3 relative below about 0.1 bar for every gas here.

Note

Pressures in this module are in bar, the one documented departure from SI at the user interface (docs/dev/conventions.md section 1), because the field works in bar. Everything else is SI: number densities are in m^-3, temperatures in K.

optmat imports CoolProp, which costs about a second, so the import happens inside the functions and import solprop stays cheap. Lookups are cached, and none is made at module load.

Functions

density(gas, pressure_bar[, temperature, ideal])

Return the number density of a gas.

ideal_gas_density(pressure_bar[, temperature])

Return the ideal-gas number density.

pressure(gas, number_density[, temperature, ...])

Return the pressure at which a gas reaches a given number density.

solprop.physdata.equation_of_state.density(gas, pressure_bar, temperature=293.15, *, ideal=False)[source]#

Return the number density of a gas.

Parameters:
gasGas or str

The species.

pressure_barfloat

Absolute pressure in bar (the documented non-SI user-interface unit), >= 0. Zero returns zero without consulting the equation of state, which is undefined there; a pressure gradient terminating in vacuum needs this.

temperaturefloat, optional

Temperature in K, > 0. Defaults to 293.15 K.

idealbool, optional

Use p / (k_B T) instead of the equation of state. Default False.

Returns:
float

Number density in m^-3.

Raises:
MaterialError

If the gas is unknown, the pressure is negative, the temperature is not positive, or the state lies outside the equation of state’s domain.

Notes

The equation of state is optmat’s real-gas one: at 293.15 K the deviation from ideal is about 0.14 % at 2 bar and 2.5 % at 40 bar for argon, so it matters for the high-pressure fills used in self-compression.

Examples

>>> from solprop.physdata import Gas, density
>>> f"{density(Gas.Ar, 1.0):.6e}"
'2.472418e+25'
>>> density(Gas.He, 0.0)
0.0
solprop.physdata.equation_of_state.ideal_gas_density(pressure_bar, temperature=293.15)[source]#

Return the ideal-gas number density.

rho = p / (k_B T). Independent of the species, so it takes no gas argument.

Parameters:
pressure_barfloat

Absolute pressure in bar (the documented non-SI user-interface unit), >= 0.

temperaturefloat, optional

Temperature in K, > 0. Defaults to 293.15 K.

Returns:
float

Number density in m^-3.

Raises:
MaterialError

If the pressure is negative or the temperature is not positive.

Examples

The Loschmidt constant is the ideal-gas density at 1 atm and 0 degrees Celsius.

>>> from solprop.physdata import ideal_gas_density
>>> f"{ideal_gas_density(1.01325, 273.15):.6e}"
'2.686780e+25'
solprop.physdata.equation_of_state.pressure(gas, number_density, temperature=293.15, *, ideal=False)[source]#

Return the pressure at which a gas reaches a given number density.

The inverse of density() at fixed temperature.

Parameters:
gasGas or str

The species.

number_densityfloat

Number density in m^-3, >= 0. Zero returns zero.

temperaturefloat, optional

Temperature in K, > 0. Defaults to 293.15 K.

idealbool, optional

Use p = rho k_B T instead of the equation of state. Default False.

Returns:
float

Absolute pressure in bar (the documented non-SI user-interface unit).

Raises:
MaterialError

If the gas is unknown, the density is negative, the temperature is not positive, or the state lies outside the equation of state’s domain.

Examples

>>> from solprop.physdata import Gas, density, pressure
>>> f"{pressure(Gas.Ar, density(Gas.Ar, 5.0)):.6f}"
'5.000000'