Gas planning
What it's for
Surface air consumption (SAC) and respiratory minute volume (RMV), rock-bottom gas, turn pressures for thirds and halves, and bailout time.
Formulas
: surface consumption as a pressure rate, bar/min (or psi/min if the input is psi). : pressure used, in the same unit. : time, minutes. : absolute pressure at the average depth, ata. : respiratory minute volume at the surface, L/min. : cylinder water volume, L. : team size. : stress factor applied to . : depth, m. : ascent rate, m/min. : pressure at half the depth, which averages the ascent. , : absolute pressure and duration of stop , ata and minutes. - The result is surface litres.
minGasPressuredivides by the cylinder volume to give a pressure.
sac() is the volume form: total litres used divided by
Turn pressures by volume
turnPressures sets thirds and halves from gas volume, not pressure. Volume is capacity times actual fill pressure, not the rated maximum.
Both rules are team limits. The cylinder holding less usable volume sets a shared ceiling, and the same volume is then expressed as a pressure for each cylinder. A larger cylinder therefore shows a lower turn pressure for the same litres.
Each returned value is usable pressure: the bar the diver may breathe from that cylinder before turning. It is not the gauge reading to turn at; the turn reading is the fill pressure minus this value. The field names (thirdsA, halvesA, …) are kept for compatibility with the rebreather app. This is a two-diver team calculation:
: gas volume of the limiting cylinder (capacity × fill), L. : its capacity, L. : capacity of cylinder A or B, L. : shared reserve, bar. - Halves are clamped at 0 when the reserve exceeds the limiting cylinder's fill.
This is deliberate. With mismatched cylinders, matching pressure readings is unsafe: the diver on the bigger cylinder has already used more gas, and in a shared-gas emergency the smaller cylinder might not hold enough to cover both divers. Thirds have no reserve subtracted. Halves subtract the shared reserve.
Assumptions and limits
- Ideal gas: volume is capacity times gauge pressure.
bailoutMinutesis a direct-ascent estimate at a fixed average depth. It is not stop-inclusive and is not decompression planning.- CCR metabolic O₂ rate (
ccrO2Rate) is independent of depth. - Invalid input (negative volumes, zero time, a
teamSizeof zero) throws aRangeError.
Sources
The library cites no published source for these. They are standard consumption and reserve formulas. The turn-pressure rationale is the reasoning recorded in the source comments.
Examples
import { sac, rockBottom, turnPressures, bailoutMinutes } from 'dive-math/planning'
sac(1800, 20, 30) // => 20
rockBottom({ rmvLpm: 20, depthM: 30, ascentRateMpm: 9, stops: [{ depthM: 5, minutes: 3 }], stressFactor: 2, teamSize: 2 }) // => 1026.67
turnPressures({ capA: 11.1, capB: 12.9, fillABar: 200, fillBBar: 200, reserveBar: 50 }).thirdsB // => 57.36
bailoutMinutes(2220, 42.5, 30) // => 13.06API
See the planning API reference.