Example #1
0
    def setKwargs(self, kwarg):
        config = getMainWindowConfig()
        self.setConfig(config)
        for key in ["MEoS", "iapws", "GERG", "freesteam", "coolProp",
                    "refprop"]:
            if kwarg[key] != Corriente.kwargs[key]:
                self.__getattribute__(key).setChecked(kwarg[key])

        if kwarg["K"] != Corriente.kwargs["K"]:
            index = K_name.index(kwarg["K"])
            self.K.setCurrentIndex(index)
        if kwarg["H"] != Corriente.kwargs["H"]:
            index = H_name.index(kwarg["H"])
            self.H.setCurrentIndex(index)
        if kwarg["mix"] != Corriente.kwargs["mix"]:
            index = mix.index(kwarg["mix"])
            self.mixing_rule.setCurrentIndex(index)
        if kwarg["Cp_ideal"] != Corriente.kwargs["Cp_ideal"]:
            self.Cp_ideal.setCurrentIndex(kwarg["Cp_ideal"])
        if kwarg["alfa"] != Corriente.kwargs["alfa"]:
            try:
                index = alfa.index(kwarg["alfa"])
                self.alfa.setCurrentIndex(index)
            except ValueError:
                pass
Example #2
0
    def setKwargs(self, kwarg):
        config = getMainWindowConfig()
        self.setConfig(config)
        for key in [
                "MEoS", "iapws", "GERG", "freesteam", "coolProp", "refprop"
        ]:
            if kwarg[key] != Corriente.kwargs[key]:
                self.__getattribute__(key).setChecked(kwarg[key])

        if kwarg["K"] != Corriente.kwargs["K"]:
            index = K_name.index(kwarg["K"])
            self.K.setCurrentIndex(index)
        if kwarg["H"] != Corriente.kwargs["H"]:
            index = H_name.index(kwarg["H"])
            self.H.setCurrentIndex(index)
        if kwarg["mix"] != Corriente.kwargs["mix"]:
            index = mix.index(kwarg["mix"])
            self.mixing_rule.setCurrentIndex(index)
        if kwarg["Cp_ideal"] != Corriente.kwargs["Cp_ideal"]:
            self.Cp_ideal.setCurrentIndex(kwarg["Cp_ideal"])
        if kwarg["alfa"] != Corriente.kwargs["alfa"]:
            try:
                index = alfa.index(kwarg["alfa"])
                self.alfa.setCurrentIndex(index)
            except ValueError:
                pass
Example #3
0
    def __lib(self, compuesto, T):
        Tr=T/compuesto.Tc
        a=0.457235*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.077796*R_atml*compuesto.Tc/compuesto.Pc.atm

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            alfa=(1+compuesto.MathiasCopeman[0]*(1-Tr**0.5))**2
        else:
            alfa=(1+compuesto.MathiasCopeman[0]*(1-Tr**0.5)+compuesto.MathiasCopeman[1]*(1-Tr**0.5)**2+compuesto.MathiasCopeman[2]*(1-Tr**0.5)**3)**2
        return a*alfa, b, a, m
Example #4
0
    def __lib(self, compuesto, T):
        Tr=T/compuesto.Tc
        a=0.457235*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.077796*R_atml*compuesto.Tc/compuesto.Pc.atm

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            alfa=(1+compuesto.MathiasCopeman[0]*(1-Tr**0.5))**2
        else:
            alfa=(1+compuesto.MathiasCopeman[0]*(1-Tr**0.5)+compuesto.MathiasCopeman[1]*(1-Tr**0.5)**2+compuesto.MathiasCopeman[2]*(1-Tr**0.5)**3)**2
        return a*alfa, b, a, m
Example #5
0
    def __lib(self, compuesto, T):
        """Librería de cálculo de la ecuación de estado de Soave-Redlich-Kwong,"""
        Tr=T/compuesto.Tc
        ac=0.42748*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.08664*R_atml*compuesto.Tc/compuesto.Pc.atm
        m=0.48508+1.55191*compuesto.f_acent-0.15613*compuesto.f_acent**2

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            alfa=exp(compuesto.Androulakis[0]*(1-Tr**(2./3)))
        else:
            alfa=(1+compuesto.Androulakis[0]*(1-Tr**(2./3))+compuesto.Androulakis[1]*(1-Tr**(2./3))**2+compuesto.Androulakis[2]*(1-Tr**(2./3))**3)**2
        return ac*alfa, b, ac, m
Example #6
0
    def __lib(self, compuesto, T):
        """Librería de cálculo de la ecuación de estado de Soave-Redlich-Kwong,"""
        Tr=T/compuesto.Tc
        ac=0.42748*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.08664*R_atml*compuesto.Tc/compuesto.Pc.atm
        m=0.48508+1.55191*compuesto.f_acent-0.15613*compuesto.f_acent**2

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            alfa=exp(compuesto.Androulakis[0]*(1-Tr**(2./3)))
        else:
            alfa=(1+compuesto.Androulakis[0]*(1-Tr**(2./3))+compuesto.Androulakis[1]*(1-Tr**(2./3))**2+compuesto.Androulakis[2]*(1-Tr**(2./3))**3)**2
        return ac*alfa, b, ac, m
