예제 #1
0
    def eq_calculate_hext(self):

        eq = self.CreateEquation("Hext", "Heat balance - Hext")
        xdomains = distribute_on_domains(self.XDomains, eq, eClosedClosed)
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        domains = xdomains + ydomains

        g = self.g
        Text = self.Text()
        Do = self.Do()

        To = daeVariable_wrapper(self.To, domains)
        hext = daeVariable_wrapper(self.hext, domains)
        fNtub = daeVariable_wrapper(self.fNtub, ydomains)

        Tast = 0.5 * (Text + To) / Constant(1 * K)
        Past = self.Pext() / Constant(1 * Pa)

        hvap = vaporization_enthalpy(Past, simplified = True) * Constant(1 * J * (kg**-1) )

        rhov = vapour_density( Past, simplified = True) * Constant(1 * (kg ** (1))*(m ** (-3)))
        rho_o = density( Tast, Past, simplified = True) * Constant(1 * (kg ** (1))*(m ** (-3)))
        mu_o = viscosity( Tast, Past, simplified = True) * Constant(1 * (Pa ** (1))*(s ** (1)))
        kappa_o = conductivity( Tast, Past, simplified = True)  * Constant(1 * (K ** (-1))*(W ** (1))*(m ** (-1)))

        num = (g * rho_o * (rho_o - rhov) * kappa_o ** 3 * hvap)

        den = mu_o * Abs(Text - To) * Do

        hd1 = (0.729 * (num / den) ** 0.25)

        eq.Residual = hext - fNtub * hd1
예제 #2
0
    def eq_fD(self):

        eq = self.CreateEquation("fDturb", "Turbulent darcy factor")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        fD = daeVariable_wrapper(self.fD, domains)

        v = daeVariable_wrapper(self.v, domains)
        D = daeVariable_wrapper(self.D, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)

        mu = viscosity(Tast, Past, simplified=True) * Constant(1 * (Pa**(1)) *
                                                               (s**(1)))
        rho = density(Tast, Past, simplified=True) * Constant(1 * (kg**(1)) *
                                                              (m**(-3)))

        Re = D * Abs(v) * rho / mu

        A = (2.457 * Log(((7 / Re)**0.9 + 0.27 * self.epw() / D)**-1))**16
        B = (37530 / Re)**16
        ff = 2 * ((8 / Re)**12 + (A + B)**-1.5)**(1 / 12)

        eq.Residual = fD - 4 * ff
예제 #3
0
    def eq_heat_balance(self):

        eq = self.CreateEquation("HeatBal", "Heat balance - T")
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        xdomains = distribute_on_domains(self.XDomains, eq, eOpenClosed)
        domains = xdomains + ydomains

        L = self.L()
        D = daeVariable_wrapper(self.D, domains)
        k = daeVariable_wrapper(self.k, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)

        cp = heat_capacity(Tast, Past, simplified=True) * Constant(1 *
                                                                   (J**(1)) *
                                                                   (K**(-1)) *
                                                                   (kg**(-1)))
        rho = density(Tast, Past, simplified=True) * Constant(1 * (kg**(1)) *
                                                              (m**(-3)))

        A = 0.25 * 3.14 * D**2
        eq.Residual = self.dt(rho * cp * A * T) + \
                      d(k * cp * T, self.x, eCFDM) / L - \
                      Qout
예제 #4
0
    def eq_calculate_Ti(self):

        eq = self.CreateEquation("WallHeat", "Heat balance - wall")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
        Qout = daeVariable_wrapper(self.Qout, domains)
        To = daeVariable_wrapper(self.To, domains)
        Ti = daeVariable_wrapper(self.Ti, domains)
        Reswall = Log(self.Do() / self.Di()) / (2 * self.pi * self.kwall())
        eq.Residual = Qout - (To - Ti ) / Reswall
예제 #5
0
    def eq_Rf(self):

        eq = self.CreateEquation("Rf", "Rf")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        D = daeVariable_wrapper(self.D, domains)
        Rf = daeVariable_wrapper(self.Rf, domains)
        kf = self.kf
        Di = self.Di()

        eq.Residual = Rf - Di * Log(Di / D) / (2 * kf)
예제 #6
0
    def eq_internal_diameter(self):

        eq = self.CreateEquation("D", "D_internal_flow_diameter")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        D = daeVariable_wrapper(self.D, domains)
        mf = daeVariable_wrapper(self.mf, domains)
        rhof = self.rhof
        Di = self.Di()

        eq.Residual = D - Sqrt(Di**2 - 4 * mf * Di / rhof)
