Real-world gas calculations

Please register or login

Welcome to ScubaBoard, the world's largest scuba diving community. Registration is not required to read the forums, but we encourage you to join. Joining has its benefits and enables you to participate in the discussions.

Benefits of registering include

  • Ability to post and comment on topics and discussions.
  • A Free photo gallery to share your dive photos with the world.
  • You can make this box go away

Joining is quick and easy. Log in or Register now!

I was once filling my tank up and the molecules started noticing each other. Boy molecule met girl molecule and the rest was history.
This would be particularly true if the boy molecules were hydrogen and the girl molecules were oxygen...
 
When we took our first dive cert, we were taught about the different gas laws...
<massive snip>
Great post! Yes, lots of Science, but with enough empirical fudge-factoring to smell a lot like Engineering. I stopped paying attention in thermo when we hit gas fugacity. BUT, speaking as a scientist, I'd much rather have my gas mixes determined by a chemical engineer.

Oh wait, Storker IS a chemical engineer! Good job!
 
Oh wait, Storker IS a chemical engineer!
Is it that obvious?
 
When we took our first dive cert, we were taught about the different gas laws, perhaps most notably Boyle's law, P1·V1 = P2·V2, or P·V = constant. I've seen the quip that Boyle is an acronym for Breathe Or Your Lungs Explode, but that's of course not true. Even if it's funny and a good reminder of its effect. All the gas laws are just subsets of the same law, the ideal gas law, so there really isn't any point in remembering more than one gas law: The ideal gas law, which states that

where n is the number of molecules in our gas and R is just a constant. The ideal gas constant, to be more precise.

But this isn't true. The ideal gas law depends on two very important simplifications of the real world. That's why it's called the ideal gas law. "Consider a spherical cow"... The ideal gas law assumes that the gas molecules don't take up any space, and that they don't care at all about each other. This is of course wrong, but at the surface at ambient temperature and pressure those phenomena are so insignificant that they don't matter. Or, in other words, we can treat our gas as an ideal gas. It follows the ideal gas law, so it behaves ideally. The problem comes when we start pumping our gas into pressurized tanks. At 200-300 bar pressure, the gas molecules are packed so tightly that they start noticing each other, and some of them may be attracted to each other. They're also packed so tightly that the space each gas molecule takes up becomes noticeable to the other gas molecules. This makes the gas start to behave in a non-ideal manner.

Generally, the pressure rises faster than the ideal gas law predicts, and in practice this means that a 300 bar tank at service pressure holds about 10% less gas than it should have done if the gas behaved like an ideal gas also at 300 bar. This is one of the reasons that 300 bar tanks aren't very popular among those who mix gas by partial pressure blending, because if we use the ideal gas law to PP blend to 300 bar our mix will be richer than it should be. At 200 bar, the difference is so small that we really don't have to worry about it, and even at 232 bar the difference isn't very big.

The most common method to account for non-ideal behavior is to introduce a fudge factor into the ideal gas law. The simplest way is to introduce a compressiblity factor:

which turns the ideal gas law into PV = ZnRT (or PV = zRT if you wish). As long as we have values for Z for our specific gas mix in the pressure range we're interested in, it's all good. If all you're interested in is air, you're good. Even Wikipedia gives us those values. They've lifted those values from a much more reputable source, though: Perry's Chemical Engineeer's Handbook (AKA The Chemical Engineer's Bible).

But what if we're blending EAN36, or 21/35? Good luck finding compressibility factors for those mixes. Enter van der Waals' equation of state. van der Waals' equation is a bit messy, but it introduces two fudge factors into the ideal gas law: One (called b) to account for the fact that the gas molecules have a real volume and can't occupy the same space in our tanks, and one (called a) to account for the fact that gas molecules sometimes are attracted to each other. In science-speak, that makes the vdW equation a semi-empirical model, because the adjustable constants actually mean something, they're not just fudge factors thrown in to make the model fit reality. They represent actual physical phenomena. Even if the value of a and b have to be determined experimentally. The van der Waals' equation looks like this:


