solprop.physdata.equation_of_state#

Gas number density and pressure from the equation of state.

density() is optmat’s real-gas equation of state (SEP 3), CoolProp’s Helmholtz-energy equations through optmat.gas.eos, adapted by OptmatGas; pressure() is its exact inverse, and ideal_gas_density() the ideal-gas value for comparison.

Pressures are in bar, the one documented departure from SI at the user interface (docs/dev/conventions.md §1); number densities are in m^-3 and 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. The manual page is docs/guide/media/materials.md, “Density”.

Functions

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

Return the number density of a gas.

ideal_gas_density(pressure[, 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, temperature=293.15, *, ideal=False)[source]#

Return the number density of a gas.

Parameters:
gasGas or str

The species.

pressurefloat

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 or not finite, the temperature is not positive and finite, or the state lies outside the equation of state’s domain; the ideal law refuses the same states.

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, 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:
pressurefloat

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 not finite, or the temperature is not positive and finite.

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 or not finite, the temperature is not positive and finite, or the state lies outside the equation of state’s domain; the ideal law refuses the same states.

Examples

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