Example #7
0
    def __lib(self, compuesto, T):
        Tr = T / compuesto.Tc
        a = 0.457235 * R_atml**2 * compuesto.Tc**2 / compuesto.Pc.atm
        b = 0.077796 * R_atml * compuesto.Tc / compuesto.Pc.atm
        m = 0.37464 + 1.54226 * compuesto.f_acent - 0.26992 * compuesto.f_acent**2

        Config = config.getMainWindowConfig()
        Alpha_Mathias = Config.getint("Thermo", "Alfa")
        if Alpha_Mathias == 1 and Tr > 1:
            d = 1. + m / 2.
            c = 1. - 1. / d
            alfa = exp(c * (1 - Tr**d))**2
        else:
            alfa = (1 + m * (1 - Tr**0.5))**2
        return a * alfa, b, a, m
Example #8
0
    def __lib(self, compuesto, T):
        Tr=T/compuesto.Tc
        a=0.457235*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.077796*R_atml*compuesto.Tc/compuesto.Pc.atm
        m=0.37464+1.54226*compuesto.f_acent-0.26992*compuesto.f_acent**2

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            d=1.+m/2.
            c=1.-1./d
            alfa=exp(c*(1-Tr**d))**2
        else:
            alfa=(1+m*(1-Tr**0.5))**2
        return a*alfa, b, a, m
Example #9
0
    def __lib(self, compuesto, T):
        """Librería de cálculo de la ecuación de estado de Soave-Redlich-Kwong,"""
        Tr = T / compuesto.Tc
        ac = 0.42748 * R_atml**2 * compuesto.Tc**2 / compuesto.Pc.atm
        b = 0.08664 * R_atml * compuesto.Tc / compuesto.Pc.atm
        m = 0.48505 + 1.55171 * compuesto.f_acent - 0.15613 * compuesto.f_acent**2

        Config = config.getMainWindowConfig()
        Alpha_Mathias = Config.getint("Thermo", "Alfa")
        if Alpha_Mathias == 1 and Tr > 1:
            d = 1. + m / 2.
            c = 1. - 1. / d
            alfa = exp(c * (1 - Tr**d))**2
        else:
            alfa = (1 + m * (1 - Tr**0.5))**2
        return ac * alfa, b, ac, m
Example #10
0
    def __lib(self, compuesto, T):
        """Librería de cálculo de la ecuación de estado de Soave-Redlich-Kwong,"""
        Tr=T/compuesto.Tc
        ac=0.42748*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.08664*R_atml*compuesto.Tc/compuesto.Pc.atm
        m=0.48508+1.55191*compuesto.f_acent-0.15613*compuesto.f_acent**2

        Config=config.getMainWindowConfig()
        Alpha_Mathias=Config.getint("Thermo","Alfa")
        if Alpha_Mathias==1 and Tr>1:
            d=1.+m/2.+0.3*compuesto.Mathias
            c=1.-1./d
            alfa=exp(c*(1-Tr**d))**2
        else:
            alfa=(1+m*(1-Tr**0.5)*compuesto.Mathias*(1-Tr)*(0.7-Tr))**2
        return ac*alfa, b, ac, m
Example #11
0
    def calculo(self):
        if self.kwargs["solids"] is not None:
            self.ids = self.kwargs["solids"]
        else:
            Config = getMainWindowConfig()
            txt = Config.get("Components", "Solids")
            if isinstance(txt, str):
                self.ids = eval(txt)
            else:
                self.ids = txt
        self.componente = [Componente(int(i)) for i in self.ids]

        caudal = self.kwargs.get("caudalSolido", [])
        diametro_medio = self.kwargs.get("diametroMedio", 0.0)
        fraccion = self.kwargs.get("distribucion_fraccion", [])
        diametros = self.kwargs.get("distribucion_diametro", [])

        if self.status == 0:
            self._bool = False
            return
        else:
            self._bool = True

        self.caudalUnitario = [MassFlow(i) for i in caudal]
        self.caudal = MassFlow(sum(self.caudalUnitario))
        self.diametros = diametros
        self.fracciones = fraccion
        if self.status == 2:
            self.diametros = [
                Length(i, "m", magnitud="ParticleDiameter") for i in diametros
            ]
            self.fracciones = fraccion
            diametro_medio = 0
            self.fracciones_acumuladas = [0]
            for di, xi in zip(diametros, fraccion):
                diametro_medio += di * xi
                self.fracciones_acumuladas.append(
                    xi + self.fracciones_acumuladas[-1])
            del self.fracciones_acumuladas[0]
        self.diametro_medio = Length(diametro_medio,
                                     magnitud="ParticleDiameter")
        self.RhoS(self.kwargs.get("T", 300))
Example #12
0
    def __lib(self, compuesto, T):
        Tr = T / compuesto.Tc
        a = 0.42748 * R_atml**2 * compuesto.Tc**2 / compuesto.Pc.atm
        b = 0.08664 * R_atml * compuesto.Tc / compuesto.Pc.atm
        if not compuesto.SRKGraboski[1]:
            m = 0.48505 + 1.55171 * compuesto.f_acent - 0.15613 * compuesto.f_acent**2

            Config = config.getMainWindowConfig()
            Alpha_Mathias = Config.getint("Thermo", "Alfa")
            if Alpha_Mathias == 1 and Tr > 1:
                d = 1. + m / 2.
                c = 1. - 1. / d
                alfa = exp(c * (1 - Tr**d))**2
            else:
                alfa = (1 + m * (1 - Tr**0.5))**2
        elif not compuesto.SRKGraboski[0]:
            S1 = 0.48508 + 1.55171 * compuesto.f_acent - 0.15613 * compuesto.f_acent**2
            S2 = compuesto.SRKGraboski[1]
            alfa = (1 + S1 * (1 - Tr**0.5) + S2 * (1 - Tr**0.5) / Tr**0.5)**2
        return a * alfa, b
