def props(in1=None, in2=None, in3=None, in4=None, in5=None, in6=None): try: return cp.PropsU(in1=in1,in2=in2,in3=in3,in4=in4,in5=in5,in6=in6,in7="SI") except ValueError as ve: #print "Error in CoolProp, try adjusting the fluid or T and p:" print ve return -1.0*np.NAN
def inCoolProp(self, name): from CoolProp.CoolProp import FluidsList #print FluidsList() result = name in FluidsList() if not result: try: CP.PropsU('Tmin', 'T', 0, 'P', 0, name, "SI") return True except ValueError as e: print(e) return False
gaseous = CP.DerivTerms(key, T[2], D[2], fluid) supercrit = CP.DerivTerms(key, T[3], D[3], fluid) print '{:<25}: {:>10.5f}; {:>10.5f}; {:>10.5f}; {:>10.5f}'.format( key, liquid, twophase, gaseous, supercrit) for key in keys: liquid = CP.DerivTermsU(key, T[0], D[0], fluid, 'SI') twophase = CP.DerivTermsU(key, T[1], D[1], fluid, 'SI') gaseous = CP.DerivTermsU(key, T[2], D[2], fluid, 'SI') supercrit = CP.DerivTermsU(key, T[3], D[3], fluid, 'SI') print '{:<25}: {:>10.5f}; {:>10.5f}; {:>10.5f}; {:>10.5f}'.format( key, liquid, twophase, gaseous, supercrit) print print "Testing Props: " for key in keys: liquid = CP.Props(key, "T", float(T[0]), "D", float(D[0]), fluid) twophase = CP.Props(key, "T", float(T[1]), "D", float(D[1]), fluid) gaseous = CP.Props(key, "T", float(T[2]), "D", float(D[2]), fluid) supercrit = CP.Props(key, "T", float(T[3]), "D", float(D[3]), fluid) print '{:<25}: {:>10.5f}; {:>10.5f}; {:>10.5f}; {:>10.5f}'.format( key, liquid, twophase, gaseous, supercrit) for key in keys: liquid = CP.PropsU(key, "T", float(T[0]), "D", float(D[0]), fluid, 'SI') twophase = CP.PropsU(key, "T", float(T[1]), "D", float(D[1]), fluid, 'SI') gaseous = CP.PropsU(key, "T", float(T[2]), "D", float(D[2]), fluid, 'SI') supercrit = CP.PropsU(key, "T", float(T[3]), "D", float(D[3]), fluid, 'SI') print '{:<25}: {:>10.5f}; {:>10.5f}; {:>10.5f}; {:>10.5f}'.format( key, liquid, twophase, gaseous, supercrit)
print "Fluid in CoolProp: " + str(inCP) print inVal = 'D' xData = data.rho oldCoeffs = liqObj.getCoefficients(inVal) newCoeffs = liqObj.fitCoefficients(inVal, T=tData, xData=xData) print "Density, old: " + str(oldCoeffs) print "Density, new: " + str(newCoeffs) print liqObj.setCoefficients(inVal, newCoeffs) fData = numpy.array([liqObj.Props(inVal, T=Tin, P=Pin) for Tin in tDat1]) ax1.plot(tData - 273.15, xData, 'o', label="Data Sheet") ax1.plot(tDat1 - 273.15, fData, 'o', label="Python") if inCP: Tmin = CP.PropsU('Tmin', 'T', 0, 'P', 0, data.Name, "SI") Tmax = CP.PropsU('Tmax', 'T', 0, 'P', 0, data.Name, "SI") tDat2 = numpy.linspace(Tmin + 1, Tmax - 1, 100) ax1.plot(tDat2 - 273.15, CP.PropsU(inVal, 'T', tDat2, 'P', Pin * 1e3, data.Name, "SI"), label="CoolProp") ax12 = ax1.twinx() fData = numpy.array([liqObj.Props(inVal, T=Tin, P=Pin) for Tin in tData]) ax12.plot(tData - 273.15, relError(fData, xData, True), 'o', label="Error", alpha=0.25) ax12.set_ylabel(r'$\mathregular{rel.\/Error\/(\%)}$') ax1.set_ylabel(r'$\mathregular{Density\/(kg\/m^{-3})}$')