예제 #7
0
    def eq_calculate_To(self):

        eq = self.CreateEquation("WallHeat1", "Heat balance - wall")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        Do = self.Do()
        Text = self.Text()
        pi = self.pi

        To = daeVariable_wrapper(self.To, domains)
        hext = daeVariable_wrapper(self.hext, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)

        eq.Residual = Qout - (Text - To) * (pi * Do * hext)
예제 #8
0
    def eq_calculate_Ti(self):

        eq = self.CreateEquation("WallHeat2", "Heat balance - wall")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        kwall = self.kwall()
        Do = self.Do()
        Di = self.Di()
        pi = self.pi

        Ti = daeVariable_wrapper(self.Ti, domains)
        To = daeVariable_wrapper(self.To, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)

        eq.Residual = Qout *  Log(Do / Di) - (To - Ti) * (2 * pi * kwall)
예제 #9
0
    def eq_phid(self):

        eq = self.CreateEquation("phid", "phid")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        k2 = self.k2
        ksp = self.ksp

        conc_H = 10**(-self.pH())
        conc_Ca = self.Ca() / 1000 / 40.078
        conc_CO3 = k2 * self.Alc() / 1000 / (100.0869 * (conc_H + 2 * k2))

        phid = daeVariable_wrapper(self.phid, domains)
        D = daeVariable_wrapper(self.D, domains)
        v = daeVariable_wrapper(self.v, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        #Tast = 35+273.15
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)
        vast = v / Constant(1 * m / s)

        rho = density(Tast, Past, simplified=True) * Constant(1 * (kg**(1)) *
                                                              (m**(-3)))
        kappa = conductivity(Tast, Past, simplified=True) * Constant(
            1 * (K**(-1)) * (W**(1)) * (m**(-1)))
        muast = viscosity(Tast, Past, simplified=True)
        mu = muast * Constant(1 * (Pa**(1)) * (s**(1)))

        Re = D * v * rho / mu

        kr = Exp(38.74 - Constant(20700.0 * 4.184 * J / mol) / (self.Rg * T))

        Dab = Constant(3.07e-15 * m**2 / s) * (Tast / muast)

        Sc = mu / (rho * Dab)

        kd = 0.023 * vast * Re**-0.17 * Sc**-0.67

        # eq.Residual = phid - 24 * 3600 * Constant(1 * kg * m ** -2 * s ** -1) * kd * \
        #               conc_CO3 * (1 - ksp / (conc_Ca * conc_CO3)) / \
        #               (1 + kd / (kr * conc_CO3) + conc_CO3 / conc_Ca)

        eq.Residual = phid - Constant(1 * kg * m ** -2 * s ** -1) * kd * \
                      conc_CO3 * (1 - ksp / (conc_Ca * conc_CO3)) / \
                      (1 + kd / (kr * conc_CO3) + conc_CO3 / conc_Ca)
예제 #10
0
    def eq_entalphy(self):

        eq = self.CreateEquation("Entalphy", "Fluid Entalphy")
        xdomains = distribute_on_domains(self.XDomains, eq, eClosedClosed)
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        domains = xdomains + ydomains

        k = daeVariable_wrapper(self.k, domains)

        H = daeVariable_wrapper(self.H, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)
        cp = heat_capacity( Tast, Past, simplified = True) * Constant(1 * (J ** (1))*(K ** (-1))*(kg ** (-1)))

        eq.Residual = k * cp * T - H
예제 #11
0
    def eq_total_he(self):

        eq = self.CreateEquation("TotalHeat", "Heat balance - Qout")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
        T = daeVariable_wrapper(self.T, domains)
        To = daeVariable_wrapper(self.To, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)
        hint = daeVariable_wrapper(self.hint, domains)
        D = daeVariable_wrapper(self.D, domains)

        Resint = 1 / (self.pi * D * hint) # mK/W
        Reswall = Log(self.Do() / self.Di()) / (2 * self.pi * self.kwall())  # mK/W
        # TODO - Lembrar de colocar o Refilme no caso com Biofilme
        #Resfilm = Log(self.Di() / self.D()) / (2 * self.pi * self.kappa())
        Resistance = (Resint + Reswall + self.ResF() * self.pi * D) # mK/W

        eq.Residual = Qout * Resistance - ( To - T)
