openairbearing.core.gas

Gas property models for the film and porous-flow equations.

The solvers never assume a particular equation of state. They use the gas through four functions of absolute pressure (Pa) at the (isothermal) gas temperature, and the derivatives that the Newton iteration needs (Gas):

rho(p)   density, kg/m³
mu(p)    dynamic viscosity, Pa·s
phi(p)   flow potential, the integral of rho/mu over pressure, kg/(m³·s)
p_from_phi(phi)   its inverse

Pressure-driven mass flux in a thin film and Darcy mass flux in a porous body are both proportional to rho/mu times the pressure gradient, which is the gradient of phi. For an ideal gas with constant viscosity, phi = p² / (2 R T mu), which recovers the usual p² formulation. A non-ideal gas only has to supply the same functions.

Three ways to get a gas, and gas_at to pick among them by name:

  • the presets AIR, NITROGEN, HYDROGEN, HELIUM: ideal gases at 20 °C;

  • ideal_gas(name, T): an ideal gas at any temperature, with its viscosity at that temperature (the gases of FLUIDS: those four, argon and carbon dioxide);

  • real_gas(name, T, p_max): density and viscosity as functions of pressure from the gas’s equation of state, tabulated at temperature T (the same six gases).

The last two take their properties from the CoolProp library (the “gas” extra: pip install “openairbearing[gas]”); TabulatedGas takes a table from any other source. The film is isothermal at the gas temperature given, which is the temperature of the gas entering the bearing when the bearing has that temperature too.

class Gas(*args, **kwargs)[source]

Bases: Protocol

What a gas model must provide.

All pressures are absolute, in Pa. Every function takes a number or an array and returns the same shape.

rho(p), drho_dp(p)          density, kg/m³, and its slope in p
mu(p)                       dynamic viscosity, Pa·s
phi(p)                      flow potential, kg/(m³·s)
dphi_dp(p), d2phi_dp2(p)    rho/mu and its slope in p
p_from_phi(phi)             pressure at a flow potential, Pa
name: str
rho(p)[source]
drho_dp(p)[source]
mu(p)[source]
phi(p)[source]
dphi_dp(p)[source]
d2phi_dp2(p)[source]
p_from_phi(phi)[source]
class IdealGas(name: str = 'air', mu0: float = 1.81e-05, R: float = 287.05, T: float = 293.15)[source]

Bases: object

Isothermal ideal gas with pressure-independent viscosity.

rho = p/(R T) and phi = p²/(2 R T mu0). The functions are those of Gas.

name: str = 'air'
mu0: float = 1.81e-05
R: float = 287.05
T: float = 293.15
rho(p)[source]
drho_dp(p)[source]
mu(p)[source]
phi(p)[source]
dphi_dp(p)[source]
d2phi_dp2(p)[source]
p_from_phi(phi)[source]
at(T: float, mu0: float | None = None) → IdealGas[source]

Same gas at another temperature T (K).

mu0 is the viscosity at that temperature, Pa·s; left out, the viscosity stays what it was.

class TabulatedGas(name: str, T: float, p, rho, mu)[source]

Bases: object

A gas given by its density and viscosity on a grid of pressures.

The flow potential is integrated from the table, and everything is interpolated with cubic splines, so the derivatives the solver needs are smooth. Use it up to the highest tabulated pressure only; below the lowest one the gas is continued as an ideal gas with the viscosity of that pressure. The functions are those of Gas.

  • name: name of the gas. T: temperature of the table, K.

  • p: absolute pressures, Pa: at least 8, increasing (ValueError otherwise).

  • rho, mu: density in kg/m³ and dynamic viscosity in Pa·s at those pressures.

rho(p)[source]
drho_dp(p)[source]
mu(p)[source]
phi(p)[source]
dphi_dp(p)[source]
d2phi_dp2(p)[source]
p_from_phi(phi)[source]
gas_at(name: str, T: float = 293.15, real: bool = False, p_max: float = 2e6) → Gas[source]

The gas model for a name, a temperature and a choice of ideal or real.

name is one of FLUIDS (ValueError otherwise), T in K. real=True gives real_gas tabulated up to p_max (Pa), which must cover the supply pressure; otherwise the gas is ideal. The presets (ideal, 20 °C) are returned as they are, so that the common case needs no property library.

ideal_gas(name: str, T: float = 293.15) → IdealGas[source]

Ideal gas at temperature T (K), with its viscosity at T and 1 atm.

name is one of FLUIDS. Needs the CoolProp library.

real_gas(name: str, T: float = 293.15, p_max: float = 2e6, p_min: float = 2e3, n: int = 200) → TabulatedGas[source]

Real gas at temperature T (K), tabulated from p_min to p_max (Pa).

Density and viscosity come from the gas’s equation of state and transport correlations (CoolProp), at n pressures in geometric progression. name is one of FLUIDS. p_max must cover the supply pressure.