Example #13
0
    def __lib(self, compuesto, T):
        Tr=T/compuesto.Tc
        a=0.42748*R_atml**2*compuesto.Tc**2/compuesto.Pc.atm
        b=0.08664*R_atml*compuesto.Tc/compuesto.Pc.atm
        if not compuesto.SRKGraboski[1]:
            m=0.48505+1.55171*compuesto.f_acent-0.15613*compuesto.f_acent**2

            Config=config.getMainWindowConfig()
            Alpha_Mathias=Config.getint("Thermo","Alfa")
            if Alpha_Mathias==1 and Tr>1:
                d=1.+m/2.
                c=1.-1./d
                alfa=exp(c*(1-Tr**d))**2
            else:
                alfa=(1+m*(1-Tr**0.5))**2
        elif not compuesto.SRKGraboski[0]:
            S1=0.48508+1.55171*compuesto.f_acent-0.15613*compuesto.f_acent**2
            S2=compuesto.SRKGraboski[1]
            alfa=(1+S1*(1-Tr**0.5)+S2*(1-Tr**0.5)/Tr**0.5)**2
        return  a*alfa, b
Example #14
0
    def calculo(self):
        if self.kwargs["solids"] is not None:
            self.ids = self.kwargs["solids"]
        else:
            Config = getMainWindowConfig()
            txt = Config.get("Components", "Solids")
            if isinstance(txt, str):
                self.ids = eval(txt)
            else:
                self.ids = txt
        self.componente = [Componente(int(i)) for i in self.ids]

        caudal = self.kwargs.get("caudalSolido", [])
        diametro_medio = self.kwargs.get("diametroMedio", 0.0)
        fraccion = self.kwargs.get("distribucion_fraccion", [])
        diametros = self.kwargs.get("distribucion_diametro", [])

        if self.status == 0:
            self._bool = False
            return
        else:
            self._bool = True

        self.caudalUnitario = [MassFlow(i) for i in caudal]
        self.caudal = MassFlow(sum(self.caudalUnitario))
        self.diametros = diametros
        self.fracciones = fraccion
        if self.status == 2:
            self.diametros = [Length(i, "m", magnitud="ParticleDiameter")
                              for i in diametros]
            self.fracciones = fraccion
            diametro_medio = 0
            self.fracciones_acumuladas = [0]
            for di, xi in zip(diametros, fraccion):
                diametro_medio += di*xi
                self.fracciones_acumuladas.append(
                    xi+self.fracciones_acumuladas[-1])
            del self.fracciones_acumuladas[0]
        self.diametro_medio = Length(diametro_medio,
                                     magnitud="ParticleDiameter")
        self.RhoS(self.kwargs.get("T", 300))
Example #15
0
 def showBIP(self):
     config = getMainWindowConfig()
     ids = eval(config.get("Components", "components"))
     index = EoSBIP.index(K_status[self.K.currentIndex()])
     dlg = BIP.Ui_BIP(ids, index)
     dlg.exec_()
Example #16
0
def Mix_Panagiotopoulos(parameters, kij):
    """Mixing Rules of Panagiotopoulos (1985)"""
    ai = parameters[0]
    bi = parameters[1:]
    b = [0]*len(bi)
    a = 0
    for i in range(len(self.componente)):
        for j in range(len(bi)):
            b[j] += self.fraccion[i]*bi[j][i]
        for j in range(len(self.componente)):
            a += self.fraccion[i]*self.fraccion[j]*(ai[i]*ai[j])**0.5*(1-kij[i][j]+(kij[i][j]-kij[j][i])*self.fraccion[i])
    return tuple([a]+b)

def Mix_Melhem(parameters, kij):
    """Mixing Rules of Melhem (1991)"""
    ai = parameters[0]
    bi = parameters[1:]
    b = [0]*len(bi)
    a = 0
    for i in range(len(self.componente)):
        for j in range(len(bi)):
            b[j] += self.fraccion[i]*bi[j][i]
        for j in range(len(self.componente)):
            a += self.fraccion[i]*self.fraccion[j]*(ai[i]*ai[j])**0.5*(1-kij[i][j]+(kij[i][j]-kij[j][i])*self.fraccion[i]/(self.fraccion[i]+self.fraccion[j]))
    return tuple([a]+b)


