def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "TCO" self.description = "Citrus oil terpene - d-Limonene" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1071.02,-0.778166])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([223.775,5.2159])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-3.47971,-0.0107031,1.14086e-06])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.174156,-1.85052e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "TCO" self.description = "Terpene from citrus oils - d-Limonene" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1071.02,-0.778166])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([223.775,5.2159])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-3.47971,-0.0107031,1.14086e-06])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000174156,-1.85052e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HFE" self.description = "Hydrofluoroether - HFE-7100 3M Novec" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1822.37,-0.918485])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([871.834,0.858788])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-4.22878,-0.0114765,7.39823e-06])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([9.92958e-01,-8.33333e-05])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "SAB" self.description = "Synthetic alkyl benzene - Marlotherm X" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1102.34,-0.801667])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1360.94,1.51667])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.21288,-0.0665792,8.5066e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000208374,-2.61667e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HCB" self.description = "Hydrocarbon blend - Dynalene MV" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1071.78,-0.772024])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([761.393,3.52976])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([7.16819,-0.0863212,0.000130604])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000203186,-2.3869e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "PMS1" self.description = "Polydimethylsiloxan 1. - Baysilone KT3" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1172.35,-0.9025])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1223.69,1.48417])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([6.36183,-0.0636352,7.51428e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000207526,-2.84167e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "PMS2" self.description = "Polydimethylsiloxan 2. - Syltherm XLT Dow Corning Co." self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1155.94,-1.02576])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1153.55,2.10788])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.66926,-0.065582,8.09988e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000172305,-2.11212e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HFE" self.description = "Hydrofluoroether - HFE-7100 3M Novec" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1822.37,-0.918485])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([871.834,0.858788])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([-4.22878,-0.0114765,7.39823e-06])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([9.92958e-05,-8.33333e-08])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "DEB" self.description = "Diethylbenzene mixture - Dowtherm J Dow Chemical Co." self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1076.5,-0.731182])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([999.729,2.87576])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([3.5503,-0.0566396,7.03331e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000189132,-2.06364e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HCM" self.description = "Hydrocarbon mixture (synthetic) - Therminol D12 (Gilotherm D12) Solutia" self.reference = "Melinder-BOOK-2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([971.725,-0.718788])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([844.023,4.31212])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([18.3237,-0.14706,0.000209096])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0.000153716,-1.51212e-07])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HCM" self.description = "Hydrocarbon mixture - Gilotherm D12" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([971.725,-0.718788])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([844.023,4.31212])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([18.3237,-0.14706,0.000209096])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.153716,-1.51212e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "SAB" self.description = "Synthetic alkyl benzene - Marlotherm X" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1102.34,-0.801667])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1360.94,1.51667])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.21288,-0.0665792,8.5066e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.208374,-2.61667e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "HCB" self.description = "Hydrocarbon blend - Dynalene MV" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1071.78,-0.772024])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([761.393,3.52976])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([7.16819,-0.0863212,0.000130604])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.203186,-2.3869e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "PMS2" self.description = "Polydimethylsiloxan 2 - Syltherm XLT" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1155.94,-1.02576])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1153.55,2.10788])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([5.66926,-0.065582,8.09988e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.172305,-2.11212e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "PMS1" self.description = "Polydimethylsiloxan 1 - Baysilone KT3" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1172.35,-0.9025])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([1223.69,1.48417])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([6.36183,-0.0636352,7.51428e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.207526,-2.84167e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def __init__(self): CoefficientData.__init__(self) PureData.__init__(self) self.name = "DEB" self.description = "Diethylbenzene mixture - Dowtherm J" self.reference = "Melinder2010" self.Tmin = -80.0 + 273.15 self.Tmax = 100.0 + 273.15 self.TminPsat = self.Tmax self.Tbase = 0.0 self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL _,_,self.density.coeffs = IncompressibleFitter.shapeArray(np.array([1076.5,-0.731182])) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL _,_,self.specific_heat.coeffs = IncompressibleFitter.shapeArray(np.array([999.729,2.87576])) self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL _,_,self.viscosity.coeffs = IncompressibleFitter.shapeArray(np.array([3.5503,-0.0566396,7.03331e-05])) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL _,_,self.conductivity.coeffs = IncompressibleFitter.shapeArray(np.array([0000.189132,-2.06364e-04])) self.density.source = self.density.SOURCE_COEFFS self.specific_heat.source = self.specific_heat.SOURCE_COEFFS self.conductivity.source = self.conductivity.SOURCE_COEFFS self.viscosity.source = self.viscosity.SOURCE_COEFFS
def getFromFile(self, data): fullPath = self.getFile(data) # TODO: improve this case if not os.path.isfile(fullPath): arr = np.empty((1,1)) arr[:] = np.NAN return arr r,c,res = IncompressibleFitter.shapeArray(np.loadtxt(fullPath,dtype=type('string'))) # numbers = res.astype(np.float) numbers = np.zeros((r,c)) for i in range(r): for j in range(c): nu = np.NAN try: nu = np.float(res[i,j]) if i==0: nu *= 1e-2 # Percent to fraction if j==0: nu += 273.15 # Celsius to Kelvin if not self.allowNegativeData and nu<0: nu = np.NAN # invalid entries except (ValueError, TypeError) as ve: if False: print("Could not convert entry: {0}".format(ve)) if i==0: nu = 0.0 # Dummy for tables without concentration (TFreeze and Vol2Mass) pass numbers[i,j] = nu if numbers[1,0]>numbers[-1,0]: numbers[1:,:] = numbers[1:,:][::-1,:] if numbers[0,1]>numbers[0,-1]: numbers[:,1:] = numbers[:,1:][:,::-1] return numbers
def round(self, x): r,c,res = IncompressibleFitter.shapeArray(x) #digits = -1*np.floor(np.log10(res))+self.significantDigits-1 for i in range(r): for j in range(c): if np.isfinite(res[i,j]): res[i,j] = self.roundSingle(res[i,j]) return res
def getFromFile(self, data): fullPath = self.getFile(data) content = np.loadtxt(fullPath,dtype=type('string'),delimiter=",",skiprows=3) r,c,res = IncompressibleFitter.shapeArray(content) # numbers = res.astype(np.float) numbers = np.zeros((r,c)) for i in range(r): for j in range(c): nu = np.NAN try: nu = np.float(res[i,j]) if i==0: nu *= 1e-2 # Percent to fraction if not self.allowNegativeData and nu<0: nu = np.NAN # invalid entries except (ValueError, TypeError) as ve: if False: print("Could not convert entry: {0}".format(ve)) if i==0: nu = 0.0 # Dummy for tables without concentration (TFreeze and Vol2Mass) pass numbers[i,j] = nu if numbers[1,0]>numbers[-1,0]: numbers[1:,:] = numbers[1:,:][::-1,:] if numbers[0,1]>numbers[0,-1]: numbers[:,1:] = numbers[:,1:][:,::-1] return numbers
def getFromFile(self, data): fullPath = self.getFile(data) _,_,res = IncompressibleFitter.shapeArray(np.loadtxt(fullPath)) return res
def fitAll(self, fluidObject=SolutionData()): if fluidObject.Tbase==None: fluidObject.Tbase = (fluidObject.Tmin + fluidObject.Tmax) / 2.0 if fluidObject.xbase==None: fluidObject.xbase = (fluidObject.xmin + fluidObject.xmax) / 2.0 tData = fluidObject.temperature.data xData = fluidObject.concentration.data tBase = fluidObject.Tbase xBase = fluidObject.xbase # Set the standard order for polynomials std_xorder = 3+1 std_yorder = 5+1 std_coeffs = np.zeros((std_xorder,std_yorder)) errList = (ValueError, AttributeError, TypeError, RuntimeError) if fluidObject.density.coeffs == None: try: fluidObject.density.setxyData(tData,xData) fluidObject.density.coeffs = np.copy(std_coeffs) fluidObject.density.type = IncompressibleData.INCOMPRESSIBLE_POLYNOMIAL fluidObject.density.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.density.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(fluidObject.name,'density',ve)) pass if fluidObject.specific_heat.coeffs == None: try: fluidObject.specific_heat.setxyData(tData,xData) fluidObject.specific_heat.coeffs = np.copy(std_coeffs) fluidObject.specific_heat.type = IncompressibleData.INCOMPRESSIBLE_POLYNOMIAL fluidObject.specific_heat.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.specific_heat.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(fluidObject.name,'specific heat',ve)) pass if fluidObject.conductivity.coeffs == None: try: fluidObject.conductivity.setxyData(tData,xData) fluidObject.conductivity.coeffs = np.copy(std_coeffs) fluidObject.conductivity.type = IncompressibleData.INCOMPRESSIBLE_POLYNOMIAL fluidObject.conductivity.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.conductivity.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(fluidObject.name,'conductivity',ve)) pass if fluidObject.viscosity.coeffs == None: try: fluidObject.viscosity.setxyData(tData,xData) tried = False if len(fluidObject.viscosity.yData)==1:# and np.isfinite(fluidObject.viscosity.data).sum()<10: fluidObject.viscosity.coeffs = np.array([+5e+2, -6e+1, +1e+1]) fluidObject.viscosity.type = IncompressibleData.INCOMPRESSIBLE_EXPONENTIAL fluidObject.viscosity.fitCoeffs(tBase,xBase) if fluidObject.viscosity.coeffs==None or IncompressibleFitter.allClose(fluidObject.viscosity.coeffs, np.array([+5e+2, -6e+1, +1e+1])): # Fit failed tried = True if len(fluidObject.viscosity.yData)>1 or tried: #fluidObject.viscosity.coeffs = np.zeros(np.round(np.array(std_coeffs.shape) * 1.5)) fluidObject.viscosity.coeffs = np.copy(std_coeffs) fluidObject.viscosity.type = IncompressibleData.INCOMPRESSIBLE_EXPPOLYNOMIAL fluidObject.viscosity.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.viscosity.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(fluidObject.name,'viscosity',ve)) pass if fluidObject.saturation_pressure.coeffs == None: try: fluidObject.saturation_pressure.setxyData(tData,xData) tried = False if len(fluidObject.saturation_pressure.yData)==1:# and np.isfinite(fluidObject.saturation_pressure.data).sum()<10: fluidObject.saturation_pressure.coeffs = np.array([-5e+3, +6e+1, -1e+1]) fluidObject.saturation_pressure.type = IncompressibleData.INCOMPRESSIBLE_EXPONENTIAL fluidObject.saturation_pressure.fitCoeffs(tBase,xBase) if fluidObject.saturation_pressure.coeffs==None or IncompressibleFitter.allClose(fluidObject.saturation_pressure.coeffs, np.array([-5e+3, +6e+1, -1e+1])): # Fit failed tried = True if len(fluidObject.saturation_pressure.yData)>1 or tried: #fluidObject.saturation_pressure.coeffs = np.zeros(np.round(np.array(std_coeffs.shape) * 1.5)) fluidObject.saturation_pressure.coeffs = np.copy(std_coeffs) fluidObject.saturation_pressure.type = IncompressibleData.INCOMPRESSIBLE_EXPPOLYNOMIAL fluidObject.saturation_pressure.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.saturation_pressure.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(fluidObject.name,'saturation pressure',ve)) pass # reset data for getArray and read special files if fluidObject.xid!=fluidObject.ifrac_pure and fluidObject.xid!=fluidObject.ifrac_undefined: if fluidObject.T_freeze.coeffs == None: fluidObject.T_freeze.setxyData([0.0],xData) try: if len(fluidObject.T_freeze.xData)==1:# and np.isfinite(fluidObject.T_freeze.data).sum()<10: fluidObject.T_freeze.coeffs = np.array([+7e+2, -6e+1, +1e+1]) fluidObject.T_freeze.type = IncompressibleData.INCOMPRESSIBLE_EXPONENTIAL else: fluidObject.specific_heat.coeffs = np.copy(std_coeffs) fluidObject.T_freeze.type = IncompressibleData.INCOMPRESSIBLE_EXPPOLYNOMIAL fluidObject.T_freeze.fitCoeffs(tBase,xBase) except errList as ve: if fluidObject.T_freeze.DEBUG: print("{0}: Could not fit {1} coefficients: {2}".format(fluidObject.name,"T_freeze",ve)) pass
def fitFluid(self): if self.Tbase==None: self.Tbase = (self.Tmin + self.Tmax) / 2.0 if self.xbase==None: self.xbase = (self.xmin + self.xmax) / 2.0 std_coeffs = np.zeros((4,6)) errList = (ValueError, AttributeError, TypeError, RuntimeError) try: self.density.coeffs = np.copy(std_coeffs) self.density.type = self.density.INCOMPRESSIBLE_POLYNOMIAL self.density.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.density.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(self.name,'density',ve)) pass try: self.specific_heat.coeffs = np.copy(std_coeffs) self.specific_heat.type = self.specific_heat.INCOMPRESSIBLE_POLYNOMIAL self.specific_heat.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.specific_heat.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(self.name,'specific heat',ve)) pass try: self.conductivity.coeffs = np.copy(std_coeffs) self.conductivity.type = self.conductivity.INCOMPRESSIBLE_POLYNOMIAL self.conductivity.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.conductivity.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(self.name,'conductivity',ve)) pass # try: # self.viscosity.coeffs = np.copy(std_coeffs) # self.viscosity.type = self.viscosity.INCOMPRESSIBLE_EXPPOLYNOMIAL # self.viscosity.fitCoeffs(self.Tbase,self.xbase) # except errList as ve: # if self.viscosity.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(self.name,'viscosity',ve)) # pass try: tried = False if len(self.viscosity.yData)==1:# and np.isfinite(fluidObject.viscosity.data).sum()<10: self.viscosity.coeffs = np.array([+7e+2, -6e+1, +1e+1]) self.viscosity.type = IncompressibleData.INCOMPRESSIBLE_EXPONENTIAL self.viscosity.fitCoeffs(self.Tbase,self.xbase) if self.viscosity.coeffs==None or IncompressibleFitter.allClose(self.viscosity.coeffs, np.array([+7e+2, -6e+1, +1e+1])): # Fit failed tried = True if len(self.viscosity.yData)>1 or tried: self.viscosity.coeffs = np.copy(std_coeffs)#np.zeros(np.round(np.array(std_coeffs.shape) * 1.5)) self.viscosity.type = IncompressibleData.INCOMPRESSIBLE_EXPPOLYNOMIAL self.viscosity.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.viscosity.DEBUG: print("{0}: Could not fit polynomial {1} coefficients: {2}".format(self.name,'viscosity',ve)) pass # reset data for getArray and read special files if self.xid!=self.ifrac_pure and self.xid!=self.ifrac_undefined: allowNegativeData_org = self.allowNegativeData self.allowNegativeData = True try: x,_,z = self.getArray(dataID='TFreeze') self.T_freeze.yData = (x - 273.15) / 100.0 self.T_freeze.xData = [0.0] if np.min(z)<150: z += 273.15 self.T_freeze.data = z.T try: self.T_freeze.source = self.T_freeze.SOURCE_DATA self.T_freeze.type = self.T_freeze.INCOMPRESSIBLE_EXPONENTIAL self.T_freeze.coeffs = np.array([+7e+6, +6e+4, +1e+1]) self.T_freeze.fitCoeffs(self.Tbase,self.xbase) #if np.isfinite(self.T_freeze.data).sum()<10: # self.T_freeze.coeffs = np.array([+7e+6, +6e+4, +1e+1]) # self.T_freeze.type = self.T_freeze.INCOMPRESSIBLE_EXPONENTIAL #else: # self.T_freeze.coeffs = np.zeros(np.round(np.array(std_coeffs.shape) * 2)) # self.T_freeze.type = self.T_freeze.INCOMPRESSIBLE_EXPPOLYNOMIAL #self.T_freeze.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.T_freeze.DEBUG: print("{0}: Could not fit {1} coefficients: {2}".format(self.name,"T_freeze",ve)) pass except errList as ve: if self.T_freeze.DEBUG: print("{0}: Could not load {1} data: {2}".format(self.name,"T_freeze",ve)) pass # reset data for getArray again self.allowNegativeData = allowNegativeData_org try: x,_,z = self.getArray(dataID='Vol2Mass') massData = z[:,0] /100.0 volData = (x - 273.15) /100.0 if self.xid==self.ifrac_volume: _,_,self.mass2input.data = IncompressibleFitter.shapeArray(volData,axs=1) self.mass2input.xData = [0.0] self.mass2input.yData = massData try: self.mass2input.coeffs = np.copy(std_coeffs) self.mass2input.source = self.mass2input.SOURCE_DATA self.mass2input.type = self.mass2input.INCOMPRESSIBLE_POLYNOMIAL self.mass2input.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.mass2input.DEBUG: print("{0}: Could not fit {1} coefficients: {2}".format(self.name,"mass2input",ve)) pass elif self.xid==self.ifrac_mass: _,_,self.volume2input.data = IncompressibleFitter.shapeArray(massData,axs=1) self.volume2input.xData = [0.0] self.volume2input.yData = volData try: self.volume2input.coeffs = np.copy(std_coeffs) self.volume2input.source = self.volume2input.SOURCE_DATA self.volume2input.type = self.volume2input.INCOMPRESSIBLE_POLYNOMIAL self.volume2input.fitCoeffs(self.Tbase,self.xbase) except errList as ve: if self.volume2input.DEBUG: print("{0}: Could not fit {1} coefficients: {2}".format(self.name,"volume2input",ve)) pass else: raise ValueError("Unknown xid specified.") except errList as ve: if self.mass2input.DEBUG or self.volume2input.DEBUG: print("{0}: Could not load {1} data: {2}".format(self.name,"Vol2Mass",ve)) pass
def getArray(self, dataID=None, func=None, x_in=None, y_in=None, DEBUG=False): """ Tries to read a data file, overwrites it if x or y do not match :param dataID : ID to contruct the path to the data file :param func : Callable object that can take x_in and y_in :param x_in : a 1D array in x direction or 2D with one column, most likely temperature :param y_in : a 1D array in y direction or 2D with one row, most likely cocentration :param DEBUG : a boolean that controls verbosity :returns : Returns a tuple with three entries: x(1D),y(1D),data(2D) """ x = None y = None z = None # First we try to read the file if (not dataID is None and os.path.isfile(self.getFile(dataID))): # File found fileArray = self.getFromFile(dataID) x = np.copy(fileArray[1:,0 ]) y = np.copy(fileArray[0 ,1:]) z = np.copy(fileArray[1:,1:]) else: if DEBUG: print("No readable file found for {0}: {1}".format(dataID,self.getFile(dataID))) updateFile = DEBUG if not x_in is None: # Might need update if not x is None: # Both given, check if different mask = np.isfinite(x) if IncompressibleFitter.allClose(x[mask], x_in[mask]): if DEBUG: print("Both x-arrays are the same, no action required.") updateFile = (updateFile or False) # Do not change a True value to False else: updateFile = True if DEBUG: print("x-arrays do not match. {0} contains \n {1} \n and will be updated with \n {2}".format(self.getFile(dataID),x,x_in)) else: updateFile = True elif x is None: if DEBUG: print("Could not load x from file {0} and no x_in provided, aborting.".format(self.getFile(dataID))) return None,None,None else: updateFile = (updateFile or False) # Do not change a True value to False if not y_in is None: # Might need update if not y is None: # Both given, check if different mask = np.isfinite(y) if IncompressibleFitter.allClose(y[mask], y_in[mask]): if DEBUG: print("Both y-arrays are the same, no action required.") updateFile = (updateFile or False) # Do not change a True value to False else: updateFile = True if DEBUG: print("y-arrays do not match. {0} contains \n {1} \n and will be updated with \n {2}".format(self.getFile(dataID),y,y_in)) else: updateFile = True elif y is None: if DEBUG: print("Could not load y from file {0} and no y_in provided, aborting.".format(self.getFile(dataID))) return None,None,None else: updateFile = (updateFile or False) # Do not change a True value to False if DEBUG: print("Updating data file {0}".format(updateFile)) if not updateFile: return x,y,z # Done, data read from file # Overwrite inputs x = x_in y = y_in z = np.zeros( (len(x)+1,len(y)+1) ) r,c = z.shape if func is None: raise ValueError("Need a function to update the data file.") for i in range(r-1): for j in range(c-1): z[i+1,j+1] = func(x[i],y[j]) z[0,0 ] = np.NaN z[1:,0] = x z[0,1:] = y if not dataID is None: self.writeToFile(dataID, z) else: if DEBUG: print("Not updating data file, dataID is missing.") return x,y,z[1:,1:]