# MBD – Model Based Diving?

Recently, CCS held its annual autumn kick-off. This year, the kick-off was held in the penthouse at Avalon Hotel in Gothenburg. This years inspirational speech was given by Annelie Pompe, a professional adventurer, who among other things talked about freediving. Therefore, this seems like an excellent opportunity for a deep dive (pun very much intended) into the very exciting topic of diving!

While the allures of freediving may be obvious after listening to Annelie, of course there are potential risks as well. Apart from shallow water blackouts and barotrauma, there is also the risk of decompression sickness. DCS have traditionally been associated with scuba diving using compressed gas, however, studies have shown that DCS syndromes may manifest after repeated deep breath hold dives. While Annelie talked about freediving, the focus for this newsletter will be more on diving using compressed gas.

So, why talk about DCS in a MBD context? Well, the effects behind DCS can be modeled.

As you all know, the air we breath contains approximately 78% nitrogen and 21% oxygen. In decompression theory, these ratios are often expressed as partial pressure instead of percent. At surface level, where the pressure is 1 bar (1 atm), the partial pressures would be 0.78 bar for nitrogen and 0.21 bar for oxygen. However, while the air contain several gases, only oxygen is metabolized in the body. Nitrogen and other gases are not metabolized and is called inert. When breathing, the inert gases are dissolved in the blood by gas exchange in the lungs. The blood is transported to the rest of the body, where the gas is exchanged to the tissue. This exchange continues until the partial pressure of the dissolved gas is equal to the partial pressure of the gas in the lungs, at which point the tissue becomes saturated. The rate of saturation varies between different types of tissue, e.g. the nervous system gets saturated fast, while fat and bones get saturated slowly.

While at sea level, where the nitrogen partial pressure is 0.78 bar, all tissue in the body is saturated at 0.78 bar (actually slightly less, but we will get to that). Now, if a diver should dive to 30 meters where the ambient pressure is 4 bar and stay there for a very long time (the slowest tissue saturates in a few days), all body tissue would be saturated with nitrogen at a partial pressure of 3.12 bar. This is not an issue, provided that the diver has enough oxygen to remain at depth indefinitely of course. While diving is fun, let us assume for the sake of argument that most divers would like to ascend to the surface at some point. If the diver could ascend from 30 meters to the surface instantely, the partial pressure in the tissue would still be 3.12 bar, while the partial pressure in the air would only be 0.78 bar – the tissue is said to be supersaturated. Thus, the nitrogen would be released from the tissue to the blood stream in order to equalize the pressure difference, forming micro bubbles which are transported to the lungs and ventilated out of the body. However, just as in a soda bottle, if the gas is released too rapidly, these micro bubbles may grow large enough to get trapped and block blood flow. A small blockage in a joint may not cause any major inconvenience, the risk is of course that bubbles may block the heart or vessels in the brain. This condition is referred to as decompression sickness (DCS) or the bends (since early symptoms include stiff joints).

Supersaturation and the resulting pressure differential is good, it is required to vent out gases. But, what is “too rapidly” when talking about the gas release? This is exactly what decompression theory addresses.

# Haldanean Model and beyond

The first to present a decompression theory was John Scott Haldane, in 1908. He proposed the use of body “compartments”, a mathematical model describing the partial pressure in hypotethical type of tissue. The compartment is characterized by its half-time, i.e. the time it takes for the tissue to reach half of its saturation level. This compartment model was developed further during several decades and was the dominating model until the 1960s when it was enhanced by considering more complex bubble models.

The rate of change of partial pressure for an inert gas in tissue is proportional to the partial pressure difference between the gas in the lungs and in dissolved gas in the tissue, i.e.

$\frac{dP_t(t)}{dt} = k (P_{alv}(t)-P_t(t))$

where  $P_t$ is the partial pressure in the tissue, $P_{alv}$ is the partial pressure in the lungs (alveoli) and $k$ is a tissue dependant constant. The constant k can be expressed in terms of the compartment half-time as $k=ln(2)/\tau$. Assuming constant partial pressure in the lungs (i.e. when the diver remains at a fixed depth), the solution can be expressed as:

$P_t(t) = P_{t0} + (P_{alv0}-P_{t0})(1-e^{-kt})$

where subscript 0 indicates the pressure at t=0. This is called the Haldane equation. Since instantaneous descents and ascents is uncommon, it is reasonable to extend the equation to include a linear variation in lung pressure,

$P_{alv} = P_{alv0} + Rt$

where R is the change rate of the partial pressure of the gas in the lungs. This addition results in:

$\frac{dP}{dt} = k (P_{alv0}(t)-P_t(t)) + kRt$

with the solution:

$P_t(t) = P_{alv0} + R(t - \frac{1}{k}) - (P_{alv0} - P_{t0} - \frac{R}{k})e^{-kt}$

