Skip to content

Units ​

What it's for ​

The library works in metric internally: bar, metres, litres, degrees Celsius and litres per minute. The units module converts imperial input and output at the edges of your app. Conversions are plain arithmetic and do not validate their input.

Formulas ​

ppsi=14.5037738pbardft=3.280839895dmVL=28.3168466Vft3TF=95TC+32
  • ppsi, pbar: pressure in psi and bar.
  • dft, dm: depth in feet and metres.
  • VL, Vft3: volume in litres and cubic feet. Flow rates use the same factor (L/min and cu ft/min).
  • TF, TC: temperature in degrees Fahrenheit and Celsius. Kelvin is TK=TC+273.15.

Assumptions and limits ​

  • Conversions do not validate input. NaN in gives NaN out.
  • Every conversion is available in both directions, as named helpers (psiToBar, mToFt, cuftToLitres) and as unit-string helpers (toBar, fromMeters, toLpm).
  • Unit strings are 'bar' | 'psi', 'm' | 'ft', 'l' | 'cf', 'lpm' | 'cfm' and 'C' | 'F'.

Sources ​

  • psi per bar: NIST SP 811 Appendix B (1 psi = 6.894757 kPa).
  • Litres per cubic foot: NIST SP 811 (1 ft³ = 28.316846592 L).
  • Feet per metre: the international foot, exactly 0.3048 m.
  • Kelvin offset: SI definition.

Examples ​

ts
import { psiToBar, cuftToLitres, toLpm } from 'dive-math/units'
psiToBar(3000) // => 206.84
cuftToLitres(80) // => 2265.35
toLpm(1.5, 'cfm') // => 42.48

API ​

See the units API reference.

Reference only — verify every fill and dive plan independently.