Skip to content

Real gas (Z) ​

What it's for ​

Real gases at cylinder pressure hold fewer or more moles than the ideal gas law predicts. The compressibility factor Z corrects for that. The library uses it, when you opt in with useRealGas, for free-gas volumes, blending, cascades and boosters.

Formulas ​

A virial fit per component:

Zi(P)=1+aiP+biP2+ciP3

Mixed linearly by mole fraction:

Zmix=1+∑iFi(Zi−1)

The ideal-gas pressure that holds the same moles, normalised so that 1 atm maps to 1 atm:

Pideal=PZ(Patm)Z(P)
  • P: absolute pressure, bar. Always absolute, never gauge.
  • Patm=1.01325 bar.
  • ai,bi,ci: fit coefficients for component i (table below).
  • Fi: fraction of component i (O₂, N₂, He).

Coefficients ​

Gasabc
o2-7.18092073703e-42.81852572808e-6-1.50290620492e-9
n2-2.19260353292e-42.92844845532e-6-2.07613482075e-9
he4.87320026468e-4-8.83632921053e-85.33304543646e-11

Assumptions and limits ​

  • Valid for 0 to 500 bar absolute. Outside that range the functions throw a RangeError.
  • The coefficient source does not state its reference temperature. Treat results as room-temperature approximations.
  • realPressureForIdealEquivalent uses fixed-point iteration and throws if the answer leaves the model range.
  • Z is evaluated at absolute pressure everywhere in the library.

Sources ​

  • Coefficients come from atdotde/realblender (a Python script), as used by Subsurface and by the GasPlanner scuba-physics library (MIT, copyright 2018 JirkaPok). See THIRD_PARTY_NOTICES.md.

Examples ​

ts
import { AIR, gas } from 'dive-math/gas'
import { mixZ, idealEquivalentPressure } from 'dive-math/real-gas'
mixZ(AIR, 207) // => 1.0402
mixZ(gas(1), 207) // => 0.9588
idealEquivalentPressure(gas(0.25, 0.25), 200) // => 192.05

API ​

See the real-gas API reference.

Reference only — verify every fill and dive plan independently.