#imports
import CoolProp.CoolProp as cp
import numpy as np
import pandas as pd
import hvplot.pandas
#import holoviews as hv
Co2-Properties
CoolProp Example - CO2 Density
Density function (calls CoolProp)
#fucntion definition
def density(P,T,fluid):
return cp.PropsSI('D', 'T', (T-32)*5/9 + 273.15, 'P', P*6894.75728, fluid)
=np.vectorize(density) densityfunc
Making of the density Plot
='CO2'
fluid= np.arange(400,5400,25.)
P_psi= np.arange(20,320,20.)
T_F
= np.meshgrid(T_F, P_psi, sparse=False)
T, P =densityfunc(P,T,fluid)
d
= pd.DataFrame(d.T, columns = P_psi, index = [str(i)+' F' for i in T_F])
df =df.T.hvplot(
plt='line',
kind=T_F.size*['k'],
color=list(np.linspace(1,.3,T_F.size)),
alpha='Pressure [psi]', ylabel='Density [kg/m^3]', height=500, width=780,
xlabel=f'{fluid} density along isotherm',grid=True
title
)#hv.save(plt, f"{fluid}_density.html", backend="bokeh")
plt
Documentation: http://www.coolprop.org/