Deco engine
How the deco engine works
A plain-language tour of the Bühlmann ZH-L16C dissolved-gas model behind the Dive Kit deco planner: tissue compartments, M-values, the ascent criterion and how CNS and OTU are counted, with worked numbers from the engine.
最后更新 2026年10月30日
本页内容
What it is
The Deco Planner runs a decompression model called Bühlmann ZH-L16C. It is the same family of model used by Shearwater dive computers, Subsurface, and MultiDeco. This page explains, in plain terms, what that model does when you build a plan: how it tracks the gas in your body, why a ceiling appears, and why you end up holding stops on the way up.
You do not need any of this to use the planner. But if you want to understand the numbers it gives you, this is the foundation.
A dissolved-gas model
Bühlmann ZH-L16C is a dissolved-gas model, sometimes called a Haldane-type model after the physiologist who pioneered the idea a century ago. The core idea is simple. When you breathe gas under pressure, inert gas (nitrogen, and helium if you dive trimix) dissolves into your tissues. Ascend too fast and that dissolved gas comes out of solution as bubbles, which is what causes decompression sickness. The model’s job is to track how much inert gas you have taken on, and to tell you how fast you can come up without forming dangerous bubbles.
It cannot track every cell in your body, so it uses a stand-in.
16 tissue compartments
The model represents your body as 16 compartments. These are not real organs. They are mathematical buckets, each one standing in for tissues that absorb and release gas at a particular speed.
Each compartment has a fixed half-time, the time it takes to fill or empty halfway. The published ZH-L16C half-times run from about 4 minutes for the fastest compartment up to 635 minutes for the slowest. Fast compartments behave like blood and brain: they load up quickly and clear quickly. Slow compartments behave like joints and bone: they take hours to saturate and hours to let go.
Tracking 16 speeds at once is the whole point. A short, deep dive is driven by the fast compartments. A long dive loads the slow ones, and they are what keep you holding stops long after the fast tissues have cleared.
On-gassing and off-gassing
The amount of inert gas dissolved in a compartment is its tension, measured as a pressure in bar. Underwater, the surrounding pressure is high, so gas pushes into your tissues and tension rises. This is on-gassing. On ascent and at the surface the pressure drops, gas comes back out, and tension falls. This is off-gassing.
Dive Kit computes this with the standard Haldane equation, and it recomputes it in 1-second steps as your depth changes. That matters: your tissues are loading and unloading while you move, not just while you sit at a fixed depth. Modelling the descent and ascent second by second is where a lot of the realism comes from.
Helium is tracked separately from nitrogen in every compartment. Helium loads and unloads roughly 2.65 times faster than nitrogen, the ratio of the published ZH-L16C half-times. When a compartment holds both gases, the engine uses the correctly weighted blend of its nitrogen and helium coefficients, recomputed continuously as your gas mix changes. That is why a trimix dive produces a differently shaped deco profile, not just a scaled one.
Why a ceiling and stops appear
Here is the mental picture the whole model rests on. Imagine a graph of a compartment’s tension against the ambient pressure around you. Ambient pressure is the pressure squeezing you: the air at the surface plus the weight of the water overhead. Two lines matter.
- The ambient-pressure line. This is where tension equals the pressure around you. Below it, deeper, you are safe. The moment you ascend past it, your tissue holds more gas than the surrounding pressure can keep dissolved. That state is supersaturation, the “fizzing” condition where bubbles can start to form.
- The M-value line. This is the most supersaturation a compartment can tolerate before the risk is judged unacceptable. It is a hard ceiling. The relationship is a straight line,
M = a + ambient pressure / b, with publishedaandbconstants for each compartment.
The band between these two lines is the decompression zone. Decompression is the craft of climbing up into that band to off-gas as fast as possible, without ever punching through the M-value ceiling. The Deco Planner shows the depth where your ascent first crosses into it, as Deco zone starts at above the stop table (see Where the deco zone starts).
One thing that is easy to misread: only time at depth changes any of this. Setting a higher breathing rate in the planner changes how much gas the dive costs and nothing about the schedule, because the model has no term for how hard you are working. Adding a delay before ascent does change the schedule, for the ordinary reason that you spend those minutes at depth still on-gassing.
A ceiling is simply the shallowest depth your most-loaded compartment can tolerate right now without crossing its M-value. A stop is the planner holding you at a fixed depth until your tissues off-gas enough that the ceiling recedes and you can come up to the next stop. As you off-gas, the ceiling rises, and you follow it toward the surface.
Plain Bühlmann lets you ascend right up to the M-value line. Most technical divers want a margin below that ceiling. Dive Kit adds that margin with gradient factors, which are explained in full on the gradient factors page.
Any app or dive computer that runs the Bühlmann algorithm uses this same gradient-factor and ceiling approach, so a Dive Kit schedule lines up with theirs. Some of those tools, such as Shearwater computers, Subsurface, and MultiDeco, also let you switch to the VPM bubble model in their settings. VPM is a different algorithm with no gradient factors, so a VPM-only planner like V-Planner will not produce a matching schedule.
The ascent criterion
The engine decides whether you may leave a stop with one test, repeated every second you hold it.
-
Update every compartment. The engine applies the Haldane equation to each of the 16 compartments for the second just spent, separately for nitrogen and helium. A compartment’s total inert-gas tension is
P = PN2 + PHe. -
Blend the coefficients. Each compartment has published
aandbvalues for nitrogen and for helium. When it holds both gases, the engine weights them by the tensions:a = (aN2 × PN2 + aHe × PHe) ÷ P, and the same forb. -
Apply the gradient factor. The engine reads the gradient factor
GF(as a fraction, so 64.4% is 0.644) for the depth you are at, from the line described on Gradient factors. -
Work out the tolerated ambient pressure. This is the lowest surrounding pressure the compartment accepts at that gradient factor:
P_tol = (P − a × GF) × b ÷ (GF − GF × b + b)At GF 100% this reduces to Bühlmann’s own
P_tol = (P − a) × b, which is the M-value lineM = a + P_amb ÷ bsolved for the ambient pressure. -
Take the worst compartment. The leading compartment is the one with the highest
P_tol. Converted to depth,(P_tol − surface pressure) × metres per bar, it is the ceiling. -
Compare with the next stop. The engine rounds the ceiling up to the stop grid (3 m steps, plus your last stop depth). If that rounds shallower than the stop you are on, you may go up. Otherwise you hold another second.
Two settings shape when that “may go up” turns into an ascent. With whole-minute stops (the default), the engine holds you to the next whole minute on the stop, so it records every minute you hold. Your last stop is always held for at least 1 minute.
Worked example
The dive: 45 m for 25 minutes on trimix 21/35, EANx50 as the deco gas, GF 50/80, and the app’s other defaults (EN 13319 water, sea level, 6 m last stop, whole-minute stops). The engine schedules 1 minute at 18 m, 1 at 15 m, 2 at 12 m, 4 at 9 m and 21 at 6 m.
At the 9 m stop the gradient factor is 64.4%. The leading compartment is compartment 6 (nitrogen half-time 38.3 minutes, helium 14.48 minutes). Its numbers one minute before the engine lets you leave, and at the second it does:
| One minute before | When you leave | |
|---|---|---|
| PN2 + PHe | 1.3489 + 0.9258 = 2.2747 bar | 1.3413 + 0.8825 = 2.2238 bar |
Blended a, b | 0.6330, 0.8240 | 0.6298, 0.8245 |
a × GF | 0.4076 | 0.4055 |
b ÷ (GF − GF × b + b) | 0.8791 | 0.8794 |
| Tolerated ambient pressure | 1.6413 bar | 1.5990 bar |
Ceiling ((P_tol − 1.01325) × 10.000) | 6.28 m | 5.86 m |
| Next stop | 6 m | 6 m |
| Decision | 6.28 m rounds to 9 m: hold | 5.86 m rounds to 6 m: go up |
Helium leaves compartment 6 faster than nitrogen (0.0433 bar of helium against 0.0076 bar of nitrogen in that minute), which is why the blended a and b drift as you hold. The 5.86 m ceiling equals the engine’s own ceiling sample at that second to four decimal places.
Two oxygen clocks: ambient vs inspired PPO₂
The model above is about inert gas. Oxygen needs a separate accounting, and it involves a subtle but important distinction in which PPO₂ (partial pressure of oxygen) the engine uses.
There are two PPO₂ values for the same breath of gas:
- Inspired PPO₂ is the oxygen pressure once the gas reaches your alveoli. Your lungs saturate inhaled gas with water vapour at body temperature, and that water vapour displaces a small amount of every other gas. The correction is about 0.0627 bar.
- Ambient PPO₂ is the oxygen pressure of the gas as you breathe it, before the water-vapour correction.
Dive Kit uses these for two different things, on purpose:
- Tissue gas loading uses inspired PPO₂. Modelling how gas actually diffuses into tissue depends on the alveolar partial pressures, so the water-vapour correction belongs here.
- CNS oxygen toxicity uses ambient PPO₂. The CNS (central nervous system) clock tracks seizure risk. It comes from NOAA and US Navy exposure experiments that measured the breathing gas PPO₂, not the alveolar value. Those published limits already bake in any physiological correction, so applying the water-vapour subtraction again would double-count it and understate your real exposure.
This is the same convention used by other Bühlmann implementations such as Shearwater, Garmin, Subsurface, and MultiDeco. It is not a quirk.
The difference is large where it matters most. On 100% oxygen at 6 m, ambient PPO₂ is 1.60 bar while inspired PPO₂ is about 1.54 bar. Both values land in the same steep band of the NOAA CNS table, but the rate within that band changes fast: the allowed exposure is roughly 45 minutes for the ambient value and roughly 92 minutes for the inspired value, about a 2x gap right at a critical boundary. Using ambient PPO₂ keeps the CNS clock honest and slightly conservative.
How CNS and OTU are counted
The engine adds oxygen exposure every time it updates the tissues: each second of travel and of every stop, and each half-minute block of a level. Each update takes the ambient PPO₂ at that depth and the minutes spent there.
CNS. For a PPO₂ between 0.5 and 1.65 bar, the engine looks up the exposure limit in minutes from the NOAA table, written as straight-line pieces limit = slope × PPO₂ + intercept:
| PPO₂ (bar) | Slope | Intercept | Limit at the top of the band |
|---|---|---|---|
| 0.5 to 0.6 | −1800 | 1800 | 720 min |
| 0.6 to 0.7 | −1500 | 1620 | 570 min |
| 0.7 to 0.8 | −1200 | 1410 | 450 min |
| 0.8 to 0.9 | −900 | 1170 | 360 min |
| 0.9 to 1.1 | −600 | 900 | 240 min |
| 1.1 to 1.5 | −300 | 570 | 120 min |
| 1.5 to 1.65 | −750 | 1245 | 7.5 min |
At 1.6 bar the limit is 45 minutes. A segment adds minutes ÷ limit to the CNS fraction, shown as a percentage. Below 0.5 bar it adds nothing. Above 1.65 bar the engine extends the last line and never lets the limit fall below 6.67 minutes. Between dives, CNS halves every 90 minutes at the surface.
OTU. Above 0.5 bar each minute adds ((PPO₂ − 0.5) ÷ 0.5) ^ 0.83 units. OTU does not decay between dives.
Worked example
Take the 25 minutes at 45 m on 21/35 from the dive above. The ambient PPO₂ is 0.21 × (1.01325 + 45 ÷ 10.000) = 1.1578 bar, in the 1.1 to 1.5 band.
- CNS limit: −300 × 1.1578 + 570 = 222.67 minutes. The segment adds 25 ÷ 222.67 = 11.23%.
- OTU rate: (0.6578 ÷ 0.5) ^ 0.83 = 1.2556 per minute. The segment adds 31.39 OTU.
Adding up every segment of the dive (descent, bottom, ascent and the EANx50 stops) gives the engine’s plan totals: CNS 21.53% and OTU 60.66.
These clocks follow published exposure limits. A CNS figure under 100% keeps you inside those limits. It does not rule out oxygen toxicity, whose onset varies between divers and from day to day.
Why the engine is native C++
Dive Kit’s deco engine is written in C++ and runs natively on your phone through a native module, rather than in JavaScript. There are two reasons.
- Speed. The planner recomputes the entire schedule, second by second, every time you change a depth, a time, a gas, or a setting, and it does so for the base plan plus every contingency scenario at once. Native code does that fast enough to feel instant as you type.
- Consistent arithmetic. Decompression math is full of repeated exponential calculations. A native implementation gives the same, well-defined floating-point behaviour on every device.
The engine is an independent implementation written from the published Bühlmann papers and Erik Baker’s equations. The open-source projects it is compared against, such as Subsurface, are cross-checks, not code it was derived from. See how Dive Kit compares to MultiDeco for how those checks are run.
Behaviour and limits
- Bühlmann is a model fitted to data. Decompression sickness is probabilistic, so no schedule is a promise of safety.
- The model assumes the gases, depths, rates, and settings you entered are exactly what you dive. Cold, hard work, and current all make you on-gas faster than the model predicts.
- When a Dive Kit schedule matches another planner’s, that shows the two compute the same arithmetic. It does not show the plan is safe.
- This is a planning tool used on the surface. It does not replace training, a dive computer, a sensible personal margin, or your own judgement.
Related
- Gradient factors explains the conservatism dial built on top of this model.
- How Dive Kit compares to MultiDeco covers how the schedules are cross-checked.
- Deco Planner is the tool that runs this engine.
本指南部分内容借助 AI 起草,可能存在错误。内容仅供学习参考,不能替代专业培训。请始终在你的认证范围内潜水,并以仪器读数为准。