コード例 #1
0
    def Solve(self):
        super(Horizontal, self).Solve()

        converged = False
        converged1 = False

        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady',
                                        (self.GetPath(), ))
            return

        Wv, Wll, rhov, rhol, P, Th, Ts, Mist, Ks, Qv, Qll, Ut, Uv, Vh, Vs = results

        # Initialize LD
        if P > 14.7 and P <= 264.7:
            LD = 1.5 / 250.0 * (P - 14.7) + 1.5
        elif P > 264.7 and P <= 514.7:
            LD = 1.0 / 250.0 * (P - 14.7) + 2.0
        elif P > 514.7:
            LD = 5.0

        D = (4.0 * (Vh + Vs) / (0.6 * pi * LD))**(1.0 / 3.0)
        D = round(D)
        if D <= 4.0:
            D = 4.0

        outerIter = 0
        while not converged and outerIter < self.maxIter:
            outerIter += 1
            At = pi * (D**2) / 4.0

            # Calculate Low Liq. Area
            Hlll = round(0.5 * D + 7.0)  # D is in ft but Hlll is in inches
            Hlll = Hlll / 12.0
            X = Hlll / D
            Y = HNATable(1, X)
            Alll = Y * At

            # Calculate the Vap. disengagement area, Av
            Hv = 0.2 * D
            if int(Mist) == 1 and Hv <= 2.0:
                Hv = 2.0
            else:
                if Hv <= 1.0:
                    Hv = 1.0
            X = Hv / D
            Y = HNATable(1, X)
            Av = Y * At

            # Calculate minimum length fo surge and holdup
            L = (Vh + Vs) / (At - Av - Alll)
            # Calculate liquid dropout
            Phi = Hv / Uv
            # Calculate actual vapor velocity
            Uva = Qv / Av
            # Calculate minimum length for vapor disengagement
            Lmin = Uva * Phi
            Li = L

            sign = -1.0
            needToIter = False

            if L < Lmin:
                Li = Lmin

            if L < 0.8 * Lmin:
                sign = 1.0
                needToIter = True

            elif L > 1.2 * Lmin:
                if int(Mist) == 1 and Hv <= 2.0:
                    Hv = 2.0
                    Li = L
                elif not int(Mist) == 0 and Hv <= 1.0:
                    Hv = 1.0
                    Li = L
                else:
                    needToIter = True

            if needToIter:
                innerIter = 0
                while not converged1 and innerIter < self.maxIter:
                    innerIter += 1
                    Hv = Hv + sign * 0.5
                    if int(Mist) == 1 and Hv <= 2.0:  # baru tambah Bang !
                        Hv = 2.0
                    if int(Mist) == 0 and Hv <= 1.0:  # baru tambah Bang !
                        Hv = 1.0
                    X = Hv / D
                    Y = HNATable(1, X)
                    Av = Y * At

                    X = Hlll / D
                    Y = HNATable(1, X)
                    Alll = Y * At

                    Li = (Vh + Vs) / (At - Av - Alll)
                    Phi = Hv / Uv
                    Uva = Qv / Av
                    Lmin = Uva * Phi
                    if Li < 0.8 * Lmin:
                        sign = 1.0
                        converged1 = False
                    elif Li > 1.2 * Lmin:
                        sign = -1.0
                        converged1 = False
                    else:
                        Li = Li
                        converged1 = True
                if not converged1 and self.parent:
                    self.parent.InfoMessage('CouldNotConvergeInner',
                                            (self.GetPath(), self.maxIter))
            converged1 = False
            L = Li
            LD = L / D
            # Check LD
            if LD < (0.8 * 1.5):
                if D <= 4.0:
                    D = D
                    converged = True
                else:
                    D = D - 0.5
                    converged = False

            if LD > (1.2 * 6.0):
                D = D + 0.5
                converged = False
            else:
                converged = True
            if not converged and self.parent:
                self.parent.InfoMessage('CouldNotConvergeOuter',
                                        (self.GetPath(), self.maxIter))

        converged = False
        # Calculate vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, L)

        # to check minimum Hv value
        if int(Mist) == 1 and Hv <= 2.0:
            Hv = 2.0
        if int(Mist) == 0 and Hv <= 1.0:
            Hv = 1.0

        # Recalculate LD so it lies between 1.5 - 6.0

        while not converged:
            LD = L / D
            if (LD < 1.5) and D <= 4.0:
                L = L + 0.5

                converged = False
            elif LD < 1.5:
                D = D - 0.5
                converged = False
            elif (LD > 6.0):
                D = D + 0.5
                converged = False
            else:
                converged = True

        converged = False
        # Calculate normal liquid level and High liquid level
        Hhll = D - Hv
        if (Hhll < 0.0):
            Hhll = 0.0
        Anll = Alll + Vh / L
        X = Anll / At
        Y = HNATable(2, X)
        Hnll = Y * D

        # Send all outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], L)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(LD)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hv)
        self.SetValueFromFieldUnits(self._output['HighLiqLevel'], Hhll)
        self.SetValueFromFieldUnits(self._output['NormalLiqLevel'], Hnll)
        self.SetValueFromFieldUnits(self._output['LowLiqLevel'], Hlll)
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
コード例 #2
0
    def Solve(self):
        super(Vertical, self).Solve()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady',
                                        (self.GetPath(), ))
            return

        converged = False

        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady',
                                        (self.GetPath(), ))
            return

        Wv, Wll, rhov, rhol, P, Th, Ts, Mist, Ks, Qv, Qll, Ut, Uv, Vh, Vs = results

        # Calculate internal diameter, Dvd
        Dvd = (4.0 * Qv / (pi * Uv))**0.5
        if int(Mist) == 1:
            D = FinalValue(Dvd + 0.4)
        else:
            D = FinalValue(Dvd)

        # Obtaining low liquid level height, Hlll
        Hlll = 0.5
        if P < 300:
            Hlll = 1.25

        # Calculate the height from Hlll to  Normal liq level, Hnll
        Hh = Vh / (pi / 4.0 * Dvd**2)
        if Hh < 1.0:
            Hh = 1.0
        Hh = FinalValue(Hh)

        # Calculate the height from Hnll to  High liq level, Hhll
        Hs = Vs / (pi / 4.0 * Dvd**2)
        if Hs < 0.5:
            Hs = 0.5
        Hs = FinalValue(Hs)

        # Calculate dN
        Qm = Qll + Qv
        lamda = Qll / Qm
        rhoM = rhol * lamda + rhov * (1 - lamda)
        dN = (4 * Qm / (pi * 60.0 / (rhoM**0.5)))**0.5
        dN = FinalValue(dN)

        # Calculate Hlin, assume with inlet diverter
        Hlin = 1.0 + dN

        # Calculate the vapor disengagement height
        Hv = 0.5 * Dvd
        if int(Mist) == 1:
            Hv2 = 2.0 + dN / 2.0
        else:
            Hv2 = 3.0 + dN / 2.0

        if Hv2 < Hv:
            Hv = Hv2
        Hv = ceil(Hv)

        # Calculate total height, Ht
        Hme = 0.0
        if int(Mist) == 1:
            Hme = 1.5
        Ht = Hlll + Hh + Hs + Hlin + Hv + Hme
        Ht = FinalValue(Ht)

        # Calculate Vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, Ht)

        # Check if LD is between 1.5 and 6.0
        while not converged:
            LD = Ht / D
            if (LD < 1.5):
                D = D - 0.5
                converged = False
            elif (LD > 6.0):
                D = D + 0.5
                converged = False
            else:
                converged = True

        converged = False

        LD = Ht / D

        # Find maximum and normal liquid level
        Hhll = Hs + Hh + Hlll
        Hnll = Hh + Hlll

        # send the outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], Ht)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(LD)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hv)
        self.SetValueFromFieldUnits(self._output['HighLiqLevel'], Hhll)
        self.SetValueFromFieldUnits(self._output['NormalLiqLevel'], Hnll)
        self.SetValueFromFieldUnits(self._output['LowLiqLevel'], Hlll)
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
コード例 #3
0
ファイル: DesignSep3Phase.py プロジェクト: shao130/sim42
    def Solve(self):
        super(HorizontalWithWeir, self).Solve()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return
        
        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return

        Wv, Wll, Whl, rhov, rhol, rhoh, mul, muh, P, Ts, Th, Mist, Ks, Qv, Qll, Qhl, K, Ut, Uv, Vh, Vs, LD, Till, Tihl = results
        
        converged = False
        converged1 = False
        converged2 = False
        
        D = (16.0*(Vh+Vs)/(0.6*pi*LD))**(1.0/3.0)
        if (D <= 4.0):
            D = 4.0
        while not converged:
            At = pi*(D**2)/4.0
            Hv = 0.2*D
            if int(Mist) == 1 and Hv <= 2.0:
                Hv = 2.0
            elif not int(Mist) == 0 and Hv <= 1.0:
                Hv = 1.0

            X1 = Hv/D
            Av = HNATable(1, X1)*At
            # Calculate low liq level
            Hlll = 0.5*D + 7.0
            X2 = round(Hlll)/(D*12.0)
            Alll = HNATable(1, X2)*At
            # Calculate weir height
            Hw = D - Hv
            # Check if Hw is less than 2 ft
            while not converged2:
                if Hw < 2.0:
                    D = D + 0.5 
                At = pi*(D**2)/4.0
                Hv = 0.2*D
                if int(Mist) == 1 and Hv <= 2.0:
                    Hv = 2.0
                elif not int(Mist) == 0 and Hv <= 1.0:
                    Hv = 1.0

                X1 = Hv/D
                Av = HNATable(1, X1)*At
                # Calculate low liq level
                Hlll = 0.5*D + 7.0
                X2 = (FinalValue(Hlll))/(D*12.0)
                Alll = HNATable(1, X2)*At
                # Calculate weir height
                Hw = D - Hv
                # Check if Hw is less than 2 ft
                if Hw < 2.0:
                    converged2 = False
                else:
                    converged2 = True
                    
            converged2 = False

            # Calculate minimum length of the light liquid compartment
            L2 = (Vh + Vs)/(At-Av-Alll)
            L2 = FinalValue(L2)
            Hhl = Hw/2.0
            Hll = Hhl
            X3 = Hhl/D
            Ahl = HNATable(1, X3)*At
            All = At - Av - Ahl
            # Calculate the setting velocity of heavy liquid and light liquid
            Uhl = Ks*(rhoh-rhol)/mul
            Ulh = Ks*(rhoh-rhol)/muh
            # Calculate the setling time of the heavy liq out of the light liq
            Thl = 12.0*Hll/Uhl
            Tlh = 12.0*Hhl/Ulh
            # Calculate L1 max
            L1a = Tlh*Qhl/Ahl
            L1b = Thl*Qll/All
            if L1a > L1b:
                L1 = L1a
            else:
                L1 = L1b
            L1 = FinalValue(L1)

            # Find L
            L = L1 + L2
            # Calculate liquid dropout
            Phi = Hv/Uv
            # Calculate actual vapor velocity
            Uva = Qv/Av
            # Calculate L minimum for vapor-liquid separation
            Lmin = Uva*Phi
            Li = L

            sign = -1.0
            needToIter = False

            if L < Lmin:
                Li = Lmin

            if L < (0.8*Lmin):
                sign = 1.0
                needToIter = True
                
            if L > (1.2*Lmin):
                if int(Mist) == 1 and Hv <= 2.0:
                    Hv = 2.0
                    L = Li
                elif not int(Mist) == 0 and Hv <= 1.0:
                    Hv = 1.0
                    L = Li
                else:
                    needToIter = True

            if needToIter:
                innerIter = 0
                while not converged1 and innerIter < self.maxIter:
                    innerIter += 1
                    Hv = Hv + sign*0.5
                    if int(Mist) == 1 and Hv <= 2.0:   # baru tambah Bang !
                        Hv = 2.0
                    if int(Mist) == 0 and Hv <= 1.0:   # baru tambah Bang !
                        Hv = 1.0
                    X1 = Hv/D
                    Av = HNATable(1, X1)*At
                    Hlll = 0.5*D + 7.0
                    Hlll = FinalValue(Hlll)
                    X2 = Hlll/(D*12.0)
                    Alll = HNATable(1, X2)*At
                    # Calculate weir height
                    Hw = D - Hv
                    # Check if Hw is less than 2 ft
                    if Hw < 2.0:
                        D = D + 0.5
                        while not converged2:
                            At = pi*(D**2)/4.0
                            Hv = 0.2*D
                            if int(Mist) == 1 and Hv <= 2.0:
                                Hv = 2.0
                            elif not int(Mist) == 0 and Hv <= 1.0:
                                Hv = 1.0

                            X1 = Hv/D
                            Av = HNATable(1, X1)*At
                            # Calculate low liq level
                            Hlll = 0.5*D + 7.0
                            X2 = FinalValue(Hlll)/(D*12.0)
                            Alll = HNATable(1, X2)*At
                            # Calculate weir height
                            Hw = D - Hv
                            # Check if Hw is less than 2 ft
                            if Hw < 2.0:
                                converged2 = False
                            else:
                                converged2 = True
                    
                    converged2 = False
                    L2 = (Vh + Vs)/(At-Av-Alll)
                    L2 = FinalValue(L2)
                    Hhl = Hw/2.0
                    Hll = Hhl
                    X3 = Hhl/D
                    Ahl = HNATable(1, X3)*At
                    All = At - Av - Ahl
                    # Calculate the setting velocity of heavy liquid and light liquid
                    Uhl = Ks*(rhoh-rhol)/mul
                    Ulh = Ks*(rhoh-rhol)/muh
                    # Calculate the setling time of the heavy liq out of the light liq
                    Thl = 12.0*Hll/Uhl
                    Tlh = 12.0*Hhl/Ulh
                    # Calculate L1 max
                    L1a = Tlh*Qhl/Ahl
                    L1b = Thl*Qll/All
                    if L1a > L1b:
                        L1 = L1a
                    else:
                        L1 = L1b
                    L1 = FinalValue(L1)

                    # Find L
                    Li = L1 + L2
                    # Calculate liquid dropout
                    Phi = Hv/Uv
                    # Calculate actual vapor velocity
                    Uva = Qv/Av
                    # Calculate L minimum for vapor-liquid separation
                    Lmin = Uva*Phi
                    if Li < (0.8*Lmin):
                        sign = 1.0
                        converged1 = False
                    if Li > (1.2*Lmin):
                        sign = -1.0
                        converged1 = False
                    else:
                        Li = Li
                        converged1 = True
                if not converged1 and self.parent:
                    self.parent.InfoMessage('CouldNotConvergeInner', (self.GetPath(), self.maxIter))
            converged1 = False
            L = Li
            
            # Calculate L/D        
            LD = L/D

            # Check L/D
            if LD < 1.2:
                if (D <= 4.0):
                    D = D
                    converged = True
                else:
                    D = D - 0.5
                    converged = False
            elif LD > 7.2:
                D = D + 0.5
                converged = False
            else:
                converged = True

        converged = False
        
        # Calculate the vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, L)
        
        # Recalculate L/D
        D, LD = self.RecalculateLD(L, D)
        
        # Calculate NLL and HLL
        Hhll = D - Hv
        Anll = Alll + (Vh/L)
        
        # Obtain Hnll using table 3 by knowing the Anll/At value
        # from Anll/At to Ahl/At set HNATable = 1
        X = Anll / At
        Y = HNATable(2, X)
        Hnll = Y * D
        Hlll = Hlll/12.0
 
        
        # send the outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], L)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(LD)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hv)
        self.SetValueFromFieldUnits(self._output['NormalLiqLevel'], Hnll)
        self.SetValueFromFieldUnits(self._output['HighLiqLevel'], Hhll)
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
        self.SetValueFromFieldUnits(self._output['WeirHeight'], Hw)
        self.SetValueFromFieldUnits(self._output['LengthToWeir'], L2)
