-
Notifications
You must be signed in to change notification settings - Fork 0
Algorithms
matejhron edited this page May 10, 2026
·
3 revisions
The orchestration layer that strings together the Haldane / Schreiner equations, Bühlmann M-values, and the Baker gradient-factor ramp into a working dive simulator. The Decompression-Model chapters cover the underlying equations; this section is about how those equations are called to produce a dive plan.
- The user provides a dive setup: bottom gas + optional deco gases,
$GF_{low}$ /$GF_{high}$ , and either a full waypoint array or just{maxDepth, bottomTime}. -
generateDecoProfile(maxDepth, bottomTime, gases, gfLow, gfHigh, …)(js/diveSetup.js:326) is the top-level entry. It callscalculateNDL()first; if$t_{bottom} \le NDL$ it returns a simple no-stop profile. Otherwise it simulates descent + bottom time to get tissue state, then hands off togenerateDecoSchedule(). -
generateDecoSchedule()(js/decoModel.js) computes gas-switch MODs, callsfindFirstStopAtGFLow()to determinepAnchorand the first stop in one pass, then runs the deco loop to generate the stop list. - Output is a waypoint array (embedded stops + gas switches) plus metadata (total deco time, controlling compartment,
pAnchor,anchorDepth). - Chart rendering replays the waypoints at 10-second resolution via
calculateTissueLoading()(js/decoModel.js:1178) and overlays per-timepoint ceilings viacalculateCeilingTimeSeriesDetailed()(js/decoModel.js:617).
flowchart TD
A[generateDecoProfile<br/>diveSetup.js:326] --> B{bottomTime<br/>vs NDL}
B -- "t ≤ NDL" --> C[generateSimpleProfile]
B -- "t > NDL" --> D[simulate descent + bottom]
D --> E[generateDecoSchedule<br/>decoModel.js:899]
E --> F[findFirstStopAtGFLow<br/>strict GF_low first-stop search]
F --> H[deco stop loop]
H --> I[waypoints + stops]
I --> J[calculateTissueLoading<br/>decoModel.js:1178]
I --> K[calculateCeilingTimeSeriesDetailed<br/>decoModel.js:617]
The pipeline is single-pass per dive setup: tissue state flows forward from surface, pAnchor is computed once at ascent start and passed downstream to every function that needs a GF-ramp reference.
- Algo-01-Ascent-Simulation — replay a waypoint array over all 16 compartments; segment dispatch between Haldane (level) and Schreiner (slope).
- Algo-02-NDL-Calculation — binary search for no-decompression limit at a given depth and gas.
-
Algo-03-First-Stop-Ramped-GF — the two-step
pAnchor→ first-stop discovery. The subtlest chapter. -
Algo-04-Deco-Stop-Loop — from first stop to surface, generate the stop list; the
DECO_STOP_MAX_MINUTESsafety cap. - Algo-05-Multi-Gas-Switching — MOD calculation, sequential switching, gas-switch waypoint insertion.
- Algo-06-Ceiling-Time-Series — per-timepoint ceiling overlay for chart rendering.
Cross-cutting: Architecture for the module/function index; Decompression-Model for the equations themselves; References for the prior-art decotengu docs whose structure these chapters mirror.