From badd3b0787acaf3cbecdd9a9935d34de886fb5c2 Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Thu, 16 Jul 2020 20:45:15 +0630 Subject: Fetching results for input data of MaterialStream --- DockWidgets/DockWidgetMaterialStream.py | 75 ++++++++++++++++----------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'DockWidgets/DockWidgetMaterialStream.py') 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 -- cgit From 788b7f4bbb7aa51839c0836b1ab163fa831ce8fc Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Thu, 30 Jul 2020 21:19:00 +0630 Subject: Fixed populating the wrong simulation results --- DockWidgets/DockWidgetMaterialStream.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'DockWidgets/DockWidgetMaterialStream.py') diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index 130b290..f53e331 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -168,6 +168,15 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): i.results_category(i.name) #i.show() + + def clear_results(self): + self.mTreeWidget.clear() + self.mTableWidget.setRowCount(0) + self.lTreeWidget.clear() + self.lTableWidget.setRowCount(0) + self.vTreeWidget.clear() + self.vTableWidget.setRowCount(0) + # result data tab def results_category(self,name): flag = True -- cgit From f21a9a6ff969e4472100ee0f2ad498018700d935 Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Mon, 3 Aug 2020 21:13:22 +0630 Subject: Update Thermo Package option for MaterialStream DockWidget --- DockWidgets/DockWidgetMaterialStream.py | 38 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'DockWidgets/DockWidgetMaterialStream.py') diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index f53e331..915bea3 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -64,20 +64,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): print("input_params_list ", self.input_dict) for c,i in enumerate(self.input_dict): - if(i=="thermo_package"): - print("thermo1") - combo = QComboBox() - self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] - print("thermo2") - for j in self.lines: - combo.addItem(str(j)) - lay = QGridLayout() - lay.addWidget(QLabel(i+":"), 0,0, alignment=Qt.AlignLeft) - lay.addWidget(combo, 0, 1, alignment=Qt.AlignRight) - self.formLayout.addRow(lay) - self.input_dict[i] = combo - print("thermo") - elif(i=="x_pc"): + if(i=="x_pc"): noc = len(compound_selected) print(noc) self.x_pclist.clear() @@ -111,6 +98,12 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): lay.addWidget(QLabel("mol/s"),0,2, alignment=Qt.AlignCenter) self.formLayout.addRow(lay) self.input_dict[i] = l + + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cbTP.addItem(str(j)) + self.input_dict['Thermo Package'] = self.cbTP + except Exception as e: print(e) @@ -123,13 +116,8 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): print("param.input_dict ", self.input_dict) for i in self.input_dict: - if(i=="thermo_package"): - if (self.input_dict[i].currentText()): - self.dict[i] = self.input_dict[i].currentText() - else: - self.show_error() - break - elif(i =="x_pc"): + print(i) + if(i =="x_pc"): l=[] mf = [] total_moles = 0 @@ -145,14 +133,18 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.obj.variables[compound_selected[c]]['value'] = str(float(l[c])/total_moles) self.x_pclist[c].setText(mf[-1]) self.dict[i] = ",".join(mf) + elif (i == "Thermo Package"): + self.dict[i] = self.input_dict[i].currentText() else: if (self.input_dict[i].text()): self.dict[i] = self.input_dict[i].text() else: - print(self.input_dict[i].text()) + print(self.input_dict[i]) self.show_error() break - + # print(self.input_dict[-1].currentText()) + # self.dict['Thermo Package'] = self.input_dict['Thermo Package'].currentText() + print("param ", self.dict) self.obj.param_setter(self.dict) self.hide() -- cgit From 62b3c9106e1a3cadb1c570818ca7f1a86dffd914 Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Wed, 5 Aug 2020 20:16:55 +0630 Subject: Added DockWidgetCompressorExpander --- DockWidgets/DockWidgetMaterialStream.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'DockWidgets/DockWidgetMaterialStream.py') diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index 915bea3..ee57902 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -36,9 +36,9 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.lTreeWidget.setHeaderItem(header) self.vTreeWidget.setHeaderItem(header) - self.mTreeWidget.itemClicked.connect(lambda : self.printer(self.mTreeWidget.currentItem())) - self.lTreeWidget.itemClicked.connect(lambda : self.printer(self.lTreeWidget.currentItem())) - self.vTreeWidget.itemClicked.connect(lambda : self.printer(self.vTreeWidget.currentItem())) + # self.mTreeWidget.itemClicked.connect(lambda : self.printer(self.mTreeWidget.currentItem())) + # self.lTreeWidget.itemClicked.connect(lambda : self.printer(self.lTreeWidget.currentItem())) + # self.vTreeWidget.itemClicked.connect(lambda : self.printer(self.vTreeWidget.currentItem())) # input data tab def modes(self): -- cgit From 37a360da5346302eb881071f7db2fe7159f8e643 Mon Sep 17 00:00:00 2001 From: lucaszhao19 Date: Wed, 5 Aug 2020 21:07:37 +0630 Subject: Remove unnecessary codes from all dock widgets --- DockWidgets/DockWidgetMaterialStream.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) (limited to 'DockWidgets/DockWidgetMaterialStream.py') diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py index ee57902..a661362 100644 --- a/DockWidgets/DockWidgetMaterialStream.py +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -2,10 +2,7 @@ from PyQt5.QtCore import * from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.uic import loadUiType -import pandas as pd -from functools import partial from ComponentSelector import * -from collections import defaultdict from Graphics import * ui_dialog,_ = loadUiType('DockWidgets/DockWidgetMaterialStream.ui') @@ -24,9 +21,8 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.modes() self.comboBox.currentIndexChanged.connect(self.mode_selection) - print("constructor ", self.input_dict) self.pushButton_2.clicked.connect(self.param) - self.dict = {} + self.dict = {} # a dictionary self.name_type = None self.container = container @@ -36,10 +32,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.lTreeWidget.setHeaderItem(header) self.vTreeWidget.setHeaderItem(header) - # self.mTreeWidget.itemClicked.connect(lambda : self.printer(self.mTreeWidget.currentItem())) - # self.lTreeWidget.itemClicked.connect(lambda : self.printer(self.lTreeWidget.currentItem())) - # self.vTreeWidget.itemClicked.connect(lambda : self.printer(self.vTreeWidget.currentItem())) - # input data tab def modes(self): modes_list = self.obj.modes_list @@ -60,9 +52,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.input_params_list() def input_params_list(self): - try: - print("input_params_list ", self.input_dict) - + try: for c,i in enumerate(self.input_dict): if(i=="x_pc"): noc = len(compound_selected) @@ -113,7 +103,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): def param(self): try: self.dict={} - print("param.input_dict ", self.input_dict) for i in self.input_dict: print(i) @@ -142,8 +131,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): print(self.input_dict[i]) self.show_error() break - # print(self.input_dict[-1].currentText()) - # self.dict['Thermo Package'] = self.input_dict['Thermo Package'].currentText() print("param ", self.dict) self.obj.param_setter(self.dict) @@ -152,14 +139,10 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): except Exception as e: print(e) - @staticmethod def show_result(lst): - #DockWidget1.flag = True for i in lst: i.results_category(i.name) - #i.show() - def clear_results(self): self.mTreeWidget.clear() @@ -243,7 +226,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): child = QTreeWidgetItem(vroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) t += 1 flag = False - #print(obj.variables) # Phase Properties Tab phaseResLst = [] @@ -295,7 +277,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog): self.vTableWidget.setItem(vrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) self.vTableWidget.resizeColumnsToContents() if not '[' in val: - #print(p[val.split('.')[1]]) print(obj.variables[val.split('.')[1]]['name']) mrowPosition = self.mTableWidget.rowCount() self.mTableWidget.insertRow(mrowPosition) -- cgit