This extended equation of the Haldane equation is called the Schreiner equation. But why stop here? When introducing the partial pressure of nitrogen above, 78% nitrogen content in the air gave 0.78 bar partial pressure, assuming 1 bar ambient pressure. Since the diver breathes air at the same pressure as the ambient pressure, i.e. 1 bar at surface and an additional 1 bar per 10 meters depth, it would be easy to assume that the pressure in the alveoli would be equal to the ambient pressure. However, a few factors affect the alveoli pressure, in particular:

• water vapor pressure, due to humidification in the upper airways, reducing the alveoli pressure by 0.0627 bar (based on 37 deg C water vapor)
• oxygen/carbondioxide exchange, where the ventilation of carbondioide reduces the pressure by 0.0543 bar (corresponding to the partial pressure of carbondioxide in the blood, since the content of carbondioxide in air is negligable)

Thus, the pressure in the alveoli can be expressed as:

$P_{alv} = (P_{amb} - P_{H_2O} - P_{CO_2} + \Delta P_{O2})*0.78$

For the oxygen/carbondioxide gas exchange, the respiratory quotient, RQ, can be defined as $RQ = P_{O_2} / P_{CO_2}$. The RQ typically lies in an interval of 0.7-1.0 (with 0.9 being used by the US. Navy), depending on  the level of exertion (and of course physical health and nutrition). Introducing RQ in the equation above, the alveoli partial pressure can be expressed as:

$P_{alv} = (P_{amb} - P_{H_2O} - \frac{1-RQ}{RQ} P_{CO_2} )*0.78$

So, how does this look for an actual dive profile?

## Model Simulation

Assume that a diver starts at the surface, without any residual nitrogen stored in the body tissue, i.e. saturated at sea level partial pressure. The diver makes a fast descent to 30 meters (i.e close to instantaneous) and remains at the same depth for 20 minutes.The diver, overly cautious, then makes a very slow ascent of 2 meters per min (R = -0.3 bar/min) before reaching the surface. If focusing on two types of tissue, with an expected half-time of 5 and 40 min respectively, the equations above results in a simulation model for the dive:

• Descension/bottom time:
$P_{t0} = (1 - 0.0627 + (1-0.9)/0.9*0.0543)*0.78 = 0.7358 bar$
$P_{alv0} = (4 - 0.0627 + (1-0.9)/0.9*0.0543)*0.78 = 3.0578 bar$
$P_{t5}(t) = P_{t0} + (P_{alv0}-P_{t0})(1-e^{-\frac{ln(2)}{5}t})$
$P_{t40}(t) = P_{t0} + (P_{alv0}-P_{t0})(1-e^{-\frac{ln(2)}{40}t})$
• Ascension:
$P_{t_05} = P_{t0} + (P_{alv0}-P_{t0})(1-e^{-\frac{ln(2)}{5}*20})$
$P_{t_040} = P_{t0} + (P_{alv0}-P_{t0})(1-e^{-\frac{ln(2)}{40}*20})$
$P_{alv0} = (max(4 +Rt, 1) - 0.0627 + (1-0.9)/0.9*0.0543)*0.78 = 3.0578 bar$
$P_{t5}(t) = P_{alv0} + R(t - \frac{5}{ln(2)}) - (P_{alv0} - P_{t_05} - \frac{R*5}{ln(2)})e^{-\frac{ln(2)}{5}t}$
$P_{t40}(t) = P_{alv0} + R(t - \frac{40}{ln(2)}) - (P_{alv0} - P_{t_040} - \frac{R*40}{ln(2)})e^{-\frac{ln(2)}{40}t}$
• Post dive:
$P_{alv0} = (1- 0.0627 + (1-0.9)/0.9*0.0543)*0.78 = 0.7358 bar$
$P_{t_05} = P_{alv0} + R(15 - \frac{5}{ln(2)}) - (P_{alv0} - P_{t_05} - \frac{R*5}{ln(2)})e^{-\frac{ln(2)}{5}*15}$
$P_{t_040} = P_{alv0} + R(15- \frac{40}{ln(2)}) - (P_{alv0} - P_{t_040} - \frac{R*40}{ln(2)})e^{-\frac{ln(2)}{40}*15}$
$P_{t5}(t) = P_{t_05} + (P_{alv0}-P_{t_05})(1-e^{-\frac{ln(2)}{5}t})$
$P_{t40}(t) = P_{t_040} + (P_{alv0}-P_{t_040})(1-e^{-\frac{ln(2)}{40}t})$

That was quite a few expressions, but how do the results look for this dive profile?