예제 #12
0
    def eq_upperbound_pressureloss(self):

        eq = self.CreateEquation("UpperBoundPressureLoss", "Upper Bound Pressure Loss")
        xdomains = distribute_on_domains(self.XDomains, eq, eUpperBound)
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        domains = xdomains + ydomains

        dPub = daeVariable_wrapper(self.dPub, ydomains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        v = daeVariable_wrapper(self.v, domains)
        Kub = self.Kub()

        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)
        rho = density(Tast, Past, simplified=True) * Constant(1 * (kg ** (1)) * (m ** (-3)))
        eq.Residual = dPub - 0.5 * Kub * rho * v ** 2
예제 #13
0
    def eq_ep(self):

        eq = self.CreateEquation("Roughness", "Roughness")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        ep = daeVariable_wrapper(self.ep, domains)
        epw = self.epw()

        eq.Residual = ep - epw
예제 #14
0
    def eq_internal_diameter(self):

        eq = self.CreateEquation("D", "D_internal_flow_diameter")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        Di = self.Di()
        D = daeVariable_wrapper(self.D, domains)

        eq.Residual = D - Di
예제 #15
0
    def eq_total_he(self):

        eq = self.CreateEquation("TotalHeat", "Heat balance - Qout")
        Text = self.Text()
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
        T = daeVariable_wrapper(self.T, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)
        hint = daeVariable_wrapper(self.hint, domains)
        hext = daeVariable_wrapper(self.hext, domains)
        D = daeVariable_wrapper(self.D, domains)

        Resint = 1 / (self.pi * D * hint) # mK/W
        Reswall = Log(self.Do() / self.Di()) / (2 * self.pi * self.kwall())  # mK/W
        #Resfilm = Log(self.Di() / D) / (2 * self.pi * self.kappa())
        Resext = 1 / (self.pi * self.Do() * hext)
        #Resistance = (Resext + Resint + Reswall + Resfilm + self.ResF() * self.L()) # mK/W
        Resistance = (Resext + Resint + Reswall + self.ResF() * self.L()) # mK/W
        eq.Residual = Qout * Resistance - ( Text - T )
예제 #16
0
    def eq_velocity(self):

        eq = self.CreateEquation("v", "v_fluid_velocity")
        xdomains = distribute_on_domains(self.XDomains, eq, eClosedClosed)
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        domains = xdomains + ydomains

        k = daeVariable_wrapper(self.k, domains)
        D = daeVariable_wrapper(self.D, domains)
        v = daeVariable_wrapper(self.v, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)

        rho = density( Tast, Past, simplified = True) * Constant(1 * (kg ** (1))*(m ** (-3)))

        A = 0.25 * 3.14 * D ** 2
        eq.Residual = v - k / ( rho * A )
예제 #17
0
    def eq_mass_balance(self):

        eq = self.CreateEquation("MassBal", "Mass balance")
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        xdomains = distribute_on_domains(self.XDomains, eq, eOpenClosed)
        domains = xdomains + ydomains

        L = self.L()
        k = daeVariable_wrapper(self.k, domains)
        D = daeVariable_wrapper(self.D, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)

        rho = density( Tast, Past, simplified = True) * Constant(1 * (kg ** (1))*(m ** (-3)))

        Area = 0.25 * 3.14 * D ** 2

        eq.Residual =  self.dt(rho * Area ) + 24 * 3600 * d(k, self.x, eCFDM) / L
예제 #18
0
    def eq_mommentum_balance(self):

        eq = self.CreateEquation("MomBal", "Momentum balance")
        ydomains = distribute_on_domains(self.YDomains, eq, eClosedClosed)
        xdomains = distribute_on_domains(self.XDomains, eq, eOpenClosed)
        domains = xdomains + ydomains

        g = self.g
        L = self.L()
        tetha = self.tetha()
        k = daeVariable_wrapper(self.k, domains)
        fD = daeVariable_wrapper(self.fD, domains)
        v = daeVariable_wrapper(self.v, domains)
        D = daeVariable_wrapper(self.D, domains)
        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        Tast = T / Constant(1 * K)
        Past = P / Constant(1 * Pa)

        rho = density( Tast, Past, simplified = True) * Constant(1 * (kg ** (1))*(m ** (-3)))

        hL = 0.5 * fD * (v ** 2) / ( D * g )

        DeltaP = g * rho * hL

        A = 0.25 * 3.14 * D ** 2

        eq.Residual = A * d(P, self.x,eCFDM) / L + \
                      A * DeltaP + A * rho * g * Sin(tetha)
