Does PYroMat only consider ideal gases?

  • #1
Juanda
Gold Member
426
150
TL;DR Summary
I get different results of ##Z## depending on the method I use to find it.
On a different thread, we calculated ##Z## for ##\mathrm{CO_2}## for some pressure and temperature conditions.
(Let's assume this is absolute pressure. Not gage pressure.)
$$T=297 \ \mathrm{K}; \ P=5438467 \ \mathrm{Pa}; \ V = 0.05 \ \mathrm{m^3}$$
I did it 3 ways:
  1. "By hand" using tables from a book and eyeballing values from a table. ##Z=0.64##
  2. Using a Python Library named "GasCompressibility". ##Z=0.61##. Pretty close. I guess the differences are a result of my eyeballed values from a table.
  3. Using a Python Library named "PYroMat". This allowed us to directly find the specific volume of the gas for the given conditions without having to calculate ##Z## which is very convenient. However, it produced a different specific volume than the one obtained with the other methods so ##Z## must be different. After calculating it from other values. I got ##Z=1##.
Since the first two give very similar results, I assume they are correct and the third one is at fault. However, I can't find the error. In fact, the third one should be the simplest since it doesn't require intermediate calculations.
After checking their web more closely, I saw this note:
1725726475600.png


Is it possible that this library is assuming ideal gas behavior for all gases? That'd explain why I'm getting ##Z=1##. I think that's odd because the library can be used for multi-phase mixtures and saturated gas differs significantly from ideal gas behavior.
1725726610060.png



This is some simple code I used to compare the results from the two libraries.
GetCompressibility-vs-PYroMat:
import pyromat as pm
import gascompressibility as gc


V = 0.05 # Tank's volume [m3]
Temperature_sensor_array = 297 #[K]
Pressure_sensor_array = 5438467 #[Pa]
P_cr_CO2 = 7.39*10**6 # Critical pressure (top of the bell) [Pa]
T_cr_CO2 = 304.2 # Critical temperature (top of the bell) [K]
R = 188.9 # Gas constant [J/kgK]

# Using PYroMat to find Z.
pm.config['unit_pressure']='Pa'
pm.config['unit_temperature']='K'
pm.config['unit_mass']='kg'
pm.config['unit_volume']='m3'
co2 = pm.get('ig.CO2')
Specific_volume_pyromat = co2.v(T=Temperature_sensor_array, p=Pressure_sensor_array) #[m3/kg]
Specific_volume_pyromat = Specific_volume_pyromat[0]
Z_PYroMat = Pressure_sensor_array*Specific_volume_pyromat/(R*Temperature_sensor_array)
print('Z calculated from "PYroMat is: Z =', round(Z_PYroMat, 5))




# Using GasCompressibilty to find Z.
P_R_CO2 = Pressure_sensor_array/P_cr_CO2
T_R_CO2 = Temperature_sensor_array/T_cr_CO2

#This library requires odd units and gage pressure.
Pressure_sensor_array_PSGI = (Pressure_sensor_array-(0.1*10**6))/6895
Temperature_sensor_array_F = (Temperature_sensor_array - 273.15) * 9 / 5 + 32

Z_0 = gc.calc_z(sg=1, P=Pressure_sensor_array_PSGI, T=Temperature_sensor_array_F, H2S=None, CO2=1, N2=None, Pr=P_R_CO2, Tr=T_R_CO2, pmodel='piper')
print('Z calculated from "GetCompressibility is: Z =', round(Z_0, 5))
 
Science news on Phys.org
  • #2
Juanda said:
TL;DR Summary: I get different results of ##Z## depending on the method I use to find it.

On a different thread, we calculated ##Z## for ##\mathrm{CO_2}## for some pressure and temperature conditions.
(Let's assume this is absolute pressure. Not gage pressure.)
$$T=297 \ \mathrm{K}; \ P=5438467 \ \mathrm{Pa}; \ V = 0.05 \ \mathrm{m^3}$$
I did it 3 ways:
  1. "By hand" using tables from a book and eyeballing values from a table. ##Z=0.64##
  2. Using a Python Library named "GasCompressibility". ##Z=0.61##. Pretty close. I guess the differences are a result of my eyeballed values from a table.
  3. Using a Python Library named "PYroMat". This allowed us to directly find the specific volume of the gas for the given conditions without having to calculate ##Z## which is very convenient. However, it produced a different specific volume than the one obtained with the other methods so ##Z## must be different. After calculating it from other values. I got ##Z=1##.
Since the first two give very similar results, I assume they are correct and the third one is at fault. However, I can't find the error. In fact, the third one should be the simplest since it doesn't require intermediate calculations.
After checking their web more closely, I saw this note:
View attachment 350921

Is it possible that this library is assuming ideal gas behavior for all gases? That'd explain why I'm getting ##Z=1##. I think that's odd because the library can be used for multi-phase mixtures and saturated gas differs significantly from ideal gas behavior.
View attachment 350922


This is some simple code I used to compare the results from the two libraries.
GetCompressibility-vs-PYroMat:
import pyromat as pm
import gascompressibility as gc


V = 0.05 # Tank's volume [m3]
Temperature_sensor_array = 297 #[K]
Pressure_sensor_array = 5438467 #[Pa]
P_cr_CO2 = 7.39*10**6 # Critical pressure (top of the bell) [Pa]
T_cr_CO2 = 304.2 # Critical temperature (top of the bell) [K]
R = 188.9 # Gas constant [J/kgK]

# Using PYroMat to find Z.
pm.config['unit_pressure']='Pa'
pm.config['unit_temperature']='K'
pm.config['unit_mass']='kg'
pm.config['unit_volume']='m3'
co2 = pm.get('ig.CO2')
Specific_volume_pyromat = co2.v(T=Temperature_sensor_array, p=Pressure_sensor_array) #[m3/kg]
Specific_volume_pyromat = Specific_volume_pyromat[0]
Z_PYroMat = Pressure_sensor_array*Specific_volume_pyromat/(R*Temperature_sensor_array)
print('Z calculated from "PYroMat is: Z =', round(Z_PYroMat, 5))




# Using GasCompressibilty to find Z.
P_R_CO2 = Pressure_sensor_array/P_cr_CO2
T_R_CO2 = Temperature_sensor_array/T_cr_CO2

#This library requires odd units and gage pressure.
Pressure_sensor_array_PSGI = (Pressure_sensor_array-(0.1*10**6))/6895
Temperature_sensor_array_F = (Temperature_sensor_array - 273.15) * 9 / 5 + 32

Z_0 = gc.calc_z(sg=1, P=Pressure_sensor_array_PSGI, T=Temperature_sensor_array_F, H2S=None, CO2=1, N2=None, Pr=P_R_CO2, Tr=T_R_CO2, pmodel='piper')
print('Z calculated from "GetCompressibility is: Z =', round(Z_0, 5))
Do either of the first two methods use the Pitzer and Brewer acentric factor to get a more accurate value of Z?

The title of your third method specifically indicates ideal gases.
 
  • Like
Likes Lord Jestocost
  • #3
Chestermiller said:
Do either of the first two methods use the Pitzer and Brewer acentric factor to get a more accurate value of Z?
I searched the book for those keyworks and they don't show up. Although maybe its mentioned in the source Chemistry book.
1726037476368.png


I tried searching for them on the GasCompresssibility webpage and it doesn't show it either. Would this match what you're expecting regarding how things are calculated?
1726037765670.png

This link also details which model is used to calculate ##Z##.

Chestermiller said:
The title of your third method specifically indicates ideal gases.
Yes. I read it but I don't see how that matches the fact that the library is also used for saturated mixtures. The vapor in the mixture is most definitely not behaving as an ideal gas, right?
Juanda said:
After checking their web more closely, I saw this note:
View attachment 350921

Is it possible that this library is assuming ideal gas behavior for all gases? That'd explain why I'm getting ##Z=1##. I think that's odd because the library can be used for multi-phase mixtures and saturated gas differs significantly from ideal gas behavior.
View attachment 350922
 
  • #4
Juanda said:
I searched the book for those keyworks and they don't show up. Although maybe its mentioned in the source Chemistry book.
View attachment 351035

I tried searching for them on the GasCompresssibility webpage and it doesn't show it either. Would this match what you're expecting regarding how things are calculated?
View attachment 351036
This link also details which model is used to calculate ##Z##.

These are multi-constant equations.
Juanda said:
Yes. I read it but I don't see how that matches the fact that the library is also used for saturated mixtures. The vapor in the mixture is most definitely not behaving as an ideal gas, right?
A saturated vapor is pure gas, and not a mixture; it is a single phase at its dew point. A mixture is comprised of several molecular species.

See Smith and van Ness, Introduction to Chemical Engineering Thermodynamics.
 
  • #5
Chestermiller said:
A saturated vapor is pure gas, and not a mixture; it is a single phase at its dew point. A mixture is comprised of several molecular species.
Sorry. I said mixture but I meant to say multi-phase. I was trying to say that the PYroMat library is able to calculate saturated liquid+vapor mixtures which I find odd since it seems to be treating the vapor as an ideal gas.

Juanda said:
Is it possible that this library is assuming ideal gas behavior for all gases? That'd explain why I'm getting ##Z=1##. I think that's odd because the library can be used for multi-phase mixtures and saturated gas differs significantly from ideal gas behavior.
View attachment 350922

Aren't these kinds of tables (below) obtained experimentally? Maybe PYroMat is using experimental values for the multi-phase calculations and then it switches to ideal gas once it's all vapor?
1726058367792.png


I'm trying to decide if PYroMat is a library I should get more used to using or if I should discard it. The library GasCompressibility seems useful and reliable since it produced the same result as the "by hand" calculation using the book.
 
  • #6
Juanda said:
Sorry. I said mixture but I meant to say multi-phase. I was trying to say that the PYroMat library is able to calculate saturated liquid+vapor mixtures which I find odd since it seems to be treating the vapor as an ideal gas.
Even if it treats the vapor as an ideal gas, it must use data on the density of the saturated liquid as a function of temperature, and, if you specify the mass fraction vapor, you can get the averaged specific volume of the combination of liquid and vapor.
Juanda said:
Aren't these kinds of tables (below) obtained experimentally? Maybe PYroMat is using experimental values for the multi-phase calculations and then it switches to ideal gas once it's all vapor?
View attachment 351038

Tables like this are generated from analytically fitting data, with the fits constrained by thermodynamic relationships. This table takes into account non-ideality. To generate this table, all you need to know the Cv or Cp of the gas as a function of temperature in the ideal gas limit, the PvT real gas behavior of the gas, the Cp of the liquid at low pressures (say 1 bar) and the PvT behavior of the liquid.
Juanda said:
I'm trying to decide if PYroMat is a library I should get more used to using or if I should discard it. The library GasCompressibility seems useful and reliable since it produced the same result as the "by hand" calculation using the book.
I'm not familiar with this tool, but if it assumes ideal gas behavior of the vapor, it is probably not going to satisfy your needs at all conditions.
 
  • Informative
Likes Juanda
Back
Top