- #1

Juanda

Gold Member

- 425

- 149

- 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.

$$T=297 \ \mathrm{K}; \ P=5438467 \ \mathrm{Pa}; \ V = 0.05 \ \mathrm{m^3}$$

I did it 3 ways:

After checking their web more closely, I saw this note:

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.

This is some simple code I used to compare the results from the two libraries.

*(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:

- "By hand" using tables from a book and eyeballing values from a table. ##Z=0.64##
- 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.
- 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##.

After checking their web more closely, I saw this note:

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.

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))
```