Exemple #1
0
 def computeHeatExchange(self, fStateFilm = None):      
     if (fStateFilm is None):
         fStateFilm = FluidState(self.fluidName)
         fStateFilm.update_Tp(self.inletTemperature, self.inletPressure)
         self.inletEnthalpy = fStateFilm.h
     
     self.Pr = fStateFilm.Pr
     self.cond = fStateFilm.cond
     
     # Determining Nusselt number
     if (self.Re <= 2.3e3):
         # laminar flow
         self.Nu = 3.66
     elif (self.Re > 2.3e3 and self.Re < 1e4):
         # transition    
         interpCoeff = (self.Re - 2.3e3) / (1e4 - 2.3e3) 
         Nu_low = 3.66
         xi = (1.8 * 4 - 1.5)**(-2)
         Nu_high = ((xi / 8.) * 1e4 * self.Pr) / (1 + 12.7 * math.sqrt(xi / 8.) * (self.Pr**(2 / 3.) - 1)) * \
         (1 + (self.internalDiameter / self.length)**(2 / 3.))
         self.Nu = interpCoeff * Nu_high + (1 - interpCoeff) * Nu_low
     elif (self.Re >= 1e4): # and self.Re <= 1e6):
         # turbulent flow
         xi = (1.8 * math.log(self.Re, 10) - 1.5)**(-2)
         self.Nu = ((xi / 8.) * self.Re * self.Pr) / (1 + 12.7 * math.sqrt(xi / 8.) * (self.Pr**(2 / 3.) - 1))
     #elif (self.Re > 1e6):
     #    raise ValueError("Reynolds Number outside range of validity")
     
     self.alpha = self.cond * self.Nu / self.internalDiameter
     
     if (self.computationWithIteration == True):            
         LMTD = - (self.outletTemperature - self.inletTemperature) / \
                 math.log((self.TWall - self.inletTemperature) / \
                     (self.TWall - self.outletTemperature))
         self.QDot = self.alpha * self.internalSurfaceArea * LMTD
     else:
         self.QDot = self.alpha * self.internalSurfaceArea * (self.inletTemperature - self.TWall)
     
     self.outletEnthalpy = self.inletEnthalpy - (self.QDot / self.massFlowRate)
     
     fStateOut = FluidState(self.fluidName)
     fStateOut.update_ph(self.outletPressure, self.outletEnthalpy)
     prevOutletTemperature = self.outletTemperature 
     self.outletTemperature = fStateOut.T
     
     if ((self.outletTemperature - self.TWall)*(self.inletTemperature - self.TWall) < 0):
         if (self.computationWithIteration == True):
             self.outletTemperature = 0.5 * prevOutletTemperature + 0.5 * self.TWall
         else:
             self.outletTemperature = self.TWall
     else:
         if (self.computationWithIteration == True):
             self.outletTemperature = 0.9 * prevOutletTemperature + 0.1 * self.outletTemperature    
Exemple #2
0
def testState():
    s1 = FluidState('ParaHydrogen')
    s1.update('P', 700e5, 'T', 288)
    print("p={0}".format(s1.p()))
    print("T={0}".format(s1.T()))
    print("rho={0}".format(s1.rho()))
    print("h={0}".format(s1.h()))
    print("s={0}".format(s1.s()))
    print("cp={0}".format(s1.cp()))
    print("cv={0}".format(s1.cv()))
    print("gamma={0}".format(s1.gamma()))
    print("dpdt_v={0}".format(s1.dpdt_v()))
    print("dpdv_t={0}".format(s1.dpdv_t()))
    print("beta={0}".format(s1.beta()))
    print("mu={0}".format(s1.mu()))
    print("lambfa={0}".format(s1.cond()))
    print("Pr={0}".format(s1.Pr()))

    s2 = FluidState('ParaHydrogen')
    s2.update_Tp(s1.T(), s1.p())
    print("update_Tp rho={0}".format(s2.rho()))
    s3 = FluidState('ParaHydrogen')
    s3.update_Trho(s1.T(), s1.rho())
    print("update_Trho p={0}".format(s3.p()))
    s4 = FluidState('ParaHydrogen')
    s4.update_prho(s1.p(), s1.rho())
    print("update_prho T={0}".format(s4.T()))
    s5 = FluidState('ParaHydrogen')
    s5.update_ph(s1.p(), s1.h())
    print("update_ph ={0}".format(s5.T()))
    s6 = FluidState('ParaHydrogen')
    s6.update_ps(s1.p(), s1.s())
    print("update_ps T={0}".format(s6.T()))
    s7 = FluidState('ParaHydrogen')
    s7.update_pq(1e5, 0)
    print("update_pq T={0}".format(s7.T()))
    s8 = FluidState('ParaHydrogen')
    s8.update_Tq(25, 0)
    print("update_Tq p={0}".format(s8.p()))
    print('--------------------')
    print('Initialize state from fluid')
    h2 = Fluid('ParaHydrogen')
    s9 = FluidState(h2)
    s9.update_Tp(s1.T(), s1.p())
    print("rho={0}".format(s9.rho()))
