Info Real gas - the real deal

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 suspect there was a user error when using REFPROP. It has a plethora of settings and fluid selections, which is probably where the misstep happened.
REFPROP gives a compressibility factor (Z) of 1.0313 for air at the values you specified (70 °F and 3000 psi), and 1.0363 at 300 K and 3000 psi.

If I had to make a wild guess, I’d say whoever calculated the Z-factor likely selected the wrong fluid in REFPROP. Methane, for example, would come close to the incorrect value of 0.881. It has a Z-factor of 0.83172 at 300 K and 3000 psi. REFPROP also has a free version available, called MINI-REFPROP. It has at least air as a pseudo pure fluid.

I love COOLPROP and surprised it isn’t more widely adopted in the gas industry. It also hasn’t seen any real recognition in the SCUBA world yet, which is odd. It’s an open-source library for calculating various fluid properties, and it can be used easily by anyone with basic Python skills.

I got tired of writing Python scripts manually, so I built a small app to run a local server.

The app launches a Flask server that can be accessed via a local browser, no internet required and the app certainly doesn't connect to anything outside your local server. It’s not the neatest solution, but it was the quickest approach I could think of that didn’t involve writing a full standalone program. It was intended for personal use, so I didn’t pay much attention to which licenses to include. I sincerely apologize if I forgot to add a license and will do so when someone points it out (It's been a while and I can't recall all the dependencies). None of the heavy lifting in the app is my own. I just pulled everything together into a usable package. All I did was write the HTML and PHP front-end.
Maybe that’s of use to someone like me that likes to play around with the physics.

For what it’s worth, COOLPROP also returns a Z of 1.0313 at 3000 psi and 70 °F.
Well, if there was a user error, it was not on my side.

I am looking at two libraries CoolProp and Thermo. Thermo seems to cover more functionality. I will review the code shortly.

Do you have the code for your app anywhere on GitHub? If so, I can incorporate it into my soon-to-be-live site dedicated to tech diving, caves, with some used gear for sale, too.
 
When I looked into it, Thermo looked more suited for chemical stuff, rather than physical states. I do not have enough knowledge to judge Thermo vs CoolProp, but at the time it seemed to me that CoolProp was the more "mature" solution.

I do not have the code on Github, but like I said it isn't difficult. Anyone that is somewhat familiar with python or compiling can compile it from these sources:

requirements.txt
Code:
CoolProp
flask
Diver-CoolProp.spec
Python:
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['Diver-CoolProp.py'],
    pathex=[],
    binaries=[],
    datas=[('templates', 'templates'), ('internal', 'internal')],
    hiddenimports=['Flask', 'CoolProp'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    name='Diver-CoolProp',
    icon="logo.ico",
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

The .html is attached as it's too long for ScubaBoard.

Compiling is done via pyinstaller Diver-CoolProp.spec, and that is essentially it.

I'm not entirely sure how you want to implement it into your website. I tried to have CoolProp running in a webassembly, but failed miserably. Short of spending quite a bit of time, I don't see how one would run it directly within the browser, as no thermodynamic library I have found runs natively in Java or PHP. Most run on C++ and have Python implementations. These can't be called upon directly within the browser. If you can setup a back-end that runs python, I guess that would be the cleanest option.

I briefly looked into Pyscript to run it sandboxed on the machine calling the site, but haven't found the time to properly implement it. SmoWeb has a back-end and client-end ready for deployment on Github.
 

Attachments

Great thread. I am only rarely blending and have been using free apps like DiveCalculator ‎Dive Calculator without ever checking what model is behind. Now I have checked and cannot find any info.

Does anybody know?

Without knowing what gas model is used, how big would the difference be for worst and likely ones?
 
@LFMarm, basic apps typically assume ideal gases. The Gas Blender Toolkit can do ideal or Van der Waals. You can run some scenarios to see the differences. (You can also confirm whether your current tool is/is not doing ideal.)
 

Back
Top Bottom