mixing = [Mix_vdW1f, Mix_Stryjek_Vera, Mix_Panagiotopoulos, Mix_Melhem]
conf = config.getMainWindowConfig().getint("Thermo", "Mixing")
Mixing_Rule = mixing[conf]
Example #17
0
    def _method(self):
        """Find the thermodynamic method to use"""
        Config = config.getMainWindowConfig()

        # MEoS availability,
        if self.kwargs["MEoS"] is not None:
            _meos = self.kwargs["MEoS"]
        else:
            _meos = Config.getboolean("Thermo", "MEoS")
        mEoS_available = self.ids[0] in mEoS.id_mEoS
        MEoS = _meos and len(self.ids) == 1 and mEoS_available

        # iapws availability
        if self.kwargs["iapws"] is not None:
            _iapws = self.kwargs["iapws"]
        else:
            _iapws = Config.getboolean("Thermo", "iapws")
        IAPWS = _iapws and len(self.ids) == 1 and self.ids[0] == 62

        # freesteam availability
        if self.kwargs["freesteam"] is not None:
            _freesteam = self.kwargs["freesteam"]
        else:
            _freesteam = Config.getboolean("Thermo", "freesteam")
        FREESTEAM = _freesteam and len(self.ids) == 1 and \
            self.ids[0] == 62 and os.environ["freesteam"]

        COOLPROP_available = True
        GERG_available = True
        REFPROP_available = True
        for id in self.ids:
            if id not in coolProp.__all__:
                COOLPROP_available = False
            if id not in refProp.__all__:
                REFPROP_available = False
            if id not in gerg.id_GERG:
                GERG_available = False

        # coolprop availability
        if self.kwargs["coolProp"] is not None:
            _coolprop = self.kwargs["coolProp"]
        else:
            _coolprop = Config.getboolean("Thermo", "coolprop")
        COOLPROP = _coolprop and os.environ["CoolProp"] and COOLPROP_available

        # refprop availability
        if self.kwargs["refprop"] is not None:
            _refprop = self.kwargs["refprop"]
        else:
            _refprop = Config.getboolean("Thermo", "refprop")
        REFPROP = _refprop and os.environ["refprop"] and REFPROP_available

        # GERG availability
        if self.kwargs["GERG"] is not None:
            _gerg = self.kwargs["GERG"]
        else:
            _gerg = Config.getboolean("Thermo", "GERG")
        GERG = _gerg and GERG_available

        # Final selection
        if IAPWS and FREESTEAM:
            self._thermo = "freesteam"
            self._dependence = "freesteam"
        elif IAPWS:
            self._thermo = "iapws"
        elif _meos and REFPROP:
            self._thermo = "refprop"
            self._dependence = "refprop"
        elif _meos and COOLPROP:
            self._thermo = "coolprop"
            self._dependence = "CoolProp"
        elif MEoS and GERG:
            self._thermo = "gerg"
        elif MEoS:
            self._thermo = "meos"
        else:
            self._thermo = "eos"
Example #18
0
    b = [0] * len(bi)
    a = 0
    for i in range(len(self.componente)):
        for j in range(len(bi)):
            b[j] += self.fraccion[i] * bi[j][i]
        for j in range(len(self.componente)):
            a += self.fraccion[i] * self.fraccion[j] * (ai[i] * ai[j])**0.5 * (
                1 - kij[i][j] + (kij[i][j] - kij[j][i]) * self.fraccion[i])
    return tuple([a] + b)


def Mix_Melhem(parameters, kij):
    """Mixing Rules of Melhem (1991)"""
    ai = parameters[0]
    bi = parameters[1:]
    b = [0] * len(bi)
    a = 0
    for i in range(len(self.componente)):
        for j in range(len(bi)):
            b[j] += self.fraccion[i] * bi[j][i]
        for j in range(len(self.componente)):
            a += self.fraccion[i] * self.fraccion[j] * (ai[i] * ai[j])**0.5 * (
                1 - kij[i][j] + (kij[i][j] - kij[j][i]) * self.fraccion[i] /
                (self.fraccion[i] + self.fraccion[j]))
    return tuple([a] + b)


mixing = [Mix_vdW1f, Mix_Stryjek_Vera, Mix_Panagiotopoulos, Mix_Melhem]
conf = config.getMainWindowConfig().getint("Thermo", "Mixing")
Mixing_Rule = mixing[conf]
Example #19
0
    def __init__(self, curva=[], parent=None):
        """curva: Parametro opcional indicando la curva de la bomba"""
        super(Ui_bombaCurva, self).__init__(parent)
        self.setWindowTitle(
            QtGui.QApplication.translate("pychemqt", "Pump curves dialog"))
        self.showMaximized()

        self.gridLayout = QtGui.QGridLayout(self)
        self.botones = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Apply | QtGui.QDialogButtonBox.Open
            | QtGui.QDialogButtonBox.Save | QtGui.QDialogButtonBox.Reset,
            QtCore.Qt.Vertical)
        self.botones.clicked.connect(self.botones_clicked)
        self.gridLayout.addWidget(self.botones, 1, 1, 3, 1)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 1, 2, 3, 1)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Curves")),
            1, 3)
        self.lista = QtGui.QComboBox()
        self.lista.currentIndexChanged.connect(self.cambiarCurvaVista)
        self.gridLayout.addWidget(self.lista, 1, 4)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Diameter")),
            2, 3)
        self.diametro = Entrada_con_unidades(int, width=60, textounidad='"')
        self.gridLayout.addWidget(self.diametro, 2, 4)
        self.gridLayout.addWidget(
            QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "RPM")), 3,
            3)
        self.rpm = Entrada_con_unidades(int, width=60, textounidad="rpm")
        self.gridLayout.addWidget(self.rpm, 3, 4)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 4, 1, 1, 4)

        self.Tabla = Tabla(
            4,
            horizontalHeader=[
                QtGui.QApplication.translate("pychemqt", "Flowrate"),
                QtGui.QApplication.translate("pychemqt", "Head"),
                QtGui.QApplication.translate("pychemqt", "Power"),
                QtGui.QApplication.translate("pychemqt", "NPSH")
            ],
            verticalOffset=1,
            filas=1,
            stretch=False)
        self.Tabla.setColumnWidth(0, 100)
        self.unidadesCaudal = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 0, self.unidadesCaudal)
        self.Tabla.setColumnWidth(1, 80)
        self.unidadesCarga = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 1, self.unidadesCarga)
        self.Tabla.setColumnWidth(2, 80)
        self.unidadesPotencia = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 2, self.unidadesPotencia)
        self.Tabla.setColumnWidth(3, 80)
        self.unidadesNPSH = QtGui.QComboBox()
        self.Tabla.setCellWidget(0, 3, self.unidadesNPSH)
        self.Tabla.setRowHeight(0, 24)
        self.Tabla.setFixedWidth(360)
        self.Tabla.setConnected()
        self.Tabla.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.gridLayout.addWidget(self.Tabla, 5, 1, 1, 4)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed), 1, 5, 5, 1)

        self.checkCarga = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Heat"))
        self.gridLayout.addWidget(self.checkCarga, 1, 6)
        self.checkPotencia = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Power"))
        self.gridLayout.addWidget(self.checkPotencia, 1, 7)
        self.checkNPSH = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "NPSH"))
        self.gridLayout.addWidget(self.checkNPSH, 1, 8)
        self.rejilla = QtGui.QCheckBox(
            QtGui.QApplication.translate("pychemqt", "Grid"))
        self.rejilla.toggled.connect(self.rejilla_toggled)
        self.gridLayout.addWidget(self.rejilla, 1, 9)
        self.gridLayout.addItem(
            QtGui.QSpacerItem(1000, 20, QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Fixed), 1, 10)
        self.Plot = Plot(self, width=5, height=1, dpi=100)
        self.gridLayout.addWidget(self.Plot, 2, 6, 4, 5)

        self.buttonBox = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.gridLayout.addWidget(self.buttonBox, 6, 9, 1, 2)

        if curva:
            self.curvas = curva
            for i in curva:
                self.lista.addItem(str(i[0]) + '", ' + str(i[1]) + " rpm")
            self.lista.setCurrentIndex(self.lista.count() - 1)
            self.cambiarCurvaVista(self.lista.count() - 1)

            #            self.curva=curva[-1]
            #            self.diametro.setValue(self.curva[0])
            #            self.rpm.setValue(self.curva[1])
            #            self.Tabla.setMatrix(self.curva[2:])
            #            self.Tabla.addRow()
            self.actualizarPlot()
        else:
            self.curva = []

        for i in Length.__text__:
            self.unidadesCarga.addItem(i)
            self.unidadesNPSH.addItem(i)
        for i in VolFlow.__text__:
            self.unidadesCaudal.addItem(i)
        for i in Power.__text__:
            self.unidadesPotencia.addItem(i)

        self.oldIndices = [0, 0, 0, 0]
        self.unidadesCaudal.currentIndexChanged.connect(
            partial(self.cambiar_unidades, 0, VolFlow, "VolFlow"))
        self.unidadesCarga.currentIndexChanged.connect(
            partial(
                self.cambiar_unidades,
                1,
                Length,
                "Head",
            ))
        self.unidadesPotencia.currentIndexChanged.connect(
            partial(self.cambiar_unidades, 2, Power, "Power"))
        self.unidadesNPSH.currentIndexChanged.connect(
            partial(
                self.cambiar_unidades,
                3,
                Length,
                "Head",
            ))

        Config = config.getMainWindowConfig()
        self.unidadesCaudal.setCurrentIndex(Config.getint("Units", "QLiq"))
        self.unidadesCarga.setCurrentIndex(Config.getint("Units", "Head"))
        self.unidadesPotencia.setCurrentIndex(Config.getint("Units", "Power"))
        self.unidadesNPSH.setCurrentIndex(Config.getint("Units", "Head"))

        self.checkCarga.toggled.connect(self.actualizarPlot)
        self.checkPotencia.toggled.connect(self.actualizarPlot)
        self.checkNPSH.toggled.connect(self.actualizarPlot)
Example #20
0
    def __init__(self, curva=[], parent=None):
        """curva: Parametro opcional indicando la curva de la bomba"""
        super(Ui_bombaCurva, self).__init__(parent)
        self.setWindowTitle(QtWidgets.QApplication.translate("pychemqt", "Pump curves dialog"))
        self.showMaximized()

        self.gridLayout = QtWidgets.QGridLayout(self)
        self.botones = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Apply
            | QtWidgets.QDialogButtonBox.Open
            | QtWidgets.QDialogButtonBox.Save
            | QtWidgets.QDialogButtonBox.Reset,
            QtCore.Qt.Vertical,
        )
        self.botones.clicked.connect(self.botones_clicked)
        self.gridLayout.addWidget(self.botones, 1, 1, 3, 1)
        self.gridLayout.addItem(
            QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 2, 3, 1
        )
        self.gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Curves")), 1, 3)
        self.lista = QtWidgets.QComboBox()
        self.lista.currentIndexChanged.connect(self.cambiarCurvaVista)
        self.gridLayout.addWidget(self.lista, 1, 4)
        self.gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Diameter")), 2, 3)
        self.diametro = Entrada_con_unidades(int, width=60, textounidad='"')
        self.gridLayout.addWidget(self.diametro, 2, 4)
        self.gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "RPM")), 3, 3)
        self.rpm = Entrada_con_unidades(int, width=60, textounidad="rpm")
        self.gridLayout.addWidget(self.rpm, 3, 4)
        self.gridLayout.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 4
        )

        self.Tabla = Tabla(
            4,
            horizontalHeader=[
                QtWidgets.QApplication.translate("pychemqt", "Flowrate"),
                QtWidgets.QApplication.translate("pychemqt", "Head"),
                QtWidgets.QApplication.translate("pychemqt", "Power"),
                QtWidgets.QApplication.translate("pychemqt", "NPSH"),
            ],
            verticalOffset=1,
            filas=1,
            stretch=False,
        )
        self.Tabla.setColumnWidth(0, 100)
        self.unidadesCaudal = QtWidgets.QComboBox()
        self.Tabla.setCellWidget(0, 0, self.unidadesCaudal)
        self.Tabla.setColumnWidth(1, 80)
        self.unidadesCarga = QtWidgets.QComboBox()
        self.Tabla.setCellWidget(0, 1, self.unidadesCarga)
        self.Tabla.setColumnWidth(2, 80)
        self.unidadesPotencia = QtWidgets.QComboBox()
        self.Tabla.setCellWidget(0, 2, self.unidadesPotencia)
        self.Tabla.setColumnWidth(3, 80)
        self.unidadesNPSH = QtWidgets.QComboBox()
        self.Tabla.setCellWidget(0, 3, self.unidadesNPSH)
        self.Tabla.setRowHeight(0, 24)
        self.Tabla.setFixedWidth(360)
        self.Tabla.setConnected()
        self.Tabla.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.gridLayout.addWidget(self.Tabla, 5, 1, 1, 4)
        self.gridLayout.addItem(
            QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 5, 5, 1
        )

        self.checkCarga = QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Heat"))
        self.gridLayout.addWidget(self.checkCarga, 1, 6)
        self.checkPotencia = QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Power"))
        self.gridLayout.addWidget(self.checkPotencia, 1, 7)
        self.checkNPSH = QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "NPSH"))
        self.gridLayout.addWidget(self.checkNPSH, 1, 8)
        self.rejilla = QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Grid"))
        self.rejilla.toggled.connect(self.rejilla_toggled)
        self.gridLayout.addWidget(self.rejilla, 1, 9)
        self.gridLayout.addItem(
            QtWidgets.QSpacerItem(1000, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed), 1, 10
        )
        self.Plot = Plot(self, width=5, height=1, dpi=100)
        self.gridLayout.addWidget(self.Plot, 2, 6, 4, 5)

        self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)
        self.gridLayout.addWidget(self.buttonBox, 6, 9, 1, 2)

        if curva:
            self.curvas = curva
            for i in curva:
                self.lista.addItem(str(i[0]) + '", ' + str(i[1]) + " rpm")
            self.lista.setCurrentIndex(self.lista.count() - 1)
            self.cambiarCurvaVista(self.lista.count() - 1)

            #            self.curva=curva[-1]
            #            self.diametro.setValue(self.curva[0])
            #            self.rpm.setValue(self.curva[1])
            #            self.Tabla.setMatrix(self.curva[2:])
            #            self.Tabla.addRow()
            self.actualizarPlot()
        else:
            self.curva = []

        for i in Length.__text__:
            self.unidadesCarga.addItem(i)
            self.unidadesNPSH.addItem(i)
        for i in VolFlow.__text__:
            self.unidadesCaudal.addItem(i)
        for i in Power.__text__:
            self.unidadesPotencia.addItem(i)

        self.oldIndices = [0, 0, 0, 0]
        self.unidadesCaudal.currentIndexChanged.connect(partial(self.cambiar_unidades, 0, VolFlow, "VolFlow"))
        self.unidadesCarga.currentIndexChanged.connect(partial(self.cambiar_unidades, 1, Length, "Head"))
        self.unidadesPotencia.currentIndexChanged.connect(partial(self.cambiar_unidades, 2, Power, "Power"))
        self.unidadesNPSH.currentIndexChanged.connect(partial(self.cambiar_unidades, 3, Length, "Head"))

        Config = config.getMainWindowConfig()
        self.unidadesCaudal.setCurrentIndex(Config.getint("Units", "QLiq"))
        self.unidadesCarga.setCurrentIndex(Config.getint("Units", "Head"))
        self.unidadesPotencia.setCurrentIndex(Config.getint("Units", "Power"))
        self.unidadesNPSH.setCurrentIndex(Config.getint("Units", "Head"))

        self.checkCarga.toggled.connect(self.actualizarPlot)
        self.checkPotencia.toggled.connect(self.actualizarPlot)
        self.checkNPSH.toggled.connect(self.actualizarPlot)
Example #21
0
            else:
                input.setResaltado(False)
        self.blockSignals(False)

    def reset(self):
        """Reset dialog widgets to initial clear status"""
        self.fluid = self.fluid.__class__()
        self.status.setState(self.fluid.status, self.fluid.msg)
        self.rhoo.clear()
        self.To.clear()
        for input in self.Inputs:
            input.clear()
            input.setResaltado(False)


if __name__ == "__main__":
    import sys
    from lib.refProp import RefProp
    from lib.mEoS import H2O

    app = QtWidgets.QApplication(sys.argv)
    conf = config.getMainWindowConfig()

    fluid = RefProp(ids=[62])
    # fluid = H2O()

    SteamTables = AddPoint(fluid)

    SteamTables.show()
    sys.exit(app.exec_())
Example #22
0
 def showBIP(self):
     config = getMainWindowConfig()
     ids = eval(config.get("Components", "components"))
     index = EoSBIP.index(K_status[self.K.currentIndex()])
     dlg = BIP.Ui_BIP(ids, index)
     dlg.exec_()