예제 #19
0
    def eq_calculate_hint(self):

        eq = self.CreateEquation("InternalConvection", "Internal convection - hint")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        T = daeVariable_wrapper(self.T, domains)
        P = daeVariable_wrapper(self.P, domains)
        fD = daeVariable_wrapper(self.fD, domains)
        hint = daeVariable_wrapper(self.hint, domains)
        D = daeVariable_wrapper(self.D, domains)
        v = daeVariable_wrapper(self.v, domains)

        # Calculates the Nussel dimensionless number using Petukhov correlation modified by Gnielinski. See Incropera 4th Edition [8.63]
        mu = viscosity( T / Constant(1 * K) , P / Constant(1 * Pa), simplified = True)
        kappa = conductivity( T / Constant(1 * K), P / Constant(1 * Pa), simplified = True)
        cp = heat_capacity( T / Constant(1 * K), P / Constant(1 * Pa), simplified = True)
        rho = density( T / Constant(1 * K), P / Constant(1 * Pa), simplified = True)

        Dast = D / Constant(1 * m )
        vast = v / Constant(1 * m * s ** -1)

        Re = Dast * Abs(vast) * rho / mu
        prandtl = cp * mu / kappa
        nusselt = (fD / 8.) * (Re - 1000.) * prandtl / (
                1. + 12.7 * Sqrt(fD / 8.) * (prandtl ** (2 / 3)) - 1.)
        eq.Residual = hint - nusselt * kappa / Dast * Constant(1 * W/(K * m**2))
예제 #20
0
    def eq_film(self):

        self.stnFouling = self.STN("stnFouling")

        self.STATE("Static")

        eq = self.CreateEquation("FilmOFF", "Film - OFF")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
        mf = daeVariable_wrapper(self.mf, domains)
        eq.Residual = mf - self.mfi()

        self.STATE("Dynamic")

        self.IF(Time() < 0.1 * Constant(1 * s), eventTolerance=1E-1)

        eq = self.CreateEquation("FilmOFF", "Film - OFF")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        mf = daeVariable_wrapper(self.mf, domains)
        eq.Residual = mf - self.mfi()

        self.ELSE()

        eq = self.CreateEquation("FilmON", "Film - ON")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        mf = daeVariable_wrapper(self.mf, domains)
        phid = daeVariable_wrapper(self.phid, domains)
        phir = daeVariable_wrapper(self.phir, domains)

        #sigmoidal = 1/(1+np.exp( 3 * ( 30 - Time() / Constant(1 * s)) )) - 1/(1+np.exp( 3 * (30 - 0.1 ) ))
        #sigmoidal = 1 #FORCED

        eq.Residual = self.dt(mf) - (phid - phir)
        # eq.Residual = self.dt(mf) - sigmoidal * (phid - phir)

        self.END_IF()

        self.END_STN()
예제 #21
0
    def eq_phir(self):

        eq = self.CreateEquation("phir", "phir")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
        phir = daeVariable_wrapper(self.phir, domains)
        phid = daeVariable_wrapper(self.phid, domains)
        D = daeVariable_wrapper(self.D, domains)
        v = daeVariable_wrapper(self.v, domains)

        kf = self.kf
        rhof = self.rhof
        psi = self.psi
        Di = self.Di()

        espes = (Di - D) / 2

        vast = v / Constant(1 * m / s)
        kfast = kf / Constant(1 * (W**(1)) * (m**(-1)) * (K**(-1)))
        espesast = espes / Constant(1 * m)
        rhofast = rhof / Constant(1 * kg / m**3)

        eq.Residual = phir - phid * 0.00212 * vast**2 / (Sqrt(kfast) * psi)
    def eq_total_he(self):

        eq = self.CreateEquation("TotalHeat", "Heat balance - Qout")
        domains = distribute_on_domains(self.Domains, eq, eClosedClosed)

        Text = self.Text()
        T = daeVariable_wrapper(self.T, domains)
        Qout = daeVariable_wrapper(self.Qout, domains)
        hext = daeVariable_wrapper(self.hext, domains)
        hint = daeVariable_wrapper(self.hint, domains)
        D = daeVariable_wrapper(self.D, domains)
        Rf = daeVariable_wrapper(self.Rf, domains)

        kwall = self.kwall()
        Do = self.Do()
        Di = self.Di()
        pi = self.pi

        Resext = 1 / (pi * Do * hext)
        Resint = 1 / (pi * D * hint)
        Reswall = Log(Do / Di) / (2 * pi * kwall)

        eq.Residual = Qout * (Resint + Reswall + Resext + Rf /
                              (Di * pi)) - (Text - T)
예제 #23
0
 def eq_total_he(self):
     eq = self.CreateEquation("TotalHeat", "Heat balance - Qout")
     domains = distribute_on_domains(self.Domains, eq, eClosedClosed)
     Qout = daeVariable_wrapper(self.Qout, domains)
     eq.Residual = Qout