diff options
author | lucaszhao19 | 2020-07-16 20:45:15 +0630 |
---|---|---|
committer | lucaszhao19 | 2020-07-16 20:45:15 +0630 |
commit | badd3b0787acaf3cbecdd9a9935d34de886fb5c2 (patch) | |
tree | 58a595459887d208db2f243fb2eb47d870b74b7b | |
parent | 4754490bd9f60c89f66f886e399abc9ea91e932a (diff) | |
download | Chemical-Simulator-GUI-badd3b0787acaf3cbecdd9a9935d34de886fb5c2.tar.gz Chemical-Simulator-GUI-badd3b0787acaf3cbecdd9a9935d34de886fb5c2.tar.bz2 Chemical-Simulator-GUI-badd3b0787acaf3cbecdd9a9935d34de886fb5c2.zip |
Fetching results for input data of MaterialStream
-rw-r--r-- | DockWidgets/DockWidgetMaterialStream.py | 75 | ||||
-rw-r--r-- | DockWidgets/__pycache__/DockWidget.cpython-37.pyc | bin | 6155 -> 6155 bytes | |||
-rw-r--r-- | DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc | bin | 8739 -> 8853 bytes | |||
-rw-r--r-- | Streams.py | 24 | ||||
-rw-r--r-- | Undo.dat | bin | 4777 -> 31950 bytes |
5 files changed, 52 insertions, 47 deletions
diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index 78959fc..130b290 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -40,13 +40,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.lTreeWidget.itemClicked.connect(lambda : self.printer(self.lTreeWidget.currentItem())) self.vTreeWidget.itemClicked.connect(lambda : self.printer(self.vTreeWidget.currentItem())) - - # def printer(self, treeItem ): - # foldername = treeItem.text(0) - # comment = treeItem.text(1) - # data = treeItem.text(2) - # print(foldername , ': ' , comment , ' (' + data + ')') - # input data tab def modes(self): modes_list = self.obj.modes_list @@ -69,6 +62,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): def input_params_list(self): try: print("input_params_list ", self.input_dict) + for c,i in enumerate(self.input_dict): if(i=="thermo_package"): print("thermo1") @@ -83,39 +77,31 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.formLayout.addRow(lay) self.input_dict[i] = combo print("thermo") - elif(i=="condType"): - combo = QComboBox() - self.lines = ["Total","Partial"] - for j in self.lines: - combo.addItem(str(j)) - lay = QGridLayout() - lay.addWidget(QLabel("Condensor Type :"+":"), 0, 0, alignment=Qt.AlignLeft) - lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) - self.formLayout.addRow(lay) - self.input_dict[i] = combo elif(i=="x_pc"): noc = len(compound_selected) print(noc) self.x_pclist.clear() - + gp = QGroupBox("Mole Fractions") lay = QGridLayout() for j in range(noc): l = QLineEdit() if self.input_dict[i] != '': - l.setText(str(self.obj.variables[compound_selected[j]]['value'])) + l.setText(str(self.obj.variables['x_pc']['value'][j])) + print('l = ', str(self.obj.variables['x_pc']['value'][j])) + self.input_dict[i] = "x_pc" 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) - + self.x_pclist.append(l) gp.setLayout(lay) - self.formLayout.addRow(gp) + self.formLayout.addRow(gp) else: print("elseloop") l = QLineEdit() if self.input_dict[i] != None: l.setText(str(self.input_dict[i])) + lay = QGridLayout() lay.addWidget(QLabel(i+":"),0,0, alignment=Qt.AlignLeft) lay.addWidget(l,0,1, alignment=Qt.AlignCenter) @@ -124,8 +110,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): else: lay.addWidget(QLabel("mol/s"),0,2, alignment=Qt.AlignCenter) self.formLayout.addRow(lay) - self.input_dict[i] = l - + self.input_dict[i] = l except Exception as e: print(e) @@ -144,12 +129,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): else: self.show_error() break - elif(i=="condType"): - if (self.input_dict[i].currentText()): - self.dict[i] = self.input_dict[i].currentText() - else: - self.show_error() - break elif(i =="x_pc"): l=[] mf = [] @@ -197,6 +176,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): result=self.container.result obj = self.container.fetch_object(name) + d = {"Mole Fraction":"x_pc", "Mass Fraction":"xm_pc", "Mole Flow":"F_pc", "Mass Flow":"Fm_pc"} lst = list(d.keys()) klst = list(d.values()) @@ -206,21 +186,21 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): # Amounts Tab if obj.type == 'MaterialStream': - l = [] # list for basis names + ll = [] # list for basis names for basis in d: propertyname = name + '.' + d[basis] print("basis ", basis, propertyname) for i in result[0]: if (propertyname in i): - l.append(i) - print(l) + ll.append(i) + print(ll) j = 0 t = 0 namee = klst[j] print("namee ", namee) - for i,k in enumerate(l): + for i,k in enumerate(ll): ind = result[0].index(k) print("index ", ind) print("str ", k) @@ -323,10 +303,27 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.mTableWidget.resizeColumnsToContents() - print(obj.variables) - except Exception as e: - print(e) - + # updating the input data from fetched results from simulation + print(self.comboBox.currentText()) + + self.input_dict = {} + self.input_dict = self.obj.param_getter(self.comboBox.currentText()) + print("before", self.input_dict) + self.input_dict.pop("x_pc") + temp = self.input_dict.pop('thermo_package') + for i in range(len(compound_selected)): + print(i) + self.input_dict['x_pc[1,' + str(i+1) + ']'] = self.obj.variables['x_pc[1,' + str(i+1) +']']['value'] + self.input_dict['thermo_package'] = temp + print("after", self.input_dict) + + # chaning index for updating the input data + indexx = self.comboBox.currentIndex() + self.comboBox.setCurrentIndex(1) + self.comboBox.setCurrentIndex(indexx) + -
\ No newline at end of file + + except Exception as e: + print(e)
\ No newline at end of file diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex b042722..fec7953 100644 --- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differindex e42b5d7..16bd08d 100644 --- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc @@ -38,7 +38,7 @@ class MaterialStream(): 'xvap' : {'name':'Vapour Phase Mole Fraction', 'value':None, 'unit':'g/s'}, 'H_p[1]' : {'name':'Mixture Phase Molar Entalpy', 'value':None, 'unit':'g/s'}, 'S_p[1]' : {'name':'Mixture Phase Molar Entropy', 'value':None, 'unit':'g/s'}, - 'F_p[1]' : {'name':'Mixture Molar Flow Rate', 'value':None, 'unit':'g/s'}, + 'F_p[1]' : {'name':'Mixture Molar Flow Rate', 'value':100, 'unit':'g/s'}, 'H_p[2]' : {'name':'Liquid Phase Molar Entalpy', 'value':None, 'unit':'g/s'}, 'S_p[2]' : {'name':'Liquid Phase Molar Entropy', 'value':None, 'unit':'g/s'}, @@ -48,7 +48,7 @@ class MaterialStream(): 'S_p[3]' : {'name':'Vapour Phase Molar Entropy', 'value':None, 'unit':'g/s'}, 'F_p[3]' : {'name':'Vapour Molar Flow Rate', 'value':None, 'unit':'g/s'}, - 'x_pc' : {'name':'Mole Fraction', 'value':1.0, 'unit':'mol/s'}, + 'x_pc' : {'name':'Mole Fraction', 'value':[], 'unit':'mol/s'}, 'xm_pc' : {'name':'Mass Fraction', 'value':None, 'unit':'g/s'}, 'F_pc' : {'name':'Mole Flow', 'value':100, 'unit':'mol/s'}, @@ -57,8 +57,9 @@ class MaterialStream(): self.init_variables() def init_variables(self): + Nc = len(self.compound_names) for i, val in enumerate(self.compound_names): - self.variables['x_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Fraction', 'value':None, 'unit':'mol/s'} + self.variables['x_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Fraction', 'value':round(1/Nc,4), 'unit':'mol/s'} self.variables['xm_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mass Fraction', 'value':None, 'unit':'g/s'} self.variables['F_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Flow', 'value':None, 'unit':'mol/s'} self.variables['Fm_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mass Flow', 'value':None, 'unit':'g/s'} @@ -79,31 +80,38 @@ class MaterialStream(): def param_getter(self,mode): dict = {} + temp = [] + for i, val in enumerate(self.compound_names): + temp.append(self.variables['x_pc[1,' + str(i+1) + ']']['value']) + self.variables['x_pc']['value'] = temp + if(mode=="PT"): self.mode1 = 'P' self.mode2 = 'T' + dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['T']['value'], - "MolFlow":self.variables['F_pc']['value'],"x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + "MolFlow":self.variables['F_p[1]']['value'],"x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + elif(mode=="PH"): self.mode1 = 'P' self.mode2 = 'H_p[1]' dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['H_p[1]']['value'], - "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} elif(mode=="PVF"): self.mode1 = 'P' self.mode2 = 'xvap' dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['xvap']['value'], - "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} elif(mode=="TVF"): self.mode1 = 'T' self.mode2 = 'xvap' dict = {self.mode1:self.variables['T']['value'], self.mode2:self.variables['xvap']['value'], - "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} elif(mode=="PS"): self.mode1 = 'P' self.mode2 = 'S_p[1]' dict = {self.mode1:self.variables['P']['value'], self.mode2: self.variables['S_p[1]']['value'], - "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} + "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package} return dict |