In [2]:
import pandas as pd
import pyfas as fa
A tab file contains thermodynamic properties pre-calculated by a thermodynamic simulator like PVTsim. It is good practice to analyze these text files before using them. Unfortunately there are several file layouts (key
, fixed
, with just a fluid, etc.). The Tab
class handles some (most?) of the possible cases but not necessarily all the combinations.
The only public method is extract_all
and returns a pandas dataframe with the thenrmodynamic properties.
At this moment in time the dtaframe obtained is not unique, it depends on the tab format and on the number of fluids in the original tab file. Room to improve here.
In [14]:
tab_path = '../../pyfas/test/test_files/'
fname = '3P_single-fluid_key.tab'
tab = fa.Tab(tab_path+fname)
In [15]:
tab.export_all()
In [16]:
tab.data
Out[16]:
Some key info about the tab file are provided as tab.metadata
In [17]:
tab.metadata
Out[17]:
Here under an example of a 3D plot of the liquid hydropcarbon viscosity
In [48]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import itertools as it
def plot_property_keyword(pressure, temperature, thermo_property):
fig = plt.figure(figsize=(16, 12))
ax = fig.add_subplot(111, projection='3d')
X = []
Y = []
for x, y in it.product(pressure, temperature):
X.append(x/1e5)
Y.append(y)
ax.scatter(X, Y, thermo_property)
ax.set_ylabel('Temperature [C]')
ax.set_xlabel('Pressure [bar]')
ax.set_xlim(0, )
ax.set_title('ROHL')
return fig
In [49]:
plot_property_keyword(tab.metadata['p_array'],
tab.metadata['t_array'],
tab.data.T['ROHL'].values[0])
Out[49]:
In [ ]: