def calculo(self): self.entrada = self.kwargs["entrada"] metodo = self.kwargs["metodo"] self.Pout = Pressure(self.kwargs["Pout"]) razon = self.kwargs["razon"] self.rendimientoCalculado = Dimensionless(self.kwargs["rendimiento"]) if self.kwargs["etapas"]: self.etapas = self.kwargs["etapas"] else: self.etapas = 1. self.power = Power(self.kwargs["trabajo"]) def f(Pout, rendimiento): W_ideal = self.__Wideal(Pout) power = W_ideal * self.entrada.caudalmasico.gs / rendimiento return power if metodo in [0, 3] or (metodo == 5 and self.Pout): if self.etapas == 1: razon = self.Pout.atm / self.entrada.P.atm else: razon = (self.Pout.atm / self.entrada.P.atm)**(1. / self.etapas) elif metodo in [1, 4] or (metodo == 5 and razon): if self.etapas == 1: self.Pout = Pressure(self.entrada.P * razon) else: self.Pout = Pressure(razon**self.etapas * self.entrada.P) if metodo in [0, 1]: Wideal = self.__Wideal(self.Pout.atm) power = Wideal * self.entrada.caudalmasico.gs / self.rendimientoCalculado self.power = Power(power * self.etapas) elif metodo == 2: funcion = lambda P: f(P, self.rendimientoCalculado) - self.power self.Pout = Pressure(fsolve(funcion, self.entrada.P + 1)) if self.etapas == 1: razon = self.Pout / self.entrada.P else: razon = (self.Pout / self.entrada.P)**(1. / self.etapas) elif metodo in [3, 4]: funcion = lambda rendimiento: f(self.Pout.atm, rendimiento ) - self.power self.rendimientoCalculado = Dimensionless(fsolve(funcion, 0.5)) elif metodo == 5: Wideal = self.__Wideal(self.Pout.atm) caudalmasico = MassFlow( self.power * self.rendimientoCalculado / Wideal, "gs") self.Tout = self.__Tout(Wideal) self.entrada = self.entrada.clone(caudalMasico=caudalmasico) Wideal = self.__Wideal(self.Pout.atm) self.Tout = Temperature(self.__Tout(Wideal)) self.salida = [self.entrada.clone(T=self.Tout, P=self.Pout)] self.razonCalculada = Dimensionless(self.Pout / self.entrada.P) self.deltaT = DeltaT(self.salida[0].T - self.entrada.T) self.deltaP = DeltaP(self.salida[0].P - self.entrada.P) self.cp_cv = self.entrada.Gas.cp_cv self.Pin = self.entrada.P self.Tin = self.entrada.T
def calculo(self): self.entrada = self.kwargs["entrada"] self.rendimientoCalculado = Dimensionless(self.kwargs["rendimiento"]) if self.kwargs["Pout"]: DeltaP = Pressure(self.kwargs["Pout"] - self.entrada.P) elif self.kwargs["deltaP"]: DeltaP = Pressure(self.kwargs["deltaP"]) elif self.kwargs["Carga"]: DeltaP = Pressure(self.kwargs["Carga"] * self.entrada.Liquido.rho * g) else: DeltaP = Pressure(0) if self.kwargs["usarCurva"]: if self.kwargs["diametro"] != self.kwargs["curvaCaracteristica"][ 0] or self.kwargs["velocidad"] != self.kwargs[ "curvaCaracteristica"][1]: self.curvaActual = self.calcularCurvaActual() else: self.curvaActual = self.kwargs["curvaCaracteristica"] self.Ajustar_Curvas_Caracteristicas() if not self.kwargs["usarCurva"]: head = Length(DeltaP / g / self.entrada.Liquido.rho) power = Power(head * g * self.entrada.Liquido.rho * self.entrada.Q / self.rendimientoCalculado) P_freno = Power(power * self.rendimientoCalculado) elif not self.kwargs["incognita"]: head = Length(polyval(self.CurvaHQ, self.entrada.Q)) self.DeltaP = Pressure(head * g * self.entrada.Liquido.rho) power = Power(self.entrada.Q * DeltaP) P_freno = Power(polyval(self.CurvaPotQ, self.entrada.Q)) self.rendimientoCalculado = Dimensionless(power / P_freno) else: head = Length(self.DeltaP / g / self.entrada.Liquido.rho) caudalvolumetrico = roots( [self.CurvaHQ[0], self.CurvaHQ[1], self.CurvaHQ[2] - head])[0] power = Power(caudalvolumetrico * self.DeltaP) self.entrada = Corriente( self.entrada.T, self.entrada.P.atm, caudalvolumetrico * self.entrada.Liquido.rho * 3600, self.entrada.mezcla, self.entrada.solido) P_freno = Power(polyval(self.CurvaPotQ, caudalvolumetrico)) self.rendimientoCalculado = Dimensionless(power / P_freno) self.headCalculada = head self.power = power self.P_freno = P_freno self.salida = [self.entrada.clone(P=self.entrada.P + DeltaP)] self.Pin = self.entrada.P self.PoutCalculada = self.salida[0].P self.Q = self.entrada.Q.galUSmin self.volflow = self.entrada.Q
def calculo(self): entrada = self.kwargs["entrada"] self.rendimientoCalculado = Dimensionless(self.kwargs["rendimiento"]) if self.kwargs["Pout"]: DeltaP = Pressure(self.kwargs["Pout"] - entrada.P) elif self.kwargs["deltaP"]: DeltaP = Pressure(self.kwargs["deltaP"]) elif self.kwargs["Carga"]: DeltaP = Pressure(self.kwargs["Carga"] * entrada.Liquido.rho * g) else: DeltaP = Pressure(0) if self.kwargs["usarCurva"]: b1 = self.kwargs["diametro"] != self.kwargs["curvaCaracteristica"][ 0] # noqa b2 = self.kwargs["velocidad"] != self.kwargs[ "curvaCaracteristica"][1] # noqa if b1 or b2: self.curvaActual = self.calcularCurvaActual() else: self.curvaActual = self.kwargs["curvaCaracteristica"] self.Ajustar_Curvas_Caracteristicas() if not self.kwargs["usarCurva"]: head = Length(DeltaP / g / entrada.Liquido.rho) power = Power(head * g * entrada.Liquido.rho * entrada.Q / self.rendimientoCalculado) P_freno = Power(power * self.rendimientoCalculado) elif not self.kwargs["incognita"]: head = Length(polyval(self.CurvaHQ, entrada.Q)) DeltaP = Pressure(head * g * entrada.Liquido.rho) power = Power(entrada.Q * DeltaP) P_freno = Power(polyval(self.CurvaPotQ, entrada.Q)) self.rendimientoCalculado = Dimensionless(power / P_freno) else: head = Length(self.DeltaP / g / entrada.Liquido.rho) poli = [self.CurvaHQ[0], self.CurvaHQ[1], self.CurvaHQ[2] - head] Q = roots(poli)[0] power = Power(Q * self.DeltaP) entrada = entrada.clone(split=Q / entrada.Q) P_freno = Power(polyval(self.CurvaPotQ, Q)) self.rendimientoCalculado = Dimensionless(power / P_freno) self.deltaP = DeltaP self.headCalculada = head self.power = power self.P_freno = P_freno self.salida = [entrada.clone(P=entrada.P + DeltaP)] self.Pin = entrada.P self.PoutCalculada = self.salida[0].P self.volflow = entrada.Q self.cp_cv = entrada.Liquido.cp_cv
def calculo(self): self.entrada = self.kwargs["entrada"] self.Pout = Pressure(self.kwargs["Pout"]) self.razon = Dimensionless(self.kwargs["razon"]) self.rendimientoCalculado = Dimensionless(self.kwargs["rendimiento"]) self.power = Power(-abs(self.kwargs["trabajo"])) def f(Pout, rendimiento): W_ideal = self.__Wideal(Pout) power = W_ideal * self.entrada.caudalmasico.gs * rendimiento return power self.cp_cv = self.entrada.Gas.cp_cv if self.kwargs["metodo"] in [0, 3] or \ (self.kwargs["metodo"] == 5 and self.Pout): self.razon = Dimensionless(self.Pout / self.entrada.P) elif self.kwargs["metodo"] in [1, 4] or \ (self.kwargs["metodo"] == 5 and self.razon): self.Pout = Pressure(self.entrada.P * self.razon) if self.kwargs["metodo"] in [0, 1]: Wideal = self.__Wideal(self.Pout) G = self.entrada.caudalmasico.gs self.power = Power(Wideal * G * self.rendimientoCalculado) elif self.kwargs["metodo"] == 2: def function(P): return f(P, self.rendimientoCalculado) - self.power self.Pout = Pressure(fsolve(function, self.entrada.P.atm + 1), "atm") self.razon = Dimensionless(self.Pout / self.entrada.P) elif self.kwargs["metodo"] in [3, 4]: def function(rendimiento): return f(self.Pout.atm, rendimiento) - self.power self.rendimientoCalculado = Dimensionless(fsolve(function, 0.5)) elif self.kwargs["metodo"] == 5: Wideal = self.__Wideal(self.Pout) G = MassFlow(self.power / self.rendimientoCalculado / Wideal, "gs") self.Tout = self.__Tout(Wideal) self.entrada = self.entrada.clone(caudalMasico=G) Wideal = self.__Wideal(self.Pout) self.Tout = Temperature(self.__Tout(Wideal)) self.razonCalculada = Dimensionless(self.Pout / self.entrada.P) self.salida = [self.entrada.clone(T=self.Tout, P=self.Pout)] self.deltaT = DeltaT(self.salida[0].T - self.entrada.T) self.deltaP = DeltaP(self.salida[0].P - self.entrada.P) self.Pin = self.entrada.P self.Tin = self.entrada.T
def calculo(self): #TODO: De momento, no se implementan las cuestiones de cinetica de intercambio de calor y materia que definirían las dimensiones necesarias del equipo HR = self.kwargs.get("HR", 100) self.Heat = Power(self.kwargs["Heat"]) self.deltaP = Pressure(self.kwargs["deltaP"]) self.entradaAire = self.kwargs["entradaAire"] Pout = min(self.kwargs["entradaSolido"].P.atm, self.kwargs["entradaAire"].P.atm) - self.deltaP.atm aguaSolidoSalida = self.kwargs["HumedadResidual"] * self.kwargs[ "entradaSolido"].solido.caudal.kgh aguaSolidoEntrada = self.kwargs["entradaSolido"].caudalmasico.kgh if self.kwargs["mode"] == 0: Caudal_aguaenAireSalida = aguaSolidoEntrada - aguaSolidoSalida + self.entradaAire.caudalMasico.kgh * self.entradaAire.Xw Caudal_airesalida = self.entradaAire.caudalMasico.kgh * self.entradaAire.Xa if self.entradaAire.Hs > Caudal_aguaenAireSalida / Caudal_airesalida: H = Caudal_aguaenAireSalida / Caudal_airesalida else: H = self.entradaAire.Hs aguaSolidoSalida += Caudal_aguaenAireSalida / Caudal_airesalida - self.entradaAire.Hs self.SalidaAire = PsychroState(caudal=Caudal_aguaenAireSalida + Caudal_airesalida, tdb=self.entradaAire.Tdb, H=H) self.SalidaSolido = self.kwargs["entradaSolido"].clone( T=self.SalidaAire.Tdb, P=Pout, split=aguaSolidoSalida / aguaSolidoEntrada) else: pass
def _Pbar(Z): """ Standard atmosphere pressure as a function of altitude as explain in [1]_ pag 1.1 Eq 3 Parameters ------------ Z : float Altitude, [m] Returns ------- P : float Standard barometric pressure, [Pa] Examples -------- Selected point from Table 1 in [1]_ >>> "%0.3f" % _Pbar(-500).kPa '107.478' >>> "%0.3f" % _Pbar(8000).kPa '35.600' """ P = (1-2.25577e-5*Z) ** 5.2559 return Pressure(P, "atm")
def _Psat(T): """ Water vapor saturation pressure calculation as explain in [1]_ pag 1.2, Eq 5-6 Parameters ------------ T : float Temperature, [K] Returns ------- P : float Saturation pressure, [Pa] """ if 173.15 <= T < 273.15: # Saturation pressure over ice, Eq 5 C = [-5674.5359, 6.3925247, -0.009677843, 0.00000062215701, 2.0747825E-09, -9.484024E-13, 4.1635019] pws = exp(C[0]/T + C[1] + C[2]*T + C[3]*T**2 + C[4]*T**3 + C[5]*T**4 + C[6]*log(T)) elif 273.15 <= Tdb <= 473.15: # Saturation pressure over liquid water, Eq 6 C = [-5800.2206, 1.3914993, -0.048640239, 0.000041764768, -0.000000014452093, 6.5459673] pws = exp(C[0]/T + C[1] + C[2]*T + C[3]*T**2 + C[4]*T**3 + C[5]*log(T)) else: raise NotImplementedError("Incoming out of bound") return Pressure(pws)
def calculo(self): tdp, tdb, twb, P, Pvs, Pv, ws, w, HR, v, h = self._lib() self.tdp = Temperature(tdp) self.tdb = Temperature(tdb) self.twb = Temperature(twb) self.P = Pressure(P) self.Pvs = Pressure(Pvs) self.Pv = Pressure(Pv) self.ws = Dimensionless(ws, txt="kgw/kgda") self.w = Dimensionless(w, txt="kgw/kgda") self.HR = Dimensionless(HR, txt="%") self.mu = Dimensionless(w/ws*100) self.v = SpecificVolume(v) self.rho = Density(1/v) self.h = Enthalpy(h, "kJkg") self.Xa = 1/(1+self.w/0.62198) self.Xw = 1-self.Xa
def readStatefromJSON(self, state): """Load instance parameter from saved file""" self.Pout = Pressure(state["Pout"]) self.Tout = Temperature(state["Tout"]) self.rendimientoCalculado = Dimensionless(state["rendimientoCalculado"]) # noqa self.power = Power(state["power"]) self.razonCalculada = Dimensionless(state["razonCalculada"]) self.razon = Dimensionless(state["razon"]) self.deltaT = DeltaT(state["deltaT"]) self.deltaP = DeltaP(state["deltaP"]) self.cp_cv = Dimensionless(state["cp_cv"]) self.Pin = Pressure(state["Pin"]) self.Tin = Temperature(state["Tin"]) self.cp_cv = Dimensionless(state["cp_cv"]) self.statusCoste = state["statusCoste"] if self.statusCoste: self.C_adq = Currency(state["C_adq"]) self.C_inst = Currency(state["C_inst"]) self.salida = [None]
def calculo(self): self.entradaGas = self.kwargs["entradaGas"] self.entradaLiquido = self.kwargs["entradaLiquido"] self.Dt = Length(self.kwargs["diametro"]) self.Lt = Length(self.kwargs["Lt"]) if self.kwargs["k"]: self.k = Dimensionless(self.kwargs["k"]) else: self.k = Dimensionless(1000.) if self.kwargs["f"]: self.f = Dimensionless(self.kwargs["f"]) else: self.f = Dimensionless(0.5) self.At = Area(pi / 4 * self.Dt**2) self.Vg = Speed(self.entradaGas.Q / self.At) self.R = self.entradaLiquido.Q / self.entradaGas.Q self.dd = Length(58600 * (self.entradaLiquido.Liquido.sigma / self.entradaLiquido.Liquido.rho)**0.5 / self.Vg**2 + 597 * (self.entradaLiquido.Liquido.mu / self.entradaLiquido.Liquido.epsilon**0.5 / self.entradaLiquido.Liquido.rho**0.5)**0.45 * (1000 * self.R)**1.5) self.efficiency_i = self._Efficiency() self.efficiencyCalc = self._GlobalEfficiency(self.efficiency_i) if self.statusDeltaP: self.deltaP = self._deltaP() else: self.deltaP = DeltaP(0) Solido_NoCapturado, Solido_Capturado = self.entradaGas.solido.Separar( self.efficiency_i) self.Pin = min(self.entradaGas.P, self.entradaLiquido.P) self.Pout = Pressure(self.Pin - self.deltaP) self.Min = self.entradaGas.solido.caudal self.Dmin = self.entradaGas.solido.diametro_medio self.Mr = Solido_NoCapturado.caudal self.Dmr = Solido_NoCapturado.diametro_medio self.Ms = Solido_Capturado.caudal self.Dms = Solido_Capturado.diametro_medio self.salida = [] self.salida.append( self.entradaGas.clone(solido=Solido_NoCapturado, P=self.Pin - self.deltaP)) self.salida.append( self.entradaLiquido.clone(solido=Solido_Capturado, P=self.Pin - self.deltaP))
def readStatefromJSON(self, state): """Load instance parameter from saved file""" self.deltaP = DeltaP(state["deltaP"]) self.rendimientoCalculado = Dimensionless( state["rendimientoCalculado"]) # noqa self.headCalculada = Length(state["headCalculada"]) self.power = Power(state["power"]) self.P_freno = Power(state["P_freno"]) self.Pin = Pressure(state["Pin"]) self.PoutCalculada = Pressure(state["PoutCalculada"]) self.volflow = VolFlow(state["volflow"]) self.cp_cv = Dimensionless(state["cp_cv"]) self.statusCoste = state["statusCoste"] if self.statusCoste: self.C_bomba = Currency(state["C_bomba"]) self.C_motor = Currency(state["C_motor"]) self.C_adq = Currency(state["C_adq"]) self.C_inst = Currency(state["C_inst"]) if self.kwargs["usarCurva"]: pass self.salida = [None]