コード例 #4
0
ファイル: DesignSep3Phase.py プロジェクト: shao130/sim42
    def Solve(self):
        super(HorizontalWithBoot, self).Solve()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return
        
        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return

        Wv, Wll, Whl, rhov, rhol, rhoh, mul, muh, P, Ts, Th, Mist, Ks, Qv, Qll, Qhl, K, Ut, Uv, Vh, Vs, LD, Till, Tihl = results
        
        Hllv = 1.0       #lightliquid level
        Hllb = 0.5       #heavyliquid level
        converged = False
        converged1 = False
        converged2 = False

        D = (4.0*(Vh+Vs)/(0.6*pi*LD))**(1.0/3.0)
        if (D <= 4.0):
            D = 4.0
        while not converged:
            At = pi*(D**2)/4.0
            Hv = 0.2*D
            if int(Mist) == 1:
                if Hv <= 2.0:
                    Hv = 2.0
            else:
                if Hv <= 1.0:
                    Hv = 1.0

            X1 = Hv/D
            X2 = Hllv/D
            Av = HNATable(1, X1)*At
            Allv = HNATable(1, X2)*At
            # Calculate minimum length
            L = (Vh + Vs)/(At-Av-Allv)
            # Calculate liquid dropout
            Phi = Hv/Uv
            # Calculate actual vapor velocity
            Uva = Qv/Av
            # Calculate L minimum for vapor-liquid separation
            Lmin = Uva*Phi
            Li = L

            sign = -1.0
            needToIter = False

            if L < Lmin:
                Li = Lmin

            if L < (0.8*Lmin):
                sign = 1.0
                needToIter = True
                
            if L > (1.2*Lmin):
                if int(Mist) == 1 and Hv <= 2.0:
                    Hv = 2.0
                    Li = L
                elif not int(Mist) == 0 and Hv <= 1.0:
                    Hv = 1.0
                    Li = L
                else:
                    needToIter = True

            if needToIter:
                innerIter = 0
                while not converged1 and innerIter < self.maxIter:
                    innerIter += 1
                    Hv = Hv + sign*0.5
                    if int(Mist) == 1 and Hv <= 2.0:   # baru tambah Bang !
                        Hv = 2.0
                    if int(Mist) == 0 and Hv <= 1.0:   # baru tambah Bang !
                        Hv = 1.0
                    Hllv = 1.0
                    Hllb = 0.5
                    X1 = Hv/D
                    X2 = Hllv/D
                    Y1 = HNATable(1, X1)
                    Av = Y1*At
                    Y2 = HNATable(1, X2)
                    Allv = Y2*At
                    Li = (Vh + Vs)/(At-Av-Allv)
                    Phi = Hv/Uv
                    Uva = Qv/Av
                    Lmin = Uva*Phi
                    if Li < (0.8*Lmin):
                        sign = 1.0
                        converged1 = False
                    elif Li > (1.2*Lmin):
                        sign = -1.0
                        converged1 = False
                    else:
                        Li = Li
                        converged1 = True
                if not converged1 and self.parent:
                    self.parent.InfoMessage('CouldNotConvergeInner', (self.GetPath(), self.maxIter))
            converged1 = False
            L = Li
            
            # Calculate the setting velocity of heavy liquid
            Uhl = Ks*(rhoh-rhol)/mul
            # Calculate the setting velocity of heavy liquid
            Ulh = Ks*(rhoh-rhol)/muh
            # Calculate the setling time of the heavy liq out of the light liq
            Thl = 12.0*(Hllb + D - Hv)/Uhl
            if (Thl <= 0.0):
                    Hv = Hv - 0.5
            # Calculate the residence time of the light liq
            innerIter = 0
            while not converged2 and innerIter < self.maxIter:
                innerIter += 1
                Till = (At-Av)*L/Qll            
                if Till < Thl:
                    L = Thl*Qll/(At - Av)
                    converged2 = False
                else:
                    converged2 = True
                    
            if not converged2 and self.parent:
                    self.parent.InfoMessage('CouldNotConvergeInner', (self.GetPath(), self.maxIter))
                    
            converged2 = False
            
            # Calculate L/D        
            LD = L/D

            # Check L/D
            if LD < (0.8*1.5):
                if (D < 4.0):
                    D = D
                    converged = True
                else:
                    D = D - 0.5
                    converged = False
            if LD > (1.2*6.0):
                D = D + 0.5
                converged = False
            else:
                converged = True

        converged = False
            
        # Calculate the vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, L)
        
        # Recalculate L/D
        D, LD = self.RecalculateLD(L, D)
        
        # Calculate NLL and HLL
        Hhll = D - Hv
        Anll = Allv + (Vh / L)
        
        # Obtain Hnll using table 3 by knowing the Anll/At value
        # from Anll/At to Ahl/At set HNATable = 1
        X = Anll / At
        Y = HNATable(2, X)
        Hnll = Y * D

        # Design the heavy liquid boot
        Hhl = 1.0
        Up = 0.75*Ulh
        # Boot diameter
        Db = (4.0*12.0*Qhl/(pi*Up))**0.5
        while not converged:
            Tlh = 12.0*Hhl/Ulh
            Tihl = pi*Hhl*(Db**2.0)/(4.0*Qhl)
            if Tihl < Tlh:
                Db = Db + 0.5
                converged = False
            else:
                converged = True

        converged = False

        Hb = Hhl + Hllb

        # send the outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], L)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(LD)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hv)
        self.SetValueFromFieldUnits(self._output['NormalLiqLevel'], Hnll)
        self.SetValueFromFieldUnits(self._output['HighLiqLevel'], Hhll)
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
        self.SetValueFromFieldUnits(self._output['BootDiameter'], Db)
        self.SetValueFromFieldUnits(self._output['BootHeight'], Hb)
