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!

Storker

ScubaBoard Supporter
ScubaBoard Supporter
Scuba Instructor
Divemaster
Messages
17,334
Reaction score
13,743
Location
close to a Hell which occasionally freezes over
# of dives
100 - 199
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.
upload_2020-11-6_9-51-4.png

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:
upload_2020-11-6_10-21-35.png


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":
upload_2020-11-6_9-56-48.png


And these are the book values:
upload_2020-11-6_9-56-34.png
 

Attachments

  • upload_2020-11-6_9-50-51.png
    upload_2020-11-6_9-50-51.png
    22.5 KB · Views: 98
So the idea is that when you have a tank with compressed gas, the number of gas molecules inside that closed compartment will stay the same. If the temperature goes up, the pressure will go up non-linear, following the formula.

I'm trying to translate that to a real-world application. Two banks, each bank has 6 tanks of 50 liters. One bank is rated for 232bar, the other one 300bar. Each bank has a pressure sensor, and the values are added to a graph every 5 minutes:
graph-pressure.png

The spikes in the graph are errors, caused by simultaneous read-outs of the sensors by other processes. Ignore those.

Every 2nd tank in the bank has a temperature sensor attached to it, values are added to a graph every 5 minutes:
graph-temperature.png

Temperatures are dropping significantly over the last three days, so that might correlate to the pressure drop.

Using the van der Waals equation, I should be able to calculate the volume, and that should be a straight line, assuming there are no leaks in the system (I'm not so sure about that, yet...).

Sofar, I've calculated the volume with compressibility factors from a table, resulting in this graph:
graph-volume.png

So this looks like the volume stays the same.
For the compressibility factor, I used a calculator that models air as 78% N2, 21% O2, Ar 0.9%, CO2 0.04%

Using van der Waals' formula to calculate the volume, what values do I use for n and R?

There's quite a difference between the values that @Storker mentions. Would be interesting to graph both of them:
"vdW constants":
upload_2020-11-6_9-56-48-png.622538.png

book values:
upload_2020-11-6_9-56-34-png.622537.png
 
So the idea is that when you have a tank with compressed gas, the number of gas molecules inside that closed compartment will stay the same. If the temperature goes up, the pressure will go up non-linear, following the formula.
Correct. But you aren't going much over 240 bar, have you checked how well the data fit with the ideal gas law? n is constant, V is constant and R is a constant, so you end up with P ∝ T (or P = c·T if you like). Just make sure that T is in degrees Kelvin (K = °C + 273.15)

For the compressibility factor, I used a calculator that models air as 78% N2, 21% O2, Ar 0.9%, CO2 0.04%
I wouldn't bother worrying about the Ar and the CO2. The amounts are so small that I'm pretty certain they wouldn't skew the calcs enough that it makes a difference in a real world application. 79% N2/21% O2 is what I'd go with.

Using van der Waals' formula to calculate the volume, what values do I use for n and R?
n is the number of molecules (unit: mol¹) in the tank. So that value depends on how full you pump your tanks.
R is the universal gas constant, 8.314 J/K⋅mol = 0.08314L⋅bar/K⋅mol = 0.08205 L⋅atm/K⋅mol



¹ 1 mol - very often misspelt "mole"² - is 6.022·10^23 molecules.
1 guacamole.

*rimshot*
² But a mole is not a unit. It's a small, furry critter that likes to burrow.
 
Temperatures are dropping significantly over the last three days, so that might correlate to the pressure drop.

Using the van der Waals equation, I should be able to calculate the volume, and that should be a straight line, assuming there are no leaks in the system
Eyeballing those graphs, it looks as if the pressure is dropping also during the last 24 hours, with ~constant temperature. Which it shouldn't do (because I assume that your tanks are rigid. Steel 50L, perhaps?) unless you're losing gas. Me, I'd check for leaks.
 
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 gas law depends on two very important simplification 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. The van der Waals' equation looks like this:


Except that the equation looks 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
I was once filling my tank up and the molecules started noticing each other. Boy molecule met girl molecule and the rest was history.

You should consider putting those equations into a web page to aid with blending calculations. Heck,even a page with an easy volume calculation would be pretty sweet.
 
I was once filling my tank up and the molecules started noticing each other. Boy molecule met girl molecule and the rest was history.
Thanks for getting my innuendo.

I briefly considered adding a paragraph about being on a crowded dance floor versus being about the only two people on a football field, but concluded that it would probably detract too much from the message I was trying to send.
 
I briefly considered adding a paragraph about being on a crowded dance floor versus being about the only two people on a football field, but concluded that it would probably detract too much from the message I was trying to send.

It's always an advantage to know your audience.
 
https://www.shearwater.com/products/peregrine/

Back
Top Bottom