class CalculateDialog(QtWidgets.QDialog): """Dialog to calculate a specified point""" def __init__(self, parent=None): super(CalculateDialog, self).__init__(parent) title = QtWidgets.QApplication.translate("pychemqt", "Calculate friction factor") self.setWindowTitle(title) layout = QtWidgets.QGridLayout(self) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")) layout.addWidget(label, 1, 0) self.metodos = QtWidgets.QComboBox() for f in f_list: line = f.__doc__.split("\n")[0] year = line.split(" ")[-1] name = line.split(" ")[-3] doc = name + " " + year self.metodos.addItem(doc) self.metodos.currentIndexChanged.connect(self.calculate) layout.addWidget(self.metodos, 1, 1, 1, 2) self.fanning = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Calculate fanning friction factor")) self.fanning.toggled.connect(self.calculate) layout.addWidget(self.fanning, 2, 0, 1, 3) layout.addWidget(QtWidgets.QLabel("Re"), 3, 1) self.Re = Entrada_con_unidades(float, tolerancia=4) self.Re.valueChanged.connect(self.calculate) layout.addWidget(self.Re, 3, 2) layout.addWidget(QtWidgets.QLabel("e/D"), 4, 1) self.eD = Entrada_con_unidades(float) self.eD.valueChanged.connect(self.calculate) layout.addWidget(self.eD, 4, 2) layout.addWidget(QtWidgets.QLabel("f"), 5, 1) self.f = Entrada_con_unidades(float, readOnly=True, decimales=8) layout.addWidget(self.f, 5, 2) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Close) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) def calculate(self, value): index = self.metodos.currentIndex() F = f_list[index] Re = self.Re.value eD = self.eD.value if Re and eD is not None: f = F(Re, eD) if self.fanning.isChecked(): f /= 4 self.f.setValue(f)
class CalculateDialog(QtWidgets.QDialog): """Dialog to calculate a specified point""" def __init__(self, parent=None): super(CalculateDialog, self).__init__(parent) title = QtWidgets.QApplication.translate( "pychemqt", "Calculate friction factor") self.setWindowTitle(title) layout = QtWidgets.QGridLayout(self) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")) layout.addWidget(label, 1, 0) self.metodos = QtWidgets.QComboBox() for f in f_list: line = f.__doc__.split("\n")[1] year = line.split(" ")[-1] name = line.split(" ")[-3] doc = name + " " + year self.metodos.addItem(doc) self.metodos.currentIndexChanged.connect(self.calculate) layout.addWidget(self.metodos, 1, 1, 1, 2) self.fanning = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Calculate fanning friction factor")) self.fanning.toggled.connect(self.calculate) layout.addWidget(self.fanning, 2, 0, 1, 3) layout.addWidget(QtWidgets.QLabel("Re"), 3, 1) self.Re = Entrada_con_unidades(float, tolerancia=4) self.Re.valueChanged.connect(self.calculate) layout.addWidget(self.Re, 3, 2) layout.addWidget(QtWidgets.QLabel("e/D"), 4, 1) self.eD = Entrada_con_unidades(float) self.eD.valueChanged.connect(self.calculate) layout.addWidget(self.eD, 4, 2) layout.addWidget(QtWidgets.QLabel("f"), 5, 1) self.f = Entrada_con_unidades(float, readOnly=True, decimales=8) layout.addWidget(self.f, 5, 2) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Close) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) def calculate(self, value): index = self.metodos.currentIndex() F = f_list[index] Re = self.Re.value eD = self.eD.value if Re and eD is not None: f = F(Re, eD) if self.fanning.isChecked(): f /= 4 self.f.setValue(f)
class CalculateDialog(QtWidgets.QDialog): """Dialog to calculate a specified point""" def __init__(self, parent=None): super(CalculateDialog, self).__init__(parent) title = QtWidgets.QApplication.translate( "pychemqt", "Calculate compressibility factor of natural gas") self.setWindowTitle(title) layout = QtWidgets.QGridLayout(self) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")) layout.addWidget(label, 1, 0) self.method = QtWidgets.QComboBox() for Z in Z_list: name = Z.__name__[2:].replace("_", "-") year = re.search("((\d+))", Z.__doc__).group(0) doc = "%s (%s)" % (name, year) self.method.addItem(doc) self.method.currentIndexChanged.connect(self.calculate) layout.addWidget(self.method, 1, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("Tr"), 2, 1) self.Tr = Entrada_con_unidades(float, tolerancia=4) self.Tr.valueChanged.connect(self.calculate) layout.addWidget(self.Tr, 2, 2) layout.addWidget(QtWidgets.QLabel("Pr"), 3, 1) self.Pr = Entrada_con_unidades(float) self.Pr.valueChanged.connect(self.calculate) layout.addWidget(self.Pr, 3, 2) layout.addWidget(QtWidgets.QLabel("Z"), 4, 1) self.Z = Entrada_con_unidades(float, readOnly=True, decimales=8) layout.addWidget(self.Z, 4, 2) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Close) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) def calculate(self, value): index = self.method.currentIndex() Z = Z_list[index] Tr = self.Tr.value Pr = self.Pr.value if Pr and Tr is not None: z = Z(Tr, Pr) self.Z.setValue(z)
class CalculateDialog(QtWidgets.QDialog): """Dialog to calculate a specified point""" def __init__(self, parent=None): super(CalculateDialog, self).__init__(parent) title = QtWidgets.QApplication.translate( "pychemqt", "Calculate compressibility factor of natural gas") self.setWindowTitle(title) layout = QtWidgets.QGridLayout(self) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")) layout.addWidget(label, 1, 0) self.method = QtWidgets.QComboBox() for Z in Z_list: name = Z.__name__[2:].replace("_", "-") year = re.search("((\d+))", Z.__doc__).group(0) doc = "%s (%s)" % (name, year) self.method.addItem(doc) self.method.currentIndexChanged.connect(self.calculate) layout.addWidget(self.method, 1, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("Tr"), 2, 1) self.Tr = Entrada_con_unidades(float, tolerancia=4) self.Tr.valueChanged.connect(self.calculate) layout.addWidget(self.Tr, 2, 2) layout.addWidget(QtWidgets.QLabel("Pr"), 3, 1) self.Pr = Entrada_con_unidades(float) self.Pr.valueChanged.connect(self.calculate) layout.addWidget(self.Pr, 3, 2) layout.addWidget(QtWidgets.QLabel("Z"), 4, 1) self.Z = Entrada_con_unidades(float, readOnly=True, decimales=8) layout.addWidget(self.Z, 4, 2) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Close) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) def calculate(self, value): index = self.method.currentIndex() Z = Z_list[index] Tr = self.Tr.value Pr = self.Pr.value if Pr and Tr is not None: z = Z(Tr, Pr) self.Z.setValue(z)
class UI_reacciones(QtWidgets.QDialog): reaction = reaction.Reaction() def __init__(self, reaccion=None, parent=None): super(UI_reacciones, self).__init__(parent) self.evaluate = Evaluate() self.evaluate.finished.connect(self.rellenar) self.indices, self.nombres, M = getComponents() gridLayout = QtWidgets.QGridLayout(self) lyt = QtWidgets.QHBoxLayout() lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Key component"))) self.key = QtWidgets.QComboBox() for i, nombre in enumerate(self.nombres): self.key.addItem("%i - %s" % (i + 1, nombre)) self.key.currentIndexChanged.connect(partial(self.changeParams, "key")) lyt.addWidget(self.key) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)) gridLayout.addLayout(lyt, 1, 1, 1, 5) lyt = QtWidgets.QHBoxLayout() lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Phase"))) self.fase = QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_PHASE: self.fase.addItem(txt) self.fase.currentIndexChanged.connect( partial(self.changeParams, "fase")) lyt.addWidget(self.fase) self.Formula = QtWidgets.QLabel() self.Formula.setAlignment(QtCore.Qt.AlignCenter) self.Formula.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) lyt.addWidget(self.Formula) gridLayout.addLayout(lyt, 2, 1, 1, 5) lyt = QtWidgets.QVBoxLayout() title = self.nombres[:] title.append("") self.Estequiometria = Tabla(1, verticalHeaderLabels=title, horizontalHeader=[ QtWidgets.QApplication.translate( "pychemqt", "Coefficients") ], filas=len(self.indices)) self.Estequiometria.setFixedHeight(22 * len(self.indices) + 22 + 4 + 22) lyt.addWidget(self.Estequiometria) self.Estequiometria.addRow() brush = QtGui.QBrush(QtGui.QColor("#eaeaea")) self.Estequiometria.item(len(self.indices), 0).setBackground(brush) self.Estequiometria.item(len(self.indices), 0).setFlags(QtCore.Qt.NoItemFlags) self.Estequiometria.cellChanged.connect(self.reaccionCambiada) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)) gridLayout.addLayout(lyt, 3, 1, 1, 2) lyt = QtWidgets.QGridLayout() lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 1) self.formula = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Use name in formula")) self.formula.toggled.connect(partial(self.changeParams, "formula")) lyt.addWidget(self.formula, 1, 2, 1, 2) self.customHr = QtWidgets.QCheckBox( "ΔHr " + QtWidgets.QApplication.translate("pychemqt", "user specified")) self.customHr.toggled.connect(self.changeHr) lyt.addWidget(self.customHr, 2, 2, 1, 2) lyt.addWidget(QtWidgets.QLabel("ΔHr<sup>o</sup>"), 3, 2) self.Hr = Entrada_con_unidades(unidades.MolarEnthalpy, readOnly=True) self.Hr.valueChanged.connect(partial(self.changeParams, "Hr")) lyt.addWidget(self.Hr, 3, 3) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding)) gridLayout.addLayout(lyt, 3, 3, 1, 2) gridLayout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 2) lyt = QtWidgets.QHBoxLayout() lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Type"))) self.tipo = QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_TYPE: self.tipo.addItem(txt) self.tipo.currentIndexChanged.connect( partial(self.changeParams, "tipo")) lyt.addWidget(self.tipo) lyt.addItem( QtWidgets.QSpacerItem(20, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Concentration"))) self.base = QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_BASE: self.base.addItem(txt) self.base.currentIndexChanged.connect( partial(self.changeParams, "base")) lyt.addWidget(self.base) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)) gridLayout.addLayout(lyt, 5, 1, 1, 5) self.stacked = QtWidgets.QStackedWidget() self.tipo.currentIndexChanged.connect(self.stacked.setCurrentIndex) gridLayout.addWidget(self.stacked, 6, 1, 1, 5) gridLayout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 1, 1, 5) widget = QtWidgets.QWidget() self.stacked.addWidget(widget) lyt = QtWidgets.QGridLayout(widget) lyt.addWidget( QtWidgets.QLabel("<h3>" + QtWidgets.QApplication.translate( "pychemqt", "Estequiometric reaction") + "</h3>"), 1, 1, 1, 4) self.Conversion = Tabla(1, verticalHeaderModel="C", filas=3) self.Conversion.setConnected() self.Conversion.setFixedWidth(100) lyt.addWidget(self.Conversion, 2, 1, 3, 1) label = QtWidgets.QLabel() label.setPixmap( QtGui.QPixmap(os.environ["pychemqt"] + "/images/equation/reaction_conversion.png")) lyt.addWidget(label, 2, 2, 1, 3) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Temperature unit")), 3, 2) self.unidadesTemperatura = QtWidgets.QComboBox() for i in unidades.Temperature.__text__: self.unidadesTemperatura.addItem(i) lyt.addWidget(self.unidadesTemperatura, 3, 3) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 4, 4) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 5, 1, 1, 5) widget = QtWidgets.QWidget() self.stacked.addWidget(widget) lyt = QtWidgets.QGridLayout(widget) self.check_KFijo = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Fixed")) self.check_KFijo.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KFijo, 1, 1, 1, 2) lyt.addWidget(QtWidgets.QLabel("K<sub>eq</sub>"), 1, 3) self.Keq = Entrada_con_unidades(float) lyt.addWidget(self.Keq, 1, 4) label = QtWidgets.QLabel() label.setPixmap( QtGui.QPixmap(os.environ["pychemqt"] + "/images/equation/reaction_equilibrium.png")) lyt.addWidget(label, 1, 5, 1, 4) self.check_KEq = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Equation")) self.check_KEq.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KEq, 2, 1, 1, 2) self.check_KTabla = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Table")) self.check_KTabla.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KTabla, 2, 5, 1, 2) self.KEq_Dat = Tabla( 1, verticalHeaderLabels=["A", "B", "C", "D", "E", "F", "G", "H"], filas=8) self.KEq_Dat.setFixedHeight(22 * 8 + 4) self.KEq_Dat.setFixedWidth(120) lyt.addWidget(self.KEq_Dat, 3, 3, 1, 2) self.KEq_Tab = Tabla( 4, horizontalHeader=["T, K", "Keq", "Kcalc", "%Error"], verticalHeader=False, columnReadOnly=[False, False, True, True]) self.KEq_Tab.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.KEq_Tab.setFixedWidth(400) self.KEq_Tab.setConnected() self.KEq_Tab.rowFinished.connect(self.Regresion) self.KEq_Tab.setAlternatingRowColors(False) lyt.addWidget(self.KEq_Tab, 3, 5, 1, 4) lyt.addWidget(QtWidgets.QLabel("r²"), 4, 5) self.r2 = Entrada_con_unidades(float, readOnly=True) lyt.addWidget(self.r2, 4, 6) self.botonTablaPlot = QtWidgets.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.environ["pychemqt"] + "/images/button/plot.png")), QtWidgets.QApplication.translate("pychemqt", "Plot")) self.botonTablaPlot.clicked.connect(self.Plot) lyt.addWidget(self.botonTablaPlot, 4, 7) self.botonTablaClear = QtWidgets.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.environ["pychemqt"] + "/images/button/clear.png")), QtWidgets.QApplication.translate("pychemqt", "Clear")) self.botonTablaClear.clicked.connect(self.KEq_Tab.clear) lyt.addWidget(self.botonTablaClear, 4, 8) label = QtWidgets.QLabel() label.setPixmap( QtGui.QPixmap(os.environ["pychemqt"] + "/images/equation/reaction_equilibrium2.png")) label.setAlignment(QtCore.Qt.AlignCenter) lyt.addWidget(label, 5, 1, 1, 8) self.checkGibbs = QtWidgets.QRadioButton( QtWidgets.QApplication.translate( "pychemqt", "From Gibbs free energy minimization")) lyt.addWidget(self.checkGibbs, 6, 1, 1, 4) self.check_KFijo.setChecked(True) widget = QtWidgets.QWidget() self.stacked.addWidget(widget) lyt = QtWidgets.QGridLayout(widget) widget = QtWidgets.QWidget() self.stacked.addWidget(widget) lyt = QtWidgets.QGridLayout(widget) self.status = Status() gridLayout.addWidget(self.status, 10, 1) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) gridLayout.addWidget(self.buttonBox, 10, 2, 1, 4) if reaccion: self.setReaction(reaccion) def changeParams(self, parametro, valor): self.calculo(**{parametro: valor}) def calculo(self, **kwargs): self.status.setState(4) self.evaluate.start(self.reaction, kwargs) def changeHr(self, bool): self.Hr.setReadOnly(not bool) self.changeParams("customHr", bool) def reaccionCambiada(self): kwargs = { "componentes": self.indices, "coeficientes": self.Estequiometria.getColumn(0)[:-1] } self.calculo(**kwargs) def setReaction(self, reaction): self.reaction = reaction self.rellenar() # if self.Estequiometria.getValue(0, self.Base.currentIndex()): # reaccion=reaction.Reaction(self.indices, self.Estequiometria.getColumn(0), base=self.Base.currentIndex(), estequiometria=[0, 0, 0.5], formulas=self.checkFormula.isChecked(), calor=self.checkCalorEspecificado.isChecked(), Hr=self.Hr.value, tipo=self.tipo.currentIndex(), conversion=self.Conversion.getColumn(0)[-1::-1]) # self.Balance.setValue(reaccion.error) # if reaccion.state: # self.Formula.setText(reaccion._txt(self.checkFormula.isChecked())) # self.Hr.setValue(reaccion.Hr) # else: # self.Formula.clear() # self.Hr.clear() # self.botonAdd.setEnabled(reaccion.state and not self.botonEdit.isChecked()) # self.reaccion=reaccion def rellenar(self): self.blockSignals(True) for variable in self.reaction.kwargsValue: self.__getattribute__(variable).setValue( self.reaction.kwargs[variable]) for combo in self.reaction.kwargsList: self.__getattribute__(combo).setCurrentIndex( self.reaction.kwargs[combo]) for check in self.reaction.kwargsCheck: self.__getattribute__(check).setChecked( self.reaction.kwargs[check]) self.Estequiometria.setColumn(0, self.reaction.kwargs["coeficientes"]) # self.Conversion.setColumn(0, self.reaction.estequiometria[-1::-1]) self.blockSignals(False) self.status.setState(self.reaction.status, self.reaction.msg) self.Estequiometria.item(len(self.indices), 0).setText(str(self.reaction.error)) if self.reaction.status: self.Formula.setText(self.reaction._txt()) self.Hr.setValue(self.reaction.Hr) def KeqChanged(self): self.Keq.setReadOnly(not self.check_KFijo.isChecked()) self.KEq_Dat.setEnabled(self.check_KEq.isChecked()) self.KEq_Tab.setEnabled(self.check_KTabla.isChecked()) self.botonTablaClear.setEnabled(self.check_KTabla.isChecked()) self.botonTablaPlot.setEnabled(self.check_KTabla.isChecked()) def Regresion(self): t = array(self.KEq_Tab.getColumn(0)[:-1]) k = array(self.KEq_Tab.getColumn(1)[:-1]) if len(t) >= 4: if 4 <= len(t) < 8: inicio = r_[0, 0, 0, 0] f = lambda par, T: exp(par[0] + par[1] / T + par[2] * log(T) + par[3] * T) resto = lambda par, T, k: k - f(par, T) else: inicio = r_[0, 0, 0, 0, 0, 0, 0, 0] f = lambda par, T: exp(par[0] + par[1] / T + par[2] * log( T) + par[3] * T + par[4] * T**2 + par[5] * T**3 + par[6] * T**4 + par[7] * T**5) resto = lambda par, T, k: k - f(par, T) ajuste = leastsq(resto, inicio, args=(t, k)) kcalc = f(ajuste[0], t) error = (k - kcalc) / k * 100 self.KEq_Dat.setColumn(0, ajuste[0]) self.KEq_Tab.setColumn(2, kcalc) self.KEq_Tab.setColumn(3, error) if ajuste[1] in [1, 2, 3, 4]: self.ajuste = ajuste[0] def Plot(self): if self.ajuste != None: t = array(self.KEq_Tab.getColumn(0)[:-1]) k = array(self.KEq_Tab.getColumn(1)[:-1]) if 4 <= len(t) < 8: f = lambda par, T: exp(par[0] + par[1] / T + par[2] * log(T) + par[3] * T) else: f = lambda par, T: exp(par[0] + par[1] / T + par[2] * log( T) + par[3] * T + par[4] * T**2 + par[5] * T**3 + par[6] * T**4 + par[7] * T**5) grafico = plot.Plot() grafico.data(t, k, 'ro', t, f(self.ajuste, t)) grafico.exec_()
class UI_equipment(UI_equip): """Diálogo de definición de tamices de sólidos""" Equipment = Screen() def __init__(self, equipment=None, parent=None): """ equipment: instancia de equipo inicial """ super(UI_equipment, self).__init__(Screen, entrada=False, parent=parent) #Pestaña entrada # self.Entrada= UI_corriente.Ui_corriente(entrada) # self.Entrada.Changed.connect(self.cambiar_entrada) # self.tabWidget.insertTab(0, self.Entrada, QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Area:", None)), 1, 1, 1, 1) self.Area = Entrada_con_unidades(unidades.Area) self.Area.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Area, 1, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 0, 1, 2) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) gridLayout_Costos.addWidget(self.Costos, 4, 1, 2, 5) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 6, 0, 1, 6) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 6) self.groupBox_Costos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos, 7, 0, 1, 6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)), 0, 1, 1, 1) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 0, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)), 1, 1, 1, 1) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 1, 2, 1, 1) #Pestaña salida self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido = UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab( self.SalidaGas, QtWidgets.QApplication.translate("equipment", "Gas filtrado", None)) self.Salida.addTab( self.SalidaSolido, QtWidgets.QApplication.translate("equipment", "Sólidos recogidos", None)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex() == 0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class FoulingWidget(QtGui.QWidget): """Widget con los parametros de fouling de tuberias""" valueChanged = QtCore.pyqtSignal(float) Fouling_Factor = { "Industrial": { "Fuel oil no.2": 0.000352, "Fuel oil no.6": 0.000881, "Transformer oil": 0.000173, "Engine Lube oil": 0.000173, "Quench oil": 0.000705, "Manufactured gas": 0.001761, "Engine exhaust gas": 0.001761, "Steam (nonoil bearing)": 0.000088, "Exhaust steam (oil bearing)": 0.0003, "Refrigerant vapors (Oil bearing)": 0.000352, "Compressed air": 0.000176, "Ammonia vapor": 0.000176, "CO2 vapor": 0.000176, "Chlorine vapor": 0.000352, "Coal flue gas": 0.001761, "Natural gas flue gas": 0.000881, "Molten heat transfer salts": 0.000088, "Refrigerant liquids": 0.000176, "Hydraulic fluid": 0.000176, "Industrial organic heat transfer media": 0.000352, "Ammonia liquid": 0.000176, "Ammonia liquid (oil bearing)": 0.000528, "Calcium chloride solutions": 0.000528, "Sodium chloride solutions": 0.000528, "CO2 liquid": 0.000176, "Chlorine liquid": 0.000352, "Methanol solutions": 0.000352, "Ethanol solutions": 0.000352, "Ethilene glycol solutions": 0.000352}, "Chemical": { "Acid gases": 0.00044, "Solvent vapors": 0.000176, "Stable overhead products": 0.000176, "MEA and DEA solutions": 0.000352, "DEG and TEG solutions": 0.000352, "Stable side draw and bottom product": 0.00026, "Caustic solutions": 0.000352, "Vegetable oils": 0.000528}, "Natural Gas-Gasoline": { "Natural gas": 0.00026, "Overhead products": 0.00026, "Lean oil": 0.000352, "Rich oil": 0.00026, "Natural gasoline": 0.00026, "Liquified petroleum gases": 0.00026}, u"Water (T<50C, v<0.9)": { "Seawater": 0.000088, "Brackish water": 0.000352, "Cooling tower (treated)": 0.000176, "Cooling tower (untreaterd)": 0.000528, "City or well water": 0.000176, "River water minimum": 0.000352, "River water average": 0.000528, "Muddy or silty": 0.000528, "Hard (>15 grains/gal": 0.000528, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, u"Water (T<50C, v>0.9)": { "Seawater": 0.000088, "Brackish water": 0.000176, "Cooling tower (treated)": 0.000176, "Cooling tower (untreaterd)": 0.000528, "City or well water": 0.000176, "River water minimum": 0.000176, "River water average": 0.000352, "Muddy or silty": 0.000352, "Hard (>15 grains/gal": 0.000528, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000088}, u"Water (T>50C, v<0.9)": { "Seawater": 0.000176, "Brackish water": 0.000528, "Cooling tower (treated)": 0.000352, "Cooling tower (untreaterd)": 0.000881, "City or well water": 0.000352, "River water minimum": 0.000528, "River water average": 0.000705, "Muddy or silty": 0.000705, "Hard (>15 grains/gal": 0.000881, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, u"Water (T>50C, v>0.9)": { "Seawater": 0.000176, "Brackish water": 0.000352, "Cooling tower (treated)": 0.000352, "Cooling tower (untreaterd)": 0.000705, "City or well water": 0.000352, "River water minimum": 0.000352, "River water average": 0.000528, "Muddy or silty": 0.000528, "Hard (>15 grains/gal": 0.000881, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, u"Refinery vapors": { "Atmospheric tower overhead vapors": 0.000176, "Light naphthas": 0.000176, "Vacuum overhead vapors": 0.000352}, u"Refinery liq.": { "Crude oil dry T<120C, v<0.6": 0.000528, "Crude oil salt T<120C, v<0.6": 0.000528, "Crude oil dry T<120C, 0.6<v<1.2": 0.000352, "Crude oil salt T<120C, 0.6<v<1.2": 0.000352, "Crude oil dry T<120C, 1.2<v": 0.000352, "Crude oil salt T<120C, 1.2<v": 0.000352, "Crude oil dry 120C<T<175C, v<0.6": 0.000528, "Crude oil salt 120C<T<175C, v<0.6": 0.000881, "Crude oil dry 120C<T<175C, 0.6<v<1.2": 0.000352, "Crude oil salt 120C<T<175C, 0.6<v<1.2": 0.000705, "Crude oil dry 120C<T<175C, 1.2<v": 0.000352, "Crude oil salt 120C<T<175C, 1.2<v": 0.000705, "Crude oil dry 175C<T<230C, v<0.6": 0.000705, "Crude oil salt 175C<T<230C, v<0.6": 0.001057, "Crude oil dry 175C<T<230C, 0.6<v<1.2": 0.000528, "Crude oil salt 175C<T<230C, 0.6<v<1.2": 0.000881, "Crude oil dry 175C<T<230C, 1.2<v": 0.000528, "Crude oil salt 175C<T<230C, 1.2<v": 0.000881, "Crude oil dry T>230C, v<0.6": 0.000881, "Crude oil salt T>230C, v<0.6": 0.001233, "Crude oil dry T>230C, 0.6<v<1.2": 0.000705, "Crude oil salt T>230C, 0.6<v<1.2": 0.001057, "Crude oil dry T>230C, 1.2<v": 0.000705, "Crude oil salt T>230C, 1.2<v": 0.001057, "Gasoline": 0.000352, "Naphtha and light distillates": 0.00044, "Kerosene": 0.00044, "Light gas oil": 0.00044, "Heavy gas oil": 0.00067, "Heavy fuel oils": 0.00105}, u"Refinery Asphalt": { "Vacuum tower bottoms": 0.001761, "Atmosphere tower bottoms": 0.001233}, u"Refinery Cracking and caking": { "Overhead vapors": 0.000352, "Light cycle oil": 0.00044, "Heavy cycle oil": 0.00061, "Light coker gas oil": 0.00061, "Heavy coker gas oil": 0.00079, "Bottoms slurry oil": 0.000528, "Light liquid products": 0.000176}, u"Refinery Reforming": { "Reformer charge": 0.000264, "Reformer effluent": 0.000264, "Hydrocracker charge and effluent": 0.000352, "Recycle gas": 0.000176, "Overhead vapors": 0.000176, "Liquid product >50 API": 0.000176, "Liquid product 30-50 API": 0.000352}, u"Refinery Light Ends": { "Overhead vapors and gases": 0.000176, "Liquid products": 0.000176, "Absorption oils": 0.00044, "Alkylation trace acid streams": 0.000352, "Reboiler streams": 0.00044}, u"Refinery Lube oil": { "Feed stock": 0.000352, "Solvent feed mix": 0.000352, "Solvent": 0.000176, "Extract": 0.000528, "Rafftnate": 0.000176, "Asphalt": 0.000881, "Wax slurries": 0.000528, "Refined lube oil": 0.000176}, u"Refinery Visbreaker": { "Overhead vapor": 0.000528, "Visbreaker bottoms": 0.001761}, u"Refinery Naphtha Hydrotreater": { "Feed": 0.000528, "Effluent": 0.000352, "Naphfthas": 0.000352, "Overhead vapors": 0.000264}, u"Refinery Catalytic": { "Charge": 0.00079, "Effluent": 0.000352, "H.T. separator": 0.000352, "Stripper charge": 0.000528, "Liquid products": 0.000352}, u"Refinery HF Alky": { "Alkylate, deprop. bottons, main fract": 0.000528, "Other": 0.000352}} def __init__(self, parent=None): super(FoulingWidget, self).__init__(parent) layout = QtGui.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.list = QtGui.QComboBox() self.list.addItem("") layout.addWidget(self.list) self.value = Entrada_con_unidades(Fouling, decimales=6) self.value.valueChanged.connect(self.valueChanged.emit) layout.addWidget(self.value) for tipo in sorted(self.Fouling_Factor): self.list.insertSeparator(self.list.count()+1) for componente in sorted(self.Fouling_Factor[tipo]): self.list.addItem(" - ".join([tipo, componente])) self.list.currentIndexChanged["QString"].connect(self.rellenar) def setValue(self, value): self.value.setValue(value) def rellenar(self, txt): if txt: tipo, componente = txt.split(" - ") value = self.Fouling_Factor[str(tipo)][str(componente)] self.value.setReadOnly(True) self.value.setValue(value) self.valueChanged.emit(value) else: self.value.setReadOnly(False)
class UI_equipment(parents.UI_equip): """Diálogo de definición de tamices de sólidos""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Centrifuge, entrada=False, parent=parent) self.entrada=entrada #Pestaña entrada self.Entrada= UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab(0, self.Entrada,QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipo=QtWidgets.QComboBox() self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Proceso inorgánico", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Proceso orgánico", None)) self.tipo.currentIndexChanged.connect(self.mostrarSubclasificacion) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 2, 1, 1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Material:", None)), 2, 1, 1, 1) self.materialInorganico=QtWidgets.QComboBox() self.materialInorganico.addItem(QtWidgets.QApplication.translate("equipment", "Acero al carbón", None)) self.materialInorganico.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialInorganico.addItem(QtWidgets.QApplication.translate("equipment", "Monel", None)) self.materialInorganico.addItem(QtWidgets.QApplication.translate("equipment", "Níquel", None)) self.materialInorganico.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.materialInorganico, 2, 2, 1, 1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),3,0,1,2) self.materialOrganico=QtWidgets.QComboBox() self.materialOrganico.addItem(QtWidgets.QApplication.translate("equipment", "Acero al carbón", None)) self.materialOrganico.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialOrganico.addItem(QtWidgets.QApplication.translate("equipment", "Monel", None)) self.materialOrganico.addItem(QtWidgets.QApplication.translate("equipment", "Níquel", None)) self.materialOrganico.addItem(QtWidgets.QApplication.translate("equipment", "Hastelloy", None)) self.materialOrganico.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.materialOrganico, 2, 2, 1, 1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),3,0,1,6) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Caudal calculado:", None)), 4, 1, 1, 1) self.caudalcalculado=Entrada_con_unidades(unidades.MassFlow, readOnly=True, retornar=False) gridLayout_Costos.addWidget(self.caudalcalculado,4,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Caudal de diseño:", None)), 5, 1, 1, 1) self.caudaldiseno=Entrada_con_unidades(unidades.MassFlow) gridLayout_Costos.addWidget(self.caudaldiseno,5,2,1,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),6,0,1,6) self.Costos=costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos,7,1,2,2) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),9,0,1,6) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),11,0,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,10,0,1,6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),0,1,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),1,1,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst,1,2,1,1) self.tabWidget.setCurrentIndex(0) self.mostrarSubclasificacion(0) def mostrarSubclasificacion(self, ind): self.materialInorganico.setVisible(not ind) self.materialOrganico.setVisible(ind) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex()==0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class UI_equipment(parents.UI_equip): """Diálogo de definición de molinos trituradores de sólidos""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Grinder, entrada=False, salida=False, parent=parent) self.entrada=entrada #Pestaña entrada self.Entrada= UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab(0, self.Entrada, QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Índice de trabajo de bond:", None)), 1, 0, 1, 1) self.Material=QtWidgets.QComboBox() self.Material.addItem(QtWidgets.QApplication.translate("equipment", "Definido por el usuario", None)) for key in sorted(BondIndex.keys()): self.Material.addItem(key) self.Material.currentIndexChanged[str].connect(self.cambiarBondWordIndex) gridLayout_Calculo.addWidget(self.Material, 1, 1, 1, 1) self.BondWorkIndex=Entrada_con_unidades(float) gridLayout_Calculo.addWidget(self.BondWorkIndex, 1, 2, 1, 1) gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,0,1,5) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipo=QtWidgets.QComboBox() self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "De cono", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Giratorio", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Dentado", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "De martillo", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "De bolas", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Pulverizador", None)) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 2, 1, 1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),2,1,1,2) self.Costos=costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos,4,1,2,5) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),6,1,1,6) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,1,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,7,1,1,6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),0,1,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),1,1,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst,1,2,1,1) #Pestaña salida self.Salida= UI_corriente.Ui_corriente(readOnly=True) self.tabWidget.insertTab(3, self.Salida,QtWidgets.QApplication.translate("equipment", "Salida", None)) self.tabWidget.setCurrentIndex(0) def cambiarBondWordIndex(self, txt): try: value=BondIndex[str(txt)] except KeyError: self.BondWorkIndex.setReadOnly(False) self.BondWorkIndex.clear() else: self.BondWorkIndex.setValue(value) self.BondWorkIndex.setReadOnly(True) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self, factor=None, indiceBase=None, indiceActual=None): if self.todos_datos(): if not factor: factor=self.Costos.factor if not indiceBase: indiceBase=self.Costos.Base if not indiceActual: indiceActual=self.Costos.Actual if self.tipo.currentIndex()==0: self.FireHeater.Coste(factor, indiceBase, indiceActual, 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(factor, indiceBase, indiceActual, 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class FoulingWidget(QtWidgets.QWidget): """Widget con los parametros de fouling de tuberias""" valueChanged = QtCore.pyqtSignal(float) Fouling_Factor = { "Industrial": { "Fuel oil no.2": 0.000352, "Fuel oil no.6": 0.000881, "Transformer oil": 0.000173, "Engine Lube oil": 0.000173, "Quench oil": 0.000705, "Manufactured gas": 0.001761, "Engine exhaust gas": 0.001761, "Steam (nonoil bearing)": 0.000088, "Exhaust steam (oil bearing)": 0.0003, "Refrigerant vapors (Oil bearing)": 0.000352, "Compressed air": 0.000176, "Ammonia vapor": 0.000176, "CO2 vapor": 0.000176, "Chlorine vapor": 0.000352, "Coal flue gas": 0.001761, "Natural gas flue gas": 0.000881, "Molten heat transfer salts": 0.000088, "Refrigerant liquids": 0.000176, "Hydraulic fluid": 0.000176, "Industrial organic heat transfer media": 0.000352, "Ammonia liquid": 0.000176, "Ammonia liquid (oil bearing)": 0.000528, "Calcium chloride solutions": 0.000528, "Sodium chloride solutions": 0.000528, "CO2 liquid": 0.000176, "Chlorine liquid": 0.000352, "Methanol solutions": 0.000352, "Ethanol solutions": 0.000352, "Ethilene glycol solutions": 0.000352}, "Chemical": { "Acid gases": 0.00044, "Solvent vapors": 0.000176, "Stable overhead products": 0.000176, "MEA and DEA solutions": 0.000352, "DEG and TEG solutions": 0.000352, "Stable side draw and bottom product": 0.00026, "Caustic solutions": 0.000352, "Vegetable oils": 0.000528}, "Natural Gas-Gasoline": { "Natural gas": 0.00026, "Overhead products": 0.00026, "Lean oil": 0.000352, "Rich oil": 0.00026, "Natural gasoline": 0.00026, "Liquified petroleum gases": 0.00026}, "Water (T<50C, v<0.9)": { "Seawater": 0.000088, "Brackish water": 0.000352, "Cooling tower (treated)": 0.000176, "Cooling tower (untreaterd)": 0.000528, "City or well water": 0.000176, "River water minimum": 0.000352, "River water average": 0.000528, "Muddy or silty": 0.000528, "Hard (>15 grains/gal": 0.000528, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, "Water (T<50C, v>0.9)": { "Seawater": 0.000088, "Brackish water": 0.000176, "Cooling tower (treated)": 0.000176, "Cooling tower (untreaterd)": 0.000528, "City or well water": 0.000176, "River water minimum": 0.000176, "River water average": 0.000352, "Muddy or silty": 0.000352, "Hard (>15 grains/gal": 0.000528, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000088}, "Water (T>50C, v<0.9)": { "Seawater": 0.000176, "Brackish water": 0.000528, "Cooling tower (treated)": 0.000352, "Cooling tower (untreaterd)": 0.000881, "City or well water": 0.000352, "River water minimum": 0.000528, "River water average": 0.000705, "Muddy or silty": 0.000705, "Hard (>15 grains/gal": 0.000881, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, "Water (T>50C, v>0.9)": { "Seawater": 0.000176, "Brackish water": 0.000352, "Cooling tower (treated)": 0.000352, "Cooling tower (untreaterd)": 0.000705, "City or well water": 0.000352, "River water minimum": 0.000352, "River water average": 0.000528, "Muddy or silty": 0.000528, "Hard (>15 grains/gal": 0.000881, "Engine jacket": 0.000176, "Distilled, condensate": 0.000088, "Distilled, boiler blowdown": 0.000352, "Distilled, treated boiler feedwater": 0.000176}, "Refinery vapors": { "Atmospheric tower overhead vapors": 0.000176, "Light naphthas": 0.000176, "Vacuum overhead vapors": 0.000352}, "Refinery liq.": { "Crude oil dry T<120C, v<0.6": 0.000528, "Crude oil salt T<120C, v<0.6": 0.000528, "Crude oil dry T<120C, 0.6<v<1.2": 0.000352, "Crude oil salt T<120C, 0.6<v<1.2": 0.000352, "Crude oil dry T<120C, 1.2<v": 0.000352, "Crude oil salt T<120C, 1.2<v": 0.000352, "Crude oil dry 120C<T<175C, v<0.6": 0.000528, "Crude oil salt 120C<T<175C, v<0.6": 0.000881, "Crude oil dry 120C<T<175C, 0.6<v<1.2": 0.000352, "Crude oil salt 120C<T<175C, 0.6<v<1.2": 0.000705, "Crude oil dry 120C<T<175C, 1.2<v": 0.000352, "Crude oil salt 120C<T<175C, 1.2<v": 0.000705, "Crude oil dry 175C<T<230C, v<0.6": 0.000705, "Crude oil salt 175C<T<230C, v<0.6": 0.001057, "Crude oil dry 175C<T<230C, 0.6<v<1.2": 0.000528, "Crude oil salt 175C<T<230C, 0.6<v<1.2": 0.000881, "Crude oil dry 175C<T<230C, 1.2<v": 0.000528, "Crude oil salt 175C<T<230C, 1.2<v": 0.000881, "Crude oil dry T>230C, v<0.6": 0.000881, "Crude oil salt T>230C, v<0.6": 0.001233, "Crude oil dry T>230C, 0.6<v<1.2": 0.000705, "Crude oil salt T>230C, 0.6<v<1.2": 0.001057, "Crude oil dry T>230C, 1.2<v": 0.000705, "Crude oil salt T>230C, 1.2<v": 0.001057, "Gasoline": 0.000352, "Naphtha and light distillates": 0.00044, "Kerosene": 0.00044, "Light gas oil": 0.00044, "Heavy gas oil": 0.00067, "Heavy fuel oils": 0.00105}, "Refinery Asphalt": { "Vacuum tower bottoms": 0.001761, "Atmosphere tower bottoms": 0.001233}, "Refinery Cracking and caking": { "Overhead vapors": 0.000352, "Light cycle oil": 0.00044, "Heavy cycle oil": 0.00061, "Light coker gas oil": 0.00061, "Heavy coker gas oil": 0.00079, "Bottoms slurry oil": 0.000528, "Light liquid products": 0.000176}, "Refinery Reforming": { "Reformer charge": 0.000264, "Reformer effluent": 0.000264, "Hydrocracker charge and effluent": 0.000352, "Recycle gas": 0.000176, "Overhead vapors": 0.000176, "Liquid product >50 API": 0.000176, "Liquid product 30-50 API": 0.000352}, "Refinery Light Ends": { "Overhead vapors and gases": 0.000176, "Liquid products": 0.000176, "Absorption oils": 0.00044, "Alkylation trace acid streams": 0.000352, "Reboiler streams": 0.00044}, "Refinery Lube oil": { "Feed stock": 0.000352, "Solvent feed mix": 0.000352, "Solvent": 0.000176, "Extract": 0.000528, "Rafftnate": 0.000176, "Asphalt": 0.000881, "Wax slurries": 0.000528, "Refined lube oil": 0.000176}, "Refinery Visbreaker": { "Overhead vapor": 0.000528, "Visbreaker bottoms": 0.001761}, "Refinery Naphtha Hydrotreater": { "Feed": 0.000528, "Effluent": 0.000352, "Naphfthas": 0.000352, "Overhead vapors": 0.000264}, "Refinery Catalytic": { "Charge": 0.00079, "Effluent": 0.000352, "H.T. separator": 0.000352, "Stripper charge": 0.000528, "Liquid products": 0.000352}, "Refinery HF Alky": { "Alkylate, deprop. bottons, main fract": 0.000528, "Other": 0.000352}} def __init__(self, parent=None): super(FoulingWidget, self).__init__(parent) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.list = QtWidgets.QComboBox() self.list.addItem("") layout.addWidget(self.list) self.value = Entrada_con_unidades(Fouling, decimales=6) self.value.valueChanged.connect(self.valueChanged.emit) layout.addWidget(self.value) for tipo in sorted(self.Fouling_Factor): self.list.insertSeparator(self.list.count()+1) for componente in sorted(self.Fouling_Factor[tipo]): self.list.addItem(" - ".join([tipo, componente])) self.list.currentIndexChanged["QString"].connect(self.rellenar) def setValue(self, value): self.value.setValue(value) def rellenar(self, txt): if txt: tipo, componente = txt.split(" - ") value = self.Fouling_Factor[str(tipo)][str(componente)] self.value.setReadOnly(True) self.value.setValue(value) self.valueChanged.emit(value) else: self.value.setReadOnly(False)
class Dialog_Finned(QtWidgets.QDialog): """Dialog to define finned tube properties""" def __init__(self, kwarg=None, parent=None): super(Dialog_Finned, self).__init__(parent=parent) self.setWindowTitle(QtWidgets.QApplication.translate( "pychemqt", "Specify tube finned characteristics")) layout = QtWidgets.QGridLayout(self) self.listTube = QtWidgets.QComboBox() self.listTube.addItem("") layout.addWidget(self.listTube, 0, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 1, 1, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Material")), 2, 1) self.listMaterial = QtWidgets.QComboBox() self.listMaterial.addItem("") self.listMaterial.addItem(QtWidgets.QApplication.translate( "pychemqt", "Carbon Steel")) layout.addWidget(self.listMaterial, 2, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Thermal Conductivity")), 3, 1) self.kFin = Entrada_con_unidades(ThermalConductivity) layout.addWidget(self.kFin, 3, 2) layout.addItem(QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Root diameter")), 5, 1) self.RootD = Entrada_con_unidades(Length, "PipeDiameter") layout.addWidget(self.RootD, 5, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Fin Height")), 6, 1) self.hFin = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.hFin, 6, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Base Fin Thickness")), 7, 1) self.BaseThickness = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.BaseThickness, 7, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Top Fin Thickness")), 8, 1) self.TopThickness = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.TopThickness, 8, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Number of fins")), 9, 1) self.Nfin = Entrada_con_unidades(float, textounidad="fins/m") layout.addWidget(self.Nfin, 9, 2) self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) for tuberia in finnedTube_database: self.listTube.addItem("%s %s" % (tuberia[0], tuberia[1])) self.listTube.currentIndexChanged.connect(self.rellenarData) self.listTube.currentIndexChanged.connect(self.setDisabled) if kwarg: self.hFin.setValue(kwarg["hFin"]) self.BaseThickness.setValue(kwarg["thicknessBaseFin"]) self.TopThickness.setValue(kwarg["thicknessTopFin"]) self.kFin.setValue(kwarg["kFin"]) self.Nfin.setValue(kwarg["nFin"]) self.RootD.setValue(kwarg["rootDoFin"]) def rellenarData(self, ind): tuberia = finnedTube_database[ind-1] if tuberia[0] == "HPT": self.Nfin.setValue(int(tuberia[1][:2])) self.BaseThickness.setValue(tuberia[12]/1000.) self.TopThickness.setValue(tuberia[12]/1000.) self.RootD.setValue(tuberia[6]/1000.) self.hFin.setValue(tuberia[13]/1000.) def setDisabled(self, bool): self.RootD.setReadOnly(bool) self.BaseThickness.setReadOnly(bool) self.TopThickness.setReadOnly(bool) self.Nfin.setReadOnly(bool) self.hFin.setReadOnly(bool) def kwarg(self): kwarg = {"hFin": self.hFin.value, "thicknessBaseFin": self.BaseThickness.value, "thicknessTopFin": self.TopThickness.value, "kFin": self.kFin.value, "nFin": self.Nfin.value, "rootDoFin": self.RootD.value} return kwarg
class Ui_ReferenceState(QtWidgets.QDialog): """Dialog for select reference state""" def __init__(self, config=None, parent=None): """config: instance with project config to set initial values""" super(Ui_ReferenceState, self).__init__(parent) self.setWindowTitle(QtWidgets.QApplication.translate( "pychemqt", "Select reference state")) layout = QtWidgets.QGridLayout(self) self.OTO = QtWidgets.QRadioButton(QtWidgets.QApplication.translate( "pychemqt", "OTO, h,s=0 at 298K and 1 atm")) layout.addWidget(self.OTO, 0, 1, 1, 7) self.NBP = QtWidgets.QRadioButton(QtWidgets.QApplication.translate( "pychemqt", "NBP, h,s=0 saturated liquid at Tb")) layout.addWidget(self.NBP, 1, 1, 1, 7) self.IIR = QtWidgets.QRadioButton(QtWidgets.QApplication.translate( "pychemqt", "IIR, h=200,s=1 saturated liquid at 273K")) layout.addWidget(self.IIR, 2, 1, 1, 7) self.ASHRAE = QtWidgets.QRadioButton(QtWidgets.QApplication.translate( "pychemqt", "ASHRAE, h,s=0 saturated liquid at 243K")) layout.addWidget(self.ASHRAE, 3, 1, 1, 7) self.personalizado = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Custom")) self.personalizado.toggled.connect(self.setEnabled) layout.addWidget(self.personalizado, 4, 1, 1, 7) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 1) layout.addWidget(QtWidgets.QLabel("T:"), 5, 2) self.T = Entrada_con_unidades(unidades.Temperature, value=298.15) layout.addWidget(self.T, 5, 3) layout.addWidget(QtWidgets.QLabel("P:"), 6, 2) self.P = Entrada_con_unidades(unidades.Pressure, value=101325) layout.addWidget(self.P, 6, 3) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed), 5, 4, 2, 1) layout.addWidget(QtWidgets.QLabel("h:"), 5, 5) self.h = Entrada_con_unidades(unidades.Enthalpy, value=0) layout.addWidget(self.h, 5, 6) layout.addWidget(QtWidgets.QLabel("s:"), 6, 5) self.s = Entrada_con_unidades(unidades.SpecificHeat, value=0) layout.addWidget(self.s, 6, 6) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 7) buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) layout.addWidget(buttonBox, 8, 1, 1, 7) if config and config.has_option("MEoS", "reference"): self.setEnabled(False) if config.get("MEoS", "reference") == "OTO": self.OTO.setChecked(True) elif config.get("MEoS", "reference") == "NBP": self.NBP.setChecked(True) elif config.get("MEoS", "reference") == "IIR": self.IIR.setChecked(True) elif config.get("MEoS", "reference") == "ASHRAE": self.ASHRAE.setChecked(True) else: self.personalizado.setChecked(True) self.setEnabled(True) self.T.setValue(config.getfloat("MEoS", "T")) self.P.setValue(config.getfloat("MEoS", "P")) self.h.setValue(config.getfloat("MEoS", "h")) self.s.setValue(config.getfloat("MEoS", "s")) else: self.OTO.setChecked(True) self.setEnabled(False) def setEnabled(self, bool): """Enable custom entriees""" self.T.setEnabled(bool) self.P.setEnabled(bool) self.h.setEnabled(bool) self.s.setEnabled(bool)
class ConfLine(QtWidgets.QWidget): """Composite widget with line format configuration tools""" join = [QtCore.Qt.MiterJoin, QtCore.Qt.BevelJoin, QtCore.Qt.RoundJoin] cap = [QtCore.Qt.FlatCap, QtCore.Qt.RoundCap, QtCore.Qt.SquareCap] line = [QtCore.Qt.SolidLine, QtCore.Qt.DashLine, QtCore.Qt.DotLine, QtCore.Qt.DashDotLine, QtCore.Qt.DashDotDotLine] def __init__(self, pen=None, parent=None): super(ConfLine, self).__init__(parent) lyt = QtWidgets.QVBoxLayout(self) lyt1 = QtWidgets.QHBoxLayout() lyt1.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Line"))) self.ColorButtonLine = ColorSelector() self.ColorButtonLine.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Default line color")) lyt1.addWidget(self.ColorButtonLine) self.width = Entrada_con_unidades( float, width=50, decimales=1, spinbox=True, step=0.1, textounidad="px") self.width.entrada.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Line Width")) lyt1.addWidget(self.width) lyt.addLayout(lyt1) lyt2 = QtWidgets.QHBoxLayout() lyt2.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Join"))) self.mitterLimit = Entrada_con_unidades( float, width=50, decimales=1, spinbox=True, step=0.1) self.mitterLimit.entrada.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Mitter Limit")) lyt2.addWidget(self.mitterLimit) toolJoinMitter = QtWidgets.QToolButton() toolJoinMitter.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-join-miter.png")))) toolJoinMitter.setIconSize(QtCore.QSize(24, 24)) toolJoinMitter.setCheckable(True) toolJoinMitter.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Join mitter: The triangular notch between the two lines is not " "filled")) lyt2.addWidget(toolJoinMitter) toolJoinBevel = QtWidgets.QToolButton() toolJoinBevel.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-join-bevel.png")))) toolJoinBevel.setIconSize(QtCore.QSize(24, 24)) toolJoinBevel.setCheckable(True) toolJoinBevel.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Join bevel: The triangular notch between the two lines is " "filled")) lyt2.addWidget(toolJoinBevel) toolJoinRound = QtWidgets.QToolButton() toolJoinRound.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-join-round.png")))) toolJoinRound.setIconSize(QtCore.QSize(24, 24)) toolJoinRound.setCheckable(True) toolJoinRound.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Join round: A circular arc between the two lines is filled")) lyt2.addWidget(toolJoinRound) self.groupJoint = QtWidgets.QButtonGroup() self.groupJoint.addButton(toolJoinMitter) self.groupJoint.addButton(toolJoinBevel) self.groupJoint.addButton(toolJoinRound) self.groupJoint.buttonClicked["int"].connect(self.mitterlimitEnabled) lyt.addLayout(lyt2) lyt3 = QtWidgets.QHBoxLayout() lyt3.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cap"))) toolCapFlat = QtWidgets.QToolButton() toolCapFlat.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-cap-butt.png")))) toolCapFlat.setIconSize(QtCore.QSize(24, 24)) toolCapFlat.setCheckable(True) toolCapFlat.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Flat Cap: A square line end that does not cover the end point of " "the line")) lyt3.addWidget(toolCapFlat) toolCapRound = QtWidgets.QToolButton() toolCapRound.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-cap-round.png")))) toolCapRound.setIconSize(QtCore.QSize(24, 24)) toolCapRound.setCheckable(True) toolCapRound.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Round Cap: A rounded line end")) lyt3.addWidget(toolCapRound) toolCapSquare = QtWidgets.QToolButton() toolCapSquare.setIcon(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"] + os.path.join("images", "button", "stroke-cap-square.png")))) toolCapSquare.setIconSize(QtCore.QSize(24, 24)) toolCapSquare.setCheckable(True) toolCapSquare.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Square Cap: A square line end that covers the end point and " "extends beyond it by half the line width")) lyt3.addWidget(toolCapSquare) self.groupCap = QtWidgets.QButtonGroup() self.groupCap.addButton(toolCapFlat) self.groupCap.addButton(toolCapRound) self.groupCap.addButton(toolCapSquare) lyt.addLayout(lyt3) lyt4 = QtWidgets.QHBoxLayout() lyt4.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Dash"))) self.guion = PFDLineCombo() lyt4.addWidget(self.guion) self.dashOffset = Entrada_con_unidades( float, width=50, decimales=1, spinbox=True, step=0.1) self.dashOffset.entrada.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Dash offset")) lyt4.addWidget(self.dashOffset) lyt.addLayout(lyt4) lyt.addItem(QtWidgets.QSpacerItem( 0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) if pen: self.ColorButtonLine.setColor(pen.color().name()) self.groupJoint.button((self.join.index( pen.joinStyle())+2)*-1).setChecked(True) self.mitterLimit.setValue(pen.miterLimit()) self.groupCap.button((self.cap.index( pen.capStyle())+2)*-1).setChecked(True) self.guion.setCurrentIndex(self.line.index(pen.style())) self.dashOffset.setValue(pen.dashOffset()) self.width.setValue(pen.widthF()) def mitterlimitEnabled(self, id): self.mitterLimit.setEnabled(id == -2) def pen(self): """Return a QPen with the live configuration""" pen = QtGui.QPen(QtGui.QColor(self.ColorButtonLine.color.name())) pen.setWidthF(self.width.value) pen.setJoinStyle(self.join[abs(self.groupJoint.checkedId())-2]) pen.setMiterLimit(self.mitterLimit.value) pen.setCapStyle(self.cap[abs(self.groupCap.checkedId())-2]) pen.setStyle(self.line[self.guion.currentIndex()]) pen.setDashOffset(self.dashOffset.value) return pen
class ConfLine(QtWidgets.QWidget): """Composite widget with line format configuration tools""" join = [QtCore.Qt.MiterJoin, QtCore.Qt.BevelJoin, QtCore.Qt.RoundJoin] cap = [QtCore.Qt.FlatCap, QtCore.Qt.RoundCap, QtCore.Qt.SquareCap] line = [ QtCore.Qt.SolidLine, QtCore.Qt.DashLine, QtCore.Qt.DotLine, QtCore.Qt.DashDotLine, QtCore.Qt.DashDotDotLine ] def __init__(self, pen=None, parent=None): super(ConfLine, self).__init__(parent) lyt = QtWidgets.QVBoxLayout(self) lyt1 = QtWidgets.QHBoxLayout() lyt1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Line"))) self.ColorButtonLine = ColorSelector() self.ColorButtonLine.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Default line color")) lyt1.addWidget(self.ColorButtonLine) self.width = Entrada_con_unidades(float, width=50, decimales=1, spinbox=True, step=0.1, textounidad="px") self.width.entrada.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Line Width")) lyt1.addWidget(self.width) lyt.addLayout(lyt1) lyt2 = QtWidgets.QHBoxLayout() lyt2.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Join"))) self.mitterLimit = Entrada_con_unidades(float, width=50, decimales=1, spinbox=True, step=0.1) self.mitterLimit.entrada.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Mitter Limit")) lyt2.addWidget(self.mitterLimit) toolJoinMitter = QtWidgets.QToolButton() toolJoinMitter.setIcon( QtGui.QIcon( QtGui.QPixmap(os.environ["CheProcess"] + os.path.join( "images", "button", "stroke-join-miter.png")))) toolJoinMitter.setIconSize(QtCore.QSize(24, 24)) toolJoinMitter.setCheckable(True) toolJoinMitter.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Join mitter: The triangular notch between the two lines is not " "filled")) lyt2.addWidget(toolJoinMitter) toolJoinBevel = QtWidgets.QToolButton() toolJoinBevel.setIcon( QtGui.QIcon( QtGui.QPixmap(os.environ["CheProcess"] + os.path.join( "images", "button", "stroke-join-bevel.png")))) toolJoinBevel.setIconSize(QtCore.QSize(24, 24)) toolJoinBevel.setCheckable(True) toolJoinBevel.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Join bevel: The triangular notch between the two lines is " "filled")) lyt2.addWidget(toolJoinBevel) toolJoinRound = QtWidgets.QToolButton() toolJoinRound.setIcon( QtGui.QIcon( QtGui.QPixmap(os.environ["CheProcess"] + os.path.join( "images", "button", "stroke-join-round.png")))) toolJoinRound.setIconSize(QtCore.QSize(24, 24)) toolJoinRound.setCheckable(True) toolJoinRound.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Join round: A circular arc between the two lines is filled")) lyt2.addWidget(toolJoinRound) self.groupJoint = QtWidgets.QButtonGroup() self.groupJoint.addButton(toolJoinMitter) self.groupJoint.addButton(toolJoinBevel) self.groupJoint.addButton(toolJoinRound) self.groupJoint.buttonClicked["int"].connect(self.mitterlimitEnabled) lyt.addLayout(lyt2) lyt3 = QtWidgets.QHBoxLayout() lyt3.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cap"))) toolCapFlat = QtWidgets.QToolButton() toolCapFlat.setIcon( QtGui.QIcon( QtGui.QPixmap( os.environ["CheProcess"] + os.path.join("images", "button", "stroke-cap-butt.png")))) toolCapFlat.setIconSize(QtCore.QSize(24, 24)) toolCapFlat.setCheckable(True) toolCapFlat.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Flat Cap: A square line end that does not cover the end point of " "the line")) lyt3.addWidget(toolCapFlat) toolCapRound = QtWidgets.QToolButton() toolCapRound.setIcon( QtGui.QIcon( QtGui.QPixmap( os.environ["CheProcess"] + os.path.join("images", "button", "stroke-cap-round.png")))) toolCapRound.setIconSize(QtCore.QSize(24, 24)) toolCapRound.setCheckable(True) toolCapRound.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Round Cap: A rounded line end")) lyt3.addWidget(toolCapRound) toolCapSquare = QtWidgets.QToolButton() toolCapSquare.setIcon( QtGui.QIcon( QtGui.QPixmap(os.environ["CheProcess"] + os.path.join( "images", "button", "stroke-cap-square.png")))) toolCapSquare.setIconSize(QtCore.QSize(24, 24)) toolCapSquare.setCheckable(True) toolCapSquare.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Square Cap: A square line end that covers the end point and " "extends beyond it by half the line width")) lyt3.addWidget(toolCapSquare) self.groupCap = QtWidgets.QButtonGroup() self.groupCap.addButton(toolCapFlat) self.groupCap.addButton(toolCapRound) self.groupCap.addButton(toolCapSquare) lyt.addLayout(lyt3) lyt4 = QtWidgets.QHBoxLayout() lyt4.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Dash"))) self.guion = PFDLineCombo() lyt4.addWidget(self.guion) self.dashOffset = Entrada_con_unidades(float, width=50, decimales=1, spinbox=True, step=0.1) self.dashOffset.entrada.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Dash offset")) lyt4.addWidget(self.dashOffset) lyt.addLayout(lyt4) lyt.addItem( QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)) if pen: self.ColorButtonLine.setColor(pen.color().name()) self.groupJoint.button( (self.join.index(pen.joinStyle()) + 2) * -1).setChecked(True) self.mitterLimit.setValue(pen.miterLimit()) self.groupCap.button( (self.cap.index(pen.capStyle()) + 2) * -1).setChecked(True) self.guion.setCurrentIndex(self.line.index(pen.style())) self.dashOffset.setValue(pen.dashOffset()) self.width.setValue(pen.widthF()) def mitterlimitEnabled(self, id): self.mitterLimit.setEnabled(id == -2) def pen(self): """Return a QPen with the live configuration""" pen = QtGui.QPen(QtGui.QColor(self.ColorButtonLine.color.name())) pen.setWidthF(self.width.value) pen.setJoinStyle(self.join[abs(self.groupJoint.checkedId()) - 2]) pen.setMiterLimit(self.mitterLimit.value) pen.setCapStyle(self.cap[abs(self.groupCap.checkedId()) - 2]) pen.setStyle(self.line[self.guion.currentIndex()]) pen.setDashOffset(self.dashOffset.value) return pen
class View_Petro(QtWidgets.QDialog): """Dialog to show the properties of a petroleum fractions""" def __init__(self, petroleo=None, parent=None): super(View_Petro, self).__init__(parent) self.setWindowTitle(QtWidgets.QApplication.translate( "pychemqt", "Petrol assay characteristics")) layout = QtWidgets.QGridLayout(self) self.nombre = QtWidgets.QLabel() layout.addWidget(self.nombre, 1, 1, 1, 5) label = QtWidgets.QLabel("M") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Molecular Weight")) layout.addWidget(label, 2, 1) self.M = Entrada_con_unidades(float, textounidad="g/mol") layout.addWidget(self.M, 2, 2) label = QtWidgets.QLabel("Tb") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Boiling Temperature")) layout.addWidget(label, 3, 1) self.Tb = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.Tb, 3, 2) label = QtWidgets.QLabel("SG") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Specific gravity at 60ºF")) layout.addWidget(label, 4, 1) self.gravity = Entrada_con_unidades(float) layout.addWidget(self.gravity, 4, 2) label = QtWidgets.QLabel("API") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "API Specific gravity")) layout.addWidget(label, 5, 1) self.API = Entrada_con_unidades(float) layout.addWidget(self.API, 5, 2) label = QtWidgets.QLabel("Kw") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Watson characterization factor")) layout.addWidget(label, 6, 1) self.watson = Entrada_con_unidades(float) layout.addWidget(self.watson, 6, 2) label = QtWidgets.QLabel("n") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Refractive Index")) layout.addWidget(label, 7, 1) self.n = Entrada_con_unidades(float) layout.addWidget(self.n, 7, 2) label = QtWidgets.QLabel("I") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Huang parameter")) layout.addWidget(label, 8, 1) self.I = Entrada_con_unidades(float) layout.addWidget(self.I, 8, 2) label = QtWidgets.QLabel("ν<sub>100F</sub>") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Kinematic viscosity at 100ºF")) layout.addWidget(label, 9, 1) self.v100 = Entrada_con_unidades(unidades.Diffusivity) layout.addWidget(self.v100, 9, 2) label = QtWidgets.QLabel("ν<sub>210F</sub>") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Kinematic viscosity at 210ºF")) layout.addWidget(label, 10, 1) self.v210 = Entrada_con_unidades(unidades.Diffusivity) layout.addWidget(self.v210, 10, 2) layout.addWidget(QtWidgets.QLabel("Tc"), 2, 4) self.Tc = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.Tc, 2, 5) layout.addWidget(QtWidgets.QLabel("Pc"), 3, 4) self.Pc = Entrada_con_unidades(unidades.Pressure) layout.addWidget(self.Pc, 3, 5) layout.addWidget(QtWidgets.QLabel("Vc"), 4, 4) self.Vc = Entrada_con_unidades(unidades.SpecificVolume) layout.addWidget(self.Vc, 4, 5) layout.addWidget(QtWidgets.QLabel("Zc"), 5, 4) self.Zc = Entrada_con_unidades(float) layout.addWidget(self.Zc, 5, 5) label = QtWidgets.QLabel("ω") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Acentric factor")) layout.addWidget(label, 6, 4) self.f_acent = Entrada_con_unidades(float) layout.addWidget(self.f_acent, 6, 5) label = QtWidgets.QLabel("m") label.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "Refractivity Intercept")) layout.addWidget(label, 7, 4) self.refractivity = Entrada_con_unidades(float) layout.addWidget(self.refractivity, 7, 5) layout.addWidget(QtWidgets.QLabel("CH"), 8, 4) self.CH = Entrada_con_unidades(float) layout.addWidget(self.CH, 8, 5) layout.addWidget(QtWidgets.QLabel("%S"), 9, 4) self.S = Entrada_con_unidades(float) layout.addWidget(self.S, 9, 5) layout.addWidget(QtWidgets.QLabel("%H"), 10, 4) self.H = Entrada_con_unidades(float) layout.addWidget(self.H, 10, 5) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "VGC")), 2, 7) self.VGC = Entrada_con_unidades(float) layout.addWidget(self.VGC, 2, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Cetane index")), 3, 7) self.cetane = Entrada_con_unidades(float) layout.addWidget(self.cetane, 3, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pour point")), 4, 7) self.pour = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.pour, 4, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Aniline point")), 5, 7) self.aniline = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.aniline, 5, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Freezing point")), 6, 7) self.freezing = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.freezing, 6, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Cloud point")), 7, 7) self.cloud = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.cloud, 7, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Smoke point")), 8, 7) self.smoke = Entrada_con_unidades(unidades.Length) layout.addWidget(self.smoke, 8, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Flash point (open)")), 9, 7) self.flashOpen = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.flashOpen, 9, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Flash point (closed)")), 10, 7) self.flashClosed = Entrada_con_unidades(unidades.Temperature) layout.addWidget(self.flashClosed, 10, 8) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 8) button = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Close) button.rejected.connect(self.reject) layout.addWidget(button, 16, 1, 1, 8) self.setReadOnly(True) if petroleo: self.rellenar(petroleo) def setReadOnly(self, bool): self.M.setReadOnly(bool) self.Tb.setReadOnly(bool) self.gravity.setReadOnly(bool) self.API.setReadOnly(bool) self.watson.setReadOnly(bool) self.Tc.setReadOnly(bool) self.Pc.setReadOnly(bool) self.Vc.setReadOnly(bool) self.Zc.setReadOnly(bool) self.f_acent.setReadOnly(bool) self.refractivity.setReadOnly(bool) self.CH.setReadOnly(bool) self.S.setReadOnly(bool) self.H.setReadOnly(bool) self.n.setReadOnly(bool) self.I.setReadOnly(bool) self.cetane.setReadOnly(bool) self.aniline.setReadOnly(bool) self.cloud.setReadOnly(bool) self.pour.setReadOnly(bool) self.freezing.setReadOnly(bool) self.smoke.setReadOnly(bool) self.v100.setReadOnly(bool) self.v210.setReadOnly(bool) self.VGC.setReadOnly(bool) self.flashOpen.setReadOnly(bool) self.flashClosed.setReadOnly(bool) def rellenar(self, petroleo): self.nombre.setText(petroleo.name) self.M.setValue(petroleo.M) self.Tb.setValue(petroleo.Tb) self.gravity.setValue(petroleo.SG) self.API.setValue(petroleo.API) self.watson.setValue(petroleo.Kw) self.Tc.setValue(petroleo.Tc) self.Pc.setValue(petroleo.Pc) self.Vc.setValue(petroleo.Vc) self.Zc.setValue(petroleo.Zc) self.f_acent.setValue(petroleo.f_acent) self.refractivity.setValue(petroleo.Ri) self.CH.setValue(petroleo.CH) self.S.setValue(petroleo.S) self.H.setValue(petroleo.H) self.n.setValue(petroleo.n) self.I.setValue(petroleo.I) self.cetane.setValue(petroleo.CetaneI) self.aniline.setValue(petroleo.AnilineP) self.cloud.setValue(petroleo.CloudP) self.pour.setValue(petroleo.PourP) self.freezing.setValue(petroleo.FreezingP) self.smoke.setValue(petroleo.SmokeP) self.v100.setValue(petroleo.v100) self.v210.setValue(petroleo.v210) # self.VGC.setValue(petroleo.VGC) if petroleo.hasCurve: self.flashOpen.setValue(petroleo.self.FlashPo) self.flashClosed.setValue(petroleo.self.FlashPc)
class Ui_CostIndex(QtGui.QDialog): """Dialog to show/configure costIndex""" def __init__(self, parent=None): super(Ui_CostIndex, self).__init__(parent) self.setWindowTitle( QtGui.QApplication.translate("pychemqt", "Cost Index")) self.custom = True layout = QtGui.QGridLayout(self) self.fecha = QtGui.QComboBox() layout.addWidget(self.fecha, 1, 1, 1, 3) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "CE INDEX")), 2, 1, 1, 2) self.index = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.index, 2, 3, 1, 1) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Equipments")), 3, 1, 1, 2) self.equipos = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.equipos, 3, 3, 1, 1) layout.addItem( QtGui.QSpacerItem(30, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 4, 1, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Heat exchangers & Tanks")), 4, 2, 1, 1) self.cambiadores_calor = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.cambiadores_calor, 4, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Process machinery")), 5, 2, 1, 1) self.maquinaria = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.maquinaria, 5, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Pipe, valves & fittings")), 6, 2, 1, 1) self.tuberias = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.tuberias, 6, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Process instruments")), 7, 2, 1, 1) self.instrumentos = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.instrumentos, 7, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Pumps & compressors")), 8, 2, 1, 1) self.bombas = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.bombas, 8, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Electrical equipments")), 9, 2, 1, 1) self.equipos_electricos = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.equipos_electricos, 9, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Structural supports & misc")), 10, 2, 1, 1) self.soportes = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.soportes, 10, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Construction labor")), 11, 1, 1, 2) self.construccion = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.construccion, 11, 3, 1, 1) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Buildings")), 12, 1, 1, 2) self.edificios = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.edificios, 12, 3, 1, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Engineering & supervision")), 13, 1, 1, 2) self.ingenieria = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.ingenieria, 13, 3, 1, 1) self.buttonBox = QtGui.QDialogButtonBox( QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 14, 1, 1, 3) self.indices = [] with open(os.environ["pychemqt"] + "dat/costindex.dat") as archivo: texto = archivo.readlines() for txt in texto: dato = txt.split() self.fecha.addItem(dato[0]) self.indices.append(dato[1:]) with open(config.conf_dir + "CostIndex.dat") as archivo: texto = archivo.readlines() self.index.setValue(float(texto[1])) self.equipos.setValue(float(texto[2])) self.cambiadores_calor.setValue(float(texto[3])) self.maquinaria.setValue(float(texto[4])) self.tuberias.setValue(float(texto[5])) self.instrumentos.setValue(float(texto[6])) self.bombas.setValue(float(texto[7])) self.equipos_electricos.setValue(float(texto[8])) self.soportes.setValue(float(texto[9])) self.construccion.setValue(float(texto[10])) self.edificios.setValue(float(texto[11])) self.ingenieria.setValue(float(texto[12])) if texto[0]: self.fecha.setCurrentIndex(self.fecha.findText(texto[0])) else: self.fecha.setCurrentIndex(-1) self.fecha.currentIndexChanged.connect(self.loadData) def setCustom(self): """Set custom currentIndex""" self.fecha.setCurrentIndex(-1) self.custom = True def loadData(self, int): """Load costIndex data from file""" self.index.setValue(float(self.indices[int][0])) self.equipos.setValue(float(self.indices[int][1])) self.cambiadores_calor.setValue(float(self.indices[int][2])) self.maquinaria.setValue(float(self.indices[int][3])) self.tuberias.setValue(float(self.indices[int][4])) self.instrumentos.setValue(float(self.indices[int][5])) self.bombas.setValue(float(self.indices[int][6])) self.equipos_electricos.setValue(float(self.indices[int][7])) self.soportes.setValue(float(self.indices[int][8])) self.construccion.setValue(float(self.indices[int][9])) self.edificios.setValue(float(self.indices[int][10])) self.ingenieria.setValue(float(self.indices[int][11])) self.custom = False def closeEvent(self, event): """Override close event to ask data changes""" dialog = QtGui.QMessageBox.question( self, QtGui.QApplication.translate("pychemqt", "Unsaved changes"), QtGui.QApplication.translate("pychemqt", "Save unsaved changes?"), QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) if dialog == QtGui.QMessageBox.Yes: self.accept() else: event.accept() def accept(self): """Overwrite accept signal to save changes""" with open(config.conf_dir + "CostIndex.dat", "w") as archivo: if self.custom: print("custom", file=archivo) else: print(self.fecha.currentText(), file=archivo) print(self.index.value, file=archivo) print(self.equipos.value, file=archivo) print(self.cambiadores_calor.value, file=archivo) print(self.maquinaria.value, file=archivo) print(self.tuberias.value, file=archivo) print(self.instrumentos.value, file=archivo) print(self.bombas.value, file=archivo) print(self.equipos_electricos.value, file=archivo) print(self.soportes.value, file=archivo) print(self.construccion.value, file=archivo) print(self.edificios.value, file=archivo) print(self.ingenieria.value, file=archivo) QtGui.QDialog.accept()
class UI_equipment(parents.UI_equip): """Diálogo de definición de filtros de mangas""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada""" super(UI_equipment, self).__init__(Baghouse, entrada=False, parent=parent) self.entrada=entrada #Pestaña entrada self.Entrada= UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab(0, self.Entrada,QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña definición rendimientos self.Rendimientos= QtGui.QTableWidget(1, 2) self.Rendimientos.setItemDelegateForColumn(1, CellEditor(self)) self.Rendimientos.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.Rendimientos.verticalHeader().hide() self.Rendimientos.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers) if self.entrada: self.rellenarTablaRendimientos() self.rendimientos=[] self.Rendimientos.cellChanged.connect(self.cambiarRendimientos) self.tabWidget.insertTab(1, self.Rendimientos,QtGui.QApplication.translate("equipment", "Rendimientos", None, QtGui.QApplication.UnicodeUTF8)) #Cálculo gridLayout_Calculo = QtGui.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Tipo de cálculo:", None, QtGui.QApplication.UnicodeUTF8)), 1, 1, 1, 1) self.TipoCalculo=QtGui.QComboBox() self.TipoCalculo.addItem(QtGui.QApplication.translate("equipment", "Calcular caída de presión", None, QtGui.QApplication.UnicodeUTF8)) self.TipoCalculo.addItem(QtGui.QApplication.translate("equipment", "Calcular tiempo de filtración", None, QtGui.QApplication.UnicodeUTF8)) self.TipoCalculo.addItem(QtGui.QApplication.translate("equipment", "Calcular número de filtros", None, QtGui.QApplication.UnicodeUTF8)) self.TipoCalculo.currentIndexChanged.connect(self.tipoCalculoCambiado) gridLayout_Calculo.addWidget(self.TipoCalculo, 1, 2, 1, 4) gridLayout_Calculo.addItem(QtGui.QSpacerItem(20,20,QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Fixed),2,1,1,6) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Nº de filtros:", None, QtGui.QApplication.UnicodeUTF8)), 3, 1, 1, 1) self.numFiltros=Entrada_con_unidades(int, spinbox=True, step=1, width=50, resaltado=True, min=1, start=1) self.numFiltros.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.numFiltros,3,2,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Tiempo de filtración:", None, QtGui.QApplication.UnicodeUTF8)), 4, 1, 1, 1) self.tiempo=Entrada_con_unidades(unidades.Time, resaltado=True) self.tiempo.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.tiempo,4,2,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Pérdida de presión:", None, QtGui.QApplication.UnicodeUTF8)), 5, 1, 1, 1) self.deltaP=Entrada_con_unidades(unidades.Pressure, retornar=False, readOnly=True) self.deltaP.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.deltaP,5,2,1,1) gridLayout_Calculo.addItem(QtGui.QSpacerItem(20,20,QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Fixed),6,1,1,6) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Membranas por filtro:", None, QtGui.QApplication.UnicodeUTF8)), 7, 1, 1, 1) self.MembranaCelda=Entrada_con_unidades(int, spinbox=True, step=1, width=70, value=78, min=1) self.MembranaCelda.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.MembranaCelda,7,2,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Diametro de membrana:", None, QtGui.QApplication.UnicodeUTF8)), 8, 1, 1, 1) self.Diametro=Entrada_con_unidades(unidades.Length, value=unidades.Length(0.5, "ft")) self.Diametro.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Diametro,8,2,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Area por membrana:", None, QtGui.QApplication.UnicodeUTF8)), 9, 1, 1, 1) self.Area=Entrada_con_unidades(unidades.Area, value=unidades.Area(16, "ft2")) self.Area.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Area,9,2,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Resistencia filtro:", None, QtGui.QApplication.UnicodeUTF8)), 7, 4, 1, 1) self.resistenciaFiltro=Entrada_con_unidades(float, spinbox=True, step=0.01, width=70, value=0.84, min=0) self.resistenciaFiltro.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.resistenciaFiltro,7,5,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Resistencia torta:", None, QtGui.QApplication.UnicodeUTF8)), 8, 4, 1, 1) self.resistenciaTorta=Entrada_con_unidades(float, spinbox=True, step=0.01, width=70, value=0.1, min=0) self.resistenciaTorta.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.resistenciaTorta,8,5,1,1) gridLayout_Calculo.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Filtros en limpieza:", None, QtGui.QApplication.UnicodeUTF8)), 9, 4, 1, 1) self.Limpieza=Entrada_con_unidades(int, spinbox=True, step=1, width=70, value=1, min=0) self.Limpieza.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Limpieza,9,5,1,1) gridLayout_Calculo.addItem(QtGui.QSpacerItem(20,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding),10,1,1,6) self.groupBox_Calculo = QtGui.QGroupBox(QtGui.QApplication.translate("equipment", "Datos calculados", None, QtGui.QApplication.UnicodeUTF8)) gridLayout_Calculo.addWidget(self.groupBox_Calculo,11,1,1,5) self.gridLayout_1 = QtGui.QGridLayout(self.groupBox_Calculo) self.gridLayout_1.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "V<sub>gas</sub>:", None, QtGui.QApplication.UnicodeUTF8)),0,1,1,1) self.Vgas=Entrada_con_unidades(unidades.Speed, retornar=False, readOnly=True) self.gridLayout_1.addWidget(self.Vgas,0,2,1,1) self.gridLayout_1.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Rendimiento:", None, QtGui.QApplication.UnicodeUTF8)),1,1,1,1) self.rendimientoCalculado=Entrada_con_unidades(float, readOnly=True) self.gridLayout_1.addWidget(self.rendimientoCalculado,1,2,1,1) self.gridLayout_1.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Superficie:", None, QtGui.QApplication.UnicodeUTF8)),2,1,1,1) self.superficie=Entrada_con_unidades(unidades.Area, readOnly=True) self.gridLayout_1.addWidget(self.superficie,2,2,1,1) gridLayout_Calculo.addItem(QtGui.QSpacerItem(20,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding),12,1,1,6) #Salidas self.SalidaGas= UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido= UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab(self.SalidaGas,QtGui.QApplication.translate("equipment", "Gas filtrado", None, QtGui.QApplication.UnicodeUTF8)) self.Salida.addTab(self.SalidaSolido,QtGui.QApplication.translate("equipment", "Sólidos recogidos", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): self.entrada=corriente self.rellenarTablaRendimientos() self.calculo() def rellenarTablaRendimientos(self): self.Rendimientos.clearContents() self.Rendimientos.setRowCount(len(self.entrada.solido.distribucion)) self.Rendimientos.setHorizontalHeaderLabels([QtGui.QApplication.translate("equipment", "Diámetro, µm", None, QtGui.QApplication.UnicodeUTF8), QtGui.QApplication.translate("equipment", "Rendimiento", None, QtGui.QApplication.UnicodeUTF8)]) for i in range(len(self.entrada.solido.distribucion)): self.Rendimientos.setRowHeight(i, 22) self.Rendimientos.setItem(i, 0, QtGui.QTableWidgetItem(representacion(1e6*self.entrada.solido.diametros[i]))) self.Rendimientos.item(i, 0).setTextAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter) self.Rendimientos.item(i, 0).setFlags(QtCore.Qt.ItemIsSelectable|QtCore.Qt.ItemIsEnabled) self.Rendimientos.setItem(i, 1, QtGui.QTableWidgetItem("")) self.Rendimientos.item(i, 1).setTextAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignVCenter) def cambiarRendimientos(self, fila, columna): numero=float(self.Rendimientos.item(fila, columna).text()) if numero<0 or numero >1: self.Rendimientos.item(fila, columna).setText("") else: if self.rendimientos==[]: self.rendimientos=[0]*self.Rendimientos.rowCount() self.rendimientos[fila]=numero def todos_datos(self): if self.TipoCalculo.currentIndex()==0: todos_datos=self.numFiltros.value and self.tiempo.value elif self.TipoCalculo.currentIndex()==1: todos_datos=self.numFiltros.value and self.deltaP.value else: todos_datos=self.tiempo.value and self.deltaP.value return todos_datos and self.Entrada.todos_datos() def calculo(self): if self.todos_datos(): if self.Limpieza.value==self.numFiltros.value: self.status.setState(5, QtGui.QApplication.translate("equipment", "Todos los filtros en limpieza", None, QtGui.QApplication.UnicodeUTF8)) else: self.status.setState(4) self.Equipment(entrada=self.entrada, metodo=self.TipoCalculo.currentIndex(), num_filtros=self.numFiltros.value, tiempo=self.tiempo.value, deltaP=self.deltaP.value.atm, resistenciaFiltro=self.resistenciaFiltro.value, resistenciaTorta=self.resistenciaTorta.value, limpieza=self.Limpieza.value, membranasFiltro=self.MembranaCelda.value, diametroMembrana=self.Diametro.value, areaMembrana=self.Area.value, rendimientos=self.rendimientos) self.rellenoSalida() if self.rendimientos==[]: self.status.setState(3, QtGui.QApplication.translate("equipment", "Usando rendimiento por defecto", None, QtGui.QApplication.UnicodeUTF8)) else: self.status.setState(1) def rellenoSalida(self): if self.TipoCalculo.currentIndex()==0: self.deltaP.setValue(self.Equipment.deltaP) elif self.TipoCalculo.currentIndex()==1: self.tiempo.setValue(self.Equipment.tiempo) else: self.numFiltros.setValue(self.Equipment.num_filtros) self.Vgas.setValue(self.Equipment.Vgas) self.rendimientoCalculado.setValue(self.Equipment.rendimiento) self.superficie.setValue(self.Equipment.floorArea) self.SalidaGas.rellenar(self.Equipment.SalidaAire) self.SalidaSolido.rellenar(self.Equipment.SalidaSolido) def tipoCalculoCambiado(self, tipo_calculo): if tipo_calculo==0: self.numFiltros.setReadOnly(False) self.numFiltros.setRetornar(True) self.numFiltros.setResaltado(True) self.tiempo.setReadOnly(False) self.tiempo.setRetornar(True) self.tiempo.setResaltado(True) self.deltaP.setReadOnly(True) self.deltaP.setRetornar(False) self.deltaP.setResaltado(False) elif tipo_calculo==1: self.numFiltros.setReadOnly(False) self.numFiltros.setRetornar(True) self.numFiltros.setResaltado(True) self.tiempo.setReadOnly(True) self.tiempo.setRetornar(False) self.tiempo.setResaltado(False) self.deltaP.setReadOnly(False) self.deltaP.setRetornar(True) self.deltaP.setResaltado(True) else: self.numFiltros.setReadOnly(True) self.numFiltros.setRetornar(False) self.numFiltros.setResaltado(False) self.tiempo.setReadOnly(False) self.tiempo.setRetornar(True) self.tiempo.setResaltado(True) self.deltaP.setReadOnly(False) self.deltaP.setRetornar(True) self.deltaP.setResaltado(True)
class UI_equipment(UI_equip): """Pump equipment edition dialog""" Equipment = Pump() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super().__init__(Pump, entrada=False, salida=False, parent=parent) self.curva = [0, 0, []] # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Output Pressure")), 1, 1) self.Pout = Entrada_con_unidades(Pressure) self.Pout.valueChanged.connect(partial(self.cambiar_data, "Pout")) lyt.addWidget(self.Pout, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Pressure increase")), 2, 1) self.deltaP = Entrada_con_unidades(Pressure) self.deltaP.valueChanged.connect(partial(self.cambiar_data, "deltaP")) lyt.addWidget(self.deltaP, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Head")), 3, 1) self.Carga = Entrada_con_unidades(Length, "Head") self.Carga.valueChanged.connect(partial(self.cambiar_data, "Carga")) lyt.addWidget(self.Carga, 3, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 2) self.usarCurva = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Pump curve")) self.usarCurva.toggled.connect(self.usarCurvaToggled) lyt.addWidget(self.usarCurva, 5, 1, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 7, 1) self.rendimiento = Entrada_con_unidades(float, min=0, max=1, spinbox=True, step=0.01) self.rendimiento.valueChanged.connect( partial(self.cambiar_data, "rendimiento")) lyt.addWidget(self.rendimiento, 7, 2) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 8, 1, 1, 6) self.groupBox_Curva = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Pump curve")) self.groupBox_Curva.setEnabled(False) lyt.addWidget(self.groupBox_Curva, 5, 4, 3, 1) layout = QtWidgets.QGridLayout(self.groupBox_Curva) self.bottonCurva = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Curve")) self.bottonCurva.clicked.connect(self.bottonCurva_clicked) layout.addWidget(self.bottonCurva, 1, 1, 1, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Variable")), 2, 1) self.incognita = QtWidgets.QComboBox(self.tabCalculo) self.incognita.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "If use curve, it can calculate the head or the flowrate, in that \ case it override flow of input stream")) self.incognita.addItem( QtWidgets.QApplication.translate("pychemqt", "Output pressure")) self.incognita.addItem( QtWidgets.QApplication.translate("pychemqt", "Flowrate")) self.incognita.currentIndexChanged.connect( partial(self.cambiar_data, "incognita")) layout.addWidget(self.incognita, 2, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Diameter")), 3, 1) self.diametro = Entrada_con_unidades(float, spinbox=True, step=0.1, suffix='"') self.diametro.valueChanged.connect( partial(self.cambiar_data, "diametro")) layout.addWidget(self.diametro, 3, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "RPM")), 4, 1) self.velocidad = Entrada_con_unidades(int, spinbox=True, step=1) self.velocidad.valueChanged.connect( partial(self.cambiar_data, "velocidad")) layout.addWidget(self.velocidad, 4, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Results")) layout = QtWidgets.QGridLayout(group) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Power")), 0, 0) self.power = Entrada_con_unidades(Power, retornar=False, readOnly=True) layout.addWidget(self.power, 0, 1) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Output Pressure")), 0, 4) self.PoutCalculada = Entrada_con_unidades(Pressure, retornar=False) self.PoutCalculada.setReadOnly(True) layout.addWidget(self.PoutCalculada, 0, 5) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Flowrate")), 1, 0) self.volflow = Entrada_con_unidades(VolFlow, "QLiq", retornar=False) self.volflow.setReadOnly(True) layout.addWidget(self.volflow, 1, 1) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Head")), 1, 4) self.headCalculada = Entrada_con_unidades(Length, retornar=False) self.headCalculada.setReadOnly(True) layout.addWidget(self.headCalculada, 1, 5) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 2, 0) self.rendimientoCalculado = Entrada_con_unidades(float, width=60) self.rendimientoCalculado.setReadOnly(True) layout.addWidget(self.rendimientoCalculado, 2, 1) layout.addItem( QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum), 0, 3) lyt.addWidget(group, 9, 1, 1, 6) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) # Design tab # self.tabDiseno = QtWidgets.QWidget() # lyt = QtWidgets.QGridLayout(self.tabDiseno) # lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( # "pychemqt", # "Not implemented\n\nRef: Gülich - Centrifugal Pumps")), 0, 0) # self.tabWidget.insertTab( # 2, self.tabDiseno, # QtWidgets.QApplication.translate("pychemqt", "Design")) # Cost tab lyt = QtWidgets.QGridLayout(self.tabCostos) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Pump type")), 1, 1) self.tipo_bomba = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_BOMBA: self.tipo_bomba.addItem(txt) self.tipo_bomba.currentIndexChanged.connect( self.bomba_currentIndexChanged) lyt.addWidget(self.tipo_bomba, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Centrifuge type")), 2, 1) self.tipo_centrifuga = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_CENTRIFUGA: self.tipo_centrifuga.addItem(txt) self.tipo_centrifuga.currentIndexChanged.connect( partial(self.changeParamsCoste, "tipo_centrifuga")) lyt.addWidget(self.tipo_centrifuga, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Material")), 3, 1) self.material = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MATERIAL: self.material.addItem(txt) self.material.currentIndexChanged.connect( partial(self.changeParamsCoste, "material")) lyt.addWidget(self.material, 3, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor type")), 4, 1) self.motor = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MOTOR: self.motor.addItem(txt) self.motor.currentIndexChanged.connect( partial(self.changeParamsCoste, "motor")) lyt.addWidget(self.motor, 4, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor RPM")), 5, 1) self.rpm = QtWidgets.QComboBox(self.tabCostos) for txt in self.Equipment.TEXT_RPM: self.rpm.addItem(txt) self.rpm.currentIndexChanged.connect( partial(self.changeParamsCoste, "rpm")) lyt.addWidget(self.rpm, 5, 2) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) lyt.addWidget(self.Costos, 6, 1, 2, 4) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 1, 1, 4) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Stimated costs")) lyt.addWidget(group, 8, 1, 1, 4) layout = QtWidgets.QGridLayout(group) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Pump")), 0, 0) self.C_bomba = Entrada_con_unidades(Currency, retornar=False) self.C_bomba.setReadOnly(True) layout.addWidget(self.C_bomba, 0, 1) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor")), 1, 0) self.C_motor = Entrada_con_unidades(Currency, retornar=False) self.C_bomba.setReadOnly(True) layout.addWidget(self.C_motor, 1, 1) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Purchase cost")), 0, 4) self.C_adq = Entrada_con_unidades(Currency, retornar=False) self.C_adq.setReadOnly(True) layout.addWidget(self.C_adq, 0, 5) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Installed cost")), 1, 4) self.C_inst = Entrada_con_unidades(Currency, retornar=False) self.C_inst.setReadOnly(True) layout.addWidget(self.C_inst, 1, 5) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 1, 1, 4) if equipment: self.setEquipment(equipment) def cambiar_data(self, parametro, valor): if parametro == "Pout": self.Carga.clear() self.deltaP.clear() elif parametro == "deltaP": self.Pout.clear() self.Carga.clear() else: self.Pout.clear() self.deltaP.clear() self.changeParams(parametro, valor) def bomba_currentIndexChanged(self, int): self.tipo_centrifuga.setDisabled(int) self.changeParamsCoste("tipo_bomba", int) def usarCurvaToggled(self, int): self.groupBox_Curva.setEnabled(int) self.rendimiento.setReadOnly(int) self.changeParams("usarCurva", int) def bottonCurva_clicked(self): dialog = bombaCurva.Ui_bombaCurva( self.Equipment.kwargs["curvaCaracteristica"], self) if dialog.exec_(): self.curva = dialog.curva self.diametro.setValue(dialog.curva[0]) self.velocidad.setValue(dialog.curva[1]) self.changeParams("curvaCaracteristica", dialog.curva)
class UI_equipment(parents.UI_equip): """Dialogo de definición de unidades de secado de sólidos""" def __init__(self, entradaSolido=None, entradaAire=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada""" super(UI_equipment, self).__init__(Dryer, parent=parent) self.entradaSolido = entradaSolido self.entradaAire = entradaAire self.Equipment = Dryer() #Pestaña entrada self.EntradaSolido = UI_corriente.Ui_corriente(self.entradaSolido) self.EntradaSolido.Changed.connect(self.cambiar_entrada) self.Entrada.addTab( self.EntradaSolido, QtGui.QApplication.translate("equipment", "Solido", None, QtGui.QApplication.UnicodeUTF8)) self.EntradaAire = UI_corriente.Ui_psychrometry(self.entradaAire) self.EntradaAire.Changed.connect(self.cambiar_aire) self.Entrada.addTab( self.EntradaAire, QtGui.QApplication.translate("equipment", "Aire", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña calculo gridLayout_Calculo = QtGui.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Tipo de cálculo:", None, QtGui.QApplication.UnicodeUTF8)), 1, 1) self.TipoCalculo = QtGui.QComboBox() self.TipoCalculo.addItem( QtGui.QApplication.translate( "equipment", "Cálculo, conocido el flujo de vapor, calcular las corrientes de salida", None, QtGui.QApplication.UnicodeUTF8)) self.TipoCalculo.addItem( QtGui.QApplication.translate( "equipment", "Diseño, calcular el flujo de aire necesario", None, QtGui.QApplication.UnicodeUTF8)) self.TipoCalculo.currentIndexChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.TipoCalculo, 1, 2, 1, 4) gridLayout_Calculo.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 2, 1, 1, 6) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Humedad relativa en el aire:", None, QtGui.QApplication.UnicodeUTF8)), 3, 1, 1, 1) self.HumedadAire = Entrada_con_unidades(float, max=1, spinbox=True, step=0.01) self.HumedadAire.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.HumedadAire, 3, 2, 1, 1) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Humedad residual del sólido:", None, QtGui.QApplication.UnicodeUTF8)), 4, 1, 1, 1) self.HumedadSolido = Entrada_con_unidades( float, max=1., spinbox=True, step=0.01, textounidad=unidades.Mass(None).text() + "/" + unidades.Mass(None).text()) self.HumedadSolido.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.HumedadSolido, 4, 2, 1, 1) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate( "equipment", "Temperatura del sólido a la salida:", None, QtGui.QApplication.UnicodeUTF8)), 5, 1, 1, 1) self.temperatura = Entrada_con_unidades(unidades.Temperature) self.temperatura.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.temperatura, 5, 2, 1, 1) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Intercambio de calor:", None, QtGui.QApplication.UnicodeUTF8)), 6, 1, 1, 1) self.Heat = Entrada_con_unidades(unidades.Power) self.Heat.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Heat, 6, 2, 1, 1) gridLayout_Calculo.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Pérdida de presión:", None, QtGui.QApplication.UnicodeUTF8)), 7, 1, 1, 1) self.DeltaP = Entrada_con_unidades(unidades.Pressure) self.DeltaP.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.DeltaP, 7, 2, 1, 1) gridLayout_Calculo.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 8, 1, 1, 6) self.groupBox_Calculo = QtGui.QGroupBox( QtGui.QApplication.translate("equipment", "Datos calculados", None, QtGui.QApplication.UnicodeUTF8)) gridLayout_Calculo.addWidget(self.groupBox_Calculo, 9, 1, 1, 5) gridLayout_1 = QtGui.QGridLayout(self.groupBox_Calculo) gridLayout_1.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Temperatura a la salida:", None, QtGui.QApplication.UnicodeUTF8)), 1, 1, 1, 1) self.temperaturaCalculada = Entrada_con_unidades(unidades.Temperature, retornar=False, readOnly=True) gridLayout_1.addWidget(self.temperaturaCalculada, 1, 2, 1, 1) gridLayout_1.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Caudal de aire:", None, QtGui.QApplication.UnicodeUTF8)), 2, 1) self.caudalVolumetrico = Entrada_con_unidades(unidades.VolFlow, "QGas", retornar=False, readOnly=True) gridLayout_1.addWidget(self.caudalVolumetrico, 2, 2, 1, 1) gridLayout_1.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Humedad del aire:", None, QtGui.QApplication.UnicodeUTF8)), 3, 1) self.HumedadCalculada = Entrada_con_unidades(float, readOnly=True, textounidad="%") gridLayout_1.addWidget(self.HumedadCalculada, 3, 2, 1, 1) gridLayout_Calculo.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 11, 1, 1, 6) #Pestaña salida self.SalidaSolido = UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab( self.SalidaSolido, QtGui.QApplication.translate("equipment", "Sólido secado", None, QtGui.QApplication.UnicodeUTF8)) self.SalidaAire = UI_corriente.Ui_psychrometry(readOnly=True) self.Salida.addTab( self.SalidaAire, QtGui.QApplication.translate("equipment", "Aire", None, QtGui.QApplication.UnicodeUTF8)) def cambiar_entrada(self, corriente): self.entradaSolido = corriente self.calculo() def cambiar_aire(self, punto): self.entradaAire = punto self.calculo() def calculo(self): if self.todos_datos(): self.Equipment(entrada=self.entrada, calculo=0, modelo=self.Modelo.currentIndex(), anchura=self.anchura.value, altura=self.altura.value, longitud=self.longitud.value) self.rellenoSalida(1) def rellenoSalida(self, estado=1, texto=""): self.caudalVolumetrico.setValue(self.entrada.caudal_volumetrico) self.velocidadGasCalculada.setValue(self.Equipment.Vgas) self.rendimientoCalculado.setValue(self.Equipment.rendimiento) self.alturaCalculada.setValue(self.Equipment.H) self.anchuraCalculada.setValue(self.Equipment.B) self.longitudCalculada.setValue(self.Equipment.L) self.SalidaGas.rellenar(self.Equipment.SalidaAire) self.SalidaSolido.rellenar(self.Equipment.SalidaSolido) self.status.setState(estado, texto) def todos_datos(self): return self.EntradaSolido.todos_datos( ) and self.EntradaAire.todos_datos()
class Widget(QtWidgets.QWidget): """Standing-Katz chart configuration""" def __init__(self, config=None, parent=None): super(Widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")), 1, 1) self.method = QtWidgets.QComboBox() for Z in Z_list: name = Z.__name__[2:].replace("_", "-") year = re.search("((\d+))", Z.__doc__).group(0) doc = "%s (%s)" % (name, year) self.method.addItem(doc) layout.addWidget(self.method, 1, 2) layout.addWidget(QtWidgets.QLabel("Pr min:"), 2, 1) self.Prmin = Entrada_con_unidades(float, width=60, decimales=1) layout.addWidget(self.Prmin, 2, 2) layout.addWidget(QtWidgets.QLabel("Pr max:"), 3, 1) self.Prmax = Entrada_con_unidades(float, width=60, decimales=1) layout.addWidget(self.Prmax, 3, 2) layout.addWidget(QtWidgets.QLabel("Tr:"), 4, 1) self.Tr = QtWidgets.QLineEdit() layout.addWidget(self.Tr, 4, 2) self.lineconfig = LineConfig( "line", QtWidgets.QApplication.translate("pychemqt", "Reduced temperature style line")) layout.addWidget(self.lineconfig, 5, 1, 1, 2) self.cruxconfig = LineConfig( "crux", QtWidgets.QApplication.translate("pychemqt", "Crux style line")) layout.addWidget(self.cruxconfig, 6, 1, 1, 2) layout.addItem( QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 3) if config and config.has_section("Standing_Katz"): self.method.setCurrentIndex( config.getint("Standing_Katz", "method")) self.Prmin.setValue(config.getfloat("Standing_Katz", "Prmin")) self.Prmax.setValue(config.getfloat("Standing_Katz", "Prmax")) self.Tr.setText(config.get("Standing_Katz", "Tr")) self.lineconfig.setConfig(config, "Standing_Katz") self.cruxconfig.setConfig(config, "Standing_Katz") def value(self, config): if not config.has_section("Standing_Katz"): config.add_section("Standing_Katz") config.set("Standing_Katz", "method", str(self.method.currentIndex())) config.set("Standing_Katz", "Prmin", str(self.Prmin.value)) config.set("Standing_Katz", "Prmax", str(self.Prmax.value)) config.set("Standing_Katz", "Tr", self.Tr.text()) config = self.lineconfig.value(config, "Standing_Katz") config = self.cruxconfig.value(config, "Standing_Katz") return config
class UI_equipment(UI_equip): """Pump equipment edition dialog""" Equipment = Pump() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super().__init__(Pump, entrada=False, salida=False, parent=parent) self.curva = [0, 0, []] # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output Pressure")), 1, 1) self.Pout = Entrada_con_unidades(Pressure) self.Pout.valueChanged.connect(partial(self.cambiar_data, "Pout")) lyt.addWidget(self.Pout, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pressure increase")), 2, 1) self.deltaP = Entrada_con_unidades(Pressure) self.deltaP.valueChanged.connect(partial(self.cambiar_data, "deltaP")) lyt.addWidget(self.deltaP, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Head")), 3, 1) self.Carga = Entrada_con_unidades(Length, "Head") self.Carga.valueChanged.connect(partial(self.cambiar_data, "Carga")) lyt.addWidget(self.Carga, 3, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 2) self.usarCurva = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Pump curve")) self.usarCurva.toggled.connect(self.usarCurvaToggled) lyt.addWidget(self.usarCurva, 5, 1, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 7, 1) self.rendimiento = Entrada_con_unidades(float, min=0, max=1, spinbox=True, step=0.01) self.rendimiento.valueChanged.connect( partial(self.cambiar_data, "rendimiento")) lyt.addWidget(self.rendimiento, 7, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 8, 1, 1, 6) self.groupBox_Curva = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Pump curve")) self.groupBox_Curva.setEnabled(False) lyt.addWidget(self.groupBox_Curva, 5, 4, 3, 1) layout = QtWidgets.QGridLayout(self.groupBox_Curva) self.bottonCurva = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Curve")) self.bottonCurva.clicked.connect(self.bottonCurva_clicked) layout.addWidget(self.bottonCurva, 1, 1, 1, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Variable")), 2, 1) self.incognita = QtWidgets.QComboBox(self.tabCalculo) self.incognita.setToolTip(QtWidgets.QApplication.translate( "pychemqt", "If use curve, it can calculate the head or the flowrate, in that \ case it override flow of input stream")) self.incognita.addItem( QtWidgets.QApplication.translate("pychemqt", "Output pressure")) self.incognita.addItem( QtWidgets.QApplication.translate("pychemqt", "Flowrate")) self.incognita.currentIndexChanged.connect( partial(self.cambiar_data, "incognita")) layout.addWidget(self.incognita, 2, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Diameter")), 3, 1) self.diametro = Entrada_con_unidades( float, spinbox=True, step=0.1, suffix='"') self.diametro.valueChanged.connect( partial(self.cambiar_data, "diametro")) layout.addWidget(self.diametro, 3, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "RPM")), 4, 1) self.velocidad = Entrada_con_unidades(int, spinbox=True, step=1) self.velocidad.valueChanged.connect( partial(self.cambiar_data, "velocidad")) layout.addWidget(self.velocidad, 4, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Results")) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Power")), 0, 0) self.power = Entrada_con_unidades(Power, retornar=False, readOnly=True) layout.addWidget(self.power, 0, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output Pressure")), 0, 4) self.PoutCalculada = Entrada_con_unidades(Pressure, retornar=False) self.PoutCalculada.setReadOnly(True) layout.addWidget(self.PoutCalculada, 0, 5) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Flowrate")), 1, 0) self.volflow = Entrada_con_unidades(VolFlow, "QLiq", retornar=False) self.volflow.setReadOnly(True) layout.addWidget(self.volflow, 1, 1) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Head")), 1, 4) self.headCalculada = Entrada_con_unidades(Length, retornar=False) self.headCalculada.setReadOnly(True) layout.addWidget(self.headCalculada, 1, 5) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Efficiency")), 2, 0) self.rendimientoCalculado = Entrada_con_unidades(float, width=60) self.rendimientoCalculado.setReadOnly(True) layout.addWidget(self.rendimientoCalculado, 2, 1) layout.addItem(QtWidgets.QSpacerItem( 40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum), 0, 3) lyt.addWidget(group, 9, 1, 1, 6) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) # Design tab # self.tabDiseno = QtWidgets.QWidget() # lyt = QtWidgets.QGridLayout(self.tabDiseno) # lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( # "pychemqt", # "Not implemented\n\nRef: Gülich - Centrifugal Pumps")), 0, 0) # self.tabWidget.insertTab( # 2, self.tabDiseno, # QtWidgets.QApplication.translate("pychemqt", "Design")) # Cost tab lyt = QtWidgets.QGridLayout(self.tabCostos) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Pump type")), 1, 1) self.tipo_bomba = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_BOMBA: self.tipo_bomba.addItem(txt) self.tipo_bomba.currentIndexChanged.connect( self.bomba_currentIndexChanged) lyt.addWidget(self.tipo_bomba, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Centrifuge type")), 2, 1) self.tipo_centrifuga = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_CENTRIFUGA: self.tipo_centrifuga.addItem(txt) self.tipo_centrifuga.currentIndexChanged.connect( partial(self.changeParamsCoste, "tipo_centrifuga")) lyt.addWidget(self.tipo_centrifuga, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Material")), 3, 1) self.material = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MATERIAL: self.material.addItem(txt) self.material.currentIndexChanged.connect( partial(self.changeParamsCoste, "material")) lyt.addWidget(self.material, 3, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor type")), 4, 1) self.motor = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MOTOR: self.motor.addItem(txt) self.motor.currentIndexChanged.connect( partial(self.changeParamsCoste, "motor")) lyt.addWidget(self.motor, 4, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor RPM")), 5, 1) self.rpm = QtWidgets.QComboBox(self.tabCostos) for txt in self.Equipment.TEXT_RPM: self.rpm.addItem(txt) self.rpm.currentIndexChanged.connect( partial(self.changeParamsCoste, "rpm")) lyt.addWidget(self.rpm, 5, 2) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) lyt.addWidget(self.Costos, 6, 1, 2, 4) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 1, 1, 4) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Stimated costs")) lyt.addWidget(group, 8, 1, 1, 4) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Pump")), 0, 0) self.C_bomba = Entrada_con_unidades(Currency, retornar=False) self.C_bomba.setReadOnly(True) layout.addWidget(self.C_bomba, 0, 1) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Motor")), 1, 0) self.C_motor = Entrada_con_unidades(Currency, retornar=False) self.C_bomba.setReadOnly(True) layout.addWidget(self.C_motor, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Purchase cost")), 0, 4) self.C_adq = Entrada_con_unidades(Currency, retornar=False) self.C_adq.setReadOnly(True) layout.addWidget(self.C_adq, 0, 5) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Installed cost")), 1, 4) self.C_inst = Entrada_con_unidades(Currency, retornar=False) self.C_inst.setReadOnly(True) layout.addWidget(self.C_inst, 1, 5) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 1, 1, 4) if equipment: self.setEquipment(equipment) def cambiar_data(self, parametro, valor): if parametro == "Pout": self.Carga.clear() self.deltaP.clear() elif parametro == "deltaP": self.Pout.clear() self.Carga.clear() else: self.Pout.clear() self.deltaP.clear() self.changeParams(parametro, valor) def bomba_currentIndexChanged(self, int): self.tipo_centrifuga.setDisabled(int) self.changeParamsCoste("tipo_bomba", int) def usarCurvaToggled(self, int): self.groupBox_Curva.setEnabled(int) self.rendimiento.setReadOnly(int) self.changeParams("usarCurva", int) def bottonCurva_clicked(self): dialog = bombaCurva.Ui_bombaCurva( self.Equipment.kwargs["curvaCaracteristica"], self) if dialog.exec_(): self.curva = dialog.curva self.diametro.setValue(dialog.curva[0]) self.velocidad.setValue(dialog.curva[1]) self.changeParams("curvaCaracteristica", dialog.curva)
class UI_equipment(parents.UI_equip): """Dialogo de definición de unidades de secado de sólidos""" def __init__(self, entradaSolido=None, entradaAire=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada""" super(UI_equipment, self).__init__(Dryer, parent=parent) self.entradaSolido=entradaSolido self.entradaAire=entradaAire self.Equipment=Dryer() #Pestaña entrada self.EntradaSolido= UI_corriente.Ui_corriente(self.entradaSolido) self.EntradaSolido.Changed.connect(self.cambiar_entrada) self.Entrada.addTab(self.EntradaSolido,QtWidgets.QApplication.translate("equipment", "Solido", None)) self.EntradaAire= UI_corriente.Ui_psychrometry(self.entradaAire) self.EntradaAire.Changed.connect(self.cambiar_aire) self.Entrada.addTab(self.EntradaAire,QtWidgets.QApplication.translate("equipment", "Aire", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo de cálculo:", None)), 1, 1) self.TipoCalculo=QtWidgets.QComboBox() self.TipoCalculo.addItem(QtWidgets.QApplication.translate("equipment", "Cálculo, conocido el flujo de vapor, calcular las corrientes de salida", None)) self.TipoCalculo.addItem(QtWidgets.QApplication.translate("equipment", "Diseño, calcular el flujo de aire necesario", None)) self.TipoCalculo.currentIndexChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.TipoCalculo, 1, 2, 1, 4) gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),2,1,1,6) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Humedad relativa en el aire:", None)), 3, 1, 1, 1) self.HumedadAire=Entrada_con_unidades(float, max=1, spinbox=True, step=0.01) self.HumedadAire.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.HumedadAire,3,2,1,1) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Humedad residual del sólido:", None)), 4, 1, 1, 1) self.HumedadSolido=Entrada_con_unidades(float, max=1., spinbox=True, step=0.01, textounidad=unidades.Mass(None).text()+"/"+unidades.Mass(None).text()) self.HumedadSolido.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.HumedadSolido,4,2,1,1) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Temperatura del sólido a la salida:", None)), 5, 1, 1, 1) self.temperatura=Entrada_con_unidades(unidades.Temperature) self.temperatura.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.temperatura,5,2,1,1) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Intercambio de calor:", None)), 6, 1, 1, 1) self.Heat=Entrada_con_unidades(unidades.Power) self.Heat.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Heat,6,2,1,1) gridLayout_Calculo.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Pérdida de presión:", None)), 7, 1, 1, 1) self.DeltaP=Entrada_con_unidades(unidades.Pressure) self.DeltaP.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.DeltaP,7,2,1,1) gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),8,1,1,6) self.groupBox_Calculo = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Datos calculados", None)) gridLayout_Calculo.addWidget(self.groupBox_Calculo,9,1,1,5) gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Calculo) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Temperatura a la salida:", None)), 1, 1, 1, 1) self.temperaturaCalculada=Entrada_con_unidades(unidades.Temperature, retornar=False, readOnly=True) gridLayout_1.addWidget(self.temperaturaCalculada,1,2,1,1) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Caudal de aire:", None)),2,1) self.caudalVolumetrico=Entrada_con_unidades(unidades.VolFlow, "QGas", retornar=False, readOnly=True) gridLayout_1.addWidget(self.caudalVolumetrico,2,2,1,1) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Humedad del aire:", None)), 3, 1) self.HumedadCalculada=Entrada_con_unidades(float, readOnly=True, textounidad="%") gridLayout_1.addWidget(self.HumedadCalculada,3,2,1,1) gridLayout_Calculo.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),11,1,1,6) #Pestaña salida self.SalidaSolido= UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab(self.SalidaSolido,QtWidgets.QApplication.translate("equipment", "Sólido secado", None)) self.SalidaAire= UI_corriente.Ui_psychrometry(readOnly=True) self.Salida.addTab(self.SalidaAire,QtWidgets.QApplication.translate("equipment", "Aire", None)) def cambiar_entrada(self, corriente): self.entradaSolido=corriente self.calculo() def cambiar_aire(self, punto): self.entradaAire=punto self.calculo() def calculo(self): if self.todos_datos(): self.Equipment(entrada=self.entrada, calculo=0, modelo=self.Modelo.currentIndex(), anchura=self.anchura.value, altura=self.altura.value, longitud=self.longitud.value) self.rellenoSalida(1) def rellenoSalida(self, estado=1, texto=""): self.caudalVolumetrico.setValue(self.entrada.caudal_volumetrico) self.velocidadGasCalculada.setValue(self.Equipment.Vgas) self.rendimientoCalculado.setValue(self.Equipment.rendimiento) self.alturaCalculada.setValue(self.Equipment.H) self.anchuraCalculada.setValue(self.Equipment.B) self.longitudCalculada.setValue(self.Equipment.L) self.SalidaGas.rellenar(self.Equipment.SalidaAire) self.SalidaSolido.rellenar(self.Equipment.SalidaSolido) self.status.setState(estado, texto) def todos_datos(self): return self.EntradaSolido.todos_datos() and self.EntradaAire.todos_datos()
class UI_equipment(parents.UI_equip): """Diálogo de definición de filtros por presión o a vación para la separación de sólidos de corrientes líquidas""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Filter, entrada=False, parent=parent) self.entrada = entrada # Pestaña entrada self.Entrada = UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab( 0, self.Entrada, QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8) ) # Pestaña calculo gridLayout_Calculo = QtGui.QGridLayout(self.tabCalculo) # Pestaña costos gridLayout_Costos = QtGui.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtGui.QLabel(QtGui.QApplication.translate("equipment", "Tipo:", None, QtGui.QApplication.UnicodeUTF8)), 1, 0, 1, 1, ) self.tipo = QtGui.QComboBox() self.tipo.addItem( QtGui.QApplication.translate( "equipment", "Rotary vacuum belt discharge", None, QtGui.QApplication.UnicodeUTF8 ) ) self.tipo.addItem( QtGui.QApplication.translate( "equipment", "Rotary vacuum drum scraper discharge", None, QtGui.QApplication.UnicodeUTF8 ) ) self.tipo.addItem( QtGui.QApplication.translate("equipment", "Rotary vacuum disk", None, QtGui.QApplication.UnicodeUTF8) ) self.tipo.addItem( QtGui.QApplication.translate("equipment", "Horizontal vacuum belt", None, QtGui.QApplication.UnicodeUTF8) ) self.tipo.addItem( QtGui.QApplication.translate("equipment", "Pressure leaf", None, QtGui.QApplication.UnicodeUTF8) ) self.tipo.addItem( QtGui.QApplication.translate("equipment", "Plate and frame", None, QtGui.QApplication.UnicodeUTF8) ) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 1, 1, 3) gridLayout_Costos.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 2, 0, 1, 2 ) self.Costos = costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos, 4, 0, 2, 5) gridLayout_Costos.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 6, 0, 1, 6 ) gridLayout_Costos.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 10, 0, 1, 6 ) self.groupBox_Costos = QtGui.QGroupBox( QtGui.QApplication.translate("equipment", "Costos calculados", None, QtGui.QApplication.UnicodeUTF8) ) gridLayout_Costos.addWidget(self.groupBox_Costos, 7, 0, 1, 4) gridLayout_5 = QtGui.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Coste Adquisición:", None, QtGui.QApplication.UnicodeUTF8) ), 1, 1, ) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 1, 2) gridLayout_5.addWidget( QtGui.QLabel( QtGui.QApplication.translate("equipment", "Coste Instalación:", None, QtGui.QApplication.UnicodeUTF8) ), 2, 1, ) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 2, 2) # Pestaña salida self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido = UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab( self.SalidaGas, QtGui.QApplication.translate("equipment", "Gas filtrado", None, QtGui.QApplication.UnicodeUTF8), ) self.Salida.addTab( self.SalidaSolido, QtGui.QApplication.translate("equipment", "Sólidos recogidos", None, QtGui.QApplication.UnicodeUTF8), ) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex() == 0: self.FireHeater.Coste( self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex() ) else: self.FireHeater.Coste( self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex() ) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class UI_confResolution_widget(QtWidgets.QWidget): """PFD resolution widget""" def __init__(self, config=None, parent=None): self.standards = [(600, 400), (640, 480), (720, 400), (800, 600), (832, 624), (1024, 768), (1152, 864), (1280, 1024), (1700, 1250), (1900, 1425), (2400, 1800), (4000, 3000)] super(UI_confResolution_widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Use default resolution:")), 0, 0) self.standard = QtWidgets.QComboBox() self.standard.addItem("") for resolucion in self.standards: self.standard.addItem("%ix%i" % resolucion) self.standard.currentIndexChanged.connect(self.changeResolution) layout.addWidget(self.standard, 0, 1) self.checkCustom = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use Custom resolution")) layout.addWidget(self.checkCustom, 1, 0, 1, 2) label = QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Width:")) label.setIndent(50) layout.addWidget(label, 2, 0) self.x = Entrada_con_unidades(int, width=60, spinbox=True, step=1) layout.addWidget(self.x, 2, 1) label = QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Height:")) label.setIndent(50) layout.addWidget(label, 3, 0) self.y = Entrada_con_unidades(int, width=60, spinbox=True, step=1) layout.addWidget(self.y, 3, 1) self.checkCustom.toggled.connect(self.x.setEnabled) self.checkCustom.toggled.connect(self.y.setEnabled) if config and config.has_section("PFD"): x = config.getint("PFD", "x") y = config.getint("PFD", "y") self.x.setValue(x) self.y.setValue(y) if (x, y) in self.standards: self.standard.setCurrentIndex(self.standards.index((x, y))+1) self.checkCustom.setChecked(False) self.x.setEnabled(False) self.y.setEnabled(False) else: self.standard.setCurrentIndex(0) self.checkCustom.setChecked(True) def changeResolution(self): """Change resolution with value of current opction selected""" x, y = self.standard.currentText().split("x") self.x.setValue(int(x)) self.y.setValue(int(y)) def value(self, config): """Function result to wizard""" if not config.has_section("PFD"): config.add_section("PFD") config.set("PFD", "x", str(self.x.value)) config.set("PFD", "y", str(self.y.value)) return config @classmethod def default(cls, config): config.add_section("PFD") Preferences = ConfigParser() Preferences.read(conf_dir+"pychemqtrc") config.set("PFD", "x", Preferences.get("PFD", "x")) config.set("PFD", "y", Preferences.get("PFD", "y")) return config
class View_Contribution(QtWidgets.QDialog): """Dialog to show the properties of a group contribution""" def __init__(self, cmp=None, parent=None): """Constructor cmp: optional new component to show the properties""" super(View_Contribution, self).__init__(parent) self.setWindowTitle( QtWidgets.QApplication.translate( "pychemqt", "Group Contribution new component")) layout = QtWidgets.QGridLayout(self) self.nombre = QtWidgets.QLabel() layout.addWidget(self.nombre, 1, 1, 1, 5) label = QtWidgets.QLabel("M") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Molecular Weight")) layout.addWidget(label, 2, 1) self.M = Entrada_con_unidades(float, textounidad="g/mol") layout.addWidget(self.M, 2, 2) label = QtWidgets.QLabel("Tb") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Boiling Temperature")) layout.addWidget(label, 3, 1) self.Tb = Entrada_con_unidades(Temperature) layout.addWidget(self.Tb, 3, 2) label = QtWidgets.QLabel("Tm") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Melting Temperature")) layout.addWidget(label, 4, 1) self.Tf = Entrada_con_unidades(Temperature) layout.addWidget(self.Tf, 4, 2) layout.addWidget(QtWidgets.QLabel("Tc"), 5, 1) self.Tc = Entrada_con_unidades(Temperature) layout.addWidget(self.Tc, 5, 2) layout.addWidget(QtWidgets.QLabel("Pc"), 6, 1) self.Pc = Entrada_con_unidades(Pressure) layout.addWidget(self.Pc, 6, 2) layout.addWidget(QtWidgets.QLabel("Vc"), 7, 1) self.Vc = Entrada_con_unidades(SpecificVolume) layout.addWidget(self.Vc, 7, 2) label = QtWidgets.QLabel("ΔHf") label.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Enthalpy of formation of ideal gas")) layout.addWidget(label, 8, 1) self.Hf = Entrada_con_unidades(Enthalpy) layout.addWidget(self.Hf, 8, 2) label = QtWidgets.QLabel("ΔGf") label.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Gibbs free energy of formation of ideal gas")) layout.addWidget(label, 9, 1) self.Gf = Entrada_con_unidades(Enthalpy) layout.addWidget(self.Gf, 9, 2) label = QtWidgets.QLabel("ΔHf") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Enthalpy of fusion")) layout.addWidget(label, 2, 4) self.Hm = Entrada_con_unidades(Enthalpy) layout.addWidget(self.Hm, 2, 5) label = QtWidgets.QLabel("ΔHv") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Enthalpy of vaporization")) layout.addWidget(label, 3, 4) self.Hv = Entrada_con_unidades(Enthalpy) layout.addWidget(self.Hv, 3, 5) layout.addWidget(QtWidgets.QLabel("Cpa"), 4, 4) self.cpa = Entrada_con_unidades(float) layout.addWidget(self.cpa, 4, 5) layout.addWidget(QtWidgets.QLabel("Cpb"), 5, 4) self.cpb = Entrada_con_unidades(float) layout.addWidget(self.cpb, 5, 5) layout.addWidget(QtWidgets.QLabel("Cpc"), 6, 4) self.cpc = Entrada_con_unidades(float) layout.addWidget(self.cpc, 6, 5) layout.addWidget(QtWidgets.QLabel("Cpd"), 7, 4) self.cpd = Entrada_con_unidades(float) layout.addWidget(self.cpd, 7, 5) layout.addWidget(QtWidgets.QLabel("μa"), 8, 4) self.mua = Entrada_con_unidades(float) layout.addWidget(self.mua, 8, 5) layout.addWidget(QtWidgets.QLabel("μb"), 9, 4) self.mub = Entrada_con_unidades(float) layout.addWidget(self.mub, 9, 5) label = QtWidgets.QLabel("SG") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Specific gravity at 60ºF")) layout.addWidget(label, 2, 7) self.gravity = Entrada_con_unidades(float) layout.addWidget(self.gravity, 2, 8) label = QtWidgets.QLabel("API") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "API Specific gravity")) layout.addWidget(label, 3, 7) self.API = Entrada_con_unidades(float) layout.addWidget(self.API, 3, 8) label = QtWidgets.QLabel("Kw") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Watson characterization factor")) layout.addWidget(label, 4, 7) self.watson = Entrada_con_unidades(float) layout.addWidget(self.watson, 4, 8) label = QtWidgets.QLabel("w") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Acentric factor")) layout.addWidget(label, 5, 7) self.f_acent = Entrada_con_unidades(float) layout.addWidget(self.f_acent, 5, 8) label = QtWidgets.QLabel("Ra") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Rackett constant")) layout.addWidget(label, 6, 7) self.rackett = Entrada_con_unidades(float) layout.addWidget(self.rackett, 6, 8) label = QtWidgets.QLabel("Vliq") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Volume Liquid Constant")) layout.addWidget(label, 7, 7) self.Vliq = Entrada_con_unidades(float) layout.addWidget(self.Vliq, 7, 8) label = QtWidgets.QLabel("Sol") label.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Solubility Parameter")) layout.addWidget(label, 8, 7) self.Parametro_solubilidad = Entrada_con_unidades(SolubilityParameter) layout.addWidget(self.Parametro_solubilidad, 8, 8) layout.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 8) btn = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Close) btn.rejected.connect(self.accept) layout.addWidget(btn, 16, 1, 1, 8) self.setReadOnly(True) if cmp: self.rellenar(cmp) def setReadOnly(self, bool): self.M.setReadOnly(bool) self.Tb.setReadOnly(bool) self.Tf.setReadOnly(bool) self.Tc.setReadOnly(bool) self.Pc.setReadOnly(bool) self.Vc.setReadOnly(bool) self.Hf.setReadOnly(bool) self.Gf.setReadOnly(bool) self.Hm.setReadOnly(bool) self.Hv.setReadOnly(bool) self.cpa.setReadOnly(bool) self.cpb.setReadOnly(bool) self.cpc.setReadOnly(bool) self.cpd.setReadOnly(bool) self.mua.setReadOnly(bool) self.mub.setReadOnly(bool) self.gravity.setReadOnly(bool) self.API.setReadOnly(bool) self.watson.setReadOnly(bool) self.f_acent.setReadOnly(bool) self.rackett.setReadOnly(bool) self.Vliq.setReadOnly(bool) self.Parametro_solubilidad.setReadOnly(bool) def rellenar(self, cmp): self.nombre.setText(cmp.name) self.M.setValue(cmp.M) self.Tb.setValue(cmp.Tb) self.Tf.setValue(cmp.Tf) self.Tc.setValue(cmp.Tc) self.Pc.setValue(cmp.Pc) self.Vc.setValue(cmp.Vc) self.Hf.setValue(cmp.Hf) self.Gf.setValue(cmp.Gf) self.Hm.setValue(cmp.Hm) self.Hv.setValue(cmp.Hv) self.cpa.setValue(cmp.cp[0]) self.cpb.setValue(cmp.cp[1]) self.cpc.setValue(cmp.cp[2]) self.cpd.setValue(cmp.cp[3]) self.gravity.setValue(cmp.SG) self.API.setValue(cmp.API) self.watson.setValue(cmp.Kw) self.f_acent.setValue(cmp.f_acent) self.rackett.setValue(cmp.rackett) self.Vliq.setValue(cmp.Vliq) self.Parametro_solubilidad.setValue(cmp.Parametro_solubilidad)
class UI_reacciones(QtWidgets.QDialog): reaction=reaction.Reaction() def __init__(self, reaccion=None, parent=None): super(UI_reacciones, self).__init__(parent) self.evaluate=Evaluate() self.evaluate.finished.connect(self.rellenar) self.indices, self.nombres, M=getComponents() gridLayout = QtWidgets.QGridLayout(self) lyt=QtWidgets.QHBoxLayout() lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Key component"))) self.key=QtWidgets.QComboBox() for i, nombre in enumerate(self.nombres): self.key.addItem("%i - %s" %(i+1, nombre)) self.key.currentIndexChanged.connect(partial(self.changeParams, "key")) lyt.addWidget(self.key) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed)) gridLayout.addLayout(lyt,1,1,1,5) lyt=QtWidgets.QHBoxLayout() lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Phase"))) self.fase=QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_PHASE: self.fase.addItem(txt) self.fase.currentIndexChanged.connect(partial(self.changeParams, "fase")) lyt.addWidget(self.fase) self.Formula=QtWidgets.QLabel() self.Formula.setAlignment(QtCore.Qt.AlignCenter) self.Formula.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed) lyt.addWidget(self.Formula) gridLayout.addLayout(lyt,2,1,1,5) lyt=QtWidgets.QVBoxLayout() title=self.nombres[:] title.append("") self.Estequiometria=Tabla(1, verticalHeaderLabels=title, horizontalHeader=[QtWidgets.QApplication.translate("pychemqt", "Coefficients")], filas=len(self.indices)) self.Estequiometria.setFixedHeight(22*len(self.indices)+22+4+22) lyt.addWidget(self.Estequiometria) self.Estequiometria.addRow() brush=QtGui.QBrush(QtGui.QColor("#eaeaea")) self.Estequiometria.item(len(self.indices), 0).setBackground(brush) self.Estequiometria.item(len(self.indices), 0).setFlags(QtCore.Qt.NoItemFlags) self.Estequiometria.cellChanged.connect(self.reaccionCambiada) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding)) gridLayout.addLayout(lyt,3,1,1,2) lyt=QtWidgets.QGridLayout() lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),1,1) self.formula=QtWidgets.QCheckBox(QtWidgets.QApplication.translate("pychemqt", "Use name in formula")) self.formula.toggled.connect(partial(self.changeParams, "formula")) lyt.addWidget(self.formula,1,2,1,2) self.customHr=QtWidgets.QCheckBox("ΔHr "+QtWidgets.QApplication.translate("pychemqt", "user specified")) self.customHr.toggled.connect(self.changeHr) lyt.addWidget(self.customHr,2,2,1,2) lyt.addWidget(QtWidgets.QLabel("ΔHr<sup>o</sup>"),3,2) self.Hr=Entrada_con_unidades(unidades.MolarEnthalpy, readOnly=True) self.Hr.valueChanged.connect(partial(self.changeParams, "Hr")) lyt.addWidget(self.Hr,3,3) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Expanding)) gridLayout.addLayout(lyt,3,3,1,2) gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),4,2) lyt=QtWidgets.QHBoxLayout() lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Type"))) self.tipo=QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_TYPE: self.tipo.addItem(txt) self.tipo.currentIndexChanged.connect(partial(self.changeParams, "tipo")) lyt.addWidget(self.tipo) lyt.addItem(QtWidgets.QSpacerItem(20,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed)) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Concentration"))) self.base=QtWidgets.QComboBox() for txt in reaction.Reaction.TEXT_BASE: self.base.addItem(txt) self.base.currentIndexChanged.connect(partial(self.changeParams, "base")) lyt.addWidget(self.base) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Fixed)) gridLayout.addLayout(lyt,5,1,1,5) self.stacked = QtWidgets.QStackedWidget() self.tipo.currentIndexChanged.connect(self.stacked.setCurrentIndex) gridLayout.addWidget(self.stacked,6,1,1,5) gridLayout.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),7,1,1,5) widget=QtWidgets.QWidget() self.stacked.addWidget(widget) lyt=QtWidgets.QGridLayout(widget) lyt.addWidget(QtWidgets.QLabel("<h3>"+QtWidgets.QApplication.translate("pychemqt", "Estequiometric reaction")+"</h3>"),1,1,1,4) self.Conversion=Tabla(1, verticalHeaderModel="C", filas=3) self.Conversion.setConnected() self.Conversion.setFixedWidth(100) lyt.addWidget(self.Conversion,2,1,3,1) label=QtWidgets.QLabel() label.setPixmap(QtGui.QPixmap(os.environ["pychemqt"]+"/images/equation/reaction_conversion.png")) lyt.addWidget(label,2,2,1,3) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("pychemqt", "Temperature unit")),3,2) self.unidadesTemperatura=QtWidgets.QComboBox() for i in unidades.Temperature.__text__: self.unidadesTemperatura.addItem(i) lyt.addWidget(self.unidadesTemperatura,3,3) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),4,4) lyt.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),5,1,1,5) widget=QtWidgets.QWidget() self.stacked.addWidget(widget) lyt=QtWidgets.QGridLayout(widget) self.check_KFijo=QtWidgets.QRadioButton(QtWidgets.QApplication.translate("pychemqt", "Fixed")) self.check_KFijo.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KFijo,1,1,1,2) lyt.addWidget(QtWidgets.QLabel("K<sub>eq</sub>"),1,3) self.Keq=Entrada_con_unidades(float) lyt.addWidget(self.Keq,1,4) label=QtWidgets.QLabel() label.setPixmap(QtGui.QPixmap(os.environ["pychemqt"]+"/images/equation/reaction_equilibrium.png")) lyt.addWidget(label,1,5,1,4) self.check_KEq=QtWidgets.QRadioButton(QtWidgets.QApplication.translate("pychemqt", "Equation")) self.check_KEq.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KEq,2,1,1,2) self.check_KTabla=QtWidgets.QRadioButton(QtWidgets.QApplication.translate("pychemqt", "Table")) self.check_KTabla.toggled.connect(self.KeqChanged) lyt.addWidget(self.check_KTabla,2,5,1,2) self.KEq_Dat=Tabla(1, verticalHeaderLabels=["A", "B", "C", "D", "E", "F", "G", "H"], filas=8) self.KEq_Dat.setFixedHeight(22*8+4) self.KEq_Dat.setFixedWidth(120) lyt.addWidget(self.KEq_Dat,3,3,1,2) self.KEq_Tab=Tabla(4, horizontalHeader=["T, K", "Keq", "Kcalc", "%Error"], verticalHeader=False, columnReadOnly=[False, False, True, True]) self.KEq_Tab.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding) self.KEq_Tab.setFixedWidth(400) self.KEq_Tab.setConnected() self.KEq_Tab.rowFinished.connect(self.Regresion) self.KEq_Tab.setAlternatingRowColors(False) lyt.addWidget(self.KEq_Tab,3,5,1,4) lyt.addWidget(QtWidgets.QLabel("r²"),4,5) self.r2=Entrada_con_unidades(float, readOnly=True) lyt.addWidget(self.r2,4,6) self.botonTablaPlot=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/plot.png")), QtWidgets.QApplication.translate("pychemqt", "Plot")) self.botonTablaPlot.clicked.connect(self.Plot) lyt.addWidget(self.botonTablaPlot,4,7) self.botonTablaClear=QtWidgets.QPushButton(QtGui.QIcon(QtGui.QPixmap(os.environ["pychemqt"]+"/images/button/clear.png")), QtWidgets.QApplication.translate("pychemqt", "Clear")) self.botonTablaClear.clicked.connect(self.KEq_Tab.clear) lyt.addWidget(self.botonTablaClear,4,8) label=QtWidgets.QLabel() label.setPixmap(QtGui.QPixmap(os.environ["pychemqt"]+"/images/equation/reaction_equilibrium2.png")) label.setAlignment(QtCore.Qt.AlignCenter) lyt.addWidget(label,5,1,1,8) self.checkGibbs=QtWidgets.QRadioButton(QtWidgets.QApplication.translate("pychemqt", "From Gibbs free energy minimization")) lyt.addWidget(self.checkGibbs,6,1,1,4) self.check_KFijo.setChecked(True) widget=QtWidgets.QWidget() self.stacked.addWidget(widget) lyt=QtWidgets.QGridLayout(widget) widget=QtWidgets.QWidget() self.stacked.addWidget(widget) lyt=QtWidgets.QGridLayout(widget) self.status=Status() gridLayout.addWidget(self.status, 10,1) self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) gridLayout.addWidget(self.buttonBox,10,2,1,4) if reaccion: self.setReaction(reaccion) def changeParams(self, parametro, valor): self.calculo(**{parametro: valor}) def calculo(self, **kwargs): self.status.setState(4) self.evaluate.start(self.reaction, kwargs) def changeHr(self, bool): self.Hr.setReadOnly(not bool) self.changeParams("customHr", bool) def reaccionCambiada(self): kwargs={"componentes": self.indices, "coeficientes": self.Estequiometria.getColumn(0)[:-1]} self.calculo(**kwargs) def setReaction(self, reaction): self.reaction=reaction self.rellenar() # if self.Estequiometria.getValue(0, self.Base.currentIndex()): # reaccion=reaction.Reaction(self.indices, self.Estequiometria.getColumn(0), base=self.Base.currentIndex(), estequiometria=[0, 0, 0.5], formulas=self.checkFormula.isChecked(), calor=self.checkCalorEspecificado.isChecked(), Hr=self.Hr.value, tipo=self.tipo.currentIndex(), conversion=self.Conversion.getColumn(0)[-1::-1]) # self.Balance.setValue(reaccion.error) # if reaccion.state: # self.Formula.setText(reaccion._txt(self.checkFormula.isChecked())) # self.Hr.setValue(reaccion.Hr) # else: # self.Formula.clear() # self.Hr.clear() # self.botonAdd.setEnabled(reaccion.state and not self.botonEdit.isChecked()) # self.reaccion=reaccion def rellenar(self): self.blockSignals(True) for variable in self.reaction.kwargsValue: self.__getattribute__(variable).setValue(self.reaction.kwargs[variable]) for combo in self.reaction.kwargsList: self.__getattribute__(combo).setCurrentIndex(self.reaction.kwargs[combo]) for check in self.reaction.kwargsCheck: self.__getattribute__(check).setChecked(self.reaction.kwargs[check]) self.Estequiometria.setColumn(0, self.reaction.kwargs["coeficientes"]) # self.Conversion.setColumn(0, self.reaction.estequiometria[-1::-1]) self.blockSignals(False) self.status.setState(self.reaction.status, self.reaction.msg) self.Estequiometria.item(len(self.indices), 0).setText(str(self.reaction.error)) if self.reaction.status: self.Formula.setText(self.reaction._txt()) self.Hr.setValue(self.reaction.Hr) def KeqChanged(self): self.Keq.setReadOnly(not self.check_KFijo.isChecked()) self.KEq_Dat.setEnabled(self.check_KEq.isChecked()) self.KEq_Tab.setEnabled(self.check_KTabla.isChecked()) self.botonTablaClear.setEnabled(self.check_KTabla.isChecked()) self.botonTablaPlot.setEnabled(self.check_KTabla.isChecked()) def Regresion(self): t=array(self.KEq_Tab.getColumn(0)[:-1]) k=array(self.KEq_Tab.getColumn(1)[:-1]) if len(t)>=4: if 4<=len(t)<8: inicio=r_[0, 0, 0, 0] f=lambda par, T: exp(par[0]+par[1]/T+par[2]*log(T)+par[3]*T) resto=lambda par, T, k: k-f(par, T) else: inicio=r_[0, 0, 0, 0, 0, 0, 0, 0] f=lambda par, T: exp(par[0]+par[1]/T+par[2]*log(T)+par[3]*T+par[4]*T**2+par[5]*T**3+par[6]*T**4+par[7]*T**5) resto=lambda par, T, k: k-f(par, T) ajuste=leastsq(resto,inicio,args=(t, k)) kcalc=f(ajuste[0], t) error=(k-kcalc)/k*100 self.KEq_Dat.setColumn(0, ajuste[0]) self.KEq_Tab.setColumn(2, kcalc) self.KEq_Tab.setColumn(3, error) if ajuste[1] in [1, 2, 3, 4]: self.ajuste=ajuste[0] def Plot(self): if self.ajuste!=None: t=array(self.KEq_Tab.getColumn(0)[:-1]) k=array(self.KEq_Tab.getColumn(1)[:-1]) if 4<=len(t)<8: f=lambda par, T: exp(par[0]+par[1]/T+par[2]*log(T)+par[3]*T) else: f=lambda par, T: exp(par[0]+par[1]/T+par[2]*log(T)+par[3]*T+par[4]*T**2+par[5]*T**3+par[6]*T**4+par[7]*T**5) grafico=plot.Plot() grafico.data(t, k, 'ro', t, f(self.ajuste, t)) grafico.exec_()
class UI_equipment(parents.UI_equip): """Diálogo de definición de filtros por presión o a vación para la separación de sólidos de corrientes líquidas""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Filter, entrada=False, parent=parent) self.entrada = entrada #Pestaña entrada self.Entrada = UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab( 0, self.Entrada, QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 0, 1, 1) self.tipo = QtWidgets.QComboBox() self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Rotary vacuum belt discharge", None)) self.tipo.addItem( QtWidgets.QApplication.translate( "equipment", "Rotary vacuum drum scraper discharge", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Rotary vacuum disk", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Horizontal vacuum belt", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Pressure leaf", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Plate and frame", None)) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 1, 1, 3) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 0, 1, 2) self.Costos = costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos, 4, 0, 2, 5) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 6, 0, 1, 6) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 6) self.groupBox_Costos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos, 7, 0, 1, 4) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)), 1, 1) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 1, 2) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)), 2, 1) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 2, 2) #Pestaña salida self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido = UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab( self.SalidaGas, QtWidgets.QApplication.translate("equipment", "Gas filtrado", None)) self.Salida.addTab( self.SalidaSolido, QtWidgets.QApplication.translate("equipment", "Sólidos recogidos", None)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex() == 0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class UI_equipment(UI_equip): """Shell and tube heat exchanger edition dialog""" Equipment = Shell_Tube() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super(UI_equipment, self).__init__(Shell_Tube, parent=parent) # Input tab self.addEntrada(QtWidgets.QApplication.translate("pychemqt", "Tubes"), "entradaTubo") self.addEntrada(QtWidgets.QApplication.translate("pychemqt", "Shell"), "entradaCarcasa") # Model tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 1, tab, QtWidgets.QApplication.translate("pychemqt", "Model")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Class")), 2, 1) self.class_ = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_CLASS: self.class_.addItem(txt) self.class_.currentIndexChanged.connect( partial(self.changeParams, "class_")) lyt.addWidget(self.class_, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Front end head")), 3, 1) self.frontHead = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_FRONTHEAD: self.frontHead.addItem(txt) self.frontHead.currentIndexChanged.connect( partial(self.changeParams, "frontHead")) lyt.addWidget(self.frontHead, 3, 2, 1, 3) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell type")), 4, 1) self.shell = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_SHELL: self.shell.addItem(txt) self.shell.currentIndexChanged.connect( partial(self.changeParams, "shell")) lyt.addWidget(self.shell, 4, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Rear end head")), 5, 1) self.rearHead = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_REARHEAD: self.rearHead.addItem(txt) self.rearHead.currentIndexChanged.connect( partial(self.changeParams, "rearHead")) lyt.addWidget(self.rearHead, 5, 2, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Orientation")), 7, 1) self.orientacion = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_ORIENTATION: self.orientacion.addItem(txt) self.orientacion.currentIndexChanged.connect( partial(self.changeParams, "orientation")) lyt.addWidget(self.orientacion, 7, 2) botonMetodos = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Calculation methods")) botonMetodos.clicked.connect(self.selectMethods) lyt.addWidget(botonMetodos, 9, 1) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) # Tubes tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 2, tab, QtWidgets.QApplication.translate("pychemqt", "Tubes")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Number of tubes")), 1, 1) self.NTubes = Entrada_con_unidades(int, width=60, spinbox=True, step=1) self.NTubes.valueChanged.connect(partial(self.changeParams, "NTube")) lyt.addWidget(self.NTubes, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Number of tube passes")), 2, 1) self.NPases = Entrada_con_unidades(int, width=60, spinbox=True, step=1) self.NPases.valueChanged.connect(partial(self.changeParams, "NPases")) lyt.addWidget(self.NPases, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube length")), 3, 1) self.LTube = Entrada_con_unidades(Length) self.LTube.valueChanged.connect(partial(self.changeParams, "LTube")) lyt.addWidget(self.LTube, 3, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube external diameter")), 4, 1) self.DeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeTube.valueChanged.connect(partial(self.changeParams, "DeTube")) lyt.addWidget(self.DeTube, 4, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube thickness")), 5, 1) self.wTube = Entrada_con_unidades(Length, "Thickness") self.wTube.valueChanged.connect(partial(self.changeParams, "wTube")) lyt.addWidget(self.wTube, 5, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube roughness")), 6, 1) self.rTube = Entrada_con_unidades(Length, "Thickness") self.rTube.valueChanged.connect(partial(self.changeParams, "rTube")) lyt.addWidget(self.rTube, 6, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Thermal conductivity")), 7, 1) self.kTube = Entrada_con_unidades(ThermalConductivity) self.kTube.valueChanged.connect(partial(self.changeParams, "kTube")) lyt.addWidget(self.kTube, 7, 2) self.buttonPipe = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Pipe Database")) self.buttonPipe.clicked.connect(self.showMaterial) lyt.addWidget(self.buttonPipe, 4, 4, 4, 1) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube pattern")), 9, 1) self.distribucionTube = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_DISTRIBUTION_TUBE: self.distribucionTube.addItem(txt) self.distribucionTube.currentIndexChanged.connect( partial(self.changeParams, "distribucionTube")) lyt.addWidget(self.distribucionTube, 9, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube pitch")), 10, 1) self.pitch = Entrada_con_unidades(Length) self.pitch.valueChanged.connect(partial(self.changeParams, "pitch")) lyt.addWidget(self.pitch, 10, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fin Tube")), 11, 1) self.buttonFin = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Finned Pipe Database")) self.buttonFin.setEnabled(False) self.buttonFin.clicked.connect(self.showFinTube) lyt.addWidget(self.buttonFin, 11, 4, 1, 1) self.finned = QtWidgets.QComboBox() self.finned.addItem(QtWidgets.QApplication.translate("pychemqt", "Bared tube")) self.finned.addItem(QtWidgets.QApplication.translate("pychemqt", "Finned tube")) self.finned.currentIndexChanged.connect(self.finnedChanged) lyt.addWidget(self.finned, 11, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fouling")), 12, 1) self.tubeFouling = FoulingWidget() self.tubeFouling.valueChanged.connect( partial(self.changeParams, "tubeFouling")) lyt.addWidget(self.tubeFouling, 12, 2, 1, 3) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Shell tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 3, tab, QtWidgets.QApplication.translate("pychemqt", "Shell")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Exchangers in paralell")), 1, 1) self.paralelo = Entrada_con_unidades(int, width=60) self.paralelo.valueChanged.connect( partial(self.changeParams, "parallel")) lyt.addWidget(self.paralelo, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Exchangers in serie")), 2, 1) self.serie = Entrada_con_unidades(int, width=60) self.serie.valueChanged.connect(partial(self.changeParams, "serie")) lyt.addWidget(self.serie, 2, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell Diameter")), 4, 1) self.DShell = Entrada_con_unidades(Length) self.DShell.valueChanged.connect(partial(self.changeParams, "DShell")) lyt.addWidget(self.DShell, 4, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell Material")), 6, 1) self.materialShell = QtWidgets.QComboBox() lyt.addWidget(self.materialShell, 6, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 7, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fouling")), 8, 1) self.shellFouling = FoulingWidget() self.shellFouling.valueChanged.connect( partial(self.changeParams, "shellFouling")) lyt.addWidget(self.shellFouling, 8, 2, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Sealing Strips")), 10, 1) self.sealingStrips = Entrada_con_unidades(float) self.sealingStrips.valueChanged.connect( partial(self.changeParams, "sealingStrips")) lyt.addWidget(self.sealingStrips, 10, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Clearances")) lyt.addWidget(group, 11, 1, 1, 6) lyt = QtWidgets.QGridLayout(group) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube to baffle hole")), 1, 1) self.ClearanceTubeBaffle = Entrada_con_unidades(Length, "Thickness") self.ClearanceTubeBaffle.valueChanged.connect( partial(self.changeParams, "clearanceTubeBaffle")) lyt.addWidget(self.ClearanceTubeBaffle, 1, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell to baffle")), 2, 1) self.ClearanceShellBaffle = Entrada_con_unidades(Length, "Thickness") self.ClearanceShellBaffle.valueChanged.connect( partial(self.changeParams, "clearanceShellBaffle")) lyt.addWidget(self.ClearanceShellBaffle, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell to bundle")), 3, 1) self.ClearanceShellBundle = Entrada_con_unidades(Length, "Thickness") self.ClearanceShellBundle.valueChanged.connect( partial(self.changeParams, "clearanceShellBundle")) lyt.addWidget(self.ClearanceShellBundle, 3, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Fitting tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 4, tab, QtWidgets.QApplication.translate("pychemqt", "Baffle")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Baffle type")), 1, 1) self.baffleType = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_BAFFLE_TYPE: self.baffleType.addItem(txt) self.baffleType.currentIndexChanged.connect( partial(self.changeParams, "baffleType")) lyt.addWidget(self.baffleType, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 1, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Inlet spacing")), 3, 1) self.baffleSpacingIn = Entrada_con_unidades(Length) self.baffleSpacingIn.valueChanged.connect( partial(self.changeParams, "baffleSpacingIn")) lyt.addWidget(self.baffleSpacingIn, 3, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Outlet spacing")), 3, 4) self.baffleSpacingOut = Entrada_con_unidades(Length) self.baffleSpacingOut.valueChanged.connect( partial(self.changeParams, "baffleSpacingOut")) lyt.addWidget(self.baffleSpacingOut, 3, 5) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Baffle spacing")), 4, 1) self.baffleSpacing = Entrada_con_unidades(Length) self.baffleSpacing.valueChanged.connect( partial(self.changeParams, "baffleSpacing")) lyt.addWidget(self.baffleSpacing, 4, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Baffle thickness")), 5, 1) self.baffleThickness = Entrada_con_unidades(Length, "Thickness") self.baffleThickness.valueChanged.connect( partial(self.changeParams, "baffleThickness")) lyt.addWidget(self.baffleThickness, 5, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Orientation")), 6, 1) self.baffleOrientation = QtWidgets.QComboBox() self.baffleOrientation.addItem(QtWidgets.QApplication.translate("pychemqt", "Horizontal")) self.baffleOrientation.addItem(QtWidgets.QApplication.translate("pychemqt", "Vertical")) self.baffleOrientation.currentIndexChanged.connect( partial(self.changeParams, "baffleOrientation")) lyt.addWidget(self.baffleOrientation, 6, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cut percent")), 7, 1) self.baffleCut = Entrada_con_unidades(float, textounidad="%") self.baffleCut.valueChanged.connect( partial(self.changeParams, "baffleCut")) lyt.addWidget(self.baffleCut, 7, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cut base")), 7, 4) self.baffleCutBase = QtWidgets.QComboBox() self.baffleCutBase.addItem(QtWidgets.QApplication.translate("pychemqt", "Diameter")) self.baffleCutBase.addItem(QtWidgets.QApplication.translate("pychemqt", "Area")) self.baffleCutBase.currentIndexChanged.connect( partial(self.changeParams, "baffleCutBase")) lyt.addWidget(self.baffleCutBase, 7, 5) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 3, 6, 1) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Nozzles")) lyt.addWidget(group, 9, 1, 1, 6) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shellside")), 0, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tubeside")), 0, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Input diameter")), 1, 1) self.nozzleInShellsideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleInShellsideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleInShellsideDiameter")) layout.addWidget(self.nozzleInShellsideDiameter, 1, 2) self.nozzleInTubesideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleInTubesideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleInTubesideDiameter")) layout.addWidget(self.nozzleInTubesideDiameter, 1, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Output diameter")), 2, 1) self.nozzleOutShellsideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleOutShellsideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleOutShellsideDiameter")) layout.addWidget(self.nozzleOutShellsideDiameter, 2, 2) self.nozzleOutTubesideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleOutTubesideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleOutTubesideDiameter")) layout.addWidget(self.nozzleOutTubesideDiameter, 2, 3) layout.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed), 1, 4, 2, 1) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Calculation Mode")), 1, 1) self.modo = QtWidgets.QComboBox() self.modo.addItem(QtWidgets.QApplication.translate("pychemqt", "Rating")) self.modo.addItem(QtWidgets.QApplication.translate("pychemqt", "Design")) lyt.addWidget(self.modo, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Cost tab lyt = QtWidgets.QGridLayout(self.tabCostos) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Type")), 1, 1) self.tipoCoste = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_COST_TYPE: self.tipoCoste.addItem(txt) self.tipoCoste.currentIndexChanged.connect( partial(self.changeParamsCoste, "tipoCoste")) lyt.addWidget(self.tipoCoste, 1, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Material")), 2, 1) self.materialCoste = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_COST_MATERIAL: self.materialCoste.addItem(txt) self.materialCoste.currentIndexChanged.connect( partial(self.changeParamsCoste, "P_dis")) lyt.addWidget(self.materialCoste, 2, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 3, 0, 1, 6) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Design Pressure")), 4, 1) self.Pdiseno = Entrada_con_unidades(Pressure) lyt.addWidget(self.Pdiseno, 4, 2, 1, 1) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 5, 0, 1, 6) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.calcularCostos) lyt.addWidget(self.Costos, 6, 1, 2, 5) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 8, 0, 1, 6) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Stimated Costs")) lyt.addWidget(group, 9, 1, 1, 5) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Purchase Cost")), 0, 1) self.C_adq = Entrada_con_unidades( Currency, retornar=False, readOnly=True) layout.addWidget(self.C_adq, 0, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Installed Cost")), 1, 1) self.C_inst = Entrada_con_unidades( Currency, retornar=False, readOnly=True) self.C_inst.entrada.setReadOnly(True) layout.addWidget(self.C_inst, 1, 2) # Output Tab self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Tubes")) self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Shell")) if equipment: self.setEquipment(equipment) def selectMethods(self): """Show dialog for select calculation methods""" dialogo = Dialog_Methods(self.Equipment) if dialogo.exec_(): self.Equipment(**dialogo.kwargs) def showMaterial(self): dialogo = Catalogo_Materiales_Dialog() if dialogo.exec_(): pass def rellenarFouling(self, widget, txt): if txt: widget.setReadOnly(True) widget.setValue(Fouling_Factor_Shell_Tube_Exchanger[str(txt)]) else: widget.setReadOnly(False) def finnedChanged(self, ind): self.buttonFin.setEnabled(ind) self.changeParams("finned", ind) def showFinTube(self): dialogo = Dialog_Finned() if dialogo.exec_(): pass def rellenar(self): pass def calcularCostos(self): if self.todos_datos(): self.Equipment.Coste(self.factorInstalacion.value(), 0, self.tipo.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.Equipment.C_adq.config()) self.C_inst.setValue(self.Equipment.C_inst.config())
class UI_equipment(UI_equip): """Double pipe heat exchanger edition dialog""" Equipment = Hairpin() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super(UI_equipment, self).__init__(Hairpin, parent=parent) # Input tab self.addEntrada(QtGui.QApplication.translate("pychemqt", "Tube"), "entradaTubo") self.addEntrada(QtGui.QApplication.translate("pychemqt", "Annulli"), "entradaExterior") # Pipe catalog tab tabCatalogo = QtGui.QWidget() self.tabWidget.insertTab( 1, tabCatalogo, QtGui.QApplication.translate("pychemqt", "Catalog")) lyt = QtGui.QGridLayout(tabCatalogo) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Tube length")), 4, 1) self.LTube = Entrada_con_unidades(Length) self.LTube.valueChanged.connect(partial(self.changeParams, "LTube")) lyt.addWidget(self.LTube, 4, 2) lyt.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 5, 1) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Tube internal diameter")), 6, 1) self.DiTube = Entrada_con_unidades(Length, "pipeDiameter") self.DiTube.valueChanged.connect(partial(self.changeParams, "DiTube")) lyt.addWidget(self.DiTube, 6, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Tube external diameter")), 7, 1) self.DeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeTube.valueChanged.connect(partial(self.changeParams, "DeTube")) lyt.addWidget(self.DeTube, 7, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Tube thickness")), 8, 1) self.wTube = Entrada_con_unidades(Length, "Thickness") self.wTube.valueChanged.connect(partial(self.changeParams, "wTube")) lyt.addWidget(self.wTube, 8, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Tube roughness")), 9, 1) self.rTube = Entrada_con_unidades(Length, "Thickness") self.rTube.valueChanged.connect(partial(self.changeParams, "rTube")) lyt.addWidget(self.rTube, 9, 2) lyt.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 10, 1) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Annulli external diameter")), 11, 1) self.DeeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeeTube.valueChanged.connect(partial(self.changeParams, "DeeTube")) lyt.addWidget(self.DeeTube, 11, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Thermal conductivity")), 12, 1) self.kTube = Entrada_con_unidades(ThermalConductivity) self.kTube.valueChanged.connect(partial(self.changeParams, "kTube")) lyt.addWidget(self.kTube, 12, 2) lyt.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Tube Count")), 13, 1) self.nTube = Entrada_con_unidades(int) self.nTube.valueChanged.connect(partial(self.changeParams, "nTube")) lyt.addWidget(self.nTube, 13, 2) buttonPipe = QtGui.QPushButton( QtGui.QApplication.translate("pychemqt", "Pipe Database")) buttonPipe.clicked.connect(self.showMaterial) lyt.addWidget(buttonPipe, 6, 3, 4, 1) lyt.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 14, 1) self.tubeFinned = QtGui.QCheckBox( QtGui.QApplication.translate("pychemqt", "Finned Tube")) lyt.addWidget(self.tubeFinned, 15, 1, 1, 4) self.buttonFin = QtGui.QPushButton( QtGui.QApplication.translate("pychemqt", "Finned Pipe Database")) self.buttonFin.setEnabled(False) self.buttonFin.clicked.connect(self.showFinTube) lyt.addWidget(self.buttonFin, 15, 3) self.tubeFinned.toggled.connect( partial(self.changeParams, "tubeFinned")) self.tubeFinned.toggled.connect(self.buttonFin.setEnabled) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Inside Fouling")), 16, 1) self.tubeFouling = FoulingWidget() self.tubeFouling.valueChanged.connect( partial(self.changeParams, "tubeFouling")) lyt.addWidget(self.tubeFouling, 16, 2, 1, 5) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Outside Fouling")), 17, 1) self.annulliFouling = FoulingWidget() self.annulliFouling.valueChanged.connect( partial(self.changeParams, "annulliFouling")) lyt.addWidget(self.annulliFouling, 17, 2, 1, 5) lyt.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 20, 1, 1, 6) # Calculate tab lyt = QtGui.QGridLayout(self.tabCalculo) lyt.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Mode")), 1, 1) self.modo = QtGui.QComboBox() for txt in self.Equipment.TEXT_MODO: self.modo.addItem(txt) self.modo.currentIndexChanged.connect( partial(self.changeParams, "modo")) lyt.addWidget(self.modo, 1, 2) lyt.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Flujo")), 2, 1) self.flujo = QtGui.QComboBox() for txt in self.Equipment.TEXT_FLUJO: self.flujo.addItem(txt) self.flujo.currentIndexChanged.connect( partial(self.changeParams, "flujo")) lyt.addWidget(self.flujo, 2, 2) lyt.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Layout")), 3, 1) self.orientacion = QtGui.QComboBox() for txt in self.Equipment.TEXT_ORIENTACION: self.orientacion.addItem(txt) self.orientacion.currentIndexChanged.connect( partial(self.changeParams, "orientacion")) lyt.addWidget(self.orientacion, 3, 2) lyt.addItem( QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 4, 1) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Output inside temperature")), 5, 1) self.tubeTout = Entrada_con_unidades(Temperature) self.tubeTout.valueChanged.connect( partial(self.changeParams, "tubeTout")) lyt.addWidget(self.tubeTout, 5, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Output annulli temperature")), 6, 1) self.annulliTout = Entrada_con_unidades(Temperature) self.annulliTout.valueChanged.connect( partial(self.changeParams, "annulliTout")) lyt.addWidget(self.annulliTout, 6, 2) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Output inside quality")), 5, 4) self.tubeXout = Entrada_con_unidades(float) self.tubeXout.valueChanged.connect( partial(self.changeParams, "tubeXout")) lyt.addWidget(self.tubeXout, 5, 5) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Output annulli quality")), 6, 4) self.annulliXout = Entrada_con_unidades(float) self.annulliXout.valueChanged.connect( partial(self.changeParams, "annulliXout")) lyt.addWidget(self.annulliXout, 6, 5) lyt.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 15, 1, 1, 6) group = QtGui.QGroupBox( QtGui.QApplication.translate("pychemqt", "Results")) lyt.addWidget(group, 16, 1, 1, 6) layout = QtGui.QGridLayout(group) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Heat Duty")), 0, 1) self.Q = Entrada_con_unidades(Power, retornar=False, readOnly=True) layout.addWidget(self.Q, 0, 2) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Tout Tube")), 1, 1) self.ToutTube = Entrada_con_unidades(Temperature, retornar=False) self.ToutTube.setReadOnly(True) layout.addWidget(self.ToutTube, 1, 2) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Tout Tube")), 2, 1) self.ToutAnnulli = Entrada_con_unidades(Temperature, retornar=False) self.ToutAnnulli.setReadOnly(True) layout.addWidget(self.ToutAnnulli, 2, 2) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "U")), 0, 4) self.U = Entrada_con_unidades(HeatTransfCoef, retornar=False) self.U.setReadOnly(True) layout.addWidget(self.U, 0, 5) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Area")), 1, 4) self.A = Entrada_con_unidades(Area, retornar=False, readOnly=True) layout.addWidget(self.A, 1, 5) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Lenght")), 2, 4) self.L = Entrada_con_unidades(Length, retornar=False, readOnly=True) layout.addWidget(self.L, 2, 5) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "DeltaP Tube")), 0, 7) self.deltaPTube = Entrada_con_unidades(DeltaP, retornar=False) self.deltaPTube.setReadOnly(True) layout.addWidget(self.deltaPTube, 0, 8) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "DeltaP Annulli")), 1, 7) self.deltaPAnnulli = Entrada_con_unidades(DeltaP, retornar=False) self.deltaPAnnulli.setReadOnly(True) layout.addWidget(self.deltaPAnnulli, 1, 8) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "CF")), 2, 7) self.CF = Entrada_con_unidades(float, retornar=False, readOnly=True) layout.addWidget(self.CF, 2, 8) lyt.addItem( QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 17, 1, 1, 6) # Cost tab lyt = QtGui.QGridLayout(self.tabCostos) lyt.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Material")), 2, 1) self.material = QtGui.QComboBox() for txt in self.Equipment.TEXT_MATERIAL: self.material.addItem(txt) self.material.currentIndexChanged.connect( partial(self.changeParamsCoste, "material")) lyt.addWidget(self.material, 2, 2) lyt.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 3, 0, 1, 6) lyt.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Design Pressure")), 4, 1) self.P_dis = Entrada_con_unidades(Pressure) self.P_dis.valueChanged.connect( partial(self.changeParamsCoste, "P_dis")) lyt.addWidget(self.P_dis, 4, 2, 1, 1) lyt.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 5, 0, 1, 6) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) lyt.addWidget(self.Costos, 6, 1, 2, 5) lyt.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 8, 0, 1, 6) lyt.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 10, 0, 1, 6) group = QtGui.QGroupBox( QtGui.QApplication.translate("pychemqt", "Stimated Costs")) lyt.addWidget(group, 9, 1, 1, 5) layout = QtGui.QGridLayout(group) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Purchase Cost")), 0, 1) self.C_adq = Entrada_con_unidades(Currency, retornar=False) self.C_adq.setReadOnly(True) layout.addWidget(self.C_adq, 0, 2) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Installed Cost")), 1, 1) self.C_inst = Entrada_con_unidades(Currency, retornar=False) self.C_inst.setReadOnly(True) self.C_inst.entrada.setReadOnly(True) layout.addWidget(self.C_inst, 1, 2) # Output Tab self.addSalida(QtGui.QApplication.translate("pychemqt", "Tube")) self.addSalida(QtGui.QApplication.translate("pychemqt", "Annulli")) if equipment: self.setEquipment(equipment) def showMaterial(self): dialogo = Catalogo_Materiales_Dialog() if dialogo.exec_(): material = dialogo.getMaterial() if material: self.rTube.setValue(material[2]) self.DiTube.setValue(material[4]) self.wTube.setValue(material[5]) self.DeTube.setValue(material[6]) def showFinTube(self): dialogo = Dialog_Finned(self.Equipment.kwargs) if dialogo.exec_(): kwarg = dialogo.kwarg() self.calculo(**kwarg)
class UI_equipment(parents.UI_equip): """Diálogo de definición de filtros de mangas""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada""" super(UI_equipment, self).__init__(Baghouse, entrada=False, parent=parent) self.entrada = entrada #Pestaña entrada self.Entrada = UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab( 0, self.Entrada, QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña definición rendimientos self.Rendimientos = QtWidgets.QTableWidget(1, 2) self.Rendimientos.setItemDelegateForColumn(1, CellEditor(self)) self.Rendimientos.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.Rendimientos.verticalHeader().hide() self.Rendimientos.setEditTriggers( QtWidgets.QAbstractItemView.AllEditTriggers) if self.entrada: self.rellenarTablaRendimientos() self.rendimientos = [] self.Rendimientos.cellChanged.connect(self.cambiarRendimientos) self.tabWidget.insertTab( 1, self.Rendimientos, QtWidgets.QApplication.translate("equipment", "Rendimientos", None)) #Cálculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo de cálculo:", None)), 1, 1, 1, 1) self.TipoCalculo = QtWidgets.QComboBox() self.TipoCalculo.addItem( QtWidgets.QApplication.translate("equipment", "Calcular caída de presión", None)) self.TipoCalculo.addItem( QtWidgets.QApplication.translate("equipment", "Calcular tiempo de filtración", None)) self.TipoCalculo.addItem( QtWidgets.QApplication.translate("equipment", "Calcular número de filtros", None)) self.TipoCalculo.currentIndexChanged.connect(self.tipoCalculoCambiado) gridLayout_Calculo.addWidget(self.TipoCalculo, 1, 2, 1, 4) gridLayout_Calculo.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 1, 1, 6) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Nº de filtros:", None)), 3, 1, 1, 1) self.numFiltros = Entrada_con_unidades(int, spinbox=True, step=1, width=50, resaltado=True, min=1, start=1) self.numFiltros.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.numFiltros, 3, 2, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tiempo de filtración:", None)), 4, 1, 1, 1) self.tiempo = Entrada_con_unidades(unidades.Time, resaltado=True) self.tiempo.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.tiempo, 4, 2, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Pérdida de presión:", None)), 5, 1, 1, 1) self.deltaP = Entrada_con_unidades(unidades.Pressure, retornar=False, readOnly=True) self.deltaP.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.deltaP, 5, 2, 1, 1) gridLayout_Calculo.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 6) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Membranas por filtro:", None)), 7, 1, 1, 1) self.MembranaCelda = Entrada_con_unidades(int, spinbox=True, step=1, width=70, value=78, min=1) self.MembranaCelda.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.MembranaCelda, 7, 2, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Diametro de membrana:", None)), 8, 1, 1, 1) self.Diametro = Entrada_con_unidades(unidades.Length, value=unidades.Length(0.5, "ft")) self.Diametro.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Diametro, 8, 2, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Area por membrana:", None)), 9, 1, 1, 1) self.Area = Entrada_con_unidades(unidades.Area, value=unidades.Area(16, "ft2")) self.Area.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Area, 9, 2, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Resistencia filtro:", None)), 7, 4, 1, 1) self.resistenciaFiltro = Entrada_con_unidades(float, spinbox=True, step=0.01, width=70, value=0.84, min=0) self.resistenciaFiltro.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.resistenciaFiltro, 7, 5, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Resistencia torta:", None)), 8, 4, 1, 1) self.resistenciaTorta = Entrada_con_unidades(float, spinbox=True, step=0.01, width=70, value=0.1, min=0) self.resistenciaTorta.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.resistenciaTorta, 8, 5, 1, 1) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Filtros en limpieza:", None)), 9, 4, 1, 1) self.Limpieza = Entrada_con_unidades(int, spinbox=True, step=1, width=70, value=1, min=0) self.Limpieza.valueChanged.connect(self.calculo) gridLayout_Calculo.addWidget(self.Limpieza, 9, 5, 1, 1) gridLayout_Calculo.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) self.groupBox_Calculo = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Datos calculados", None)) gridLayout_Calculo.addWidget(self.groupBox_Calculo, 11, 1, 1, 5) self.gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Calculo) self.gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "V<sub>gas</sub>:", None)), 0, 1, 1, 1) self.Vgas = Entrada_con_unidades(unidades.Speed, retornar=False, readOnly=True) self.gridLayout_1.addWidget(self.Vgas, 0, 2, 1, 1) self.gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Rendimiento:", None)), 1, 1, 1, 1) self.rendimientoCalculado = Entrada_con_unidades(float, readOnly=True) self.gridLayout_1.addWidget(self.rendimientoCalculado, 1, 2, 1, 1) self.gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Superficie:", None)), 2, 1, 1, 1) self.superficie = Entrada_con_unidades(unidades.Area, readOnly=True) self.gridLayout_1.addWidget(self.superficie, 2, 2, 1, 1) gridLayout_Calculo.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 12, 1, 1, 6) #Salidas self.SalidaGas = UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido = UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab( self.SalidaGas, QtWidgets.QApplication.translate("equipment", "Gas filtrado", None)) self.Salida.addTab( self.SalidaSolido, QtWidgets.QApplication.translate("equipment", "Sólidos recogidos", None)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): self.entrada = corriente self.rellenarTablaRendimientos() self.calculo() def rellenarTablaRendimientos(self): self.Rendimientos.clearContents() self.Rendimientos.setRowCount(len(self.entrada.solido.distribucion)) self.Rendimientos.setHorizontalHeaderLabels([ QtWidgets.QApplication.translate("equipment", "Diámetro, µm", None), QtWidgets.QApplication.translate("equipment", "Rendimiento", None) ]) for i in range(len(self.entrada.solido.distribucion)): self.Rendimientos.setRowHeight(i, 22) self.Rendimientos.setItem( i, 0, QtWidgets.QTableWidgetItem( representacion(1e6 * self.entrada.solido.diametros[i]))) self.Rendimientos.item( i, 0).setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.Rendimientos.item(i, 0).setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.Rendimientos.setItem(i, 1, QtWidgets.QTableWidgetItem("")) self.Rendimientos.item( i, 1).setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) def cambiarRendimientos(self, fila, columna): numero = float(self.Rendimientos.item(fila, columna).text()) if numero < 0 or numero > 1: self.Rendimientos.item(fila, columna).setText("") else: if self.rendimientos == []: self.rendimientos = [0] * self.Rendimientos.rowCount() self.rendimientos[fila] = numero def todos_datos(self): if self.TipoCalculo.currentIndex() == 0: todos_datos = self.numFiltros.value and self.tiempo.value elif self.TipoCalculo.currentIndex() == 1: todos_datos = self.numFiltros.value and self.deltaP.value else: todos_datos = self.tiempo.value and self.deltaP.value return todos_datos and self.Entrada.todos_datos() def calculo(self): if self.todos_datos(): if self.Limpieza.value == self.numFiltros.value: self.status.setState( 5, QtWidgets.QApplication.translate( "equipment", "Todos los filtros en limpieza", None)) else: self.status.setState(4) self.Equipment(entrada=self.entrada, metodo=self.TipoCalculo.currentIndex(), num_filtros=self.numFiltros.value, tiempo=self.tiempo.value, deltaP=self.deltaP.value.atm, resistenciaFiltro=self.resistenciaFiltro.value, resistenciaTorta=self.resistenciaTorta.value, limpieza=self.Limpieza.value, membranasFiltro=self.MembranaCelda.value, diametroMembrana=self.Diametro.value, areaMembrana=self.Area.value, rendimientos=self.rendimientos) self.rellenoSalida() if self.rendimientos == []: self.status.setState( 3, QtWidgets.QApplication.translate( "equipment", "Usando rendimiento por defecto", None)) else: self.status.setState(1) def rellenoSalida(self): if self.TipoCalculo.currentIndex() == 0: self.deltaP.setValue(self.Equipment.deltaP) elif self.TipoCalculo.currentIndex() == 1: self.tiempo.setValue(self.Equipment.tiempo) else: self.numFiltros.setValue(self.Equipment.num_filtros) self.Vgas.setValue(self.Equipment.Vgas) self.rendimientoCalculado.setValue(self.Equipment.rendimiento) self.superficie.setValue(self.Equipment.floorArea) self.SalidaGas.rellenar(self.Equipment.SalidaAire) self.SalidaSolido.rellenar(self.Equipment.SalidaSolido) def tipoCalculoCambiado(self, tipo_calculo): if tipo_calculo == 0: self.numFiltros.setReadOnly(False) self.numFiltros.setRetornar(True) self.numFiltros.setResaltado(True) self.tiempo.setReadOnly(False) self.tiempo.setRetornar(True) self.tiempo.setResaltado(True) self.deltaP.setReadOnly(True) self.deltaP.setRetornar(False) self.deltaP.setResaltado(False) elif tipo_calculo == 1: self.numFiltros.setReadOnly(False) self.numFiltros.setRetornar(True) self.numFiltros.setResaltado(True) self.tiempo.setReadOnly(True) self.tiempo.setRetornar(False) self.tiempo.setResaltado(False) self.deltaP.setReadOnly(False) self.deltaP.setRetornar(True) self.deltaP.setResaltado(True) else: self.numFiltros.setReadOnly(True) self.numFiltros.setRetornar(False) self.numFiltros.setResaltado(False) self.tiempo.setReadOnly(False) self.tiempo.setRetornar(True) self.tiempo.setResaltado(True) self.deltaP.setReadOnly(False) self.deltaP.setRetornar(True) self.deltaP.setResaltado(True)
class UI_equipment(parents.UI_equip): """Diálogo de definición de molinos trituradores de sólidos""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Grinder, entrada=False, salida=False, parent=parent) self.entrada = entrada #Pestaña entrada self.Entrada = UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab( 0, self.Entrada, QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) gridLayout_Calculo.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Índice de trabajo de bond:", None)), 1, 0, 1, 1) self.Material = QtWidgets.QComboBox() self.Material.addItem( QtWidgets.QApplication.translate("equipment", "Definido por el usuario", None)) for key in sorted(BondIndex.keys()): self.Material.addItem(key) self.Material.currentIndexChanged[str].connect( self.cambiarBondWordIndex) gridLayout_Calculo.addWidget(self.Material, 1, 1, 1, 1) self.BondWorkIndex = Entrada_con_unidades(float) gridLayout_Calculo.addWidget(self.BondWorkIndex, 1, 2, 1, 1) gridLayout_Calculo.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 5) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipo = QtWidgets.QComboBox() self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "De cono", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Giratorio", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Dentado", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "De martillo", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "De bolas", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Pulverizador", None)) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 1, 1, 2) self.Costos = costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos, 4, 1, 2, 5) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 6, 1, 1, 6) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) self.groupBox_Costos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos, 7, 1, 1, 6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)), 0, 1, 1, 1) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 0, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)), 1, 1, 1, 1) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 1, 2, 1, 1) #Pestaña salida self.Salida = UI_corriente.Ui_corriente(readOnly=True) self.tabWidget.insertTab( 3, self.Salida, QtWidgets.QApplication.translate("equipment", "Salida", None)) self.tabWidget.setCurrentIndex(0) def cambiarBondWordIndex(self, txt): try: value = BondIndex[str(txt)] except KeyError: self.BondWorkIndex.setReadOnly(False) self.BondWorkIndex.clear() else: self.BondWorkIndex.setValue(value) self.BondWorkIndex.setReadOnly(True) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self, factor=None, indiceBase=None, indiceActual=None): if self.todos_datos(): if not factor: factor = self.Costos.factor if not indiceBase: indiceBase = self.Costos.Base if not indiceActual: indiceActual = self.Costos.Actual if self.tipo.currentIndex() == 0: self.FireHeater.Coste(factor, indiceBase, indiceActual, 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(factor, indiceBase, indiceActual, 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class CostData(QtGui.QWidget): """Common widget to equipment with cost section It have property to easy access to properties: factor: install factor base: base index (January 1982) actual: current index values: a tuple with all properties, (factor, base,actual) """ valueChanged = QtCore.pyqtSignal(QtCore.QString, float) def __init__(self, equipment, parent=None): """constructor equipment: equipment class where the widget have to be put, define indiceCostos as a index in costIndex""" super(CostData, self).__init__(parent) self.indice = equipment.indiceCostos factor = equipment.kwargs["f_install"] gridLayout = QtGui.QGridLayout(self) gridLayout.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 1, 0, 1, 7) gridLayout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Instalation factor:")), 2, 0, 1, 1) self.factorInstalacion = Entrada_con_unidades(float, spinbox=True, decimales=1, step=0.1, width=50, value=factor) self.factorInstalacion.valueChanged.connect( partial(self.valueChanged.emit, "f_install")) gridLayout.addWidget(self.factorInstalacion, 2, 1, 1, 1) gridLayout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Base index:")), 2, 4, 1, 1) self.indiceBase = Entrada_con_unidades(float, readOnly=True, value=indiceBase[self.indice], decimales=1) gridLayout.addWidget(self.indiceBase, 2, 5, 1, 1) gridLayout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Current index:")), 3, 4, 1, 1) self.indiceActual = Entrada_con_unidades( float, readOnly=True, colorReadOnly="white", value=indiceActual[self.indice], decimales=1) gridLayout.addWidget(self.indiceActual, 3, 5, 1, 1) self.costIndex = QtGui.QToolButton() self.costIndex.setFixedSize(QtCore.QSize(24, 24)) self.costIndex.clicked.connect(self.on_costIndex_clicked) self.costIndex.setText("...") self.costIndex.setVisible(False) gridLayout.addWidget(self.costIndex, 3, 5, 1, 1) gridLayout.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 4, 0, 1, 7) def on_costIndex_clicked(self): """Show costIndes dialog to show/change""" dialog = Ui_CostIndex() if dialog.exec_(): with open(config.conf_dir + "CostIndex.dat", "r") as archivo: self.indiceActual.setValue( float(archivo.readlines()[self.indice][:-1])) self.valueChanged.emit("Current_index", self.indiceActual.value) def enterEvent(self, event): self.costIndex.setVisible(True) def leaveEvent(self, event): self.costIndex.setVisible(False) @property def factor(self): return self.factorInstalacion.value @property def base(self): return self.indiceBase.value @property def actual(self): return self.indiceActual.value @property def values(self): return self.factorInstalacion.value, self.indiceBase.value,\ self.indiceActual.value def setFactor(self, value): self.factorInstalacion.setValue(value) def setBase(self, value): self.indiceBase.setValue(value) def setActual(self, value): self.indiceActual.setValue(value) def setValues(self, factor, base, actual): self.factorInstalacion.setValue(factor) self.indiceBase.setValue(base) self.indiceActual.setValue(actual)
class UI_equipment(parents.UI_equip): """Diálogo de definición de tuberías""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Tower, parent=parent) self.entrada=entrada # #Pestaña entrada # self.Entrada= UI_corriente.Ui_corriente(entrada) # self.Entrada.Changed.connect(self.cambiar_entrada) # self.tabWidget.addTab(self.Entrada, QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Proceso:", None)), 1, 1, 1, 1) self.proceso=QtWidgets.QComboBox() self.proceso.addItem(QtWidgets.QApplication.translate("equipment", "Destilación", None)) self.proceso.addItem(QtWidgets.QApplication.translate("equipment", "Absorción", None)) self.proceso.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.proceso, 1, 2, 1, 1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo de columna:", None)), 2, 1, 1, 1) self.tipo=QtWidgets.QComboBox() self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "De pisos", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "De relleno", None)) self.tipo.currentIndexChanged.connect(self.mostrarSubclasificacion) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 2, 2, 1, 1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Material:", None)), 3, 1, 1, 1) self.material=QtWidgets.QComboBox() self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero al carbon", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Carpenter 20CB-3", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Niquel 200", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Monel 400", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Inconel 600", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Incoloy 825", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Titanio", None)) self.material.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.material, 3, 2, 1, 1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(30,30,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),1,3,5,1) self.groupBox_Pisos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Torre de pisos", None)) gridLayout_Costos.addWidget(self.groupBox_Pisos,1,4,4,2) gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Pisos) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipoPisos=QtWidgets.QComboBox() self.tipoPisos.addItem(QtWidgets.QApplication.translate("equipment", "De válvula", None)) self.tipoPisos.addItem(QtWidgets.QApplication.translate("equipment", "De rejilla", None)) self.tipoPisos.addItem(QtWidgets.QApplication.translate("equipment", "De borboteo", None)) self.tipoPisos.addItem(QtWidgets.QApplication.translate("equipment", "De tamiz", None)) self.tipoPisos.currentIndexChanged.connect(self.calcularCostos) gridLayout_1.addWidget(self.tipoPisos, 1, 2, 1, 1) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Material:", None)), 2, 1, 1, 1) self.materialPisos=QtWidgets.QComboBox() self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Acero al carbon", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Carpenter 20CB-3", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Niquel 200", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Monel 400", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Inconel 600", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Incoloy 825", None)) self.materialPisos.addItem(QtWidgets.QApplication.translate("equipment", "Titanio", None)) self.materialPisos.currentIndexChanged.connect(self.calcularCostos) gridLayout_1.addWidget(self.materialPisos, 2, 2, 1, 1) gridLayout_1.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),3,1,1,2) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Diametro:", None)), 4, 1, 1, 1) self.diametroPisos=Entrada_con_unidades(unidades.Length) gridLayout_1.addWidget(self.diametroPisos,4,2,1,1) gridLayout_1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Número:", None)), 5, 1, 1, 1) self.NumeroPisos=Entrada_con_unidades(int, spinbox=True, min=1, step=1, width=50) gridLayout_1.addWidget(self.NumeroPisos,5,2,1,1) gridLayout_1.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),6,1,1,2) self.groupBox_relleno = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Torre de relleno", None)) gridLayout_Costos.addWidget(self.groupBox_relleno,1, 4, 4, 2) gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_relleno) gridLayout_2.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Volumen:", None)), 1, 1, 1, 1) self.VolumenRelleno=Entrada_con_unidades(unidades.Volume, "VolLiq") gridLayout_2.addWidget(self.VolumenRelleno,1,2,1,1) gridLayout_2.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste unitario:", None)),2,1,1,1) self.C_unit_relleno=Entrada_con_unidades(unidades.Currency, retornar=False, textounidad="%s / %s" % (unidades.Currency(None).text(), unidades.Volume(None).text("VolLiq"))) gridLayout_2.addWidget(self.C_unit_relleno,2,2,1,1) gridLayout_2.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),3,1,1,2) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Diametro:", None)),5,1,1,1) self.Dc=Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Dc,5,2,1,2) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Altura:", None)), 6, 1, 1, 1) self.Hc=Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Hc,6,2,1,2) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Espesor (Tapa):", None)), 7, 1, 1, 1) self.EspesorSuperior=Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.EspesorSuperior,7,2,1,2) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Espesor (Fondo):", None)), 8, 1, 1, 1) self.EspesorInferior=Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.EspesorInferior,8,2,1,2) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Densidad:", None)), 9, 1, 1, 1) self.EspesorInferior=Entrada_con_unidades(unidades.Density, "DenLiq") gridLayout_Costos.addWidget(self.EspesorInferior,9,2,1,2) self.Costos=costIndex.CostData(3, 3) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos,10,1,2,4) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),12,1,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,13,1,1,5) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Pisos:", None)),0,1,1,1) self.C_pisos=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_pisos,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Carcasa:", None)),1,1,1,1) self.C_carcasa=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_carcasa,1,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Accesorios:", None)),2,1,1,1) self.C_accesorios=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_accesorios,2,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Columna:", None)),0,4,1,1) self.C_columna=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_columna,0,5,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),1,4,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq,1,5,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),2,4,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst,2,5,1,1) # #Pestaña salida # self.pSalida = QtGui.QTabWidget() # self.tabWidget.addTab(self.pSalida,QtGui.QApplication.translate("equipment", "Salida", None, QtGui.QApplication.UnicodeUTF8)) self.mostrarSubclasificacion(0) def mostrarSubclasificacion(self, ind): self.groupBox_Pisos.setVisible(not ind) self.groupBox_relleno.setVisible(ind) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): self.ShellTube.Coste(self.factorInstalacion.value(), 0, self.tipo.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.ShellTube.C_adq.config()) self.C_inst.setValue(self.ShellTube.C_inst.config())
class UI_equipment(parents.UI_equip): """Diálogo de definición de tuberías""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Tank, entrada=False, salida=False, parent=parent) self.entrada=entrada #Pestaña entrada self.Entrada= UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab(0, self.Entrada,QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Material:", None)), 1, 1, 1, 1) self.material=QtWidgets.QComboBox() self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero al carbon", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 347", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Niquel", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Monel", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Inconel", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Zirconio", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Titanio", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Ladrillo y caucho o ladrillo y acero recubierto de poliester", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Caucho o acero recubierto de plomo", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Poliester reforzado con fiberglass", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Aluminio", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Cobre", None)) self.material.addItem(QtWidgets.QApplication.translate("equipment", "Hormigón", None)) self.material.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.material, 1, 2, 1, 4) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Densidad:", None)), 2, 4, 1, 1) self.Densidad=Entrada_con_unidades(unidades.Density, "DenLiq") gridLayout_Costos.addWidget(self.Densidad,2,5,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Diametro:", None)), 2, 1, 1, 1) self.Diametro=Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Diametro,2,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Longitud:", None)), 3, 1, 1, 1) self.Longitud=Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Longitud,3,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Espesor:", None)), 4, 1, 1, 1) self.Espesor=Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.Espesor,4,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Cabeza:", None)), 5, 1, 1, 1) self.Cabeza=QtWidgets.QComboBox() self.Cabeza.addItem(QtWidgets.QApplication.translate("equipment", "Elipsoidal", None)) self.Cabeza.addItem(QtWidgets.QApplication.translate("equipment", "Semiesférico", None)) self.Cabeza.addItem(QtWidgets.QApplication.translate("equipment", "Bumped", None)) self.Cabeza.addItem(QtWidgets.QApplication.translate("equipment", "Liso", None)) self.Cabeza.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Cabeza, 5, 2, 1, 1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Espesor (cabeza):", None)), 6, 1, 1, 1) self.EspesorCabeza=Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.EspesorCabeza,6,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Longitud reborde recto:", None)), 7, 1, 1, 1) self.LongitudReborde=Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.LongitudReborde,7,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Volumen:", None)), 6, 4, 1, 1) self.Volumen=Entrada_con_unidades(unidades.Volume, "VolLiq", readOnly=True) gridLayout_Costos.addWidget(self.Volumen,6,5,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Peso:", None)), 7, 4, 1, 1) self.Peso=Entrada_con_unidades(unidades.Mass, readOnly=True) gridLayout_Costos.addWidget(self.Peso,7,5,1,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),2,3,6,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),8,0,1,6) self.Costos=costIndex.CostData(1.7, 3) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos,9,1,2,5) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),11,0,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,12,1,1,5) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),0,1,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True, tolerancia=8, decimales=2) gridLayout_5.addWidget(self.C_adq,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),1,1,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True, tolerancia=8, decimales=2) gridLayout_5.addWidget(self.C_inst,1,2,1,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),13,0,1,6) #Pestaña salida self.Salida= UI_corriente.Ui_corriente(readOnly=True) self.tabWidget.insertTab(2, self.Salida,QtWidgets.QApplication.translate("equipment", "Salida", None)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex()==0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class UI_equipment(parents.UI_equip): """Diálogo de definición de tuberías""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Tower, parent=parent) self.entrada = entrada # #Pestaña entrada # self.Entrada= UI_corriente.Ui_corriente(entrada) # self.Entrada.Changed.connect(self.cambiar_entrada) # self.tabWidget.addTab(self.Entrada, QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Proceso:", None)), 1, 1, 1, 1) self.proceso = QtWidgets.QComboBox() self.proceso.addItem( QtWidgets.QApplication.translate("equipment", "Destilación", None)) self.proceso.addItem( QtWidgets.QApplication.translate("equipment", "Absorción", None)) self.proceso.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.proceso, 1, 2, 1, 1) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo de columna:", None)), 2, 1, 1, 1) self.tipo = QtWidgets.QComboBox() self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "De pisos", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "De relleno", None)) self.tipo.currentIndexChanged.connect(self.mostrarSubclasificacion) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 2, 2, 1, 1) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Material:", None)), 3, 1, 1, 1) self.material = QtWidgets.QComboBox() self.material.addItem( QtWidgets.QApplication.translate("equipment", "Acero al carbon", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Carpenter 20CB-3", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Niquel 200", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Monel 400", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Inconel 600", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Incoloy 825", None)) self.material.addItem( QtWidgets.QApplication.translate("equipment", "Titanio", None)) self.material.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.material, 3, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(30, 30, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 3, 5, 1) self.groupBox_Pisos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Torre de pisos", None)) gridLayout_Costos.addWidget(self.groupBox_Pisos, 1, 4, 4, 2) gridLayout_1 = QtWidgets.QGridLayout(self.groupBox_Pisos) gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipoPisos = QtWidgets.QComboBox() self.tipoPisos.addItem( QtWidgets.QApplication.translate("equipment", "De válvula", None)) self.tipoPisos.addItem( QtWidgets.QApplication.translate("equipment", "De rejilla", None)) self.tipoPisos.addItem( QtWidgets.QApplication.translate("equipment", "De borboteo", None)) self.tipoPisos.addItem( QtWidgets.QApplication.translate("equipment", "De tamiz", None)) self.tipoPisos.currentIndexChanged.connect(self.calcularCostos) gridLayout_1.addWidget(self.tipoPisos, 1, 2, 1, 1) gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Material:", None)), 2, 1, 1, 1) self.materialPisos = QtWidgets.QComboBox() self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Acero al carbon", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Carpenter 20CB-3", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Niquel 200", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Monel 400", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Inconel 600", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Incoloy 825", None)) self.materialPisos.addItem( QtWidgets.QApplication.translate("equipment", "Titanio", None)) self.materialPisos.currentIndexChanged.connect(self.calcularCostos) gridLayout_1.addWidget(self.materialPisos, 2, 2, 1, 1) gridLayout_1.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 2) gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Diametro:", None)), 4, 1, 1, 1) self.diametroPisos = Entrada_con_unidades(unidades.Length) gridLayout_1.addWidget(self.diametroPisos, 4, 2, 1, 1) gridLayout_1.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Número:", None)), 5, 1, 1, 1) self.NumeroPisos = Entrada_con_unidades(int, spinbox=True, min=1, step=1, width=50) gridLayout_1.addWidget(self.NumeroPisos, 5, 2, 1, 1) gridLayout_1.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 2) self.groupBox_relleno = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Torre de relleno", None)) gridLayout_Costos.addWidget(self.groupBox_relleno, 1, 4, 4, 2) gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_relleno) gridLayout_2.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Volumen:", None)), 1, 1, 1, 1) self.VolumenRelleno = Entrada_con_unidades(unidades.Volume, "VolLiq") gridLayout_2.addWidget(self.VolumenRelleno, 1, 2, 1, 1) gridLayout_2.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste unitario:", None)), 2, 1, 1, 1) self.C_unit_relleno = Entrada_con_unidades( unidades.Currency, retornar=False, textounidad="%s / %s" % (unidades.Currency(None).text(), unidades.Volume(None).text("VolLiq"))) gridLayout_2.addWidget(self.C_unit_relleno, 2, 2, 1, 1) gridLayout_2.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 2) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Diametro:", None)), 5, 1, 1, 1) self.Dc = Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Dc, 5, 2, 1, 2) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Altura:", None)), 6, 1, 1, 1) self.Hc = Entrada_con_unidades(unidades.Length) gridLayout_Costos.addWidget(self.Hc, 6, 2, 1, 2) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Espesor (Tapa):", None)), 7, 1, 1, 1) self.EspesorSuperior = Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.EspesorSuperior, 7, 2, 1, 2) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Espesor (Fondo):", None)), 8, 1, 1, 1) self.EspesorInferior = Entrada_con_unidades(unidades.Length, "Thickness") gridLayout_Costos.addWidget(self.EspesorInferior, 8, 2, 1, 2) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Densidad:", None)), 9, 1, 1, 1) self.EspesorInferior = Entrada_con_unidades(unidades.Density, "DenLiq") gridLayout_Costos.addWidget(self.EspesorInferior, 9, 2, 1, 2) self.Costos = costIndex.CostData(3, 3) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos, 10, 1, 2, 4) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 12, 1, 1, 6) self.groupBox_Costos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos, 13, 1, 1, 5) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Pisos:", None)), 0, 1, 1, 1) self.C_pisos = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_pisos, 0, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Carcasa:", None)), 1, 1, 1, 1) self.C_carcasa = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_carcasa, 1, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Accesorios:", None)), 2, 1, 1, 1) self.C_accesorios = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_accesorios, 2, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Columna:", None)), 0, 4, 1, 1) self.C_columna = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_columna, 0, 5, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)), 1, 4, 1, 1) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 1, 5, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)), 2, 4, 1, 1) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 2, 5, 1, 1) # #Pestaña salida # self.pSalida = QtGui.QTabWidget() # self.tabWidget.addTab(self.pSalida,QtGui.QApplication.translate("equipment", "Salida", None, QtGui.QApplication.UnicodeUTF8)) self.mostrarSubclasificacion(0) def mostrarSubclasificacion(self, ind): self.groupBox_Pisos.setVisible(not ind) self.groupBox_relleno.setVisible(ind) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): self.ShellTube.Coste(self.factorInstalacion.value(), 0, self.tipo.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.ShellTube.C_adq.config()) self.C_inst.setValue(self.ShellTube.C_inst.config())
class UI_confResolution_widget(QtWidgets.QWidget): """PFD resolution widget""" def __init__(self, config=None, parent=None): self.standards = [(600, 400), (640, 480), (720, 400), (800, 600), (832, 624), (1024, 768), (1152, 864), (1280, 1024), (1700, 1250), (1900, 1425), (2400, 1800), (4000, 3000)] super(UI_confResolution_widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Use default resolution:")), 0, 0) self.standard = QtWidgets.QComboBox() self.standard.addItem("") for resolucion in self.standards: self.standard.addItem("%ix%i" % resolucion) self.standard.currentIndexChanged.connect(self.changeResolution) layout.addWidget(self.standard, 0, 1) self.checkCustom = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Use Custom resolution")) layout.addWidget(self.checkCustom, 1, 0, 1, 2) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Width:")) label.setIndent(50) layout.addWidget(label, 2, 0) self.x = Entrada_con_unidades(int, width=60, spinbox=True, step=1) layout.addWidget(self.x, 2, 1) label = QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Height:")) label.setIndent(50) layout.addWidget(label, 3, 0) self.y = Entrada_con_unidades(int, width=60, spinbox=True, step=1) layout.addWidget(self.y, 3, 1) self.checkCustom.toggled.connect(self.x.setEnabled) self.checkCustom.toggled.connect(self.y.setEnabled) if config and config.has_section("PFD"): x = config.getint("PFD", "x") y = config.getint("PFD", "y") self.x.setValue(x) self.y.setValue(y) if (x, y) in self.standards: self.standard.setCurrentIndex(self.standards.index((x, y)) + 1) self.checkCustom.setChecked(False) self.x.setEnabled(False) self.y.setEnabled(False) else: self.standard.setCurrentIndex(0) self.checkCustom.setChecked(True) def changeResolution(self): """Change resolution with value of current opction selected""" x, y = self.standard.currentText().split("x") self.x.setValue(int(x)) self.y.setValue(int(y)) def value(self, config): """Function result to wizard""" if not config.has_section("PFD"): config.add_section("PFD") config.set("PFD", "x", str(self.x.value)) config.set("PFD", "y", str(self.y.value)) return config @classmethod def default(cls, config): config.add_section("PFD") Preferences = ConfigParser() Preferences.read(conf_dir + "pychemqtrc") config.set("PFD", "x", Preferences.get("PFD", "x")) config.set("PFD", "y", Preferences.get("PFD", "y")) return config
class UI_equipment(parents.UI_equip): """Diálogo de definición de tamices de sólidos""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en kla tubería""" super(UI_equipment, self).__init__(Centrifuge, entrada=False, parent=parent) self.entrada = entrada #Pestaña entrada self.Entrada = UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab( 0, self.Entrada, QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1, 1, 1) self.tipo = QtWidgets.QComboBox() self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Proceso inorgánico", None)) self.tipo.addItem( QtWidgets.QApplication.translate("equipment", "Proceso orgánico", None)) self.tipo.currentIndexChanged.connect(self.mostrarSubclasificacion) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 2, 1, 1) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Material:", None)), 2, 1, 1, 1) self.materialInorganico = QtWidgets.QComboBox() self.materialInorganico.addItem( QtWidgets.QApplication.translate("equipment", "Acero al carbón", None)) self.materialInorganico.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialInorganico.addItem( QtWidgets.QApplication.translate("equipment", "Monel", None)) self.materialInorganico.addItem( QtWidgets.QApplication.translate("equipment", "Níquel", None)) self.materialInorganico.currentIndexChanged.connect( self.calcularCostos) gridLayout_Costos.addWidget(self.materialInorganico, 2, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 0, 1, 2) self.materialOrganico = QtWidgets.QComboBox() self.materialOrganico.addItem( QtWidgets.QApplication.translate("equipment", "Acero al carbón", None)) self.materialOrganico.addItem( QtWidgets.QApplication.translate("equipment", "Acero inoxidable 316", None)) self.materialOrganico.addItem( QtWidgets.QApplication.translate("equipment", "Monel", None)) self.materialOrganico.addItem( QtWidgets.QApplication.translate("equipment", "Níquel", None)) self.materialOrganico.addItem( QtWidgets.QApplication.translate("equipment", "Hastelloy", None)) self.materialOrganico.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.materialOrganico, 2, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 0, 1, 6) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Caudal calculado:", None)), 4, 1, 1, 1) self.caudalcalculado = Entrada_con_unidades(unidades.MassFlow, readOnly=True, retornar=False) gridLayout_Costos.addWidget(self.caudalcalculado, 4, 2, 1, 1) gridLayout_Costos.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Caudal de diseño:", None)), 5, 1, 1, 1) self.caudaldiseno = Entrada_con_unidades(unidades.MassFlow) gridLayout_Costos.addWidget(self.caudaldiseno, 5, 2, 1, 1) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 0, 1, 6) self.Costos = costIndex.CostData(1.3, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos, 7, 1, 2, 2) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 9, 0, 1, 6) gridLayout_Costos.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 11, 0, 1, 6) self.groupBox_Costos = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos, 10, 0, 1, 6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)), 0, 1, 1, 1) self.C_adq = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq, 0, 2, 1, 1) gridLayout_5.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)), 1, 1, 1, 1) self.C_inst = Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst, 1, 2, 1, 1) self.tabWidget.setCurrentIndex(0) self.mostrarSubclasificacion(0) def mostrarSubclasificacion(self, ind): self.materialInorganico.setVisible(not ind) self.materialOrganico.setVisible(ind) def cambiar_entrada(self, corriente): selfentrada = corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex() == 0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class UI_equipment(UI_equip): """Double pipe heat exchanger edition dialog""" Equipment = Hairpin() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super().__init__(Hairpin, parent=parent) # Input tab self.addEntrada(QtWidgets.QApplication.translate( "pychemqt", "Tube"), "entradaTubo") self.addEntrada(QtWidgets.QApplication.translate( "pychemqt", "Annulli"), "entradaExterior") # Pipe catalog tab tabCatalogo = QtWidgets.QWidget() self.tabWidget.insertTab( 1, tabCatalogo, QtWidgets.QApplication.translate("pychemqt", "Catalog")) lyt = QtWidgets.QGridLayout(tabCatalogo) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube length")), 4, 1) self.LTube = Entrada_con_unidades(Length) self.LTube.valueChanged.connect(partial(self.changeParams, "LTube")) lyt.addWidget(self.LTube, 4, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 1) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube internal diameter")), 6, 1) self.DiTube = Entrada_con_unidades(Length, "pipeDiameter") self.DiTube.valueChanged.connect(partial(self.changeParams, "DiTube")) lyt.addWidget(self.DiTube, 6, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube external diameter")), 7, 1) self.DeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeTube.valueChanged.connect(partial(self.changeParams, "DeTube")) lyt.addWidget(self.DeTube, 7, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube thickness")), 8, 1) self.wTube = Entrada_con_unidades(Length, "Thickness") self.wTube.valueChanged.connect(partial(self.changeParams, "wTube")) lyt.addWidget(self.wTube, 8, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Tube roughness")), 9, 1) self.rTube = Entrada_con_unidades(Length, "Thickness") self.rTube.valueChanged.connect(partial(self.changeParams, "rTube")) lyt.addWidget(self.rTube, 9, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 10, 1) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Annulli external diameter")), 11, 1) self.DeeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeeTube.valueChanged.connect( partial(self.changeParams, "DeeTube")) lyt.addWidget(self.DeeTube, 11, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Thermal conductivity")), 12, 1) self.kTube = Entrada_con_unidades(ThermalConductivity) self.kTube.valueChanged.connect(partial(self.changeParams, "kTube")) lyt.addWidget(self.kTube, 12, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube Count")), 13, 1) self.nTube = Entrada_con_unidades(int) self.nTube.valueChanged.connect(partial(self.changeParams, "nTube")) lyt.addWidget(self.nTube, 13, 2) buttonPipe = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Pipe Database")) buttonPipe.clicked.connect(self.showMaterial) lyt.addWidget(buttonPipe, 6, 3, 4, 1) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 14, 1) self.tubeFinned = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Finned Tube")) lyt.addWidget(self.tubeFinned, 15, 1, 1, 4) self.buttonFin = QtWidgets.QPushButton( QtWidgets.QApplication.translate( "pychemqt", "Finned Pipe Database")) self.buttonFin.setEnabled(False) self.buttonFin.clicked.connect(self.showFinTube) lyt.addWidget(self.buttonFin, 15, 3) self.tubeFinned.toggled.connect( partial(self.changeParams, "tubeFinned")) self.tubeFinned.toggled.connect(self.buttonFin.setEnabled) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Inside Fouling")), 16, 1) self.tubeFouling = FoulingWidget() self.tubeFouling.valueChanged.connect( partial(self.changeParams, "tubeFouling")) lyt.addWidget(self.tubeFouling, 16, 2, 1, 5) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Outside Fouling")), 17, 1) self.annulliFouling = FoulingWidget() self.annulliFouling.valueChanged.connect( partial(self.changeParams, "annulliFouling")) lyt.addWidget(self.annulliFouling, 17, 2, 1, 5) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 20, 1, 1, 6) # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Mode")), 1, 1) self.modo = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MODO: self.modo.addItem(txt) self.modo.currentIndexChanged.connect( partial(self.changeParams, "modo")) lyt.addWidget(self.modo, 1, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Flujo")), 2, 1) self.flujo = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_FLUJO: self.flujo.addItem(txt) self.flujo.currentIndexChanged.connect( partial(self.changeParams, "flujo")) lyt.addWidget(self.flujo, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Layout")), 3, 1) self.orientacion = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_ORIENTACION: self.orientacion.addItem(txt) self.orientacion.currentIndexChanged.connect( partial(self.changeParams, "orientacion")) lyt.addWidget(self.orientacion, 3, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output inside temperature")), 5, 1) self.tubeTout = Entrada_con_unidades(Temperature) self.tubeTout.valueChanged.connect( partial(self.changeParams, "tubeTout")) lyt.addWidget(self.tubeTout, 5, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output annulli temperature")), 6, 1) self.annulliTout = Entrada_con_unidades(Temperature) self.annulliTout.valueChanged.connect( partial(self.changeParams, "annulliTout")) lyt.addWidget(self.annulliTout, 6, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output inside quality")), 5, 4) self.tubeXout = Entrada_con_unidades(float) self.tubeXout.valueChanged.connect( partial(self.changeParams, "tubeXout")) lyt.addWidget(self.tubeXout, 5, 5) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output annulli quality")), 6, 4) self.annulliXout = Entrada_con_unidades(float) self.annulliXout.valueChanged.connect( partial(self.changeParams, "annulliXout")) lyt.addWidget(self.annulliXout, 6, 5) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Results")) lyt.addWidget(group, 16, 1, 1, 6) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Heat Duty")), 0, 1) self.Q = Entrada_con_unidades(Power, retornar=False, readOnly=True) layout.addWidget(self.Q, 0, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tout Tube")), 1, 1) self.ToutTube = Entrada_con_unidades(Temperature, retornar=False) self.ToutTube.setReadOnly(True) layout.addWidget(self.ToutTube, 1, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tout Tube")), 2, 1) self.ToutAnnulli = Entrada_con_unidades(Temperature, retornar=False) self.ToutAnnulli.setReadOnly(True) layout.addWidget(self.ToutAnnulli, 2, 2) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "U")), 0, 4) self.U = Entrada_con_unidades(HeatTransfCoef, retornar=False) self.U.setReadOnly(True) layout.addWidget(self.U, 0, 5) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Area")), 1, 4) self.A = Entrada_con_unidades(Area, retornar=False, readOnly=True) layout.addWidget(self.A, 1, 5) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Lenght")), 2, 4) self.L = Entrada_con_unidades(Length, retornar=False, readOnly=True) layout.addWidget(self.L, 2, 5) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "DeltaP Tube")), 0, 7) self.deltaPTube = Entrada_con_unidades(DeltaP, retornar=False) self.deltaPTube.setReadOnly(True) layout.addWidget(self.deltaPTube, 0, 8) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "DeltaP Annulli")), 1, 7) self.deltaPAnnulli = Entrada_con_unidades(DeltaP, retornar=False) self.deltaPAnnulli.setReadOnly(True) layout.addWidget(self.deltaPAnnulli, 1, 8) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "CF")), 2, 7) self.CF = Entrada_con_unidades(float, retornar=False, readOnly=True) layout.addWidget(self.CF, 2, 8) lyt.addItem(QtWidgets.QSpacerItem( 0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 17, 1, 1, 6) # Cost tab lyt = QtWidgets.QGridLayout(self.tabCostos) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Material")), 2, 1) self.material = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_MATERIAL: self.material.addItem(txt) self.material.currentIndexChanged.connect( partial(self.changeParamsCoste, "material")) lyt.addWidget(self.material, 2, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 3, 0, 1, 6) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Design Pressure")), 4, 1) self.P_dis = Entrada_con_unidades(Pressure) self.P_dis.valueChanged.connect( partial(self.changeParamsCoste, "P_dis")) lyt.addWidget(self.P_dis, 4, 2, 1, 1) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 5, 0, 1, 6) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) lyt.addWidget(self.Costos, 6, 1, 2, 5) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 8, 0, 1, 6) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Stimated Costs")) lyt.addWidget(group, 9, 1, 1, 5) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Purchase Cost")), 0, 1) self.C_adq = Entrada_con_unidades(Currency, retornar=False) self.C_adq.setReadOnly(True) layout.addWidget(self.C_adq, 0, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Installed Cost")), 1, 1) self.C_inst = Entrada_con_unidades(Currency, retornar=False) self.C_inst.setReadOnly(True) self.C_inst.entrada.setReadOnly(True) layout.addWidget(self.C_inst, 1, 2) # Output Tab self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Tube")) self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Annulli")) if equipment: self.setEquipment(equipment) def showMaterial(self): dialogo = Catalogo_Materiales_Dialog() if dialogo.exec_(): material = dialogo.getMaterial() if material: self.rTube.setValue(material[2]) self.DiTube.setValue(material[4]) self.wTube.setValue(material[5]) self.DeTube.setValue(material[6]) def showFinTube(self): dialogo = Dialog_Finned(self.Equipment.kwargs) if dialogo.exec_(): kwarg = dialogo.kwarg() self.calculo(**kwarg)
class Isolinea(QtWidgets.QDialog): """Widget for isoline configuration for mEoS plot tools""" def __init__(self, unit, ConfSection, config, section="MEOS", parent=None): """Constructor unit: subclass of unidad to define the isoline type ConfSection: title of isoline config: config of pychemqt project """ super(Isolinea, self).__init__(parent) self.ConfSection = ConfSection self.magnitud = unit.__name__ self.unidad = unit self.section = section layout = QtWidgets.QGridLayout(self) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Start")), 1, 1) self.inicio = Entrada_con_unidades(unit) layout.addWidget(self.inicio, 1, 2, 1, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fin")), 2, 1) self.fin = Entrada_con_unidades(unit) layout.addWidget(self.fin, 2, 2, 1, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Intervalo")), 3, 1) if unit.__name__ == "Temperature": self.intervalo = Entrada_con_unidades(unidades.DeltaT) elif unit.__name__ == "Pressure": self.intervalo = Entrada_con_unidades(unidades.DeltaP) else: self.intervalo = Entrada_con_unidades(unit) layout.addWidget(self.intervalo, 3, 2, 1, 3) self.Personalizar = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Customize")) layout.addWidget(self.Personalizar, 4, 1, 1, 4) self.Lista = QtWidgets.QLineEdit() layout.addWidget(self.Lista, 5, 1, 1, 4) self.Personalizar.toggled.connect(self.inicio.setDisabled) self.Personalizar.toggled.connect(self.fin.setDisabled) self.Personalizar.toggled.connect(self.intervalo.setDisabled) self.Personalizar.toggled.connect(self.Lista.setEnabled) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 4) if unit.__name__ != "float" and section != "Psychr": self.Critica = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Include critic point line")) layout.addWidget(self.Critica, 7, 1, 1, 4) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 4) self.lineconfig = LineConfig( ConfSection, QtWidgets.QApplication.translate("pychemqt", "Line Style")) layout.addWidget(self.lineconfig, 9, 1, 1, 4) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 10, 1) self.label = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Label")) layout.addWidget(self.label, 11, 1) self.variable = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Variable in Label")) layout.addWidget(self.variable, 12, 1, 1, 4) self.unit = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Units in Label")) layout.addWidget(self.unit, 13, 1, 1, 4) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Position")), 14, 1) self.label5 = Entrada_con_unidades(int, value=0, width=25, frame=False, readOnly=True) self.label5.setFixedWidth(30) layout.addWidget(self.label5, 14, 2) self.Posicion = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.Posicion.valueChanged.connect(self.label5.setValue) layout.addWidget(self.Posicion, 14, 3, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 4) if config.has_section(section): self.inicio.setValue(config.getfloat(section, ConfSection+'Start')) self.fin.setValue(config.getfloat(section, ConfSection+'End')) self.intervalo.setValue( config.getfloat(section, ConfSection+'Step')) self.Personalizar.setChecked( config.getboolean(section, ConfSection+'Custom')) if config.get(section, ConfSection+'List') != "": T = [] for i in config.get(section, ConfSection+'List').split(','): if unit.__name__ == "float": T.append(representacion(float(i))) else: T.append(representacion(unit(float(i)).config())) self.Lista.setText(",".join(T)) if unit.__name__ != "float" and section != "Psychr": self.Critica.setChecked( config.getboolean(section, ConfSection+'Critic')) self.inicio.setDisabled(self.Personalizar.isChecked()) self.fin.setDisabled(self.Personalizar.isChecked()) self.intervalo.setDisabled(self.Personalizar.isChecked()) self.Lista.setEnabled(self.Personalizar.isChecked()) self.label.setChecked( config.getboolean(section, ConfSection+'Label')) self.variable.setChecked( config.getboolean(section, ConfSection+'Variable')) self.unit.setChecked( config.getboolean(section, ConfSection+'Units')) self.Posicion.setValue( config.getint(section, ConfSection+'Position')) self.lineconfig.setConfig(config, section) def value(self, config): config.set(self.section, self.ConfSection+"Start", str(self.inicio.value)) config.set(self.section, self.ConfSection+"End", str(self.fin.value)) config.set(self.section, self.ConfSection+"Step", str(self.intervalo.value)) config.set(self.section, self.ConfSection+"Custom", str(self.Personalizar.isChecked())) T = [] if self.Lista.text(): T1 = self.Lista.text().split(',') for i in T1: if self.unidad.__name__ == "float": T.append(str(float(i))) else: T.append(str(self.unidad(float(i), "conf"))) config.set(self.section, self.ConfSection+"List", ", ".join(T)) if self.unidad.__name__ != "float" and self.section != "Psychr": config.set(self.section, self.ConfSection+"Critic", str(self.Critica.isChecked())) config = self.lineconfig.value(config, self.section) config.set(self.section, self.ConfSection+"Label", str(self.label.isChecked())) config.set(self.section, self.ConfSection+"Variable", str(self.variable.isChecked())) config.set(self.section, self.ConfSection+"Units", str(self.unit.isChecked())) config.set(self.section, self.ConfSection+"Position", str(self.Posicion.value())) return config
class PsychroInput(QtWidgets.QWidget): """Widget with parameter for psychrometric state""" parameters = ["tdb", "twb", "tdp", "w", "HR", "v", "h"] stateChanged = QtCore.pyqtSignal(PsyState) pressureChanged = QtCore.pyqtSignal() def __init__(self, state=None, readOnly=False, parent=None): """ constructor optional state parameter to assign initial psychrometric state """ super(PsychroInput, self).__init__(parent) self.state = PsychroState(P=101325) layout = QtWidgets.QGridLayout(self) self.checkPresion = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Pressure")) layout.addWidget(self.checkPresion, 1, 1, 1, 1) self.P = Entrada_con_unidades(Pressure, value=101325) self.P.valueChanged.connect(self.changePressure) layout.addWidget(self.P, 1, 2, 1, 1) self.checkAltitud = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Altitude")) layout.addWidget(self.checkAltitud, 2, 1, 1, 1) self.z = Entrada_con_unidades(Length, value=0) self.checkPresion.toggled.connect(self.P.setEnabled) self.checkAltitud.toggled.connect(self.z.setEnabled) self.z.valueChanged.connect(self.changeAltitude) self.checkPresion.setChecked(True) self.z.setEnabled(False) layout.addWidget(self.z, 2, 2, 1, 1) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Select point")), 4, 1, 1, 2) self.variables = QtWidgets.QComboBox() for txt in PsyState.TEXT_MODE: self.variables.addItem(txt) self.variables.currentIndexChanged.connect(self.updateInputs) layout.addWidget(self.variables, 5, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("Tdb:"), 6, 1, 1, 1) self.tdb = Entrada_con_unidades(Temperature) self.tdb.valueChanged.connect(partial(self.updateKwargs, "tdb")) layout.addWidget(self.tdb, 6, 2, 1, 1) layout.addWidget(QtWidgets.QLabel("Twb:"), 7, 1, 1, 1) self.twb = Entrada_con_unidades(Temperature) self.twb.valueChanged.connect(partial(self.updateKwargs, "twb")) layout.addWidget(self.twb, 7, 2, 1, 1) layout.addWidget(QtWidgets.QLabel("Tdp:"), 8, 1, 1, 1) self.tdp = Entrada_con_unidades(Temperature) self.tdp.valueChanged.connect(partial(self.updateKwargs, "tdp")) layout.addWidget(self.tdp, 8, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Humidity Ratio:")), 9, 1, 1, 1) self.w = Entrada_con_unidades(float, textounidad="kgw/kgda") self.w.valueChanged.connect(partial(self.updateKwargs, "w")) layout.addWidget(self.w, 9, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Relative humidity:")), 10, 1, 1, 1) self.HR = Entrada_con_unidades(float, textounidad="%") self.HR.valueChanged.connect(partial(self.updateKwargs, "HR")) layout.addWidget(self.HR, 10, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Volume")), 11, 1, 1, 1) self.v = Entrada_con_unidades(SpecificVolume) self.v.valueChanged.connect(partial(self.updateKwargs, "v")) layout.addWidget(self.v, 11, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Enthalpy")), 12, 1, 1, 1) self.h = Entrada_con_unidades(Enthalpy) self.h.valueChanged.connect(partial(self.updateKwargs, "h")) layout.addWidget(self.h, 12, 2, 1, 1) layout.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 13, 1, 1, 2) self.setReadOnly(readOnly) self.updateInputs(0) if state: self.setState(state) def updateInputs(self, index): """Update inputs appearance to highlight active""" for par in self.parameters: self.__getattribute__(par).setReadOnly(True) self.__getattribute__(par).setResaltado(False) for par in PsyState.VAR_NAME[index]: self.__getattribute__(par).setReadOnly(False) self.__getattribute__(par).setResaltado(True) index = self.variables.currentIndex() kwargs = {"P": self.P.value} for par in PsyState.VAR_NAME[index]: if self.__getattribute__(par).value: kwargs[par] = self.state.__getattribute__(par) self.state = PsychroState(**kwargs) def setReadOnly(self, readOnly): self.checkPresion.setEnabled(not readOnly) self.checkAltitud.setEnabled(not readOnly) self.P.setReadOnly(readOnly) self.z.setReadOnly(readOnly) self.variables.setEnabled(not readOnly) for par in self.parameters: self.__getattribute__(par).setReadOnly(True) self.__getattribute__(par).setResaltado(False) def updateKwargs(self, key, value): """Update kwargs of state instance, if its correctly defined show it""" kwargs = {key: value} self.state(**kwargs) if self.state.status: self.setState(self.state) self.stateChanged.emit(self.state) def setState(self, state): """Fill data input with state properties""" self.state = state if state.w < state.ws: for p in self.parameters: self.__getattribute__(p).setValue(state.__getattribute__(p)) def changePressure(self, value): """Change pressure to global plot and for states""" self.z.setValue(_height(value)) self.state = PsychroState(P=value) self.pressureChanged.emit() def changeAltitude(self, value): """Change pressure through altitude and ICAO equation""" presion = _Pbar(value) self.P.setValue(presion) self.state = PsychroState(P=value) self.pressureChanged.emit()
class CostData(QtWidgets.QWidget): """Common widget to equipment with cost section It have property to easy access to properties: factor: install factor base: base index (January 1982) actual: current index values: a tuple with all properties, (factor, base,actual) """ valueChanged = QtCore.pyqtSignal(str, float) def __init__(self, equipment, parent=None): """constructor equipment: equipment class where the widget have to be put, define indiceCostos as a index in costIndex""" super(CostData, self).__init__(parent) self.indice = equipment.indiceCostos factor = equipment.kwargs["f_install"] gridLayout = QtWidgets.QGridLayout(self) gridLayout.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 1, 0, 1, 7) gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Instalation factor:")), 2, 0, 1, 1) self.factorInstalacion = Entrada_con_unidades( float, spinbox=True, decimales=1, step=0.1, width=50, value=factor) self.factorInstalacion.valueChanged.connect(partial( self.valueChanged.emit, "f_install")) gridLayout.addWidget(self.factorInstalacion, 2, 1, 1, 1) gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Base index:")), 2, 4, 1, 1) self.indiceBase = Entrada_con_unidades( float, readOnly=True, value=indiceBase[self.indice], decimales=1) gridLayout.addWidget(self.indiceBase, 2, 5, 1, 1) gridLayout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Current index:")), 3, 4, 1, 1) self.indiceActual = Entrada_con_unidades( float, readOnly=True, colorReadOnly="white", value=indiceActual[self.indice], decimales=1) gridLayout.addWidget(self.indiceActual, 3, 5, 1, 1) self.costIndex = QtWidgets.QToolButton() self.costIndex.setFixedSize(QtCore.QSize(24, 24)) self.costIndex.clicked.connect(self.on_costIndex_clicked) self.costIndex.setText("...") self.costIndex.setVisible(False) gridLayout.addWidget(self.costIndex, 3, 5, 1, 1) gridLayout.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 4, 0, 1, 7) def on_costIndex_clicked(self): """Show costIndes dialog to show/change""" dialog = Ui_CostIndex() if dialog.exec_(): with open(config.conf_dir+"CostIndex.dat", "r") as archivo: self.indiceActual.setValue( float(archivo.readlines()[self.indice][:-1])) self.valueChanged.emit("Current_index", self.indiceActual.value) def enterEvent(self, event): self.costIndex.setVisible(True) def leaveEvent(self, event): self.costIndex.setVisible(False) @property def factor(self): return self.factorInstalacion.value @property def base(self): return self.indiceBase.value @property def actual(self): return self.indiceActual.value @property def values(self): return self.factorInstalacion.value, self.indiceBase.value,\ self.indiceActual.value def setFactor(self, value): self.factorInstalacion.setValue(value) def setBase(self, value): self.indiceBase.setValue(value) def setActual(self, value): self.indiceActual.setValue(value) def setValues(self, factor, base, actual): self.factorInstalacion.setValue(factor) self.indiceBase.setValue(base) self.indiceActual.setValue(actual)
class UI_equipment(UI_equip): """Diálogo de definición de tamices de sólidos""" Equipment=Screen() def __init__(self, equipment=None, parent=None): """ equipment: instancia de equipo inicial """ super(UI_equipment, self).__init__(Screen, entrada=False, parent=parent) #Pestaña entrada # self.Entrada= UI_corriente.Ui_corriente(entrada) # self.Entrada.Changed.connect(self.cambiar_entrada) # self.tabWidget.insertTab(0, self.Entrada, QtGui.QApplication.translate("equipment", "Entrada", None, QtGui.QApplication.UnicodeUTF8)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Area:", None)), 1, 1, 1, 1) self.Area=Entrada_con_unidades(unidades.Area) self.Area.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Area, 1, 2, 1, 1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),2,0,1,2) self.Costos=CostData(self.Equipment) self.Costos.valueChanged.connect(self.changeParamsCoste) gridLayout_Costos.addWidget(self.Costos,4,1,2,5) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),6,0,1,6) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),10,0,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,7,0,1,6) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),0,1,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),1,1,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst,1,2,1,1) #Pestaña salida self.SalidaGas= UI_corriente.Ui_corriente(readOnly=True) self.SalidaSolido= UI_corriente.Ui_corriente(readOnly=True) self.Salida.addTab(self.SalidaGas,QtWidgets.QApplication.translate("equipment", "Gas filtrado", None)) self.Salida.addTab(self.SalidaSolido,QtWidgets.QApplication.translate("equipment", "Sólidos recogidos", None)) self.tabWidget.setCurrentIndex(0) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex()==0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config())
class Ui_CostIndex(QtWidgets.QDialog): """Dialog to show/configure costIndex""" def __init__(self, parent=None): super(Ui_CostIndex, self).__init__(parent) self.setWindowTitle(QtWidgets.QApplication.translate("pychemqt", "Cost Index")) self.custom = True layout = QtWidgets.QGridLayout(self) self.fecha = QtWidgets.QComboBox() layout.addWidget(self.fecha, 1, 1, 1, 3) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "CE INDEX")), 2, 1, 1, 2) self.index = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.index, 2, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Equipments")), 3, 1, 1, 2) self.equipos = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.equipos, 3, 3, 1, 1) layout.addItem(QtWidgets.QSpacerItem( 30, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Heat exchangers & Tanks")), 4, 2, 1, 1) self.cambiadores_calor = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.cambiadores_calor, 4, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Process machinery")), 5, 2, 1, 1) self.maquinaria = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.maquinaria, 5, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pipe, valves & fittings")), 6, 2, 1, 1) self.tuberias = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.tuberias, 6, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Process instruments")), 7, 2, 1, 1) self.instrumentos = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.instrumentos, 7, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pumps & compressors")), 8, 2, 1, 1) self.bombas = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.bombas, 8, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Electrical equipments")), 9, 2, 1, 1) self.equipos_electricos = Entrada_con_unidades( float, width=70, decimales=1) layout.addWidget(self.equipos_electricos, 9, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Structural supports & misc")), 10, 2, 1, 1) self.soportes = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.soportes, 10, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Construction labor")), 11, 1, 1, 2) self.construccion = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.construccion, 11, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Buildings")), 12, 1, 1, 2) self.edificios = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.edificios, 12, 3, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Engineering & supervision")), 13, 1, 1, 2) self.ingenieria = Entrada_con_unidades(float, width=70, decimales=1) layout.addWidget(self.ingenieria, 13, 3, 1, 1) self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 14, 1, 1, 3) self.indices = [] with open(os.environ["pychemqt"] + "dat/costindex.dat") as archivo: texto = archivo.readlines() for txt in texto: dato = txt.split() self.fecha.addItem(dato[0]) self.indices.append(dato[1:]) with open(config.conf_dir+"CostIndex.dat") as archivo: texto = archivo.readlines() self.index.setValue(float(texto[1])) self.equipos.setValue(float(texto[2])) self.cambiadores_calor.setValue(float(texto[3])) self.maquinaria.setValue(float(texto[4])) self.tuberias.setValue(float(texto[5])) self.instrumentos.setValue(float(texto[6])) self.bombas.setValue(float(texto[7])) self.equipos_electricos.setValue(float(texto[8])) self.soportes.setValue(float(texto[9])) self.construccion.setValue(float(texto[10])) self.edificios.setValue(float(texto[11])) self.ingenieria.setValue(float(texto[12])) if texto[0]: self.fecha.setCurrentIndex(self.fecha.findText(texto[0])) else: self.fecha.setCurrentIndex(-1) self.fecha.currentIndexChanged.connect(self.loadData) def setCustom(self): """Set custom currentIndex""" self.fecha.setCurrentIndex(-1) self.custom = True def loadData(self, int): """Load costIndex data from file""" self.index.setValue(float(self.indices[int][0])) self.equipos.setValue(float(self.indices[int][1])) self.cambiadores_calor.setValue(float(self.indices[int][2])) self.maquinaria.setValue(float(self.indices[int][3])) self.tuberias.setValue(float(self.indices[int][4])) self.instrumentos.setValue(float(self.indices[int][5])) self.bombas.setValue(float(self.indices[int][6])) self.equipos_electricos.setValue(float(self.indices[int][7])) self.soportes.setValue(float(self.indices[int][8])) self.construccion.setValue(float(self.indices[int][9])) self.edificios.setValue(float(self.indices[int][10])) self.ingenieria.setValue(float(self.indices[int][11])) self.custom = False def closeEvent(self, event): """Override close event to ask data changes""" dialog = QtWidgets.QMessageBox.question( self, QtWidgets.QApplication.translate("pychemqt", "Unsaved changes"), QtWidgets.QApplication.translate("pychemqt", "Save unsaved changes?"), QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.Yes) if dialog == QtWidgets.QMessageBox.Yes: self.accept() else: event.accept() def accept(self): """Overwrite accept signal to save changes""" with open(config.conf_dir+"CostIndex.dat", "w") as archivo: if self.custom: print("custom", file=archivo) else: print(self.fecha.currentText(), file=archivo) print(self.index.value, file=archivo) print(self.equipos.value, file=archivo) print(self.cambiadores_calor.value, file=archivo) print(self.maquinaria.value, file=archivo) print(self.tuberias.value, file=archivo) print(self.instrumentos.value, file=archivo) print(self.bombas.value, file=archivo) print(self.equipos_electricos.value, file=archivo) print(self.soportes.value, file=archivo) print(self.construccion.value, file=archivo) print(self.edificios.value, file=archivo) print(self.ingenieria.value, file=archivo) QtWidgets.QDialog.accept(self)
class Dialog_Finned(QtGui.QDialog): """Dialog to define finned tube properties""" def __init__(self, kwarg=None, parent=None): super(Dialog_Finned, self).__init__(parent=parent) self.setWindowTitle(QtGui.QApplication.translate( "pychemqt", "Specify tube finned characteristics")) layout = QtGui.QGridLayout(self) self.listTube = QtGui.QComboBox() self.listTube.addItem("") layout.addWidget(self.listTube, 0, 1, 1, 2) layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 1, 1, 1, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Material")), 2, 1) self.listMaterial = QtGui.QComboBox() self.listMaterial.addItem("") self.listMaterial.addItem(QtGui.QApplication.translate( "pychemqt", "Carbon Steel")) layout.addWidget(self.listMaterial, 2, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Thermal Conductivity")), 3, 1) self.kFin = Entrada_con_unidades(ThermalConductivity) layout.addWidget(self.kFin, 3, 2) layout.addItem(QtGui.QSpacerItem(10, 10, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed), 4, 1, 1, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Root diameter")), 5, 1) self.RootD = Entrada_con_unidades(Length, "PipeDiameter") layout.addWidget(self.RootD, 5, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Fin Height")), 6, 1) self.hFin = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.hFin, 6, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Base Fin Thickness")), 7, 1) self.BaseThickness = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.BaseThickness, 7, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Top Fin Thickness")), 8, 1) self.TopThickness = Entrada_con_unidades(Length, "Thickness") layout.addWidget(self.TopThickness, 8, 2) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Number of fins")), 9, 1) self.Nfin = Entrada_con_unidades(float, textounidad="fins/m") layout.addWidget(self.Nfin, 9, 2) self.buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) layout.addWidget(self.buttonBox, 10, 1, 1, 2) for tuberia in finnedTube_database: self.listTube.addItem("%s %s" % (tuberia[0], tuberia[1])) self.listTube.currentIndexChanged.connect(self.rellenarData) self.listTube.currentIndexChanged.connect(self.setDisabled) if kwarg: self.hFin.setValue(kwarg["hFin"]) self.BaseThickness.setValue(kwarg["thicknessBaseFin"]) self.TopThickness.setValue(kwarg["thicknessTopFin"]) self.kFin.setValue(kwarg["kFin"]) self.Nfin.setValue(kwarg["nFin"]) self.RootD.setValue(kwarg["rootDoFin"]) def rellenarData(self, ind): tuberia = finnedTube_database[ind-1] if tuberia[0] == "HPT": self.Nfin.setValue(int(tuberia[1][:2])) self.BaseThickness.setValue(tuberia[12]/1000.) self.TopThickness.setValue(tuberia[12]/1000.) self.RootD.setValue(tuberia[6]/1000.) self.hFin.setValue(tuberia[13]/1000.) def setDisabled(self, bool): self.RootD.setReadOnly(bool) self.BaseThickness.setReadOnly(bool) self.TopThickness.setReadOnly(bool) self.Nfin.setReadOnly(bool) self.hFin.setReadOnly(bool) def kwarg(self): kwarg = {"hFin": self.hFin.value, "thicknessBaseFin": self.BaseThickness.value, "thicknessTopFin": self.TopThickness.value, "kFin": self.kFin.value, "nFin": self.Nfin.value, "rootDoFin": self.RootD.value} return kwarg
class PsychroInput(QtWidgets.QWidget): """Widget with parameter for psychrometric state""" parameters = ["tdb", "twb", "tdp", "w", "HR", "v", "h"] stateChanged = QtCore.pyqtSignal(PsyState) pressureChanged = QtCore.pyqtSignal() def __init__(self, state=None, readOnly=False, parent=None): """ constructor optional state parameter to assign initial psychrometric state""" super(PsychroInput, self).__init__(parent) self.state = PsychroState(P=101325) self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred) layout = QtWidgets.QGridLayout(self) self.checkPresion = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Pressure")) layout.addWidget(self.checkPresion, 1, 1, 1, 1) self.P = Entrada_con_unidades(unidades.Pressure, value=101325) self.P.valueChanged.connect(self.changePressure) layout.addWidget(self.P, 1, 2, 1, 1) self.checkAltitud = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Altitude")) layout.addWidget(self.checkAltitud, 2, 1, 1, 1) self.z = Entrada_con_unidades(unidades.Length, value=0) self.checkPresion.toggled.connect(self.P.setEnabled) self.checkAltitud.toggled.connect(self.z.setEnabled) self.z.valueChanged.connect(self.changeAltitude) self.checkPresion.setChecked(True) self.z.setEnabled(False) layout.addWidget(self.z, 2, 2, 1, 1) layout.addItem(QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Select point")), 4, 1, 1, 2) self.variables = QtWidgets.QComboBox() for txt in PsyState.TEXT_MODE: self.variables.addItem(txt) self.variables.currentIndexChanged.connect(self.updateInputs) layout.addWidget(self.variables, 5, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("Tdb:"), 6, 1, 1, 1) self.tdb = Entrada_con_unidades(unidades.Temperature) self.tdb.valueChanged.connect(partial(self.updateKwargs, "tdb")) layout.addWidget(self.tdb, 6, 2, 1, 1) layout.addWidget(QtWidgets.QLabel("Twb:"), 7, 1, 1, 1) self.twb = Entrada_con_unidades(unidades.Temperature) self.twb.valueChanged.connect(partial(self.updateKwargs, "twb")) layout.addWidget(self.twb, 7, 2, 1, 1) layout.addWidget(QtWidgets.QLabel("Tdp:"), 8, 1, 1, 1) self.tdp = Entrada_con_unidades(unidades.Temperature) self.tdp.valueChanged.connect(partial(self.updateKwargs, "tdp")) layout.addWidget(self.tdp, 8, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Humidity Ratio:")), 9, 1, 1, 1) self.w = Entrada_con_unidades(float, textounidad="kgw/kgda") self.w.valueChanged.connect(partial(self.updateKwargs, "w")) layout.addWidget(self.w, 9, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Relative humidity:")), 10, 1, 1, 1) self.HR = Entrada_con_unidades(float, textounidad="%") self.HR.valueChanged.connect(partial(self.updateKwargs, "HR")) layout.addWidget(self.HR, 10, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Volume")), 11, 1, 1, 1) self.v = Entrada_con_unidades(unidades.SpecificVolume) self.v.valueChanged.connect(partial(self.updateKwargs, "v")) layout.addWidget(self.v, 11, 2, 1, 1) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Enthalpy")), 12, 1, 1, 1) self.h = Entrada_con_unidades(unidades.Enthalpy) self.h.valueChanged.connect(partial(self.updateKwargs, "h")) layout.addWidget(self.h, 12, 2, 1, 1) layout.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed),13,1,1,2) self.setReadOnly(readOnly) self.updateInputs(0) if state: self.setState(state) def updateInputs(self, index): """Update inputs appearance to highlight active""" for par in self.parameters: self.__getattribute__(par).setReadOnly(True) self.__getattribute__(par).setResaltado(False) for par in PsyState.VAR_NAME[index]: self.__getattribute__(par).setReadOnly(False) self.__getattribute__(par).setResaltado(True) index = self.variables.currentIndex() kwargs = {"P": self.P.value} for par in PsyState.VAR_NAME[index]: if self.__getattribute__(par).value: kwargs[par] = self.state.__getattribute__(par) self.state = PsychroState(**kwargs) def setReadOnly(self, readOnly): self.checkPresion.setEnabled(not readOnly) self.checkAltitud.setEnabled(not readOnly) self.P.setReadOnly(readOnly) self.z.setReadOnly(readOnly) self.variables.setEnabled(not readOnly) for par in self.parameters: self.__getattribute__(par).setReadOnly(True) self.__getattribute__(par).setResaltado(False) def updateKwargs(self, key, value): """Update kwargs of state instance, if its correctly defined show it""" kwargs = {key: value} self.state(**kwargs) if self.state.status: self.setState(self.state) self.stateChanged.emit(self.state) def setState(self, state): """Fill data input with state properties""" self.state = state if state.w < state.ws: for par in self.parameters: self.__getattribute__(par).setValue(state.__getattribute__(par)) def changePressure(self, value): """Change pressure to global plot and for states""" self.z.setValue(_height(value)) self.state = PsychroState(P=value) self.pressureChanged.emit() def changeAltitude(self, value): """Change pressure through altitude and ICAO equation""" presion = _Pbar(value) self.P.setValue(presion) self.state = PsychroState(P=value) self.pressureChanged.emit()
class UI_equipment(UI_equip): """Shell and tube heat exchanger edition dialog""" Equipment = Shell_Tube() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super(UI_equipment, self).__init__(Shell_Tube, parent=parent) # Input tab self.addEntrada(QtWidgets.QApplication.translate("pychemqt", "Tubes"), "entradaTubo") self.addEntrada(QtWidgets.QApplication.translate("pychemqt", "Shell"), "entradaCarcasa") # Model tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 1, tab, QtWidgets.QApplication.translate("pychemqt", "Model")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Class")), 2, 1) self.class_ = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_CLASS: self.class_.addItem(txt) self.class_.currentIndexChanged.connect( partial(self.changeParams, "class_")) lyt.addWidget(self.class_, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Front end head")), 3, 1) self.frontHead = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_FRONTHEAD: self.frontHead.addItem(txt) self.frontHead.currentIndexChanged.connect( partial(self.changeParams, "frontHead")) lyt.addWidget(self.frontHead, 3, 2, 1, 3) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell type")), 4, 1) self.shell = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_SHELL: self.shell.addItem(txt) self.shell.currentIndexChanged.connect( partial(self.changeParams, "shell")) lyt.addWidget(self.shell, 4, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Rear end head")), 5, 1) self.rearHead = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_REARHEAD: self.rearHead.addItem(txt) self.rearHead.currentIndexChanged.connect( partial(self.changeParams, "rearHead")) lyt.addWidget(self.rearHead, 5, 2, 1, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Orientation")), 7, 1) self.orientacion = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_ORIENTATION: self.orientacion.addItem(txt) self.orientacion.currentIndexChanged.connect( partial(self.changeParams, "orientation")) lyt.addWidget(self.orientacion, 7, 2) botonMetodos = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Calculation methods")) botonMetodos.clicked.connect(self.selectMethods) lyt.addWidget(botonMetodos, 9, 1) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 6) # Tubes tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 2, tab, QtWidgets.QApplication.translate("pychemqt", "Tubes")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Number of tubes")), 1, 1) self.NTubes = Entrada_con_unidades(int, width=60, spinbox=True, step=1) self.NTubes.valueChanged.connect(partial(self.changeParams, "NTube")) lyt.addWidget(self.NTubes, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Number of tube passes")), 2, 1) self.NPases = Entrada_con_unidades(int, width=60, spinbox=True, step=1) self.NPases.valueChanged.connect(partial(self.changeParams, "NPases")) lyt.addWidget(self.NPases, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube length")), 3, 1) self.LTube = Entrada_con_unidades(Length) self.LTube.valueChanged.connect(partial(self.changeParams, "LTube")) lyt.addWidget(self.LTube, 3, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube external diameter")), 4, 1) self.DeTube = Entrada_con_unidades(Length, "pipeDiameter") self.DeTube.valueChanged.connect(partial(self.changeParams, "DeTube")) lyt.addWidget(self.DeTube, 4, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube thickness")), 5, 1) self.wTube = Entrada_con_unidades(Length, "Thickness") self.wTube.valueChanged.connect(partial(self.changeParams, "wTube")) lyt.addWidget(self.wTube, 5, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube roughness")), 6, 1) self.rTube = Entrada_con_unidades(Length, "Thickness") self.rTube.valueChanged.connect(partial(self.changeParams, "rTube")) lyt.addWidget(self.rTube, 6, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Thermal conductivity")), 7, 1) self.kTube = Entrada_con_unidades(ThermalConductivity) self.kTube.valueChanged.connect(partial(self.changeParams, "kTube")) lyt.addWidget(self.kTube, 7, 2) self.buttonPipe = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Pipe Database")) self.buttonPipe.clicked.connect(self.showMaterial) lyt.addWidget(self.buttonPipe, 4, 4, 4, 1) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube pattern")), 9, 1) self.distribucionTube = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_DISTRIBUTION_TUBE: self.distribucionTube.addItem(txt) self.distribucionTube.currentIndexChanged.connect( partial(self.changeParams, "distribucionTube")) lyt.addWidget(self.distribucionTube, 9, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube pitch")), 10, 1) self.pitch = Entrada_con_unidades(Length) self.pitch.valueChanged.connect(partial(self.changeParams, "pitch")) lyt.addWidget(self.pitch, 10, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fin Tube")), 11, 1) self.buttonFin = QtWidgets.QPushButton( QtWidgets.QApplication.translate("pychemqt", "Finned Pipe Database")) self.buttonFin.setEnabled(False) self.buttonFin.clicked.connect(self.showFinTube) lyt.addWidget(self.buttonFin, 11, 4, 1, 1) self.finned = QtWidgets.QComboBox() self.finned.addItem( QtWidgets.QApplication.translate("pychemqt", "Bared tube")) self.finned.addItem( QtWidgets.QApplication.translate("pychemqt", "Finned tube")) self.finned.currentIndexChanged.connect(self.finnedChanged) lyt.addWidget(self.finned, 11, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fouling")), 12, 1) self.tubeFouling = FoulingWidget() self.tubeFouling.valueChanged.connect( partial(self.changeParams, "tubeFouling")) lyt.addWidget(self.tubeFouling, 12, 2, 1, 3) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Shell tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 3, tab, QtWidgets.QApplication.translate("pychemqt", "Shell")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Exchangers in paralell")), 1, 1) self.paralelo = Entrada_con_unidades(int, width=60) self.paralelo.valueChanged.connect( partial(self.changeParams, "parallel")) lyt.addWidget(self.paralelo, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Exchangers in serie")), 2, 1) self.serie = Entrada_con_unidades(int, width=60) self.serie.valueChanged.connect(partial(self.changeParams, "serie")) lyt.addWidget(self.serie, 2, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 3, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell Diameter")), 4, 1) self.DShell = Entrada_con_unidades(Length) self.DShell.valueChanged.connect(partial(self.changeParams, "DShell")) lyt.addWidget(self.DShell, 4, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell Material")), 6, 1) self.materialShell = QtWidgets.QComboBox() lyt.addWidget(self.materialShell, 6, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 7, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fouling")), 8, 1) self.shellFouling = FoulingWidget() self.shellFouling.valueChanged.connect( partial(self.changeParams, "shellFouling")) lyt.addWidget(self.shellFouling, 8, 2, 1, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Sealing Strips")), 10, 1) self.sealingStrips = Entrada_con_unidades(float) self.sealingStrips.valueChanged.connect( partial(self.changeParams, "sealingStrips")) lyt.addWidget(self.sealingStrips, 10, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Clearances")) lyt.addWidget(group, 11, 1, 1, 6) lyt = QtWidgets.QGridLayout(group) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tube to baffle hole")), 1, 1) self.ClearanceTubeBaffle = Entrada_con_unidades(Length, "Thickness") self.ClearanceTubeBaffle.valueChanged.connect( partial(self.changeParams, "clearanceTubeBaffle")) lyt.addWidget(self.ClearanceTubeBaffle, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell to baffle")), 2, 1) self.ClearanceShellBaffle = Entrada_con_unidades(Length, "Thickness") self.ClearanceShellBaffle.valueChanged.connect( partial(self.changeParams, "clearanceShellBaffle")) lyt.addWidget(self.ClearanceShellBaffle, 2, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shell to bundle")), 3, 1) self.ClearanceShellBundle = Entrada_con_unidades(Length, "Thickness") self.ClearanceShellBundle.valueChanged.connect( partial(self.changeParams, "clearanceShellBundle")) lyt.addWidget(self.ClearanceShellBundle, 3, 2) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Fitting tab tab = QtWidgets.QWidget() self.tabWidget.insertTab( 4, tab, QtWidgets.QApplication.translate("pychemqt", "Baffle")) lyt = QtWidgets.QGridLayout(tab) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Baffle type")), 1, 1) self.baffleType = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_BAFFLE_TYPE: self.baffleType.addItem(txt) self.baffleType.currentIndexChanged.connect( partial(self.changeParams, "baffleType")) lyt.addWidget(self.baffleType, 1, 2) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 2, 1, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Inlet spacing")), 3, 1) self.baffleSpacingIn = Entrada_con_unidades(Length) self.baffleSpacingIn.valueChanged.connect( partial(self.changeParams, "baffleSpacingIn")) lyt.addWidget(self.baffleSpacingIn, 3, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Outlet spacing")), 3, 4) self.baffleSpacingOut = Entrada_con_unidades(Length) self.baffleSpacingOut.valueChanged.connect( partial(self.changeParams, "baffleSpacingOut")) lyt.addWidget(self.baffleSpacingOut, 3, 5) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Baffle spacing")), 4, 1) self.baffleSpacing = Entrada_con_unidades(Length) self.baffleSpacing.valueChanged.connect( partial(self.changeParams, "baffleSpacing")) lyt.addWidget(self.baffleSpacing, 4, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Baffle thickness")), 5, 1) self.baffleThickness = Entrada_con_unidades(Length, "Thickness") self.baffleThickness.valueChanged.connect( partial(self.changeParams, "baffleThickness")) lyt.addWidget(self.baffleThickness, 5, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Orientation")), 6, 1) self.baffleOrientation = QtWidgets.QComboBox() self.baffleOrientation.addItem( QtWidgets.QApplication.translate("pychemqt", "Horizontal")) self.baffleOrientation.addItem( QtWidgets.QApplication.translate("pychemqt", "Vertical")) self.baffleOrientation.currentIndexChanged.connect( partial(self.changeParams, "baffleOrientation")) lyt.addWidget(self.baffleOrientation, 6, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cut percent")), 7, 1) self.baffleCut = Entrada_con_unidades(float, textounidad="%") self.baffleCut.valueChanged.connect( partial(self.changeParams, "baffleCut")) lyt.addWidget(self.baffleCut, 7, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Cut base")), 7, 4) self.baffleCutBase = QtWidgets.QComboBox() self.baffleCutBase.addItem( QtWidgets.QApplication.translate("pychemqt", "Diameter")) self.baffleCutBase.addItem( QtWidgets.QApplication.translate("pychemqt", "Area")) self.baffleCutBase.currentIndexChanged.connect( partial(self.changeParams, "baffleCutBase")) lyt.addWidget(self.baffleCutBase, 7, 5) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 1, 3, 6, 1) lyt.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Nozzles")) lyt.addWidget(group, 9, 1, 1, 6) layout = QtWidgets.QGridLayout(group) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Shellside")), 0, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Tubeside")), 0, 3) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Input diameter")), 1, 1) self.nozzleInShellsideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleInShellsideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleInShellsideDiameter")) layout.addWidget(self.nozzleInShellsideDiameter, 1, 2) self.nozzleInTubesideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleInTubesideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleInTubesideDiameter")) layout.addWidget(self.nozzleInTubesideDiameter, 1, 3) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Output diameter")), 2, 1) self.nozzleOutShellsideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleOutShellsideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleOutShellsideDiameter")) layout.addWidget(self.nozzleOutShellsideDiameter, 2, 2) self.nozzleOutTubesideDiameter = Entrada_con_unidades( Length, "PipeDiameter") self.nozzleOutTubesideDiameter.valueChanged.connect( partial(self.changeParams, "nozzleOutTubesideDiameter")) layout.addWidget(self.nozzleOutTubesideDiameter, 2, 3) layout.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed), 1, 4, 2, 1) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Calculation Mode")), 1, 1) self.modo = QtWidgets.QComboBox() self.modo.addItem( QtWidgets.QApplication.translate("pychemqt", "Rating")) self.modo.addItem( QtWidgets.QApplication.translate("pychemqt", "Design")) lyt.addWidget(self.modo, 1, 2) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 1, 1, 6) # Cost tab lyt = QtWidgets.QGridLayout(self.tabCostos) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Type")), 1, 1) self.tipoCoste = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_COST_TYPE: self.tipoCoste.addItem(txt) self.tipoCoste.currentIndexChanged.connect( partial(self.changeParamsCoste, "tipoCoste")) lyt.addWidget(self.tipoCoste, 1, 2) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Material")), 2, 1) self.materialCoste = QtWidgets.QComboBox() for txt in self.Equipment.TEXT_COST_MATERIAL: self.materialCoste.addItem(txt) self.materialCoste.currentIndexChanged.connect( partial(self.changeParamsCoste, "P_dis")) lyt.addWidget(self.materialCoste, 2, 2) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 3, 0, 1, 6) lyt.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Design Pressure")), 4, 1) self.Pdiseno = Entrada_con_unidades(Pressure) lyt.addWidget(self.Pdiseno, 4, 2, 1, 1) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 5, 0, 1, 6) self.Costos = CostData(self.Equipment) self.Costos.valueChanged.connect(self.calcularCostos) lyt.addWidget(self.Costos, 6, 1, 2, 5) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 8, 0, 1, 6) lyt.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 0, 1, 6) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Stimated Costs")) lyt.addWidget(group, 9, 1, 1, 5) layout = QtWidgets.QGridLayout(group) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Purchase Cost")), 0, 1) self.C_adq = Entrada_con_unidades(Currency, retornar=False, readOnly=True) layout.addWidget(self.C_adq, 0, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Installed Cost")), 1, 1) self.C_inst = Entrada_con_unidades(Currency, retornar=False, readOnly=True) self.C_inst.entrada.setReadOnly(True) layout.addWidget(self.C_inst, 1, 2) # Output Tab self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Tubes")) self.addSalida(QtWidgets.QApplication.translate("pychemqt", "Shell")) if equipment: self.setEquipment(equipment) def selectMethods(self): """Show dialog for select calculation methods""" dialogo = Dialog_Methods(self.Equipment) if dialogo.exec_(): self.Equipment(**dialogo.kwargs) def showMaterial(self): dialogo = Catalogo_Materiales_Dialog() if dialogo.exec_(): pass def rellenarFouling(self, widget, txt): if txt: widget.setReadOnly(True) widget.setValue(Fouling_Factor_Shell_Tube_Exchanger[str(txt)]) else: widget.setReadOnly(False) def finnedChanged(self, ind): self.buttonFin.setEnabled(ind) self.changeParams("finned", ind) def showFinTube(self): dialogo = Dialog_Finned() if dialogo.exec_(): pass def rellenar(self): pass def calcularCostos(self): if self.todos_datos(): self.Equipment.Coste(self.factorInstalacion.value(), 0, self.tipo.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.Equipment.C_adq.config()) self.C_inst.setValue(self.Equipment.C_inst.config())
class UI_equipment(parents.UI_equip): """Diálogo de definición de cristalizadores""" def __init__(self, entrada=None, parent=None): """entrada: Parametro opcional de clase corriente que indica la corriente de entrada en el equipo""" super(UI_equipment, self).__init__(Crystallizer, entrada=False, parent=parent) self.entrada=entrada #Pestaña entrada self.Entrada= UI_corriente.Ui_corriente(entrada) self.Entrada.Changed.connect(self.cambiar_entrada) self.tabWidget.insertTab(0, self.Entrada,QtWidgets.QApplication.translate("equipment", "Entrada", None)) #Pestaña calculo gridLayout_Calculo = QtWidgets.QGridLayout(self.tabCalculo) #Pestaña costos gridLayout_Costos = QtWidgets.QGridLayout(self.tabCostos) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Tipo:", None)), 1, 1) self.tipo=QtWidgets.QComboBox() self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Recirculación externa forzada", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Internos de tubo forzado", None)) self.tipo.addItem(QtWidgets.QApplication.translate("equipment", "Discontinuos a vacío", None)) self.tipo.currentIndexChanged.connect(self.mostrarSubclasificacion) self.tipo.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.tipo, 1, 2, 1, 3) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Material:", None)), 2, 1) self.materialvacio=QtWidgets.QComboBox() self.materialvacio.addItem(QtWidgets.QApplication.translate("equipment", "Acero dulce", None)) self.materialvacio.addItem(QtWidgets.QApplication.translate("equipment", "Acero recubierto de caucho", None)) self.materialvacio.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.materialvacio.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.materialvacio, 2, 2, 1, 3) self.materialotros=QtWidgets.QComboBox() self.materialotros.addItem(QtWidgets.QApplication.translate("equipment", "Acero dulce", None)) self.materialotros.addItem(QtWidgets.QApplication.translate("equipment", "Acero inoxidable 304", None)) self.materialotros.currentIndexChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.materialotros, 2, 2, 1, 3) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Volumen:", None)), 4, 4) self.Volumen=Entrada_con_unidades(unidades.Volume, "VolLiq", width=80) gridLayout_Costos.addWidget(self.Volumen,4,5,1,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),3,0,1,6) self.label4=QtWidgets.QLabel() self.label4.setText(QtWidgets.QApplication.translate("equipment", "Caudal calculado:", None)) gridLayout_Costos.addWidget(self.label4, 4, 1, 1, 1) self.caudalcalculado=Entrada_con_unidades(unidades.MassFlow, readOnly=True, retornar=False) gridLayout_Costos.addWidget(self.caudalcalculado,4,2,1,1) gridLayout_Costos.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Caudal de diseño:", None)), 5, 1) self.caudaldiseno=Entrada_con_unidades(unidades.MassFlow) gridLayout_Costos.addWidget(self.caudaldiseno,5,2,1,1) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(10,10,QtWidgets.QSizePolicy.Fixed,QtWidgets.QSizePolicy.Fixed),6,0,1,6) self.Costos=costIndex.CostData(1.9, 2) self.Costos.valueChanged.connect(self.calcularCostos) gridLayout_Costos.addWidget(self.Costos,7,1,2,5) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),11,0,1,6) gridLayout_Costos.addItem(QtWidgets.QSpacerItem(20,20,QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding),9,0,1,6) self.groupBox_Costos = QtWidgets.QGroupBox(QtWidgets.QApplication.translate("equipment", "Costos calculados", None)) gridLayout_Costos.addWidget(self.groupBox_Costos,10,1,1,5) gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_Costos) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Adquisición:", None)),0,1,1,1) self.C_adq=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_adq,0,2,1,1) gridLayout_5.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate("equipment", "Coste Instalación:", None)),1,1,1,1) self.C_inst=Entrada_con_unidades(unidades.Currency, retornar=False, readOnly=True) gridLayout_5.addWidget(self.C_inst,1,2,1,1) self.tabWidget.setCurrentIndex(0) self.mostrarSubclasificacion(0) def mostrarSubclasificacion(self, ind): if ind<2: self.materialvacio.setVisible(False) self.materialotros.setVisible(True) self.Volumen.setReadOnly(True) else: self.materialvacio.setVisible(True) self.materialotros.setVisible(False) self.Volumen.setReadOnly(False) def cambiar_entrada(self, corriente): selfentrada=corriente self.calculo() def calculo(self): if self.todos_datos(): self.rellenoSalida() def rellenoSalida(self): pass def todos_datos(self): pass def calcularCostos(self): if self.todos_datos(): if self.tipo.currentIndex()==0: self.FireHeater.Coste(self.factorInstalacion.value(), 0, self.tipobox.currentIndex(), self.material.currentIndex()) else: self.FireHeater.Coste(self.factorInstalacion.value(), 1, self.tipocilindrico.currentIndex(), self.material.currentIndex()) self.C_adq.setValue(self.FireHeater.C_adq.config()) self.C_inst.setValue(self.FireHeater.C_inst.config()) def on_costIndex_clicked(self): dialog = costIndex.Ui_CostIndex() if dialog.exec_(): self.indiceActual.setText(dialog.equipos.text()) self.calcularCostos()