Example #23
0
    def calculo(self):
        Config = config.getMainWindowConfig()
        if self.kwargs["mezcla"]:
            self.mezcla = self.kwargs["mezcla"]
        else:
            self.mezcla = Mezcla(self.tipoFlujo, **self.kwargs)

        self.ids = self.mezcla.ids
        self.componente = self.mezcla.componente
        self.fraccion = self.mezcla.fraccion
        self.caudalmasico = self.mezcla.caudalmasico
        self.caudalmolar = self.mezcla.caudalmolar
        self.fraccion_masica = self.mezcla.fraccion_masica
        self.caudalunitariomasico = self.mezcla.caudalunitariomasico
        self.caudalunitariomolar = self.mezcla.caudalunitariomolar

        T = unidades.Temperature(self.kwargs.get("T", None))
        P = unidades.Pressure(self.kwargs.get("P", None))
        x = self.kwargs.get("x", None)

        self._method()
        setData = True

        if self._thermo == "freesteam":
            compuesto = freeSteam.Freesteam(**self.kwargs)
        elif self._thermo == "iapws":
            compuesto = iapws97.IAPWS97(**self.kwargs)
        elif self._thermo == "refprop":
            if not self.kwargs["ids"]:
                self.kwargs["ids"] = self.ids

            # Avoid overwrite refprop H parameter
            kwargs = self.kwargs.copy()
            del kwargs["H"]

            compuesto = refProp.RefProp(**kwargs)
        elif self._thermo == "gerg":
            ids = []
            for id in self.ids:
                ids.append(gerg.id_GERG.index(id))
            kwargs = self.kwargs
            kwargs["mezcla"] = self.mezcla
            compuesto = gerg.GERG(componente=ids, fraccion=self.fraccion, **kwargs)
        elif self._thermo == "coolprop":
            if not self.kwargs["ids"]:
                self.kwargs["ids"] = self.ids
            compuesto = coolProp.CoolProp(**self.kwargs)
        elif self._thermo == "meos":
            if self.tipoTermodinamica == "TP":
                compuesto = mEoS.__all__[mEoS.id_mEoS.index(self.ids[0])](T=T, P=P)
            elif self.tipoTermodinamica == "Tx":
                compuesto = mEoS.__all__[mEoS.id_mEoS.index(self.ids[0])](T=T, x=x)
            elif self.tipoTermodinamica == "Px":
                compuesto = mEoS.__all__[mEoS.id_mEoS.index(self.ids[0])](P=P, x=x)
        elif self._thermo == "eos":
            if self.kwargs["K"]:
                index = K_name.index(self.kwargs["K"])
                K = EoS.K[index]
                print(K)
            else:
                K = EoS.K[Config.getint("Thermo","K")]
            if self.kwargs["H"]:
                index = H_name.index(self.kwargs["H"])
                H = EoS.H[index]
                print(H)
            else:
                H = EoS.H[Config.getint("Thermo","H")]

            setData = False
            self.M = unidades.Dimensionless(self.mezcla.M)
            self.Tc = self.mezcla.Tc
            self.Pc = self.mezcla.Pc
            self.SG = unidades.Dimensionless(self.mezcla.SG)

            if self.tipoTermodinamica == "TP":
                self.T = unidades.Temperature(T)
                self.P = unidades.Pressure(P)
                eos = K(self.T, self.P.atm, self.mezcla)
                self.eos = eos
                self.x = unidades.Dimensionless(eos.x)
            else:
                self.x = unidades.Dimensionless(x)

