## Equalizing real gases

As for filling cylinders real gas corrections do matter, we try to take the compressibility factor into account in Subsurface. As the theoretical physicist I thought (as I was taught) this is handled by the van der Waals equations. Turns out, in the pressure/temperature range relevant for diving cylinders is very far from getting the corrections to the ideal gas equations right. There are errors at least in the 30% range. This is probably since we are quite far away from the tri-critical point where it is supposed to be a good approximation.

In the end, we found a cubic approximation with coefficients read off from tables of compressibility factors to be an economic way to do these computations. You can find the source here.

When today somebody asked in a diving forum for a spreadsheet to calculate the resulting pressure when streaming between two cylinders, I thought I could use these interpolations to do the calculations for real gases with different compositions. Here is what I came up with.

## When real gas corrections matter

We have all learned that most of the time the ideal gas law (maybe in its isothermal version known as Boyle-Mariotte law) is sufficiently accurate to calculate the amount of gas in cylinders. At least as long as we restrict to pressures not exceeding about 200bar (and of course we all know it’s a beginner’s mistake to assume 300 bar cylinders give you a 50% advantage in gas carried with respect to 200 bar cylinders even forgetting the problems of actually getting those filled to nominal pressure or attempting to mix in at those pressures).

But let’s look at this a bit more quantitatively: You can parametrize the error of the ideal gas law by a “compressibility factor” Z so that it becomes

$$pV = ZnRT$$

and then tabulate Z as for example done here. In the table for a realistic temperature of 300K you read off 1.0326 at 200 bar while only 1.0074 at 150 bar. So, at 200 bar, you overestimate the amount of gas in your cylinder by 3% or put differently, the amount of gas is that of an ideal gas but only at (1-3%) 200 bar = 194 bar while the amount calculated at 150bar is almost correct.

What is 3% amongst friends I hear you complain, that is likely less than the accuracy of your pressure gauge. That is of course correct but lets see how this relative error multiplies as soon as you take differences: Let’s say you want to compute your surface air consumption (SAC) for a dive in which you breath your cylinder down from 200 bar to 150 bar. Wrongly assuming the ideal gas law to hold lets you compute the amount of gas to be 50 bar times the volume of your cylinders. But as we saw, due to the compressibility factor, we should rather use 194 bar – 150 bar which is only 44 bar. Compared to the 50 bar of the ideal gas, we now have a 12% error, something that I would already consider significant. In particular when I use this value to extrapolate the gas use to other dives.

We see that suddenly the relative error multiplied by a factor of four and for the momentary gas use one needs to look at $$\partial Z/\partial p$$ as well.

The upshot is that even for 200 bar one should better use a real gas replacement to the ideal gas law. Anybody who had been in an undergraduate physics class would now probably go to van der Waal equation but as it turns out for typical diving gases in the commonly used pressure ranges that gets 1-Z rather poorly. So for Subsurface we had to use a more ad hoc approximation. But that is the topic of a future post. 