As can be seen in the plot, the pressure in the compartment increases and would in time reach steady state. At t=20, the nitrogen starts to decompress as the diver ascends, a process that continues during the post dive part. Still, this only provides a model for calculating the partial pressure in the tissue. What about ”too rapidly”, that was the main question? When is the pressure gradient too large with the risk of DCS? Well, to make a (very) long story (very) short, Haldane considered a gradient of 2 to be reasonable, i.e. the body can handle a partial pressure of dissolved nitrogen in the tissue that is twice as large as the partial pressure in the alveoli. This ratio actually worked pretty well,  but not well enough (especially not for deeper dives). In 1965, Robert D. Workman introduced ”M-values”, which are values for the maximum level of supersaturation to avoid micro bubbles forming:

$M = M_0 + \Delta Md$

where M (bar) is the maximum level of supersaturation for said compartment, M_0 (bar) is the partial pressure for said compartment at the surface, ΔM (bar/m) is the M-value rate of change and d (m) is the depth. So, how to find the M-values? Well, unfortunately, the only possibility was to test, to test different rates of ascent and see when DCS manifested. The measurements improved greatly with the introduction of Doppler measurements, allowing the researchers to detect bubbles before the divers showed symptoms. Several sets of values have been developed, by several research teams, using a various amount of compartments and some of these still serves as basis for dive computers. As mentioned previously, this is a fairly easy model and today much more complex algorithms have been developed, for example RGBM (used in the Suunto dive computers) and VPM – feel free to have a look at these on your own!

# Rebreathers

While on the subject, of course it is necessary to have a look at dive technology! As all of you know, when breathing only a small fraction of the oxygen in each breath is metabolized in the body. Most is exhaled, which is why CPR works for instance. This means that during a dive, the diver exhales the majority of the oxygen out into the water. Perhaps the fish appreciates it, but it seems like a waste, does it not? What if it was possible to re-circulate the used air? Well, this would cause hypercapnia due to the exhaled carbondioxide, and the oxygen content would soon drop, causing hypoxemia due to the decreasing oxygen levels. Ah, but what if the carbondioxide was removed from the exhaled air and oxygen was added to compensate the metabolized oxygen? That is exactly the function of a rebreather!

In a rebreather, the exhaled air passes through a scrubber, reducing the carbondioxide levels, before oxygen is added from a canister. Rebreathers have several benefits, for example:

• increased bottom times, since oxygen enriched air reduces nitrogen partial pressure
• silent diving without bubbles
• warm air (in contrast to scuba diving, where the air is cold and dry, chilling the diver)

Of course, there are risks and downsides with using rebreathers as well. They are very expensive and if the scrubber should fail, carbondioxide would increase with the risk of dying. Another risk is oxygen toxicity. Wait a second, oxygen is not toxic? Well, yes it is – for partial pressures above approximately 1.5-1.6 bar. Thus, diving with pure oxygen would be toxic and possibly lethal below 6 meters.

The easiest form of rebreather is purely manual, requiring the diver to monitor the partial pressure of oxygen and add more when needed. However, lately more technically advanced rebreathers have been developed, using electronics and microcontroller to control the partial pressure. Some of the most advanced models are produced in Gothenburg by Poseidon. These models are fully automatic, including:

• automatic pre-dive checks of all sensors
• continuous alarm handling, sensor analysis and validation
• resource management (oxygen supply, scrubber lifetime etc.)
• full redundancy, i.e. should any part of the system fail, the diver must be able to finish the dive safely

Poseidon’s first model, the ”MK6 Rebreather” uses a network of ATmega microprocessors in a network, to control the partial pressure of the oxygen in the loop. This is a novel solution, since most rebreathers use redundant sets of electronics. All nodes communicate through the network and in case of a failure, other nodes in the network may warn the diver.

All software for the rebreather was developed using state machines, in software called visualSTATE and Embedded Workbench. The pO2 controller uses two redundant O2-sensors to monitor the partial pressure and a solenoid to add more oxygen when needed. The setpoint for the controller is dependent on:

• depth of the diver
• setpoint configured by diver
• decompression ceiling, i.e. the minimum depth of the diver in order to avoid DCS

The control scenario is complicated further, as the partial pressure of all components in a gas mixture is related to the component fraction and the ambient pressure. This causes problems especially at shallow depth, where large variations in pressure occur often. Often, too much oxygen is injected, resulting in too much positive buoyancy.

For more information on the Poseidon rebreather systems, have a look at their website.

# A final word…

Using the equations derived in the modeling section and the knowledge from the rebreather section, it should be possible to simulate the full system. Depending on the level of complexity of the model chosen above, the controller could be tested thoroughly before deploying the code and letting divers test the equipment. This is one of those test cases where ”destructive testing” would probably be ”frowned upon”…

Hopefully this newsletter have provided you all with some small insights to the world of diving – a different, but very exciting, application of ModelBasedDesign!