def _mixture(self, eq, xi, par): """Apply mixing rules to individual parameters to get the mixture parameters for EoS Although it possible use any of available mixing rules, for now other properties calculation as fugacity helmholtz free energy are defined using the vdW mixing rules. Parameters ---------- eq : str codename of equation, PR, SRK... xi : list Molar fraction of component, [-] par : list list with individual parameters of equation, [-] Returns ------- mixpar : list List with mixture parameters, [-] """ self.kij = Kij(self.mezcla.ids, eq) mixpar = Mixing_Rule(xi, par, self.kij) return mixpar
def __init__(self, T, P, mezcla): ai=[] bi=[] aci=[] mi=[] for componente in mezcla.componente: a, b, ac, m=self.__lib(componente, T) ai.append(a) bi.append(b) aci.append(ac) mi.append(m) self.kij=Kij(PR) a, b=mezcla.Mixing_Rule([ai, bi], self.kij) tdadt=0 for i in range(len(mezcla.componente)): for j in range(len(mezcla.componente)): tdadt-=mezcla.fraccion[i]*mezcla.fraccion[j]*mi[j]*(aci[i]*aci[j]*mezcla.componente[j].tr(T))**0.5*(1-self.kij[i][j]) self.ai=ai self.bi=bi self.b=b self.tita=a self.delta=2*b self.epsilon=-b**2 self.eta=b self.u=2 self.w=-1 self.dTitadT=tdadt super(PR_Mathias_Copeman, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): ai=[] bi=[] aci=[] mi=[] for componente in mezcla.componente: a, b, ac, m=self.__lib(componente, T) ai.append(a) bi.append(b) aci.append(ac) mi.append(m) self.kij=Kij(SRK) a, b=mezcla.Mix_van_der_Waals([ai, bi], self.kij) tdadt=0 for i in range(len(mezcla.componente)): for j in range(len(mezcla.componente)): tdadt-=mezcla.fraccion[i]*mezcla.fraccion[j]*mi[j]*(aci[i]*aci[j]*mezcla.componente[j].tr(T))**0.5*(1-self.kij[i][j]) self.ai=ai self.bi=bi self.b=b self.tita=a self.delta=b self.epsilon=0 self.eta=b self.u=1 self.w=0 self.dTitadT=tdadt super(MSRK, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): ai=[] bi=[] ci=[] for componente in mezcla.componente: a, b, c=self.__lib(componente, T) ai.append(a) bi.append(b) ci.append(ac) self.kij=Kij(SRK) a, b=mezcla.Mix_van_der_Waals([ai, bi, ci], self.kij) tdadt=0 self.ai=ai self.bi=bi self.ci=ci self.b=b self.tita=a self.delta=b self.epsilon=0 self.eta=b self.u=c self.w=0 self.dTitadT=tdadt super(Fuller, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): ai=[] bi=[] for componente in mezcla.componente: a, b=self.__lib(componente, T) ai.append(a) bi.append(b) self.kij=Kij(None) a, b=mezcla.Mixing_Rule([ai, bi], self.kij) tdadt=0 self.ai=ai self.bi=bi self.b=b self.tita=a self.delta=b self.epsilon=0 self.eta=b #TODO: Find relation between u,w y tita,delta, epsilon... self.u=1 self.w=0 self.dTitadT=tdadt super(RK, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): x = mezcla.fraccion ai = [] bi = [] for cmp in mezcla.componente: a, b = self.__lib(cmp) ai.append(a) bi.append(b) self.kij = Kij(mezcla.ids) am, bm = Mixing_Rule(x, [ai, bi], self.kij) self.ai = ai self.bi = bi self.b = bm self.tita = am self.delta = 0 self.epsilon = 0 super(vdW, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): ai = [] bi = [] for componente in mezcla.componente: a, b = self._lib(componente, T) ai.append(a) bi.append(b) self.kij = Kij(mezcla.ids) a, b = Mixing_Rule(mezcla.fraccion, [ai, bi], self.kij) self.ai = ai self.bi = bi self.b = b self.tita = a self.delta = b self.epsilon = 0 # #TODO: Find relation between u,w y tita,delta, epsilon... # self.u = 1 # self.w = 0 super(RK, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): ai=[] bi=[] for componente in mezcla.componente: a, b=self.__lib(componente, T) ai.append(a) bi.append(b) self.kij=Kij(None) a, b=mezcla.Mixing_Rule([ai, bi], self.kij) tdadt=0 self.ai=ai self.bi=bi self.b=b self.tita=a self.delta=b self.epsilon=0 self.eta=b self.u=1 self.w=0 self.dTitadT=tdadt super(Wilson, self).__init__(T, P, mezcla)
def __init__(self, T, P, mezcla): self.T = unidades.Temperature(T) self.P = unidades.Pressure(P) self.componente = mezcla.componente self.zi = mezcla.fraccion self.kij = Kij("BWRS") Aoi = [] Boi = [] Coi = [] Doi = [] Eoi = [] ai = [] bi = [] ci = [] di = [] alfai = [] gammai = [] for compuesto in self.componente: Ao_, Bo_, Co_, Do_, Eo_, a_, b_, c_, d_, alfa_, gamma_ = self._lib( compuesto) Aoi.append(Ao_) Boi.append(Bo_) Coi.append(Co_) Doi.append(Do_) Eoi.append(Eo_) ai.append(a_) bi.append(b_) ci.append(c_) di.append(d_) alfai.append(alfa_) gammai.append(gamma_) Ao = Co = Do = Eo = Bo = a = b = c = d = alfa = gamma = 0 for i in range(len(self.componente)): Bo += self.zi[i] * Boi[i] a += self.zi[i] * ai[i]**(1. / 3) b += self.zi[i] * bi[i]**(1. / 3) c += self.zi[i] * ci[i]**(1. / 3) d += self.zi[i] * di[i]**(1. / 3) alfa += self.zi[i] * alfai[i]**(1. / 3) gamma += self.zi[i] * gammai[i]**0.5 a = a**3 b = b**3 c = c**3 d = d**3 alfa = alfa**3 gamma = gamma**2 for i in range(len(self.componente)): for j in range(len(self.componente)): Ao += self.zi[i] * self.zi[j] * Aoi[i]**0.5 * Aoi[j]**0.5 * ( 1 - self.kij[i][j]) Co += self.zi[i] * self.zi[j] * Coi[i]**0.5 * Coi[j]**0.5 * ( 1 - self.kij[i][j])**3 Do += self.zi[i] * self.zi[j] * Doi[i]**0.5 * Doi[j]**0.5 * ( 1 - self.kij[i][j])**4 Eo += self.zi[i] * self.zi[j] * Eoi[i]**0.5 * Eoi[j]**0.5 * ( 1 - self.kij[i][j])**5 self.Aoi = Aoi self.Boi = Boi self.Coi = Coi self.Doi = Doi self.Eoi = Eoi self.ai = ai self.bi = bi self.ci = ci self.di = di self.alfai = alfai self.gammai = gammai self.Ao = Ao self.Co = Co self.Do = Do self.Eo = Eo self.Bo = Bo self.a = a self.b = b self.c = c self.d = d self.alfa = alfa self.gamma = gamma Vm = lambda V: self.P.atm - R_atml * self.T / V - ( Bo * R_atml * self.T - Ao - Co / self.T**2 + Do / self.T**3 - Eo / self.T**4) / V**2 - ( b * R_atml * self.T - a - d / self.T) / V**3 - alfa * ( a + d / self.T) / V**6 - c / self.T**2 / V**3 * ( 1 + gamma / V**2) * exp(-gamma / V**2) # Usamos SRK para estimar los volumenes de ambas fases usados como valores iniciales en la iteeración srk = SRK(T, P, mezcla) Z_srk = srk.Z Vgo = Z_srk[0] * R_atml * T / P Vlo = Z_srk[1] * R_atml * T / P Vg = fsolve(Vm, Vgo) Vl = fsolve(Vm, Vlo) self.V = r_[Vg, Vl] #mol/l self.Z = P * self.V / R_atml / T self.H_exc = ( Bo * R_atml * self.T - 2 * Ao - 4 * Co / self.T**2 + 5 * Do / self.T**3 - 6 * Eo / self.T**4) / self.V + ( 2 * b * R_atml * self.T - 3 * a - 4 * d / self.T ) / 2 / self.V**2 + alfa / 5 * ( 6 * a + 7 * d / self.T) / self.V**5 + c / gamma / self.T**2 * ( 3 - (3 + gamma / self.V**2 / 2 - gamma**2 / self.V**4) * exp(-gamma / self.V**2)) self.x, self.xi, self.yi, self.Ki = self._Flash()
def __init__(self, ids, EoSIndex=0, parent=None): """Constructor""" super(Ui_BIP, self).__init__(parent) self.setWindowTitle( QtWidgets.QApplication.translate( "pychemqt", "BIP (Binary interaction parameters)")) lyt = QtWidgets.QGridLayout(self) lyt.addWidget(QtWidgets.QLabel("EoS"), 1, 1) self.eleccion = QtWidgets.QComboBox() lyt.addWidget(self.eleccion, 1, 2) lyt.addItem( QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed), 1, 3) self.stacked = QtWidgets.QStackedWidget() lyt.addWidget(self.stacked, 2, 1, 1, 3) # Get component names to show in table header names = [] for cmp in ids: databank.execute("SELECT id, name FROM compuestos WHERE id==%i" % cmp) names.append("%4i - %s" % databank.fetchone()) args = (len(ids), len(ids)) kw = { "stretch": False, "readOnly": True, "horizontalHeader": names, "verticalHeaderLabels": names } title = {"WILSON": "Aij", "UNIQUAC": "ΔUij", "NRTL": "Gij"} # Iterate over the EoS available for EoS in EoSBIP: self.eleccion.addItem(EoS) k = Kij(ids, EoS) widget = QtWidgets.QWidget() lyt2 = QtWidgets.QVBoxLayout(widget) lyt2.addWidget(QtWidgets.QLabel(title.get(EoS, "Kij"))) table1 = Tabla(*args, **kw) lyt2.addWidget(table1) # Special case for NRTL with two interaction parameters matrix if EoS == "NRTL": lyt2.addWidget(QtWidgets.QLabel("α")) table2 = Tabla(*args, **kw) lyt2.addWidget(table2) kij, aij = k table1.setData(kij) table2.setData(aij) table1.resizeColumnsToContents() table2.resizeColumnsToContents() else: table1.setData(k) table1.resizeColumnsToContents() self.stacked.addWidget(widget) self.eleccion.currentIndexChanged.connect(self.stacked.setCurrentIndex) button = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) button.accepted.connect(self.accept) button.rejected.connect(self.reject) lyt.addWidget(button, 3, 1, 1, 3) self.eleccion.setCurrentIndex(EoSIndex)
def _mixture(self, eq, ids, par): self.kij = Kij(ids, eq) mixpar = Mixing_Rule(self.mezcla.fraccion, par, self.kij) return mixpar