#            self.mezcla.recallZeros(eos.xi)
#            self.mezcla.recallZeros(eos.yi)
#            self.mezcla.recallZeros(eos.Ki, 1.)

            if 0. < self.x < 1.:
                self.Liquido = Mezcla(tipo=5, fraccionMolar=eos.xi, caudalMolar=self.caudalmolar*(1-self.x))
                self.Gas = Mezcla(tipo=5, fraccionMolar=eos.yi, caudalMolar=self.caudalmolar*self.x)
            elif self.x <= 0:
                self.Liquido = self.mezcla
                self.Gas = Mezcla()
            else:
                self.Liquido = Mezcla()
                self.Gas = self.mezcla
            self.Gas.Z = unidades.Dimensionless(float(eos.Z[0]))
            self.Liquido.Z = unidades.Dimensionless(float(eos.Z[1]))

            if H == K:
                eosH = eos
            else:
                eosH = H(self.T, self.P.atm, self.mezcla)
            self.H_exc = eosH.H_exc

            self.Liquido.Q = unidades.VolFlow(0)
            self.Gas.Q = unidades.VolFlow(0)
            self.Liquido.h = unidades.Power(0)
            self.Gas.h = unidades.Power(0)
            if self.x < 1:
                # There is liquid phase
                Hl = (self.Liquido._Ho(self.T).Jg-self.Liquido.Hv_DIPPR(self.T).Jg)*self.Liquido.caudalmasico.gh
                self.Liquido.h = unidades.Power(Hl-R*self.T/self.M*self.H_exc[1]*(1-self.x)*self.Liquido.caudalmasico.gh, "Jh")
                self.Liquido.cp = self.Liquido.Cp_Liquido(T)
                self.Liquido.rho = self.Liquido.RhoL(T, self.P)
                self.Liquido.mu = self.Liquido.Mu_Liquido(T, self.P.atm)
                self.Liquido.k = self.Liquido.ThCond_Liquido(T, self.P.atm, self.Liquido.rho)
                self.Liquido.sigma = self.Liquido.Tension(T)
                self.Liquido.Q = unidades.VolFlow(self.Liquido.caudalmasico/self.Liquido.rho)
                self.Liquido.Prandt = self.Liquido.cp*self.Liquido.mu/self.Liquido.k
            if self.x > 0:
                # There is gas phase
                Hg = self.Gas._Ho(self.T).Jg*self.Gas.caudalmasico.gh
                self.Gas.h = unidades.Power(Hg-R*self.T/self.M*self.H_exc[0]*self.x*self.Gas.caudalmasico.gh, "Jh")
                self.Gas.cp = self.Gas.Cp_Gas(T, self.P.atm)
                self.Gas.rho = unidades.Density(self.P.atm/self.Gas.Z/R_atml/self.T*self.M, "gl")
                self.Gas.rhoSd = unidades.Density(1./self.Gas.Z/R_atml/298.15*self.M, "gl")
                self.Gas.mu = self.Gas.Mu_Gas(T, self.P.atm, self.Gas.rho)
                self.Gas.k = self.Gas.ThCond_Gas(T, self.P.atm, self.Gas.rho)
                self.Gas.Q = unidades.VolFlow(self.Gas.caudalmasico/self.Gas.rho)
                self.Gas.Prandt = self.Gas.cp*self.Gas.mu/self.Gas.k

            self.Q = unidades.VolFlow(self.Liquido.Q+self.Gas.Q)
            self.h = unidades.Power(self.Liquido.h+self.Gas.h)
            self.Molaridad = [caudal/self.Q.m3h for caudal in self.caudalunitariomolar]

            # TODO:
            self.cp_cv = 0.5
            self.cp_cv_ideal = 0.5
            self.s = 0
            self.rho = 0

        if setData:
            # Asignación de valores comun
            self.cmp = compuesto
            self.T = compuesto.T
            self.P = compuesto.P
            self.x = compuesto.x
            self.M = unidades.Dimensionless(compuesto.M)
            self.Tc = compuesto.Tc
            self.Pc = compuesto.Pc
            self.h = unidades.Power(compuesto.h*self.caudalmasico)
            self.s = unidades.Entropy(compuesto.s*self.caudalmasico)
            self.rho = compuesto.rho
            self.Q = unidades.VolFlow(compuesto.v*self.caudalmasico)

            # harcoded thermo derived global properties in corriente for avoid
            # losing data
            if self._thermo != "eos":
                compuesto._fillCorriente(self)

#        if self.__class__!=mEoS.H2O:
#            agua=mEoS.H2O(T=self.T, P=self.P.MPa)
#            self.SG=unidades.Dimensionless(self.rho/agua.rho)
#        else:
            self.SG = unidades.Dimensionless(1.)

            self.Liquido = compuesto.Liquido
            self.Gas = compuesto.Gas

#            if self.x<1:      #Fase líquida
#                self.Liquido=compuesto.Liquido
#            if self.x>0:       #Fase gaseosa
#                self.Gas=compuesto
#            elif 0<self.x<1:    #Ambas fases
#                self.Liquido=compuesto.Liquido
#                self.Gas=compuesto.Gas
#                self.QLiquido=self.Q*(1-self.x)
#            elif self.x==1:            #Fase gaseosa
#                self.Gas=compuesto
#                self.Liquido=None
#                self.QLiquido=unidades.VolFlow(0)
#                self.Gas.rhoSd=unidades.Density(1./R_atml/298.15*self.M, "gl")

            if self.x > 0:
                self.Gas.Q = unidades.VolFlow(self.Q*(1-self.x))
                self.Gas.caudalmasico = unidades.MassFlow(self.caudalmasico*self.x)
                self.Gas.caudalmolar = unidades.MolarFlow(self.caudalmolar*self.x)
                kw = mix_molarflow_molarfraction(
                    self.Gas.caudalmolar, self.Gas.fraccion, self.componente)
                self.Gas.caudalunitariomasico = [
                    unidades.MassFlow(f) for f in kw["unitMassFlow"]]
                self.Gas.caudalunitariomolar = [
                    unidades.MolarFlow(f) for f in kw["unitMolarFlow"]]
                self.Gas.ids = self.ids

            if self.x < 1:
                self.Liquido.Q = unidades.VolFlow(self.Q*(1-self.x))
                self.Liquido.caudalmasico = unidades.MassFlow(self.caudalmasico*(1-self.x))
                self.Liquido.caudalmolar = unidades.MolarFlow(self.caudalmolar*(1-self.x))
                kw = mix_molarflow_molarfraction(
                    self.Liquido.caudalmolar, self.Liquido.fraccion, self.componente)
                self.Liquido.caudalunitariomasico = [
                    unidades.MassFlow(f) for f in kw["unitMassFlow"]]
                self.Liquido.caudalunitariomolar = [
                    unidades.MolarFlow(f) for f in kw["unitMolarFlow"]]
                self.Liquido.sigma = compuesto.sigma
                self.Liquido.ids = self.ids

        if Config.get("Components", "Solids"):
            if self.kwargs["solido"]:
                self.solido = self.kwargs["solido"]
            else:
                self.solido = Solid(**self.kwargs)
            if self.solido.status:
                self.solido.RhoS(T)
        else:
            self.solido = None

        if self.kwargs["caudalVolumetrico"]:
            self.kwargs["caudalMolar"] *= self.kwargs["caudalVolumetrico"]/self.Q
            Q = self.kwargs["caudalVolumetrico"]
            self.kwargs["caudalVolumetrico"] = None
            self.calculo()
            self.kwargs["caudalVolumetrico"] = Q
            self.kwargs["caudalMolar"] = None