diff options
author | Priyam Nayak | 2021-06-22 08:41:25 +0530 |
---|---|---|
committer | GitHub | 2021-06-22 08:41:25 +0530 |
commit | ecf089991f8f3c15c3c99f376be3b954ec5b3545 (patch) | |
tree | 6de70decc9a0907b5fc8b58452c28e85a84d24db | |
parent | 3f8095e27df1ea62c4356c08de09cc42ffca00ed (diff) | |
parent | 4f47bbc5cb8a325bdb31776d5c9f2963603695d4 (diff) | |
download | Chemical-Simulator-GUI-ecf089991f8f3c15c3c99f376be3b954ec5b3545.tar.gz Chemical-Simulator-GUI-ecf089991f8f3c15c3c99f376be3b954ec5b3545.tar.bz2 Chemical-Simulator-GUI-ecf089991f8f3c15c3c99f376be3b954ec5b3545.zip |
Merge pull request #24 from pravindalve/master
Fixed problem of compound updating during simulation
18 files changed, 109 insertions, 14 deletions
diff --git a/ComponentSelector.py b/ComponentSelector.py index 79edef4..e8f282c 100644 --- a/ComponentSelector.py +++ b/ComponentSelector.py @@ -148,10 +148,9 @@ class ComponentSelector(QDialog,ui_dialog): def remove_items(self): try: - item = self.tableWidget.item(self.tableWidget.currentRow(),1).text() + item = self.tableWidget.item(self.tableWidget.currentRow(),1).text() + '(chemsep)' self.tableWidget.removeRow(self.tableWidget.currentRow()) - - compound_selected.remove(item) + compound_selected.remove(item) except Exception as e: print(e) diff --git a/Container.py b/Container.py index 0ad3c50..3068c78 100644 --- a/Container.py +++ b/Container.py @@ -98,6 +98,9 @@ class Container(): def add_compounds(self,comp): self.compounds = comp + def update_compounds(self): + self.graphics.update_compounds() + def add_thermo_package(self,thermo): self.thermo_package = thermo diff --git a/DockWidgets/DockWidgetDistillationColumn.py b/DockWidgets/DockWidgetDistillationColumn.py index bd5a683..34b8590 100644 --- a/DockWidgets/DockWidgetDistillationColumn.py +++ b/DockWidgets/DockWidgetDistillationColumn.py @@ -117,6 +117,16 @@ class DockWidgetDistillationColumn(QDockWidget, ui_dialog): except Exception as e: print(e) + def update_compounds(self): + self.cb2.clear() + self.cb4.clear() + for j in self.obj.compounds: + self.cb2.addItem(str(j)) + self.cb2.setCurrentText(self.obj.variables['C_Spec']['comp']) + for j in self.obj.compounds: + self.cb4.addItem(str(j)) + self.cb4.setCurrentText(self.obj.variables['R_Spec']['comp']) + def fun2(self): if self.cb1.currentText() == 'Compound Molar Fraction' or self.cb1.currentText() == 'Compound Molar Flow (mol/s)': self.cb2.setDisabled(False) diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index 60a4aca..2e5f303 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -35,6 +35,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): for j in lines: self.cbTP.addItem(str(j)) self.modes() + # input data tab def modes(self): modes_list = self.obj.modes_list @@ -67,10 +68,13 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): print(noc) self.x_pclist.clear() - gp = QGroupBox("Mole Fractions") + self.comp_gb = QGroupBox("Mole Fractions") lay = QGridLayout() for j in range(noc): - l = QLineEdit(str(self.obj.variables['x_pc']['value'][j])) + try: + l = QLineEdit(str(self.obj.variables['x_pc']['value'][j])) + except: + l = QLineEdit() # if self.input_dict[i] != '': # l.setText(str(self.obj.variables['x_pc']['value'][j])) # print('l = ', str(self.obj.variables['x_pc']['value'][j])) @@ -80,8 +84,8 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): lay.addWidget(l,j,1, alignment=Qt.AlignCenter) self.x_pclist.append(l) lay.setSizeConstraint(QLayout.SetFixedSize) - gp.setLayout(lay) - self.formLayout.addRow(gp) + self.comp_gb.setLayout(lay) + self.formLayout.addRow(self.comp_gb) elif i == "Thermo Package": self.cbTP.setCurrentText(self.input_dict[i]) else: @@ -101,14 +105,32 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.input_dict[i] = l - - except Exception as e: print(e) def show_error(self): QMessageBox.about(self, 'Important', "Please fill all fields with data") + def update_compounds(self): + try: + noc = len(compound_selected) + print(noc) + self.x_pclist.clear() + + lay = QGridLayout() + for j in range(noc): + l = QLineEdit() + lay.addWidget(QLabel(str(compound_selected[j]) + ":"), j, 0, alignment=Qt.AlignLeft) + lay.addWidget(l, j, 1, alignment=Qt.AlignCenter) + self.x_pclist.append(l) + lay.setSizeConstraint(QLayout.SetFixedSize) + self.comp_gb.setLayout(lay) + indexx = self.comboBox.currentIndex() + self.comboBox.setCurrentIndex(1) + self.comboBox.setCurrentIndex(indexx) + except Exception as e: + print(e) + def param(self): try: self.dict={} diff --git a/DockWidgets/DockWidgetShortcutColumn.py b/DockWidgets/DockWidgetShortcutColumn.py index 96069e5..3d0c287 100644 --- a/DockWidgets/DockWidgetShortcutColumn.py +++ b/DockWidgets/DockWidgetShortcutColumn.py @@ -70,6 +70,15 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog): except Exception as e: print(e) + + def update_compounds(self): + self.cb1.clear() + self.cb2.clear() + for i in self.obj.compounds: + self.cb1.addItem(str(i)) + self.cb2.addItem(str(i)) + self.cb1.setCurrentText(self.obj.compounds[int(self.obj.variables['HKey']['value']) - 1]) + self.cb2.setCurrentText(self.obj.compounds[int(self.obj.variables['LKey']['value']) - 1]) def show_error(self): QMessageBox.about(self, 'Important', "Please fill all fields with data") diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex 0a00568..ca3b088 100644 --- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc Binary files differindex 8f43ce8..1c1f6f0 100644 --- a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differindex 066bc00..8235011 100644 --- a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc Binary files differindex c7d0661..c3d3567 100644 --- a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differindex 5c052ae..b9e781b 100644 --- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc Binary files differindex 9d19bbf..150b189 100644 --- a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc Binary files differindex bc258f6..42e53d9 100644 --- a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc Binary files differindex f90f086..d82db97 100644 --- a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc diff --git a/Graphics.py b/Graphics.py index a9a6d23..8fbbbf0 100644 --- a/Graphics.py +++ b/Graphics.py @@ -36,6 +36,11 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): def create_node_item(self,unit_operation, container): return NodeItem(unit_operation, container, self.graphicsView) + + def update_compounds(self): + for i in self.scene.items(): + if isinstance(i, NodeItem): + i.update_compounds() def load_canvas(self, obj, container): stm = ['MaterialStream','EngStm'] @@ -581,6 +586,13 @@ class NodeItem(QtWidgets.QGraphicsItem): default_tooltip = default_tooltip + f" {i} : {j}\n" self.setToolTip(default_tooltip) + def update_compounds(self): + try: + self.obj.update_compounds() + self.dock_widget.update_compounds() + except AttributeError: + pass + def findMainWindow(self): ''' @@ -1,6 +1,7 @@ import json import sys from PyQt5.QtCore import * +from ComponentSelector import compound_selected class MaterialStream(): counter = 1 @@ -56,6 +57,9 @@ class MaterialStream(): } self.init_variables() + def update_compounds(self): + self.compound_names = compound_selected + def init_variables(self): Nc = len(self.compound_names) for i, val in enumerate(self.compound_names): @@ -82,7 +86,10 @@ class MaterialStream(): temp = [] for i, val in enumerate(self.compound_names): - temp.append(self.variables['x_pc[1,' + str(i+1) + ']']['value']) + try: + temp.append(self.variables['x_pc[1,' + str(i+1) + ']']['value']) + except: + pass self.variables['x_pc']['value'] = temp if(mode=="PT"): Binary files differdiff --git a/UnitOperations.py b/UnitOperations.py index 132990a..912c19e 100644 --- a/UnitOperations.py +++ b/UnitOperations.py @@ -70,6 +70,9 @@ class UnitOperation(): def set_pos(self,pos): self.pos = pos + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def OM_Flowsheet_Initialize(self): self.OM_data_init = '' @@ -204,7 +207,10 @@ class ShortcutColumn(UnitOperation): 'Qr' : {'name':'Reboiler Duty', 'value': None, 'unit':'W'}, } - + + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self,params): print("param_setter ", params) self.variables['HKey']['value'] = self.compounds.index(params[0]) + 1 @@ -270,7 +276,10 @@ class DistillationColumn(UnitOperation): 'Stages.T': {'name':'Stagewise Temperature', 'value':[], 'unit':'K'}, 'Stages.x_pc': {'name': 'Stagewise Component Mole Fraction', 'value':[],'unit':''} } - + + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self,params): print("param_setter ", params) temp = 0 @@ -427,6 +436,9 @@ class CompoundSeparator(UnitOperation): 'SepFact_c' : {'name':'Separaction Factor', 'value':['']*len(self.compounds), 'unit':''}, } + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self,params): print("param_setter CompSep ", params) @@ -501,6 +513,9 @@ class Flash(UnitOperation): 'Pdef' : {'name':'Separation Pressure', 'value':101325, 'unit':'Pa'} } + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self,params): print("param_setter ", params) self.variables['thermo_package']['value'] = params[0] @@ -571,6 +586,9 @@ class Splitter(UnitOperation): specval = self.variables['SpecVal_s']['value'] self.specval = json.dumps(specval).replace('[','{').replace(']','}') + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self,params): print("param_setter ", params) self.variables['No']['value'] = int(params[0]) @@ -599,7 +617,10 @@ class Mixer(UnitOperation): 'NI' : {'name':'Number of Input', 'value':6, 'unit':''}, 'outPress' : {'name':'Outlet Pressure', 'value':'Inlet_Average', 'unit':''}, } - + + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + def param_setter(self, params): self.variables['NI']['value'] = int(params[0]) self.variables['outPress']['value'] = params[1] @@ -674,6 +695,9 @@ class AdiabaticCompressor(UnitOperation): 'Eff' : {'name':'Efficiency', 'value':1, 'unit':''} } + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected] + class AdiabaticExpander(UnitOperation): def __init__(self, name='AdiabaticExpander'): @@ -698,4 +722,5 @@ class AdiabaticExpander(UnitOperation): 'Eff' : {'name':'Efficiency', 'value':1, 'unit':''} } -
\ No newline at end of file + def update_compounds(self): + self.compounds = [c[:c.index('(')] for c in compound_selected]
\ No newline at end of file @@ -43,6 +43,7 @@ class MainApp(QMainWindow,ui): # Creating instances of classes for the main app self.container = Container(self.textBrowser, self.graphicsView) self.comp = ComponentSelector(self) + self.comp.accepted.connect(self.update_compounds) # Setting up interactive canvas self.scene = self.container.graphics.get_scene() @@ -140,6 +141,13 @@ class MainApp(QMainWindow,ui): self.comp.show() ''' + Updates compounds after compound selected modified during simulation creation + ''' + def update_compounds(self): + self.container.update_compounds() + + + ''' Returns current time in a required particular format ''' def current_time(self): |