Changelog: 11/2017 - Integration of CoolProp 06/2018 - Update to OpenFOAM-5.x (Mass-based thermodynamics (for example: cpMcv to CpMCv)) 03/2019 - Update to include parahydrogen properties from Refprop """ import CoolProp.CoolProp as CP #import numpy as np #import matplotlib.pyplot as plt #Fluid for thermodynamic properties (rho, Cp, CpMcv, H, S, c, E, thermal conductivity) #Custom refernce state for orthohydrogen to capture enthalpy offset of orthohydrogen CP.set_reference_state('orthohydrogen', 20.3800689304, 35150.6373702, 1417.12332, 0.036828) fluid_thermo = 'orthohydrogen' #Fluid for transport model (viscosity) fluid_transport = 'hydrogen' #**************************************************************************************** #Temperature limits (set within subcritical region for saturation tables) T0 = 15 #Temperature start (K) TMax = 32 #Temperature end (K) #Pressure limits p0 = CP.PropsSI('P', 'T', T0, 'Q', 0, fluid_thermo) #Pa pMax = CP.PropsSI('P', 'T', TMax, 'Q', 0, fluid_thermo) #Pa
#Setting Up Coolprop: P_ref = 101325 #Pa #Parahydrogen Reference State does not need to change: h_ref = CP.PropsSI('H', 'P', P_ref, 'Q', 0, 'parahydrogen') #should be about zero s_ref = CP.PropsSI('S', 'P', P_ref, 'Q', 0, 'parahydrogen') #should be roughly zero #print(h_ref)#Should be about 0 #print(s_ref)#Should be about 0 #Orthohydrogen Reference State needs to be adjusted such that its enthalpy is 702.98 kJ/kg and entropy is 0.018269 kJ/kg-K at NBP Dmolar_ref_ortho = CP.PropsSI( 'Dmolar', 'P', P_ref, 'Q', 0, 'orthohydrogen' ) #reference state must be in molar density at liquid of normal boiling point T_ref_ortho = CP.PropsSI('T', 'P', P_ref, 'Q', 0.5, 'orthohydrogen') CP.set_reference_state( 'orthohydrogen', T_ref_ortho, Dmolar_ref_ortho, 702.98 * (2 * 1.00784), 0.018269 * (2 * 1.00784) ) #sets so that enthalpy and entropy difference correctly correspond to ~702.98kJ/kg and 0.018269 kJ/kg-K at 20K; but function inputs must be molar #print(CP.PropsSI('H','P',P_ref,'Q',0,'orthohydrogen'))#should be 702980 J/kg #print(CP.PropsSI('S','P',P_ref,'Q',0,'orthohydrogen'))#should be 18.269 J/kg-K #print('') P = 101325 #Pa, pressure to test at T = [] Yo = [] RelHeq = [] RelH00 = [] RelH75 = [] RelH100 = [] for i in range( 15, 300 + 1 ): #Properties of hydrogen do not go below 14K, Room temp is about 300K
import conversions import numpy as np # NumPy: contains basic numerical routines import scipy # SciPy: contains additional numerical routines to numpy import matplotlib.pyplot as plt import CoolProp.CoolProp as cp from CoolProp.CoolProp import PropsSI as prop ## define standard constant variables p_ref = 101325 # Pa T_ref = 298.15 # K R_air = 287 # J/kg-K Cp_air = 1005 # J/kg-K R_u = 8314 # J/mol-K cp.set_reference_state('Air', "DEF") def airProperties(propertyNames, propertyValues, printOutput): ## ALL INPUTS IN SI UNITS FOR GASES if propertyNames[0] == 'P' and propertyNames[ 1] == 'T': # P must be in Pa, T must be in K u = prop('U', propertyNames[0], propertyValues[0], propertyNames[1], propertyValues[1], 'Air') h = prop('H', propertyNames[0], propertyValues[0], propertyNames[1], propertyValues[1], 'Air') s = prop('S', propertyNames[0], propertyValues[0], propertyNames[1], propertyValues[1], 'Air') rho = prop('D', propertyNames[0], propertyValues[0], propertyNames[1], propertyValues[1], 'Air')
Adapted from @author: Luka Denies from TU Delft. Changelog: 11/2017 - Integration of CoolProp 06/2018 - Update to OpenFOAM-5.x (Mass-based thermodynamics (for example: cpMcv to CpMCv)) 03/2019 - Update to include parahydrogen properties from Refprop """ import CoolProp.CoolProp as CP import numpy as np import matplotlib.pyplot as plt #Fluid for thermodynamic properties (rho, Cp, CpMcv, H, S, c, E, thermal conductivity) CP.set_reference_state('parahydrogen', 'NBP') fluid_thermo = 'parahydrogen' #Fluid for transport model (viscosity) CP.set_reference_state('hydrogen', 'NBP') fluid_transport = 'hydrogen' #**************************************************************************************** #Temperature limits (set within subcritical region for saturation tables) T0 = 15 #Temperature start (K) TMax = 32 #Temperature end (K) #Pressure limits p0 = 0.1e5 #Pa pMax = 5.5e5 #Pa
def test_NBP(): CP.set_reference_state('Propane','NBP') assert(abs(CP.Props('H','P',101.325,'Q',0,'Propane')-0) < 1e-10) assert(abs(CP.Props('S','P',101.325,'Q',0,'Propane')-0) < 1e-10)
def test_IIR(): CP.set_reference_state('Propane','IIR') assert(abs(CP.Props('H','T',273.15,'Q',0,'Propane')-200) < 1e-10) assert(abs(CP.Props('S','T',273.15,'Q',0,'Propane')-1) < 1e-10)
def test_ASHRAE(): CP.set_reference_state('Propane','ASHRAE') assert(abs(CP.Props('H','T',233.15,'Q',0,'Propane')-0) < 1e-10) assert(abs(CP.Props('S','T',233.15,'Q',0,'Propane')-0) < 1e-10)