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(UI_equip): """Generic heat exchanger equipment edition dialog""" Equipment = Heat_Exchanger() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super().__init__(Heat_Exchanger, entrada=False, salida=False, parent=parent) # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output temperature")), 1, 1) self.Tout = Entrada_con_unidades(Temperature) self.Tout.valueChanged.connect(partial(self.changeParams, "Tout")) lyt.addWidget(self.Tout, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Temperature increase")), 2, 1) self.DeltaT = Entrada_con_unidades(DeltaT) self.DeltaT.valueChanged.connect(partial(self.changeParams, "DeltaT")) lyt.addWidget(self.DeltaT, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Heat Duty")), 3, 1) self.Heat = Entrada_con_unidades(Power) self.Heat.valueChanged.connect(partial(self.changeParams, "Heat")) lyt.addWidget(self.Heat, 3, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Heat Transfer")) lyt.addWidget(group, 4, 1, 1, 2) lyt1 = QtWidgets.QGridLayout(group) lyt1.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Area")), 1, 1) self.A = Entrada_con_unidades(Area) self.A.valueChanged.connect(partial(self.changeParams, "A")) lyt1.addWidget(self.A, 1, 2) lyt1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Heat Transfer Coefficient")), 2, 1) self.U = Entrada_con_unidades(HeatTransfCoef) self.U.valueChanged.connect(partial(self.changeParams, "U")) lyt1.addWidget(self.U, 2, 2) lyt1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "External Temperature")), 3, 1) self.Text = Entrada_con_unidades(Temperature) self.Text.valueChanged.connect(partial(self.changeParams, "Text")) lyt1.addWidget(self.Text, 3, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 0, 1, 3) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pressure loss")), 6, 1) self.DeltaP = Entrada_con_unidades(DeltaP, value=0) self.DeltaP.valueChanged.connect(partial(self.changeParams, "DeltaP")) lyt.addWidget(self.DeltaP, 6, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 0, 1, 3) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Results")) lyt.addWidget(group, 8, 1, 1, 5) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Heat Duty")), 0, 1) self.HeatCalc = Entrada_con_unidades(Power, retornar=False) self.HeatCalc.setReadOnly(True) layout.addWidget(self.HeatCalc, 0, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output Temperature")), 1, 1) self.ToutCalc = Entrada_con_unidades(Temperature, retornar=False) self.ToutCalc.setReadOnly(True) layout.addWidget(self.ToutCalc, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 0, 1, 3) if equipment: self.setEquipment(equipment) def changeParams(self, parametro, valor): if parametro == "Tout": self.Heat.clear() self.DeltaT.clear() elif parametro == "DeltaT": self.Heat.clear() self.Tout.clear() elif parametro == "Heat": self.DeltaT.clear() self.Tout.clear() self.calculo(**{parametro: valor})
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 AddPoint(QtWidgets.QDialog): """Dialog to add new point to line2D""" keys = ["T", "P", "x", "rho", "v", "h", "s", "u"] def __init__(self, fluid, melting=False, parent=None): """ fluid: initial fluid instance melting: boolean to add melting line calculation """ super(AddPoint, self).__init__(parent) self.setWindowTitle( QtWidgets.QApplication.translate("pychemqt", "Add Point to line")) layout = QtWidgets.QGridLayout(self) self.fluid = fluid self.Inputs = [] for i, (title, key, unit) in enumerate(meos.inputData): layout.addWidget(QtWidgets.QLabel(title), i, 1) if unit is unidades.Dimensionless: entrada = Entrada_con_unidades(float) else: entrada = Entrada_con_unidades(unit) entrada.valueChanged.connect(partial(self.update, key)) self.Inputs.append(entrada) layout.addWidget(entrada, i, 2) self.status = Status(self.fluid.status, self.fluid.msg) layout.addWidget(self.status, i + 1, 1, 1, 2) if isinstance(fluid, meos.MEoS) and fluid._melting: self.checkMelting = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Melting Point")) self.checkMelting.setChecked(melting) layout.addWidget(self.checkMelting, i + 2, 1, 1, 2) i += 1 layout.addWidget( QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "To")), i + 2, 1) self.To = Entrada_con_unidades(unidades.Temperature) self.To.valueChanged.connect(partial(self.update, "To")) layout.addWidget(self.To, i + 2, 2) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "rhoo")), i + 3, 1) self.rhoo = Entrada_con_unidades(unidades.Density) self.rhoo.valueChanged.connect(partial(self.update, "rhoo")) layout.addWidget(self.rhoo, i + 3, 2) self.checkBelow = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Add below selected point")) layout.addWidget(self.checkBelow, i + 4, 1, 1, 2) self.buttonBox = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Reset | QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel) self.buttonBox.clicked.connect(self.click) layout.addWidget(self.buttonBox, i + 5, 1, 1, 2) def click(self, button): """Manage mouse click event over buttonbox""" if QtWidgets.QDialogButtonBox.Reset == \ self.buttonBox.standardButton(button): self.reset() elif QtWidgets.QDialogButtonBox.Ok == \ self.buttonBox.standardButton(button): self.accept() elif QtWidgets.QDialogButtonBox.Cancel == \ self.buttonBox.standardButton(button): self.reject() def update(self, key, value): """Update fluid instance with new parameter key with value""" self.status.setState(4) QtWidgets.QApplication.processEvents() if isinstance(self.fluid, meos.MEoS) and self.fluid._melting and \ self.checkMelting.isChecked() and key == "T": P = self.fluid._Melting_Pressure(value) self.fluid(**{key: value, "P": P}) else: self.fluid(**{key: value}) if self.fluid.status in (1, 3): self.fill(self.fluid) self.status.setState(self.fluid.status, self.fluid.msg) def fill(self, fluid): """Fill dialog widget with fluid properties values""" self.blockSignals(True) Config = ConfigParser() Config.read(config.conf_dir + "pychemqtrc") for key, input in zip(self.keys, self.Inputs): input.setValue(fluid.__getattribute__(key)) if key in fluid.kwargs and \ fluid.kwargs[key] != fluid.__class__.kwargs[key]: input.setResaltado(True) else: input.setResaltado(False) self.blockSignals(False) def reset(self): """Reset dialog widgets to initial clear status""" self.fluid = self.fluid.__class__() self.status.setState(self.fluid.status, self.fluid.msg) self.rhoo.clear() self.To.clear() for input in self.Inputs: input.clear() input.setResaltado(False)
class UI_equipment(UI_equip): """Generic heat exchanger equipment edition dialog""" Equipment = Heat_Exchanger() def __init__(self, equipment=None, parent=None): """ equipment: Initial equipment instance to model """ super().__init__(Heat_Exchanger, entrada=False, salida=False, parent=parent) # Calculate tab lyt = QtWidgets.QGridLayout(self.tabCalculo) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output temperature")), 1, 1) self.Tout = Entrada_con_unidades(Temperature) self.Tout.valueChanged.connect(partial(self.changeParams, "Tout")) lyt.addWidget(self.Tout, 1, 2) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Temperature increase")), 2, 1) self.DeltaT = Entrada_con_unidades(DeltaT) self.DeltaT.valueChanged.connect(partial(self.changeParams, "DeltaT")) lyt.addWidget(self.DeltaT, 2, 2) lyt.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Heat Duty")), 3, 1) self.Heat = Entrada_con_unidades(Power) self.Heat.valueChanged.connect(partial(self.changeParams, "Heat")) lyt.addWidget(self.Heat, 3, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Heat Transfer")) lyt.addWidget(group, 4, 1, 1, 2) lyt1 = QtWidgets.QGridLayout(group) lyt1.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Area")), 1, 1) self.A = Entrada_con_unidades(Area) self.A.valueChanged.connect(partial(self.changeParams, "A")) lyt1.addWidget(self.A, 1, 2) lyt1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Heat Transfer Coefficient")), 2, 1) self.U = Entrada_con_unidades(HeatTransfCoef) self.U.valueChanged.connect(partial(self.changeParams, "U")) lyt1.addWidget(self.U, 2, 2) lyt1.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "External Temperature")), 3, 1) self.Text = Entrada_con_unidades(Temperature) self.Text.valueChanged.connect(partial(self.changeParams, "Text")) lyt1.addWidget(self.Text, 3, 2) lyt.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 5, 0, 1, 3) lyt.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Pressure loss")), 6, 1) self.DeltaP = Entrada_con_unidades(DeltaP, value=0) self.DeltaP.valueChanged.connect(partial(self.changeParams, "DeltaP")) lyt.addWidget(self.DeltaP, 6, 2) lyt.addItem(QtWidgets.QSpacerItem( 20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 0, 1, 3) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Results")) lyt.addWidget(group, 8, 1, 1, 5) layout = QtWidgets.QGridLayout(group) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Heat Duty")), 0, 1) self.HeatCalc = Entrada_con_unidades(Power, retornar=False) self.HeatCalc.setReadOnly(True) layout.addWidget(self.HeatCalc, 0, 2) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Output Temperature")), 1, 1) self.ToutCalc = Entrada_con_unidades(Temperature, retornar=False) self.ToutCalc.setReadOnly(True) layout.addWidget(self.ToutCalc, 1, 2) lyt.addItem(QtWidgets.QSpacerItem( 0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 9, 0, 1, 3) if equipment: self.setEquipment(equipment) def changeParams(self, parametro, valor): if parametro == "Tout": self.Heat.clear() self.DeltaT.clear() elif parametro == "DeltaT": self.Heat.clear() self.Tout.clear() elif parametro == "Heat": self.DeltaT.clear() self.Tout.clear() self.calculo(**{parametro: valor})
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 Ui_Contribution(newComponent): """Dialog to define hypotethical new component with several group contribucion methods""" ViewDetails = View_Contribution def __init__(self, metodo, parent=None): """Metodo: name of group contribution method: Joback, Constantinou, Wilson, Marrero, Elliott, Ambrose, Klincewicz """ super(Ui_Contribution, self).__init__(parent) # Initialization variables self.grupo = [] self.indices = [] self.contribucion = [] func = {} for f in _methods: func[f.__name__] = f self.unknown = func[metodo]() title = self.unknown.__title__ title += " " + QtWidgets.QApplication.translate( "pychemqt", "new component definition") self.setWindowTitle(title) lyt = QtWidgets.QVBoxLayout(self) widget = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(widget) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Name")), 1, 0) self.nombre = QtWidgets.QLineEdit() self.nombre.textChanged.connect(partial(self.changeParams, "name")) layout.addWidget(self.nombre, 1, 1, 1, 3) self.Group = QtWidgets.QTableWidget() self.Group.verticalHeader().hide() self.Group.setRowCount(0) self.Group.setColumnCount(2) self.Group.setHorizontalHeaderItem(0, QtWidgets.QTableWidgetItem("Nk")) self.Group.setHorizontalHeaderItem( 1, QtWidgets.QTableWidgetItem( QtWidgets.QApplication.translate("pychemqt", "Group"))) self.Group.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.Group.setSortingEnabled(True) self.Group.horizontalHeader().setStretchLastSection(True) self.Group.setColumnWidth(0, 50) self.Group.setItemDelegateForColumn(0, SpinEditor(self)) self.Group.cellChanged.connect(self.cellChanged) self.Group.setEditTriggers(QtWidgets.QAbstractItemView.AllEditTriggers) layout.addWidget(self.Group, 2, 0, 3, 3) self.Formula = QtWidgets.QLabel() font = QtGui.QFont() font.setPointSize(12) self.Formula.setFont(font) self.Formula.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.Formula.setFixedHeight(50) layout.addWidget(self.Formula, 2, 3) self.btnDelete = QtWidgets.QPushButton( QtGui.QIcon( QtGui.QPixmap( os.path.join(IMAGE_PATH, "button", "editDelete.png"))), QtWidgets.QApplication.translate("pychemqt", "Delete")) self.btnDelete.clicked.connect(self.borrar) layout.addWidget(self.btnDelete, 3, 3) self.btnClear = QtWidgets.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.path.join(IMAGE_PATH, "button", "clear.png"))), QtWidgets.QApplication.translate("pychemqt", "Clear")) self.btnClear.clicked.connect(self.clear) layout.addWidget(self.btnClear, 4, 3) self.line = QtWidgets.QFrame() self.line.setFrameShape(QtWidgets.QFrame.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Sunken) layout.addWidget(self.line, 5, 0, 1, 4) self.groupContributions = QtWidgets.QListWidget() self.groupContributions.currentItemChanged.connect(self.selectChanged) self.groupContributions.itemDoubleClicked.connect(self.add) layout.addWidget(self.groupContributions, 6, 0, 6, 3) self.btnAdd = QtWidgets.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.path.join(IMAGE_PATH, "button", "add.png"))), QtWidgets.QApplication.translate("pychemqt", "Add")) self.btnAdd.setDisabled(True) self.btnAdd.clicked.connect(self.add) layout.addWidget(self.btnAdd, 6, 3) layout.addItem( QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 7, 1) # Show selection for method with several order contributions if self.unknown.SecondOrder: self.Order1 = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "1st order")) self.Order1.setChecked(True) self.Order1.toggled.connect(self.Order) layout.addWidget(self.Order1, 9, 3) self.Order2 = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "2nd order")) self.Order2.toggled.connect(self.Order) layout.addWidget(self.Order2, 10, 3) if self.unknown.ThirdOrder: self.Order3 = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "3rd order")) layout.addWidget(self.Order3, 11, 3) self.Order3.toggled.connect(self.Order) layout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 12, 1) labelTb = QtWidgets.QLabel("Tb") labelTb.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Experimental Boiling Temperature")) layout.addWidget(labelTb, 13, 0) self.Tb = Entrada_con_unidades(Temperature) self.Tb.valueChanged.connect(partial(self.changeParams, "Tb")) layout.addWidget(self.Tb, 13, 1) labelM = QtWidgets.QLabel("M") labelM.setToolTip( QtWidgets.QApplication.translate("pychemqt", "Molecular Weight")) layout.addWidget(labelM, 14, 0) self.M = Entrada_con_unidades(float, textounidad="g/mol") self.M.valueChanged.connect(partial(self.changeParams, "M")) layout.addWidget(self.M, 14, 1) label = QtWidgets.QLabel("SG") label.setToolTip( QtWidgets.QApplication.translate( "pychemqt", "Experimental Specific Gravity at 60ºF")) layout.addWidget(label, 15, 0) self.SG = Entrada_con_unidades(float) self.SG.valueChanged.connect(partial(self.changeParams, "SG")) layout.addWidget(self.SG, 15, 1) lyt.addWidget(widget) # Show widget for specific method if metodo == "Constantinou": # Disable Tb as input parameter labelTb.setEnabled(False) self.Tb.setEnabled(False) elif metodo == "Wilson": self.Tb.setResaltado(True) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Rings")), 16, 0) self.ring = QtWidgets.QSpinBox() self.ring.setFixedWidth(80) self.ring.valueChanged.connect(partial(self.changeParams, "ring")) layout.addWidget(self.ring, 16, 1) elif metodo == "Elliott": self.M.setResaltado(True) elif metodo == "Ambrose": self.Tb.setResaltado(True) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Platt number")), 16, 0) self.plat = QtWidgets.QSpinBox() self.plat.setFixedWidth(80) tr = "The Platt number is the number of pairs of carbon atoms " tr += "which are separated by three carbon-carbon bonds and is an " tr += "indicator of the degree of branching in the molecule. The " tr += "Platt number of an n-alkane is equal to the number of " tr += "carbons minus three" self.plat.setToolTip( QtWidgets.QApplication.translate("pychemqt", tr)) self.plat.valueChanged.connect(partial(self.changeParams, "platt")) layout.addWidget(self.plat, 16, 1) elif metodo == "Klincewicz": self.Tb.setResaltado(True) self.nogroupKlincewicz = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Use the simple no group contribution method")) self.nogroupKlincewicz.toggled.connect(self.nogroupCheckToggled) layout.addWidget(self.nogroupKlincewicz, 16, 0, 1, 4) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Atoms")), 17, 0) self.atoms = QtWidgets.QSpinBox() self.atoms.setFixedWidth(80) self.atoms.valueChanged.connect(partial(self.changeParams, "atoms")) layout.addWidget(self.atoms, 17, 1) newComponent.loadUI(self) for i, nombre in enumerate(self.unknown.coeff["txt"]): self.groupContributions.addItem(nombre[0]) if self.unknown.SecondOrder: self.Order() if metodo == "Klincewicz": self.nogroupCheckToggled(False) def Order(self): """Show/Hide group of undesired order""" for i in range(self.unknown.FirstOrder): item = self.groupContributions.item(i) item.setHidden(not self.Order1.isChecked()) for i in range(self.unknown.FirstOrder, self.unknown.SecondOrder): item = self.groupContributions.item(i) item.setHidden(not self.Order2.isChecked()) if self.unknown.ThirdOrder: for i in range(self.unknown.SecondOrder, self.unknown.ThirdOrder): item = self.groupContributions.item(i) item.setHidden(not self.Order3.isChecked()) def nogroupCheckToggled(self, boolean): """Set advanced properties input status for Klincewitcz method""" self.changeParams("nogroup", boolean) self.M.setResaltado(boolean) self.atoms.setEnabled(boolean) self.Group.setDisabled(boolean) self.Formula.setDisabled(boolean) self.btnDelete.setDisabled(boolean) self.btnClear.setDisabled(boolean) self.btnAdd.setDisabled(boolean) self.groupContributions.setDisabled(boolean) def borrar(self, indice=None): """Remove some group contribution from added group list""" if not indice: indice = self.Group.currentRow() if indice != -1: self.Group.removeRow(indice) del self.grupo[indice] del self.indices[indice] del self.contribucion[indice] self.calculo(**{ "group": self.indices, "contribution": self.contribucion }) def clear(self): """Clear widgets from dialog""" self.Group.clearContents() self.Group.setRowCount(0) self.grupo = [] self.indices = [] self.contribucion = [] self.Formula.clear() self.M.clear() self.nombre.clear() self.Tb.clear() self.SG.clear() self.unknown.clear() self.status.setState(self.unknown.status, self.unknown.msg) def cellChanged(self, i, j): """Process the user manual count of group contribution changed""" if j == 0: valor = int(self.Group.item(i, j).text()) if valor <= 0: self.borrar(i) else: self.contribucion[i] = int(valor) kw = {"group": self.indices, "contribution": self.contribucion} self.calculo(**kw) def selectChanged(self, i): """The add button is only enabled when the group list have any selected row""" self.btnAdd.setEnabled(i != -1) def add(self): """Add the current selected item to the list of group""" indice = self.Group.rowCount() grupo = self.groupContributions.currentItem().text() if grupo not in self.grupo: self.grupo.append(grupo) self.indices.append(self.groupContributions.currentRow()) self.contribucion.append(1) self.Group.setRowCount(indice + 1) self.Group.setItem(indice, 0, QtWidgets.QTableWidgetItem("1")) self.Group.item(indice, 0).setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.Group.setItem(indice, 1, QtWidgets.QTableWidgetItem(grupo)) self.Group.item(indice, 1).setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.Group.setRowHeight(indice, 20) else: indice = self.grupo.index(grupo) self.contribucion[indice] += 1 self.Group.item(indice, 0).setText( str(int(self.Group.item(indice, 0).text()) + 1)) kw = {"group": self.indices, "contribution": self.contribucion} self.calculo(**kw) def calculo(self, **kwargs): """Calculate function""" newComponent.calculo(self, **kwargs) if self.unknown.status in (1, 3): self.Formula.setText(self.unknown.formula)
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_Contribution(newComponent): """Dialog to define hypotethical new component with several group contribucion methods""" ViewDetails = View_Contribution def __init__(self, metodo, parent=None): """Metodo: name of group contribution method: Joback Constantinou-Gani Wilson-Jasperson Marrero-Pardillo Elliott Ambrose """ super(Ui_Contribution, self).__init__(parent) self.setWindowTitle(QtGui.QApplication.translate( "pychemqt", "Select the component group for method") +" "+ metodo) self.grupo = [] self.indices = [] self.contribucion = [] self.metodo = metodo layout = QtGui.QGridLayout(self) self.Grupos = QtGui.QTableWidget() self.Grupos.verticalHeader().hide() self.Grupos.setRowCount(0) self.Grupos.setColumnCount(2) self.Grupos.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Nk")) self.Grupos.setHorizontalHeaderItem(1, QtGui.QTableWidgetItem( QtGui.QApplication.translate("pychemqt", "Group"))) self.Grupos.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.Grupos.setSortingEnabled(True) self.Grupos.horizontalHeader().setStretchLastSection(True) self.Grupos.setColumnWidth(0, 50) self.Grupos.setItemDelegateForColumn(0, SpinEditor(self)) self.Grupos.cellChanged.connect(self.cellChanged) self.Grupos.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers) layout.addWidget(self.Grupos, 0, 0, 3, 3) self.Formula = QtGui.QLabel() font = QtGui.QFont() font.setPointSize(12) self.Formula.setFont(font) self.Formula.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.Formula.setFixedHeight(50) layout.addWidget(self.Formula, 0, 3) self.botonBorrar = QtGui.QPushButton(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"]+"/images/button/editDelete.png")), QtGui.QApplication.translate("pychemqt", "Delete")) self.botonBorrar.clicked.connect(self.borrar) layout.addWidget(self.botonBorrar, 1, 3) self.botonClear = QtGui.QPushButton(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"]+"/images/button/clear.png")), QtGui.QApplication.translate("pychemqt", "Clear")) self.botonClear.clicked.connect(self.clear) layout.addWidget(self.botonClear, 2, 3) self.line = QtGui.QFrame() self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) layout.addWidget(self.line, 3, 0, 1, 4) self.TablaContribuciones = QtGui.QListWidget() self.TablaContribuciones.currentItemChanged.connect(self.selectedChanged) self.TablaContribuciones.itemDoubleClicked.connect(self.add) layout.addWidget(self.TablaContribuciones, 4, 0, 7, 3) self.botonAdd = QtGui.QPushButton(QtGui.QIcon(QtGui.QPixmap( os.environ["pychemqt"]+"/images/button/add.png")), QtGui.QApplication.translate("pychemqt", "Add")) self.botonAdd.setDisabled(True) self.botonAdd.clicked.connect(self.add) layout.addWidget(self.botonAdd, 4, 3) layout.addItem(QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 5, 1, 1, 1) # Show widget for specific method if metodo in ["Constantinou", "Wilson"]: self.Order1 = QtGui.QRadioButton( QtGui.QApplication.translate("pychemqt", "1st order")) self.Order1.setChecked(True) self.Order1.toggled.connect(self.Order) layout.addWidget(self.Order1, 6, 3) self.Order2 = QtGui.QRadioButton( QtGui.QApplication.translate("pychemqt", "2nd order")) layout.addWidget(self.Order2, 7, 3) if metodo == "Wilson": layout.addWidget(QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Rings")), 8, 3) self.anillos = QtGui.QSpinBox() self.anillos.valueChanged.connect(partial(self.changeParams, "ring")) layout.addWidget(self.anillos, 9, 3) if metodo == "Marrero": layout.addWidget(QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Atoms")), 8, 3) self.Atomos = QtGui.QSpinBox() self.Atomos.valueChanged.connect(partial(self.changeParams, "atomos")) layout.addWidget(self.Atomos, 9, 3) if metodo == "Ambrose": layout.addWidget(QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Platt number")), 8, 3) self.Platt = QtGui.QSpinBox() self.Platt.setToolTip(QtGui.QApplication.translate( "pychemqt", "The Platt number is the number of pairs of carbon \ atoms which are separated \nby three carbon-carbon bonds and \ is an indicator of the degree of branching in the molecule.\n\ The Platt number of an n-alkane is equal to the number of \ carbons minus three")) self.Platt.valueChanged.connect(partial(self.changeParams, "platt")) layout.addWidget(self.Platt, 9, 3) layout.addItem(QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 10, 1, 1, 1) layout.addItem(QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 11, 0, 1, 4) layout.addWidget(QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Name")), 12, 0) self.nombre = QtGui.QLineEdit() self.nombre.textChanged.connect(partial(self.changeParams, "name")) layout.addWidget(self.nombre, 12, 1, 1, 3) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Molecular Weight")), 13, 0) self.M = Entrada_con_unidades(float, textounidad="g/mol") self.M.valueChanged.connect(partial(self.changeParams, "M")) layout.addWidget(self.M, 13, 1) layout.addWidget(QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Boiling point")), 14, 0) self.Tb = Entrada_con_unidades(Temperature) self.Tb.valueChanged.connect(partial(self.changeParams, "Tb")) layout.addWidget(self.Tb, 14, 1) layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate( "pychemqt", "Specific Gravity")), 15, 0) self.SG = Entrada_con_unidades(float) self.SG.valueChanged.connect(partial(self.changeParams, "SG")) layout.addWidget(self.SG, 15, 1) newComponent.loadUI(self) func = {"Constantinou": Constantinou_Gani, "Wilson": Wilson_Jasperson, "Joback": Joback, "Ambrose": Ambrose, "Elliott": Elliott, "Marrero": Marrero_Pardillo} self.unknown = func[self.metodo]() for i, nombre in enumerate(self.unknown.coeff["txt"]): self.TablaContribuciones.addItem(nombre[0]) if metodo in ["Constantinou", "Wilson"]: self.Order() def Order(self): """Show/Hide group of undesired order""" for i in range(self.unknown.FirstOrder): self.TablaContribuciones.item(i).setHidden(self.Order2.isChecked()) for i in range(self.unknown.FirstOrder, self.unknown.SecondOrder): self.TablaContribuciones.item(i).setHidden(self.Order1.isChecked()) def borrar(self, indice=None): """Remove some group contribution from list""" if not indice: indice = self.Grupos.currentRow() if indice != -1: self.Grupos.removeRow(indice) del self.grupo[indice] del self.indices[indice] del self.contribucion[indice] self.calculo(**{"group": self.indices, "contribution": self.contribucion}) def clear(self): """Clear widgets from dialog""" self.Grupos.clearContents() self.Grupos.setRowCount(0) self.grupo = [] self.indices = [] self.contribucion = [] self.Formula.clear() self.M.clear() self.nombre.clear() self.Tb.clear() self.SG.clear() self.unknown.clear() self.status.setState(self.unknown.status, self.unknown.msg) def cellChanged(self, i, j): if j == 0: valor = int(self.Grupos.item(i, j).text()) if valor <= 0: self.borrar(i) else: self.contribucion[i] = int(valor) self.calculo(**{"group": self.indices, "contribution": self.contribucion}) def selectedChanged(self, i): self.botonAdd.setEnabled(i != -1) def add(self): indice = self.Grupos.rowCount() grupo = self.TablaContribuciones.currentItem().text() if grupo not in self.grupo: self.grupo.append(grupo) self.indices.append(self.TablaContribuciones.currentRow()) self.contribucion.append(1) self.Grupos.setRowCount(indice+1) self.Grupos.setItem(indice, 0, QtGui.QTableWidgetItem("1")) self.Grupos.item(indice, 0).setTextAlignment( QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.Grupos.setItem(indice, 1, QtGui.QTableWidgetItem(grupo)) self.Grupos.item(indice, 1).setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.Grupos.setRowHeight(indice, 20) else: indice = self.grupo.index(grupo) self.contribucion[indice] += 1 self.Grupos.item(indice, 0).setText(str(int( self.Grupos.item(indice, 0).text())+1)) self.calculo(**{"group": self.indices, "contribution": self.contribucion}) def calculo(self, **kwargs): """Calculate function""" newComponent.calculo(self, **kwargs) if self.unknown.status: self.Formula.setText(self.unknown.formula)
class Ui_Contribution(newComponent): """Dialog to define hypotethical new component with several group contribucion methods""" ViewDetails = View_Contribution def __init__(self, metodo, parent=None): """Metodo: name of group contribution method: Joback Constantinou-Gani Wilson-Jasperson Marrero-Pardillo Elliott Ambrose """ super(Ui_Contribution, self).__init__(parent) self.setWindowTitle( QtGui.QApplication.translate( "pychemqt", "Select the component group for method") + " " + metodo) self.grupo = [] self.indices = [] self.contribucion = [] self.metodo = metodo layout = QtGui.QGridLayout(self) self.Grupos = QtGui.QTableWidget() self.Grupos.verticalHeader().hide() self.Grupos.setRowCount(0) self.Grupos.setColumnCount(2) self.Grupos.setHorizontalHeaderItem(0, QtGui.QTableWidgetItem("Nk")) self.Grupos.setHorizontalHeaderItem( 1, QtGui.QTableWidgetItem( QtGui.QApplication.translate("pychemqt", "Group"))) self.Grupos.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.Grupos.setSortingEnabled(True) self.Grupos.horizontalHeader().setStretchLastSection(True) self.Grupos.setColumnWidth(0, 50) self.Grupos.setItemDelegateForColumn(0, SpinEditor(self)) self.Grupos.cellChanged.connect(self.cellChanged) self.Grupos.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers) layout.addWidget(self.Grupos, 0, 0, 3, 3) self.Formula = QtGui.QLabel() font = QtGui.QFont() font.setPointSize(12) self.Formula.setFont(font) self.Formula.setAlignment(QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter) self.Formula.setFixedHeight(50) layout.addWidget(self.Formula, 0, 3) self.botonBorrar = QtGui.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.environ["pychemqt"] + "/images/button/editDelete.png")), QtGui.QApplication.translate("pychemqt", "Delete")) self.botonBorrar.clicked.connect(self.borrar) layout.addWidget(self.botonBorrar, 1, 3) self.botonClear = QtGui.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.environ["pychemqt"] + "/images/button/clear.png")), QtGui.QApplication.translate("pychemqt", "Clear")) self.botonClear.clicked.connect(self.clear) layout.addWidget(self.botonClear, 2, 3) self.line = QtGui.QFrame() self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) layout.addWidget(self.line, 3, 0, 1, 4) self.TablaContribuciones = QtGui.QListWidget() self.TablaContribuciones.currentItemChanged.connect( self.selectedChanged) self.TablaContribuciones.itemDoubleClicked.connect(self.add) layout.addWidget(self.TablaContribuciones, 4, 0, 7, 3) self.botonAdd = QtGui.QPushButton( QtGui.QIcon( QtGui.QPixmap(os.environ["pychemqt"] + "/images/button/add.png")), QtGui.QApplication.translate("pychemqt", "Add")) self.botonAdd.setDisabled(True) self.botonAdd.clicked.connect(self.add) layout.addWidget(self.botonAdd, 4, 3) layout.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 5, 1, 1, 1) # Show widget for specific method if metodo in ["Constantinou", "Wilson"]: self.Order1 = QtGui.QRadioButton( QtGui.QApplication.translate("pychemqt", "1st order")) self.Order1.setChecked(True) self.Order1.toggled.connect(self.Order) layout.addWidget(self.Order1, 6, 3) self.Order2 = QtGui.QRadioButton( QtGui.QApplication.translate("pychemqt", "2nd order")) layout.addWidget(self.Order2, 7, 3) if metodo == "Wilson": layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Rings")), 8, 3) self.anillos = QtGui.QSpinBox() self.anillos.valueChanged.connect( partial(self.changeParams, "ring")) layout.addWidget(self.anillos, 9, 3) if metodo == "Marrero": layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Atoms")), 8, 3) self.Atomos = QtGui.QSpinBox() self.Atomos.valueChanged.connect( partial(self.changeParams, "atomos")) layout.addWidget(self.Atomos, 9, 3) if metodo == "Ambrose": layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Platt number")), 8, 3) self.Platt = QtGui.QSpinBox() self.Platt.setToolTip( QtGui.QApplication.translate( "pychemqt", "The Platt number is the number of pairs of carbon \ atoms which are separated \nby three carbon-carbon bonds and \ is an indicator of the degree of branching in the molecule.\n\ The Platt number of an n-alkane is equal to the number of \ carbons minus three")) self.Platt.valueChanged.connect(partial(self.changeParams, "platt")) layout.addWidget(self.Platt, 9, 3) layout.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 10, 1, 1, 1) layout.addItem( QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding), 11, 0, 1, 4) layout.addWidget( QtGui.QLabel(QtGui.QApplication.translate("pychemqt", "Name")), 12, 0) self.nombre = QtGui.QLineEdit() self.nombre.textChanged.connect(partial(self.changeParams, "name")) layout.addWidget(self.nombre, 12, 1, 1, 3) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Molecular Weight")), 13, 0) self.M = Entrada_con_unidades(float, textounidad="g/mol") self.M.valueChanged.connect(partial(self.changeParams, "M")) layout.addWidget(self.M, 13, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Boiling point")), 14, 0) self.Tb = Entrada_con_unidades(Temperature) self.Tb.valueChanged.connect(partial(self.changeParams, "Tb")) layout.addWidget(self.Tb, 14, 1) layout.addWidget( QtGui.QLabel( QtGui.QApplication.translate("pychemqt", "Specific Gravity")), 15, 0) self.SG = Entrada_con_unidades(float) self.SG.valueChanged.connect(partial(self.changeParams, "SG")) layout.addWidget(self.SG, 15, 1) newComponent.loadUI(self) func = { "Constantinou": Constantinou_Gani, "Wilson": Wilson_Jasperson, "Joback": Joback, "Ambrose": Ambrose, "Elliott": Elliott, "Marrero": Marrero_Pardillo } self.unknown = func[self.metodo]() for i, nombre in enumerate(self.unknown.coeff["txt"]): self.TablaContribuciones.addItem(nombre[0]) if metodo in ["Constantinou", "Wilson"]: self.Order() def Order(self): """Show/Hide group of undesired order""" for i in range(self.unknown.FirstOrder): self.TablaContribuciones.item(i).setHidden(self.Order2.isChecked()) for i in range(self.unknown.FirstOrder, self.unknown.SecondOrder): self.TablaContribuciones.item(i).setHidden(self.Order1.isChecked()) def borrar(self, indice=None): """Remove some group contribution from list""" if not indice: indice = self.Grupos.currentRow() if indice != -1: self.Grupos.removeRow(indice) del self.grupo[indice] del self.indices[indice] del self.contribucion[indice] self.calculo(**{ "group": self.indices, "contribution": self.contribucion }) def clear(self): """Clear widgets from dialog""" self.Grupos.clearContents() self.Grupos.setRowCount(0) self.grupo = [] self.indices = [] self.contribucion = [] self.Formula.clear() self.M.clear() self.nombre.clear() self.Tb.clear() self.SG.clear() self.unknown.clear() self.status.setState(self.unknown.status, self.unknown.msg) def cellChanged(self, i, j): if j == 0: valor = int(self.Grupos.item(i, j).text()) if valor <= 0: self.borrar(i) else: self.contribucion[i] = int(valor) self.calculo(**{ "group": self.indices, "contribution": self.contribucion }) def selectedChanged(self, i): self.botonAdd.setEnabled(i != -1) def add(self): indice = self.Grupos.rowCount() grupo = self.TablaContribuciones.currentItem().text() if grupo not in self.grupo: self.grupo.append(grupo) self.indices.append(self.TablaContribuciones.currentRow()) self.contribucion.append(1) self.Grupos.setRowCount(indice + 1) self.Grupos.setItem(indice, 0, QtGui.QTableWidgetItem("1")) self.Grupos.item(indice, 0).setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.Grupos.setItem(indice, 1, QtGui.QTableWidgetItem(grupo)) self.Grupos.item(indice, 1).setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.Grupos.setRowHeight(indice, 20) else: indice = self.grupo.index(grupo) self.contribucion[indice] += 1 self.Grupos.item(indice, 0).setText( str(int(self.Grupos.item(indice, 0).text()) + 1)) self.calculo(**{ "group": self.indices, "contribution": self.contribucion }) def calculo(self, **kwargs): """Calculate function""" newComponent.calculo(self, **kwargs) if self.unknown.status: self.Formula.setText(self.unknown.formula)