Exemple #3
0
    def setLimits(self, pMin=None, pMax=None, hMin=None, hMax=None, TMax=None):
        # Reference points
        self.minLiquid = FluidState(self.fluid)
        self.minVapor = FluidState(self.fluid)
        self.critical = FluidState(self.fluid)
        self.critical.update_Trho(self.fluid.critical['T'],
                                  self.fluid.critical['rho'])

        # For general use
        fState = FluidState(self.fluid)

        # Pressure range
        if (pMin is None):
            pMin = self.fluid.tripple['p'] * 1.05
            if (pMin < 1e3):
                pMin = 1e3
        self.pMin = pMin

        self.minLiquid.update_pq(self.pMin, 0)
        self.minVapor.update_pq(self.pMin, 1)

        if (pMax is None):
            pMax = 3 * self.critical.p
        self.pMax = pMax

        # Enthalpy range
        domeWidth = self.minVapor.h - self.minLiquid.h
        if (hMin is None):
            hMin = self.minLiquid.h
        self.hMin = hMin

        # Determining max enthalpy
        if (TMax is None):
            if (hMax is None):
                # default max enthalpy
                if (self.critical.h > self.minVapor.h):
                    hMax = self.critical.h + domeWidth
                else:
                    hMax = self.minVapor.h + domeWidth
        else:
            fState.update_Tp(TMax, self.pMin)
            hMax = fState.h

        self.hMax = hMax

        # Axes ranges
        self.xMin = self.hMin
        self.xMax = self.hMax
        self.yMin = self.pMin
        self.yMax = self.pMax

        # Density range
        fState.update_ph(self.pMin, self.hMax)
        self.rhoMin = fState.rho
        self.rhoMax = self.minLiquid.rho

        # Temperature range
        self.TMin = self.fluid.saturation_p(self.pMin)["TsatL"]

        if (TMax is None):
            fState.update_ph(self.pMin, self.hMax)
            TMax = fState.T
        self.TMax = TMax

        # Entropy range
        self.sMin = 1.01 * self.minLiquid.s

        fState.update_ph(self.pMin, self.hMax)
        self.sMax = fState.s

        # Minor diagonal coeff
        self.minDiagonalSlope = np.log10(
            self.pMax / self.pMin) / (self.hMax - self.hMin) * 1e3

        # Major diagonal coeff
        self.majDiagonalSlope = -self.minDiagonalSlope
Exemple #4
0
	def setLimits(self, pMin = None, pMax = None,  hMin = None, hMax = None, TMax = None):
		# Reference points
		self.minLiquid = FluidState(self.fluid)
		self.minVapor = FluidState(self.fluid)
		self.critical = FluidState(self.fluid)
		self.critical.update_Trho(self.fluid.critical['T'], self.fluid.critical['rho'])

		# For general use
		fState = FluidState(self.fluid)

		# Pressure range
		if (pMin is None):
			pMin = self.fluid.tripple['p'] * 1.05
			if (pMin < 1e3):
				pMin = 1e3
		self.pMin = pMin
		
		self.minLiquid.update_pq(self.pMin, 0)		
		self.minVapor.update_pq(self.pMin, 1)
		
		if (pMax is None):
			pMax = 3 * self.critical.p
		self.pMax = pMax
		
		
		# Enthalpy range
		domeWidth = self.minVapor.h - self.minLiquid.h		
		if (hMin is None):
			hMin = self.minLiquid.h
		self.hMin = hMin
		
		# Determining max enthalpy
		if (TMax is None):
			if (hMax is None):
				# default max enthalpy	
				if (self.critical.h > self.minVapor.h):
					hMax = self.critical.h + domeWidth
				else:
					hMax = self.minVapor.h + domeWidth
		else:
			fState.update_Tp(TMax, self.pMin)
			hMax = fState.h
			
		self.hMax = hMax
		
		# Axes ranges
		self.xMin = self.hMin
		self.xMax = self.hMax
		self.yMin = self.pMin
		self.yMax = self.pMax
		
		# Density range
		fState.update_ph(self.pMin, self.hMax)
		self.rhoMin = fState.rho
		self.rhoMax = self.minLiquid.rho
		
		# Temperature range
		self.TMin = self.fluid.saturation_p(self.pMin)["TsatL"]
		
		if (TMax is None):
			fState.update_ph(self.pMin, self.hMax)
			TMax = fState.T
		self.TMax = TMax
		
		# Entropy range
		self.sMin = 1.01 * self.minLiquid.s
		
		fState.update_ph(self.pMin, self.hMax)
		self.sMax = fState.s
		
		# Minor diagonal coeff
		self.minDiagonalSlope = np.log10(self.pMax/self.pMin) / (self.hMax - self.hMin) * 1e3
		
		# Major diagonal coeff
		self.majDiagonalSlope = - self.minDiagonalSlope