Filling
What it's for
Fill-station math: cascade filling from storage banks, air-driven boosters, and hot-fill compensation for cylinders that cool after filling.
Formulas
Cascade equalisation
Connecting a bank to the target equalises them. Gas is conserved, so the equilibrium pressure satisfies a mole balance:
, , : absolute pressure in the target, the bank and at equilibrium, bar. , : water volume of the target and the bank, L. : moles per litre of cylinder, as ideal-equivalent absolute bar. With useRealGasoff,and this is the volume-weighted mean .
When desiredPressure stops a bank part-way, the bank gives up exactly the moles the target gains: realPressureForIdealEquivalent. The booster's free equalisation uses the same balance.
Banks are connected lowest pressure first, and a bank at or below the target pressure is skipped.
Booster
: booster ratio. : maximum drive pressure the regulator supplies, bar gauge. is the stall ceiling: a target above it is infeasible ( exceeds-stall).: drive air used, free litres. : gas delivered to the receiver, surface litres. : receiver absolute pressure. : supply (inlet) absolute pressure, which falls as gas is drawn and is capped by regulatedInletBarfor a two-stage regulated inlet.
The drive pressure actually used ramps up to about receiver pressure divided by ratio, so the geometric ratio cancels out of the drive-air integral. The integral is evaluated numerically. Free equalisation from the supply happens first when the supply starts above the receiver.
Gay-Lussac (hot fills)
, : absolute pressure at the fill and settled temperatures, bar. , : temperatures in kelvin.
settledPressure and hotTarget apply this at fixed volume and convert to and from gauge. applyOverfill is a flat percentage on gauge pressure.
Heat of filling
tempRise estimates the temperature rise as HEAT_COEFF times the fill rate in bar per minute. HEAT_COEFF = 0.7 °C per (bar/min) is an empirical fill-station heuristic, not a published value.
Assumptions and limits
- Pressures are gauge bar in inputs and results, except
boosterTiming'ssupplyAbsBar, which is absolute. The math converts to absolute internally. - The real-gas cascade and booster equalisation are exact mole balances within the virial Z model. The booster drive-air integral and
boosterTiminggas-per-cycle use Z at the local pressure. boosterTimingreturnsnullwhen the booster geometry or fill-rate limit is missing.- A fill that cannot be done is returned as
feasible: falsewith a reason (exceeds-stallorsupply-insufficient), never thrown. - Gay-Lussac assumes a fixed cylinder volume and a settled temperature you supply.
Sources
The library cites no external source for the cascade and booster models beyond the mole balance itself. Equipment data for boosters is documented in Equipment. The heat coefficient is a heuristic.
Examples
import { cascade, settledPressure, booster } from 'dive-math/fill'
cascade({ banks: [{ volume: 50, pressure: 300 }], target: { volume: 11.1, startPressure: 0 } }).finalPressure // => 245.5
settledPressure(230, 40, 20) // => 215.25
booster({ ratio: 40, driveP: 8, supplyVol: 50, supplyStart: 150, receiverVol: 11.1, receiverStart: 0, target: 200 }).maxOutput // => 320API
See the fill API reference.