Hey, I have a new math problem for G+ people. This worked really well back a few years ago when I did the "figure out number of bytes from a bitmask efficiently", so let's see if somebody on G+ has the background to do a good job on a totally different math problem for a totally different open-source project.
This time, it's about gas compressibility in scuba diving, obviously for the +Subsurface
The issue is that scuba cylinders end up having a (small) gas compressibility factor difference from the ideal gas law, and it's noticeable enough that some people care.
For example, one of the most common cylinders, the AL80, fits 80 cubic feet of an ideal gas, but only about 77.4 cubic feet of actual air, because air at 3000 psi (the fill pressure of an AL80) has a "compressibility Z factor" of about 1.03.
And it turns out that there are many ways to get those compressibility factors, but they all have some problems.
(a) ignore them. That's actually quite reasonable, but at higher pressures - but still relevant to scuba - the 3% error ends up being more like 10%.
(b) use a table lookup. That's what we did for a while, and it works fine, for air. Take the air compressibility table at 300K from Wikipedia, do linear interpolation between points for pressure, and you get quite good results. But only for air.
(c) use actual functions used by physicists. This is the next step we did, because one of the people involved is an actual physicist. The idea is that you can get the compressibility right for other gases too. Sadly, the common functions actually do pretty badly for the usual scuba gases and pressure ranges, probably because these are not ranges that most physicists care about.
(d) use a least-square polynomial fit of the Wikipedia values. This gets you much prettier code, and good approximations, but gets us back to "just air", but at least in a prettier form than my disgusting table lookup.
(e) something else.
My current idea for (e) is to do the same least-square fitting for the three relevant gases (Oxygen, Nitrogen and Helium) using the table at http://www.baue.org/library/zfactor_table.php
and then just doing a linear interpolation of the compressibility of the different gases based on the actual gas mix.
Anyway, I realize this is pretty esoteric, but maybe there is somebody around on G+ that can tell whether that linear mix is a good idea or just horrible.
Don't tell me about van der Waals equations or Redlich-Kwong. Our resident physicist already tried those. In the range we care about (temperature at about 20°C, pressure in the 1-350 bar range), they aren't actually sufficiently close to the experimental values to work..