I'm trying
to calculate the temperature and pressure after a reflected shock in a shock tube for a real gas using CoolProp to solve for the following thermodynamic variables used in the algorithm:
- hmass
- rhomass
- cpmass
- isothermal_compressibility
- isobaric_expansion_coefficient
The conditions we expect are often between 1000K and 2000K, with pressures of 100 bar to 300 bar, for various mixtures of hydrocarbons (e.g. methane or natural gas), oxygen, argon, and/or carbon dioxide.
I have been unable to reliably use CoolProp with either the SRK or PR cubic EOS at even a pressure of 100 bar. I encounter quite a few different errors - most commonly, there are three roots for the cubic; however, there are several other errors I've been getting that I can't make sense of.
I've included details about the environment I'm running my code in, as well as sample code and the output/errors I've gotten. Hopefully I'm not misunderstanding how to use CoolProp, or what it should be able to do, so as to waste anyone's time, but from my limited experience it seems very unpredictable and therefore unusable for me. If anyone is able to offer any advice or guidance, that would be much appreciated. I can always open an issue on the GitHub, but only if these are actual issues with CoolProp and not an issue with my implementation/understanding.
Thank you for your time.
Environment:
Python 3.8
CoolProp 6.4.1
Code Outline (".../test.py"):
import CoolProp as CP
backend = "PR"
T = 1500 # [K]
P = 100e5 # [Pa]
mixture = {
"AR": 1
}
EOS = CP.AbstractState(backend, "&".join(mixture.keys()))
EOS.set_mole_fractions(mixture.values())
EOS.update(CP.PT_INPUTS, P, T)
print(f"Density = {EOS.rhomass():.3f} kg/m^3")
Samples Cases/Outputs/Comments:
For all these cases, only the mixture dictionary and backend string are chagned from the above code outline
AR: 1 (PR)
Traceback (most recent call last):
File ".../test.py", line 14, in <module>
EOS.update(CP.PT_INPUTS, P, T)
File "CoolProp\AbstractState.pyx", line 102, in CoolProp.CoolProp.AbstractState.update
File "CoolProp\AbstractState.pyx", line 104, in CoolProp.CoolProp.AbstractState.update
ValueError: Cubic has three roots, but phase not imposed and guess density not provided
AR: 1 (SRK)
[same as above]
CO2: 1 (PR)
[same as above]
CO2: 1 (SRK)
[same as above]
Seems like neither Argon or CO2 pure fluids are working at T = 1500 K, P = 100 bar
AR: 1, CO2: 0 (PR)
Traceback (most recent call last):
File ".../test.py", line 15, in <module>
EOS.update(CP.PT_INPUTS, P, T)
File "CoolProp\AbstractState.pyx", line 102, in CoolProp.CoolProp.AbstractState.update
File "CoolProp\AbstractState.pyx", line 104, in CoolProp.CoolProp.AbstractState.update
ValueError: critical point finding routine found 0 critical points
Somehow adding Carbon Dioxide to the AbstractState but setting its mole fraction to 0 resulted in a different error than when the AbstractState was initialized with only Argon despite not changing the actual composition
AR: 0.5, CO2: 0.5 (PR)
Density = 33.054 kg/m^3
Somehow the 50-50 mixture of Argon and CO2 works for PR
AR: 0.5, CO2: 0.5 (SRK)
Traceback (most recent call last):
File ".../test.py", line 15, in <module>
EOS.update(CP.PT_INPUTS, P, T)
File "CoolProp\AbstractState.pyx", line 102, in CoolProp.CoolProp.AbstractState.update
File "CoolProp\AbstractState.pyx", line 104, in CoolProp.CoolProp.AbstractState.update
ValueError: Unable to find gaseous density for T: 1500 K, p: 1e+07 Pa
The 50-50 mixture doesn't work with SRK, though
AR: 0.3, CO2: 0.7 (PR)
Traceback (most recent call last):
File ".../test.py", line 15, in <module>
EOS.update(CP.PT_INPUTS, P, T)
File "CoolProp\AbstractState.pyx", line 102, in CoolProp.CoolProp.AbstractState.update
File "CoolProp\AbstractState.pyx", line 104, in CoolProp.CoolProp.AbstractState.update
ValueError: p is not a valid number
This error doesn't make any sense to me given that the 50-50 mixture with the same T, P, and PR didn't give an error