Except that the equation looks a mite messy, it's perfectly solvable as long as you have the values for the two constants (a and b) for the gas. And we have those, for a bunch of different gases. And we can calculate the a and b values for any mix, as long as we have the a and b values for each of the components. So we're good, right? No. Because those as and bs are supposed to work over a very large pressure and temperature range, much larger than the range we're interested in. So their values have to be some kind of a compromise, giving "good enough" accuracy over the whole range. Which, in the fairly small range we're interested in, really isn't quite "good enough". Hardly even for government work. When I took my blender cert, my textbook showed a graph of the surface volume of the gas in a tank at pressures from 0 to 300 bar. And that graph told us that at 150 bar, the tank holds about 5% more gas than what the ideal gas law predicted. I got the exact same graph when I used the vdW equation with the stock constants, so that's what they'd done to make it.
View attachment 622536
Problem is, real world compressibility data don't agree with that prediction. Those data say that the difference between what the ideal gas law tells us and how the real gas behaves at 150 bar is less than one percent. But. If we use a different set of values for a and b, will then the vdW equation give better results? It should, as long as those a and b values are fitted to our pressure range and we don't care how well the vdW equation predicts outside that small range.

I got some new values for a and b by fitting them to real world compressibility data in "my" pressure range (0-300 bar). For nitrogen, oxygen and air, the compressibility data can be found in Perry's. Helium? A mite more complicated, but there are journals dedicated to publishing all kinds of engineering data, so it should be possible to find something. And bingo, in a slightly obscure article published before I was born, I found real world compressibility data for different He/N2 mixes. Then came the slightly tedious job of testing different values for a and b and eyeballing how well the vdW predictions fit the real world data. A more computer-savvy person than me could probably have automated that process, but I can't code. So hand-fitting it was. And the result looked pretty nice, with less than 1% difference between the data and the predictions. Good enough for government work. Put it all into a spreadsheet, use the vdW equation to calculate pressure (with "my" a and b values), and presto. We're in business, and the results agree pretty well with the compressibility data:
View attachment 622539

I'd really like to test that spreadsheet by PP blending trimix to 300 bar, but since I'm not trimix certified it's not going to happen. Besides, the pressure in the tank varies with temperature, and there's no way I can measure the temperature inside the tank. The only solution is to use ample time when blending, filling slowly and taking breaks to let the tank cool down before topping to the pressure I want. But until someone proves me wrong, I'll continue to believe that I have a model which works pretty well. I'd love if someone tried to prove me wrong, though.


By the way, here are my "vdW constants":
View attachment 622538

And these are the book values:
View attachment 622537
Hi,
Might be worth it to use a different Equation of State (EOS) model to fit your data to.
Van der Waal's is pretty basic.

A slight quibble over semantics with your comment:

"Because those as and bs are supposed to work over a very large pressure and temperature range, much larger than the range we're interested in. So their values have to be some kind of a compromise, giving "good enough" accuracy over the whole range."

The VdW constants are only going to fit at ONE point: the Critical Point, where they are defined.
After that, any deviation from the VdW EOS predicted line and real life is because the assumptions made in VdW don't apply well enough.

I haven't tried very hard yet, but I think it wouldn't be so difficult to find a much better EOS that's only slightly more complex than VdW, and fits the diving case a lot better.

On another thread, DavidDem has written an Excel sheet with a VisualBasic Macro using a VERY complex EOS:
Real Gas Real Deal

It only uses three gases, but that's OK for you.
I am not a great fan of using it a lot for diving cases because I don't think you need its complexity: as I said, I think one could come up with a MUCH simpler (and more rubust) EOS that is as accurate as is needed.
The EOS that is used in the Real Gas Real Deal sheet is VERY easy to make mistakes in coding.
 

Attachments

  • Cubic EOS.png
    Cubic EOS.png
    86.6 KB · Views: 37
  • VdW calcs.png
    VdW calcs.png
    180.8 KB · Views: 33
  • Equations of State and PVT Analysis __ Equations of State and Phase Equilibria (2016).pdf
    108.3 KB · Views: 48
https://www.shearwater.com/products/teric/

Back
Top Bottom