lair.meteorology.ideal_gas_law#
- lair.meteorology.ideal_gas_law(solve_for, p=None, V=None, T=None, m=None, n=None, N=None, rho=None, alpha=None, R=None)[source]#
Solve the ideal gas law for one variable.
The solver uses one of these forms of the law, where R* is the universal gas constant and kb Boltzmann’s constant:
pV = nR * T pV = mRT pV = NkbT p = ρRT pα = RT
Give the inputs one form needs to solve for the variable directly, with no intermediate step. Inputs and the result are in SI (pint Quantities are converted to SI first; see the module docstring).
- Parameters:
solve_for (str) – The variable to solve for:
'p'(or'pressure','pres'),'V'('volume','vol'),'T'('temperature','temp'),'rho'('density'),'m'('mass'),'n'('moles') or'N'('number').p (Numeric, optional) – Pressure (Pa).
V (Numeric, optional) – Volume (m^3).
T (Numeric, optional) – Temperature (K).
m (Numeric, optional) – Mass (kg).
n (Numeric, optional) – Amount of substance (mol).
N (Numeric, optional) – Number of molecules.
rho (Numeric, optional) – Density (kg/m^3).
alpha (Numeric, optional) – Specific volume (m^3/kg).
R (Numeric, optional) – Specific gas constant (J/kg/K): 287.05 for dry air.
- Returns:
Numeric – The variable asked for, in SI.
- Raises:
ValueError – If
solve_foris not one of the names above.- Return type:
See also
hypsometricThickness of a layer between two pressures.
Examples
The density of dry air at sea level in the standard atmosphere:
>>> from lair.meteorology import ideal_gas_law >>> round(float(ideal_gas_law("rho", p=101325.0, T=288.15, R=287.05)), 3) 1.225