コード例 #5
0
ファイル: DesignSep3Phase.py プロジェクト: shao130/sim42
    def Solve(self):
        #Let it do the basic steps and leave if it can not solve
        super(Vertical, self).Solve()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return

        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return

        Wv, Wll, Whl, rhov, rhol, rhoh, mul, muh, P, Ts, Th, Mist, Ks, Qv, Qll, Qhl, K, Ut, Uv, Vh, Vs, LD, Till, Tihl = results

        Hl = 1.0       # height from liquid interface to light liquid nozzle, ft
        Hr = 12.0      # height from light liquid nozzle to baffle, inch
        Hh = 1.0       # holdup height, ft
        converged = False
        
        # Calculate vessel internal diameter
        Dvd = (4.0*Qv/(pi*Uv))**0.5
        if int(Mist) == 1:
            Dvd = Dvd + 0.4
              
        D = FinalValue(Dvd)
        
        # Calculate the setting velocity of heavy liquid
        Uhl = Ks*(rhoh-rhol)/mul
        # Calculate the setting velocity of heavy liquid
        Ulh = Ks*(rhoh-rhol)/muh
        # Calculate the setling time of the heavy liq out of the light liq and vice versa
        Thl = 12.0*Hl/Uhl
        Tlh = 12.0*Hh/Ulh
        # use Gtable to find G
        DRho = rhol - rhov
        Hlr = Hl*12.0 + Hr
        G = GTable(DRho, Hlr)
        # Calculate Ad
        Ad  = 7.48*60.0*(Qll+Qhl)/G
        # Assume the downcomer chord width, Wd = 4 inch
        
        while not converged:
            Wd = 4.0
            Wdd = Wd/(D*12.0)
            At = (pi*D**2)/4
            Y = HNATable(1, Wdd)
            Ad = Y*At
            Al = At - Ad
            # Calc. the residence time fo each phase
            Till = Hl*Al/Qll
            Ah = At
            Tihl = Hh*Ah/Qhl
            # Check for convergence
            if Till < Thl or Tihl < Tlh:
                D = D + 0.5
                converged = False
            else:
                converged = True
        
        converged = False
        
        # Calc. the height of the light liquid
        Hr = Qll*Th/Al
        # Calc. surge height
        Hs = Qll*Th/Al
        # Calc. inlet nozzle size, dN in ft
        lamda = (Qll+Qhl)/(Qll+Qhl+Qv*60.0)
        rhoLiq = (Wll/(Wll+Whl))*rhol + (Whl/(Wll+Whl))*rhoh            # use mix liquid density of light and heavy liquids
        rhoMix = rhoLiq*lamda + rhov*(1.0-lamda)
        Qm = Qv + (Qll + Qhl)/60.0
        dN = (4.0*Qm/(60.0*pi/(rhoMix**0.5)))**0.5
        dN = FinalValue(dN)

        # Calc. vessel height
        Hd1 = 0.5*D
        Hd2 = 3.0 + dN/2.0
        if int(Mist) == 1:
            Hd2 = 2.0 + dN/2.0

        Hd = Hd2
        if Hd1 > Hd2:
            Hd = Hd1
        
        Hs1 = Hs + 0.5
        if Hs1 <= 2.0:
            Hs1 = 2.0
        
        Hbn = 0.5*dN + Hs1
        Ha = 0.5    # Set
        Ht = Hh + Hl + Hr + Ha + Hbn + Hd
        if int(Mist) == 1:
            Ht = Ht + 1.5

        Htd = Ht/D
        while not converged:
            # Add 2 ft to Ht by adding 0.5 to Hr and 1.5 to Hd
            if Htd < 1.5:
                Hh = round(Hh, 0)
                Hl = round(Hh, 0)
                Hr = ceil(Hr)
                Hbn = round(Hbn, 0)
                Hd = ceil(Hd)+ 1.0
                
            Ht = Hh + Hl + Hr + Ha + Hbn + Hd
            if int(Mist) == 1:
                Ht = Ht + 1.5
                
            Htd = Ht/D      # Htd should be between 1.5 to 6.0
            if Htd < 1.5:
                Hd = Hd + 0.5
                Hbn = Hbn + 0.5
                converged = False
            else:
                converged = True
        
        converged = False
        
        # Find Normal and Maximum liquid level
        Hhll = Hh + Hl + Hr + Ha + Hs
        Hnll = Hhll - Hs

        # Calculate the vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, Ht)
        
        # send the outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], Ht)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(Htd)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hd)
        self.SetValueFromFieldUnits(self._output['NormalLiqLevel'], Hnll)
        self.SetValueFromFieldUnits(self._output['HighLiqLevel'], Hhll)
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
コード例 #6
0
ファイル: DesignSep3Phase.py プロジェクト: shao130/sim42
    def Solve(self):
        super(HorizontalWithWeirAndBucket, self).Solve()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return
        
        results = self.Initialize()
        if not self._readyForSolve:
            if self.parent:
                self.parent.InfoMessage('DesignObjNotReady', (self.GetPath(),))
            return

        Wv, Wll, Whl, rhov, rhol, rhoh, mul, muh, P, Ts, Th, Mist, Ks, Qv, Qll, Qhl, K, Ut, Uv, Vh, Vs, LD, Till, Tihl = results
  
        converged = False
        converged1 = False
        converged2 = False
        
        D = (4.0*(Qll*Till+Qhl*Tihl)/(0.7*pi*LD))**(1.0/3.0)

        while not converged:
            At = pi*(D**2)/4.0
            Hv = 0.2*D
            if int(Mist) == 1:
                if Hv <= 2.0:
                    Hv = 2.0
            else:
                if Hv <= 1.0:
                    Hv = 1.0

            X1 = Hv/D
            Av = HNATable(1, X1)*At
            # Calculate minimum length
            L1 = (Qll*Till + Qhl*Tihl)/(At-Av)
            # Calculate liquid dropout
            Phi = Hv/Uv
            # Calculate actual vapor velocity
            Uva = Qv/Av
            # Calculate L minimum for vapor-liquid separation
            Lmin = Uva*Phi
            Li = L1

            sign = -1.0
            needToIter = False

            if L1 < Lmin:
                Li = Lmin

            if L1 < (0.8*Lmin):
                sign = 1.0
                needToIter = True
                
            if L1 > (1.2*Lmin):
                if int(Mist) == 1 and Hv <= 2.0:
                    Hv = 2.0
                    L = Li
                elif not int(Mist) == 0 and Hv <= 1.0:
                    Hv = 1.0
                    L = Li
                else:
                    needToIter = True

            if needToIter:
                innerIter = 0
                while not converged1 and innerIter < self.maxIter:
                    innerIter += 1
                    Hv = Hv + sign*0.5
                    if int(Mist) == 1 and Hv <= 2.0:   # baru tambah Bang !
                        Hv = 2.0
                    if int(Mist) == 0 and Hv <= 1.0:   # baru tambah Bang !
                        Hv = 1.0
                    X1 = Hv/D
                    Av = HNATable(1, X1)*At
                    L1 = (Qll*Till + Qhl*Tihl)/(At-Av)
                    Phi = Hv/Uv
                    Uva = Qv/Av
                    Lmin = Uva*Phi
                    if L1 < (0.8*Lmin):
                        sign = 1.0
                        converged1 = False
                    if L1 > (1.2*Lmin):
                        sign = -1.0
                        converged1 = False
                    else:
                        Li = L1
                        converged1 = True
                if not converged1 and self.parent:
                    self.parent.InfoMessage('CouldNotConvergeInner', (self.GetPath(), self.maxIter))
            converged1 = False
            L1 = Li

            # Calculate the light liquid layer thickness based on heavy liq settling out
            DSG = rhoh/62.3 - rhol/62.3     # Delta S.G between light and heavy liqs.
            Hll = 0.00128*Till*DSG*(89.0*0.00000328084)**2*1488.0/mul
            #Calculate diff in height between light and heavy liq weirs
            DH = Hll*(1.0 - rhol/rhoh)

            # Design the light liquid bucket
            LLw = D - Hv
            HLLl = LLw - 0.5
            Hllb = 0.125*D
            LLLl = Hllb + 0.5
            Hllw = LLw - Hllb

            X1 = HLLl/D
            Ahll = HNATable(1, X1)*At
            X2 = LLLl/D
            Alll = HNATable(1, X2)*At
            
            # Calculate L2 and L3
            L2 = (Th + Ts)*Qll/(Ahll - Alll)
            L3a = D/12.0
            if L3a < 1.0:
                L3a = 1.0
            L3 = L3a

            # Design the heavy liq compartment
            HLw = D - Hv - DH
            HLLh = HLw - 0.5
            Hvlb = 0.0*D        # from bottom of vessel
            LLLh = 0.5
            Hhlw = HLw - Hvlb
            
            X1 = HLLh/D
            Ahvll = HNATable(1, X1)*At
            X2 = LLLh/D
            Alvll = HNATable(1, X2)*At
            
            # Calculate L4
            L4 = (Th + Ts)*Qhl/(Ahvll - Alvll)
            
            # Calculate L
            L = L1 + L2 + L3 + L4
            # Calculate LD
            LD = L/D
            # Check L/D
            if LD < 1.2:
                if (D < 4.0):
                    D = D
                    converged = True
                else:
                    D = D - 0.5
                    converged = False
            elif LD > 7.2:
                D = D + 0.5
                converged = False
            else:
                converged = True

        converged = False
        # Calculate the vessel weight and wall thickness
        VW, VWT = VesselWeightAndWallThickness(P, D, L)
        
        # Recalculate L/D
        D, LD = self.RecalculateLD(L, D)
        
        # send the outputs
        self.SetValueFromFieldUnits(self._output['VesselLength'], L)
        self.SetValueFromFieldUnits(self._output['VesselDiameter'], D)
        self._output['LDratio'].SetValue(LD)
        self.SetValueFromFieldUnits(self._output['VapDisengagementHeight'], Hv)
        #self._output['NormalLiqLevel'].SetValue('NIL')
        #self._output['HighLiqLevel'].SetValue('NIL')
        self.SetValueFromFieldUnits(self._output['VesselWeight'], VW)
        self.SetValueFromFieldUnits(self._output['VesselWallThickness'], VWT)
        self.SetValueFromFieldUnits(self._output['LLiqWeirHeight'], Hllw)
        self.SetValueFromFieldUnits(self._output['HLiqWeirHeight'], Hhlw)
        self.SetValueFromFieldUnits(self._output['LengthToLLiqWeir'], L1)
        self.SetValueFromFieldUnits(self._output['LLiqBucketLength'], L2)
        self.SetValueFromFieldUnits(self._output['LengthBetweenWeirs'], L3)
        self.SetValueFromFieldUnits(self._output['HLiqBucketLength'], L4)