diff options
Diffstat (limited to 'DockWidgets')
33 files changed, 3452 insertions, 0 deletions
diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py new file mode 100644 index 0000000..6fc7731 --- /dev/null +++ b/DockWidgets/DockWidget.py @@ -0,0 +1,220 @@ +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/DockWidget.ui') + +class DockWidget(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container, parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = {} + self.x_pclist = [] + self.modes() + self.comboBox.currentIndexChanged.connect(self.mode_selection) + + print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + self.dict = {} + + self.name_type = None + self.container = container + + # input data tab + def modes(self): + modes_list = self.obj.modes_list + if(modes_list): + for j in modes_list: + self.comboBox.addItem(str(self.obj.variables[j]['name'])) + self.mode_selection() + else: + self.comboBox.setDisabled(True) + self.input_dict= {} + self.input_dict = self.obj.param_getter() + self.input_params_list() + + def mode_selection(self): + self.input_dict= {} + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + print(self.comboBox.currentText()) + for i in self.obj.variables: + if self.obj.variables[i]['name'] == self.comboBox.currentText(): + currentText = i + break + self.input_dict = self.obj.param_getter(currentText) + print('mode selection ', self.input_dict) + self.input_params_list() + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + for c,i in enumerate(self.input_dict): + if i == None: + continue + 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)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(i+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, alignment = Qt.AlignCenter) + self.formLayout.addRow(lay) + self.input_dict[i] = combo + print("thermo") + elif(i=="Ctype"): + combo = QComboBox() + self.lines = ["Total","Partial"] + for j in self.lines: + combo.addItem(str(j)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel("Condensor Type :"), 0, 0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, 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("Compounds") + lay = QGridLayout() + for j in range(noc): + l = QLineEdit() + 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) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),j,2, alignment=Qt.AlignCenter) + self.x_pclist.append(l) + gp.setLayout(lay) + self.formLayout.addRow(gp) + else: + print("elseloop") + print(i) + if i == None: + continue + l = QLineEdit() + if self.input_dict[i] != None: + l.setText(str(self.input_dict[i])) + print('before lay') + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) #self.obj.variables[i]['name'] + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + print('after lay') + if(i != 'MolFlow'): + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + else: + lay.addWidget(QLabel('mol/s'),0,2, alignment=Qt.AlignCenter) + print('after all') + self.formLayout.addRow(lay) + 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 param(self): + try: + self.dict={} + print("param.input_dict ", self.input_dict) + for i in self.input_dict: + if (self.input_dict[i] == None): + continue + 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=="Ctype"): + 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 = [] + total_moles = 0 + for mol_frac in self.x_pclist: + if (mol_frac.text()): + l.append(mol_frac.text()) + total_moles += float(l[-1]) + else: + self.show_error() + break + for c in range(len(compound_selected)): + mf.append(str(float(l[c])/total_moles)) + self.x_pclist[c].setText(mf[-1]) + self.dict[i] = ",".join(mf) + elif(i == 'Pout' and self.obj.type == 'Mixer' or i == '' or i == 'HKey' or i == 'LKey'): + self.dict[i] = self.input_dict[i].currentText() + else: + print(self.input_dict[i], i, self.obj.type) + if (self.input_dict[i].text()): + self.dict[i] = self.input_dict[i].text() + else: + print(self.input_dict[i].text()) + self.show_error() + break + + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + 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() + + # result data tab + def results_category(self,name): + flag = True + try: + print("Under result category name ", name) + result=self.container.result + obj = self.container.fetch_object(name) + self.tableWidget.setRowCount(0) + variKeys = list(obj.variables.keys()) + print(variKeys) + for i, val in enumerate(variKeys): + propertyname = name + '.' + val + print(i,val, propertyname) + if propertyname in result[0]: + ind = result[0].index(propertyname) + resultval = str(result[-1][ind]) + print("######Resultsfetch####",val,resultval) + rowPosition = self.tableWidget.rowCount() + self.tableWidget.insertRow(rowPosition) + self.tableWidget.setItem(rowPosition , 0, QTableWidgetItem(obj.variables[val]['name'])) + self.tableWidget.setItem(rowPosition , 1, QTableWidgetItem(resultval)) + self.tableWidget.setItem(rowPosition , 2, QTableWidgetItem(obj.variables[val]['unit'])) + self.tableWidget.resizeColumnsToContents() + + except Exception as e: + print(e)
\ No newline at end of file diff --git a/DockWidgets/DockWidget.txt b/DockWidgets/DockWidget.txt new file mode 100644 index 0000000..b14eef8 --- /dev/null +++ b/DockWidgets/DockWidget.txt @@ -0,0 +1,636 @@ +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 component_selector import * +from collections import defaultdict +from Graphics import * + +ui_dialog,_ = loadUiType('DockWidget.ui') + +class DockWidget(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.inputdict = {} + self.x_pclist = [] + self.modes() + self.comboBox.currentIndexChanged.connect(self.modeSelection) + + print("constructor ", self.inputdict) + self.pushButton_2.clicked.connect(self.param) + self.dict = {} + + self.nameType = None + self.container = container + + header = QTreeWidgetItem(['Compound','Value','Unit']) + self.mTreeWidget.setHeaderItem(header) + 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())) + + 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): + modesList = self.obj.modesList + if(modesList): + for j in modesList: + self.comboBox.addItem(str(self.obj.variables[j]['name'])) + self.modeSelection() + else: + self.comboBox.setDisabled(True) + self.inputdict= {} + self.inputdict = self.obj.paramgetter() + self.inputparamslist() + + def modeSelection(self): + self.inputdict= {} + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + print(self.comboBox.currentText()) + for i in self.obj.variables: + if self.obj.variables[i]['name'] == self.comboBox.currentText(): + currentText = i + break + self.inputdict = self.obj.paramgetter(currentText) + print('mode selection ', self.inputdict) + self.inputparamslist() + + def inputparamslist(self): + try: + print("inputparamslist ", self.inputdict) + for c,i in enumerate(self.inputdict): + if i == None: + continue + if(i=="thermoPackage"): + 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)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(i+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, alignment = Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + print("thermo") + elif(i=="Ctype"): + combo = QComboBox() + self.lines = ["Total","Partial"] + for j in self.lines: + combo.addItem(str(j)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel("Condensor Type :"), 0, 0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, alignment = Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + elif(i=="x_pc"): + noc = len(compound_selected) + print(noc) + self.x_pclist.clear() + gp = QGroupBox("Compounds") + lay = QGridLayout() + for j in range(noc): + l = QLineEdit() + self.inputdict[i] = "x_pc" + lay.addWidget(QLabel(str(compound_selected[j])+":"),j,0, alignment=Qt.AlignLeft) + lay.addWidget(l,j,1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),j,2, alignment=Qt.AlignCenter) + self.x_pclist.append(l) + gp.setLayout(lay) + self.formLayout.addRow(gp) + elif (self.obj.type == 'Mixer' and i == 'Pout'): + combo = QComboBox() + print("Mixer combo") + for j in self.obj.Pout_modes: + combo.addItem(str(j)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + elif (self.obj.type == 'Splitter' and i == 'CalcType'): + combo = QComboBox() + print("Splitter combo") + for j in self.obj.CalcType_modes: + combo.addItem(str(j)) + combo.setMinimumContentsLength(15) + stream1 = QLineEdit() + stream2 = QLineEdit() + unit = QLabel('') + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + + lay.addWidget(QLabel("Stream 1 : "), 1,0, alignment = Qt.AlignLeft) + lay.addWidget(stream1, 1,1, alignment = Qt.AlignCenter) + lay.addWidget(unit, 1,2, alignment = Qt.AlignRight) + + lay.addWidget(QLabel("Stream 2 : "), 2,0, alignment = Qt.AlignLeft) + lay.addWidget(stream2, 2,1, alignment = Qt.AlignCenter) + lay.addWidget(unit, 2,2, alignment = Qt.AlignRight) + self.formLayout.addRow(lay) + print("daf ", self.formLayout) + #combo.currentIndexChanged.connect(lambda:self.SplitterStreams(combo, lay, unit)) + lst = [combo, stream1, stream2] + #lst = [combo.currentText(), stream1.text(), stream2.text()] + self.inputdict[i] = lst + # self.inputdict[i] = stream1 + # self.inputdict[i] = stream2 + print(self.inputdict[i]) + elif i == 'HKey' or i == 'LKey': + combo = QComboBox() + print("ShortcutColumn combo") + for j in self.obj.compounds: + combo.addItem(str(j)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + elif self.obj.type == 'CompoundSeparator' and i == 'SepStrm': + print(i) + rlay = QHBoxLayout() + r1 = QRadioButton('Stream 1') + r1.setChecked(True) + r2 = QRadioButton('Stream 2') + r2.setChecked(False) + rlay.addWidget(r1) + rlay.addWidget(r2) + self.formLayout.addRow(rlay) + + lst = [r1, r2] + + lay = QGridLayout() + for k,val in enumerate(self.obj.compounds): + combo = QComboBox() + print("CompoundSeparator combo") + for j in self.obj.SepFact_modes: + combo.addItem(str(j)) + l = QLineEdit() + lay.addWidget(QLabel(val+" :"), k,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, k, 1, alignment=Qt.AlignCenter) + lay.addWidget(l,k,2, alignment=Qt.AlignCenter) + lst.append(combo) + lst.append(l) + self.inputdict[i] = lst + self.formLayout.addRow(lay) + elif self.obj.type == 'Flash' and i == 'Bdef': + print(i) + # rlay = QHBoxLayout() + r1 = QCheckBox() + r1.setChecked(False) + r2 = QCheckBox() + r2.setChecked(False) + # rlay.addWidget(r1) + # rlay.addWidget(r2) + # self.formLayout.addRow(rlay) + + l1 = QLineEdit() + l1.setText(str(self.obj.variables['Tdef']['value'])) + l2 = QLineEdit() + l2.setText(str(self.obj.variables['Pdef']['value'])) + lay = QGridLayout() + lay.addWidget(r1, 0,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Tdef']['name']+":"), 0,1, alignment=Qt.AlignLeft) + lay.addWidget(l1, 0, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Tdef']['unit']),0,3, alignment=Qt.AlignRight) + l1.setDisabled(True) + + lay.addWidget(r2, 2,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Pdef']['name']+":"), 2,1, alignment=Qt.AlignLeft) + lay.addWidget(l2, 2, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Pdef']['unit']),2,3, alignment=Qt.AlignRight) + self.formLayout.addRow(lay) + l2.setDisabled(True) + r1.toggled.connect(lambda:l1.setDisabled(not r1.isChecked())) + r2.toggled.connect(lambda:l2.setDisabled(not r2.isChecked())) + + self.inputdict[i] = [r1, r2, l1, l2] + else: + print("elseloop") + print(i) + if i == None: + continue + l = QLineEdit() + if self.inputdict[i] != None: + l.setText(str(self.inputdict[i])) + print('before lay') + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) #self.obj.variables[i]['name'] + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + print('after lay') + if(i != 'MolFlow'): + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + else: + lay.addWidget(QLabel('mol/s'),0,2, alignment=Qt.AlignCenter) + print('after all') + self.formLayout.addRow(lay) + self.inputdict[i] = l + + + except Exception as e: + print(e) + + def Show_Error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict={} + print("param.inputdict ", self.inputdict) + for i in self.inputdict: + if (self.inputdict[i] == None): + continue + + if(i=="thermoPackage"): + if (self.inputdict[i].currentText()): + self.dict[i] = self.inputdict[i].currentText() + else: + self.Show_Error() + break + elif(i=="Ctype"): + if (self.inputdict[i].currentText()): + self.dict[i] = self.inputdict[i].currentText() + else: + self.Show_Error() + break + elif(i =="x_pc"): + l=[] + mf = [] + total_moles = 0 + for mol_frac in self.x_pclist: + if (mol_frac.text()): + l.append(mol_frac.text()) + total_moles += float(l[-1]) + else: + self.Show_Error() + break + for c in range(len(compound_selected)): + mf.append(str(float(l[c])/total_moles)) + self.x_pclist[c].setText(mf[-1]) + self.dict[i] = ",".join(mf) + elif(i == 'Pout' and self.obj.type == 'Mixer' or i == '' or i == 'HKey' or i == 'LKey'): + self.dict[i] = self.inputdict[i].currentText() + elif i == 'CalcType' and self.obj.type == 'Splitter': + self.dict[i] = [self.inputdict[i][0].currentText(), self.inputdict[i][1].text(), self.inputdict[i][2].text()] + elif self.obj.type == 'Flash' and i == 'Bdef': + self.dict[i] = [self.inputdict[i][0].isChecked(), self.inputdict[i][1].isChecked(), self.inputdict[i][2].text(), self.inputdict[i][3].text()] + elif self.obj.type == 'CompoundSeparator': + self.dict[i] = [self.inputdict[i][0].isChecked(),self.inputdict[i][1].isChecked()] + j = 2 + for comp in self.obj.compounds: + self.dict[i].append(self.inputdict[i][j].currentText()) + self.dict[i].append(self.inputdict[i][j+1].text()) + j += 2 + else: + print(self.inputdict[i], i, self.obj.type) + if (self.inputdict[i].text()): + self.dict[i] = self.inputdict[i].text() + else: + print(self.inputdict[i].text()) + self.Show_Error() + break + + print("param ", self.dict) + self.obj.paramsetter(self.dict) + self.hide() + + except Exception as e: + print(e) + + + @staticmethod + def showResult(lst): + #DockWidget1.flag = True + for i in lst: + i.resultsCategory(i.name) + #i.show() + + # result data tab + def resultsCategory(self,name): + flag = True + try: + print("Under result category name ", name) + result=self.container.result + obj = self.container.fetchObject(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()) + + p = {"Pressure":"P", "Temperature":"T","Vapour Phase Mole Fraction":"xvap", "Phase Molar Enthalpy":"H_p", + "Phase Molar Entropy":"S_p", "Molar Flow Rate":"F_p"} + + # Amounts Tab + if obj.type == 'MaterialStream': + l = [] # 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) + + j = 0 + t = 0 + namee = klst[j] + print("namee ", namee) + + for i,k in enumerate(l): + ind = result[0].index(k) + print("index ", ind) + print("str ", k) + resultval = str(result[-1][ind]) + print("######Resultsfetch####",resultval) + print(k[k.find(".")+1:k.find("[")]) + obj.variables[k.split('.')[1]]['value'] = resultval + if namee in k: + if i%3 == 0: + if(flag): + mroot = QTreeWidgetItem(self.mTreeWidget, [lst[j]]) + child = QTreeWidgetItem(mroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 1: + if(flag): + lroot = QTreeWidgetItem(self.lTreeWidget, [lst[j]]) + child = QTreeWidgetItem(lroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 2: + if (flag): + vroot = QTreeWidgetItem(self.vTreeWidget, [lst[j]]) + child = QTreeWidgetItem(vroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + t += 1 + flag = False + else: + j += 1 + t = 0 + namee = klst[j] + flag = True + if i%3 == 0: + if (flag): + mroot = QTreeWidgetItem(self.mTreeWidget, [lst[j]]) + child = QTreeWidgetItem(mroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 1: + if (flag): + lroot = QTreeWidgetItem(self.lTreeWidget, [lst[j]]) + child = QTreeWidgetItem(lroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 2: + if (flag): + vroot = QTreeWidgetItem(self.vTreeWidget, [lst[j]]) + 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 = [] + for phase in p: + propertyname = name + '.' + p[phase] + print("phase ", phase, propertyname) + for i in result[0]: + if i.find('['): + if (propertyname == i[0:i.find('[')]): + phaseResLst.append(i) + if propertyname == i: + phaseResLst.append(i) + print(phaseResLst) + + self.mTableWidget.setRowCount(0) + self.lTableWidget.setRowCount(0) + self.vTableWidget.setRowCount(0) + + for i,val in enumerate(phaseResLst): + ind = result[0].index(val) + resultval = str(result[-1][ind]) + print(resultval, i, val) + obj.variables[val.split('.')[1]]['value'] = resultval + if '[' in val: + print(val) + temp = val[val.find('.')+1:val.find('[')] + print(temp) + if '1' in val.split('.')[1]: + print(obj.variables[val.split('.')[1]]['name']) + mrowPosition = self.mTableWidget.rowCount() + self.mTableWidget.insertRow(mrowPosition) + self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.mTableWidget.resizeColumnsToContents() + + if '2' in val.split('.')[1]: + lrowPosition = self.lTableWidget.rowCount() + self.lTableWidget.insertRow(lrowPosition) + self.lTableWidget.setItem(lrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.lTableWidget.setItem(lrowPosition , 1, QTableWidgetItem(resultval)) + self.lTableWidget.setItem(lrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.lTableWidget.resizeColumnsToContents() + if '3' in val.split('.')[1]: + vrowPosition = self.vTableWidget.rowCount() + self.vTableWidget.insertRow(vrowPosition) + self.vTableWidget.setItem(vrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.vTableWidget.setItem(vrowPosition , 1, QTableWidgetItem(resultval)) + 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) + self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.mTableWidget.resizeColumnsToContents() + + print(obj.variables) + + except Exception as e: + print(e) + + +class DockWidgetFlash(DockWidget): + + def __init__(self,name,comptype,obj,container,parent=None): + DockWidget.__init__(self,name,comptype,obj,container,parent=None) + + def inputparamslist(self): + try: + print("inputparamslist ", self.inputdict) + for c,i in enumerate(self.inputdict): + if i == None: + continue + if(i=="thermoPackage"): + 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)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(i+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, alignment = Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + print("thermo") + elif self.obj.type == 'Flash' and i == 'Bdef': + print(i) + r1 = QCheckBox() + r1.setChecked(False) + r2 = QCheckBox() + r2.setChecked(False) + + l1 = QLineEdit() + l1.setText(str(self.obj.variables['Tdef']['value'])) + l2 = QLineEdit() + l2.setText(str(self.obj.variables['Pdef']['value'])) + lay = QGridLayout() + lay.addWidget(r1, 0,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Tdef']['name']+":"), 0,1, alignment=Qt.AlignLeft) + lay.addWidget(l1, 0, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Tdef']['unit']),0,3, alignment=Qt.AlignRight) + l1.setDisabled(True) + + lay.addWidget(r2, 2,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Pdef']['name']+":"), 2,1, alignment=Qt.AlignLeft) + lay.addWidget(l2, 2, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Pdef']['unit']),2,3, alignment=Qt.AlignRight) + self.formLayout.addRow(lay) + l2.setDisabled(True) + r1.toggled.connect(lambda:l1.setDisabled(not r1.isChecked())) + r2.toggled.connect(lambda:l2.setDisabled(not r2.isChecked())) + + self.inputdict[i] = [r1, r2, l1, l2] + except Exception as e: + print(e) + + def param(self): + try: + self.dict={} + print("param.inputdict ", self.inputdict) + for i in self.inputdict: + if (self.inputdict[i] == None): + continue + + if(i=="thermoPackage"): + if (self.inputdict[i].currentText()): + self.dict[i] = self.inputdict[i].currentText() + else: + self.Show_Error() + break + elif self.obj.type == 'Flash' and i == 'Bdef': + self.dict[i] = [self.inputdict[i][0].isChecked(), self.inputdict[i][1].isChecked(), self.inputdict[i][2].text(), self.inputdict[i][3].text()] + + print("param ", self.dict) + self.obj.paramsetter(self.dict) + self.hide() + + except Exception as e: + print(e) + +class DockWidgetFlash(DockWidget): + + def __init__(self,name,comptype,obj,container,parent=None): + DockWidget.__init__(self,name,comptype,obj,container,parent=None) + + def inputparamslist(self): + try: + print("inputparamslist ", self.inputdict) + for c,i in enumerate(self.inputdict): + if i == None: + continue + if(i=="thermoPackage"): + 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)) + combo.setMinimumContentsLength(15) + lay = QGridLayout() + lay.addWidget(QLabel(i+":"), 0,0, alignment=Qt.AlignLeft) + lay.addWidget(combo, 0, 1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(''), 0, 2, alignment = Qt.AlignCenter) + self.formLayout.addRow(lay) + self.inputdict[i] = combo + print("thermo") + elif self.obj.type == 'Flash' and i == 'Bdef': + print(i) + r1 = QCheckBox() + r1.setChecked(False) + r2 = QCheckBox() + r2.setChecked(False) + + l1 = QLineEdit() + l1.setText(str(self.obj.variables['Tdef']['value'])) + l2 = QLineEdit() + l2.setText(str(self.obj.variables['Pdef']['value'])) + lay = QGridLayout() + lay.addWidget(r1, 0,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Tdef']['name']+":"), 0,1, alignment=Qt.AlignLeft) + lay.addWidget(l1, 0, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Tdef']['unit']),0,3, alignment=Qt.AlignRight) + l1.setDisabled(True) + + lay.addWidget(r2, 2,0, alignment = Qt.AlignLeft) + lay.addWidget(QLabel(self.obj.variables['Pdef']['name']+":"), 2,1, alignment=Qt.AlignLeft) + lay.addWidget(l2, 2, 2, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables['Pdef']['unit']),2,3, alignment=Qt.AlignRight) + self.formLayout.addRow(lay) + l2.setDisabled(True) + r1.toggled.connect(lambda:l1.setDisabled(not r1.isChecked())) + r2.toggled.connect(lambda:l2.setDisabled(not r2.isChecked())) + + self.inputdict[i] = [r1, r2, l1, l2] + except Exception as e: + print(e) + + def param(self): + try: + self.dict={} + print("param.inputdict ", self.inputdict) + for i in self.inputdict: + if (self.inputdict[i] == None): + continue + + if(i=="thermoPackage"): + if (self.inputdict[i].currentText()): + self.dict[i] = self.inputdict[i].currentText() + else: + self.Show_Error() + break + elif self.obj.type == 'Flash' and i == 'Bdef': + self.dict[i] = [self.inputdict[i][0].isChecked(), self.inputdict[i][1].isChecked(), self.inputdict[i][2].text(), self.inputdict[i][3].text()] + + print("param ", self.dict) + self.obj.paramsetter(self.dict) + self.hide() + + except Exception as e: + print(e)
\ No newline at end of file diff --git a/DockWidgets/DockWidget.ui b/DockWidgets/DockWidget.ui new file mode 100644 index 0000000..5851d71 --- /dev/null +++ b/DockWidgets/DockWidget.ui @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>30</y> + <width>361</width> + <height>621</height> + </rect> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Input Data</string> + </attribute> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>9</x> + <y>9</y> + <width>331</width> + <height>71</height> + </rect> + </property> + <property name="title"> + <string>Mode Selection</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Mode : </string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>100</y> + <width>331</width> + <height>321</height> + </rect> + </property> + <property name="title"> + <string>Parameter Selection</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"/> + </item> + </layout> + </widget> + <widget class="QPushButton" name="pushButton_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>430</y> + <width>331</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Results</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QTableWidget" name="tableWidget"> + <property name="columnCount"> + <number>3</number> + </property> + <attribute name="horizontalHeaderDefaultSectionSize"> + <number>110</number> + </attribute> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <column> + <property name="text"> + <string>Attribute</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string>Unit</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetCompoundSeparator.py b/DockWidgets/DockWidgetCompoundSeparator.py new file mode 100644 index 0000000..1818290 --- /dev/null +++ b/DockWidgets/DockWidgetCompoundSeparator.py @@ -0,0 +1,99 @@ +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/DockWidgetCompoundSeparator.ui') + +class DockWidgetCompoundSeparator(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + + print("constructor ", self.input_dict) + self.input_params_list() + self.dict = [] + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + if self.type == 'CompoundSeparator': + + # self.gridLayout = QGridLayout() + calculationGroupBox = QGroupBox('Calculation Parameters') + + calculationLayout = QGridLayout() + + r1 = QRadioButton('Stream 1') + r1.setChecked(True) + r1.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + r2 = QRadioButton('Stream 2') + r2.setChecked(False) + r2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + + lst = [r1, r2] + calculationLayout.addWidget(r1, 0, 1) + calculationLayout.addWidget(r2, 0, 2) + + for k,val in enumerate(self.obj.compounds): + combo = QComboBox() + print("CompoundSeparator combo") + for j in self.obj.SepFact_modes: + combo.addItem(str(j)) + combo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + l = QLineEdit() + l.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + calculationLayout.addWidget(QLabel(val+" :"), k+1,0, alignment=Qt.AlignLeft) + calculationLayout.addWidget(combo, k+1, 1, alignment=Qt.AlignCenter) + calculationLayout.addWidget(l,k+1,2, alignment=Qt.AlignCenter) + lst.append(combo) + lst.append(l) + + calculationLayout.setColumnStretch(3, len(self.obj.compounds)+1) + calculationGroupBox.setLayout(calculationLayout) + + btn = QPushButton('Submit') + btn.clicked.connect(self.param) + + self.gridLayout.setVerticalSpacing(5) + self.gridLayout.addWidget(calculationGroupBox,0,0) + self.gridLayout.addWidget(btn,1,0) + + self.input_dict = lst + + except Exception as e: + print(e) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict=[] + print("param.input_dict ", self.input_dict) + + self.dict = [self.input_dict[0].isChecked(), self.input_dict[1].isChecked()] + j = 2 + for i in range(len(self.obj.compounds)): + print(j+i) + self.dict.append(self.input_dict[j+i].currentText()) + self.dict.append(self.input_dict[j+i+1].text()) + j += 1 + + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e) diff --git a/DockWidgets/DockWidgetCompoundSeparator.ui b/DockWidgets/DockWidgetCompoundSeparator.ui new file mode 100644 index 0000000..2d9a4b2 --- /dev/null +++ b/DockWidgets/DockWidgetCompoundSeparator.ui @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>form</class> + <widget class="QWidget" name="form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QWidget" name="gridLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>331</width> + <height>191</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"/> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetDistillationColumn.py b/DockWidgets/DockWidgetDistillationColumn.py new file mode 100644 index 0000000..65e9932 --- /dev/null +++ b/DockWidgets/DockWidgetDistillationColumn.py @@ -0,0 +1,120 @@ +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/DockWidgetDistillationColumn.ui') + +class DockWidgetDistillationColumn(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + self.dict = [] + self.input_params_list() + self.name_type = None + self.container = container + + # input data tab + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + # tab 1 + self.l1.setText(self.obj.variables['Nt']['name']+":") + self.le1.setText(str(self.obj.variables['Nt']['value'])) + self.l2.setText(self.obj.variables['In_s']['name']+":") + self.l3.setText(self.obj.variables['InT_s']['name']+":") + + # tab 2 + self.l4.setText(self.obj.variables['Ctype']['name']+":") + self.u1.setText(self.obj.variables['Ctype']['unit']) + self.l5.setText(self.obj.variables['Pcond']['name']+":") + self.le5.setText(str(self.obj.variables['Pcond']['value'])) + self.u2.setText(self.obj.variables['Pcond']['unit']) + self.l6.setText(self.obj.variables['C_Spec']['name']+":") + self.l7.setText("Compounds :") + + self.cb5.addItem("Total") + self.cb5.addItem("Partial") + for j in self.obj.Cspec_list: + self.cb1.addItem(str(j)) + for j in self.obj.compounds: + self.cb2.addItem(str(j)) + self.cb2.setDisabled(True) + self.cb1.currentIndexChanged.connect(self.fun2) + + + # tab3 + self.l8.setText(self.obj.variables['Preb']['name']+":") + self.le7.setText(str(self.obj.variables['Preb']['value'])) + self.u3.setText(self.obj.variables['Preb']['unit']) + self.l9.setText(self.obj.variables['R_Spec']['name']+":") + self.l10.setText('Compounds') + + for j in self.obj.Rspec_list: + self.cb3.addItem(str(j)) + for j in self.obj.compounds: + self.cb4.addItem(str(j)) + self.cb4.setDisabled(True) + self.cb3.currentIndexChanged.connect(self.fun3) + + self.input_dict = [self.le1, self.le2, self.le3, self.cb5, self.le5, self.cb1, self.cb2, self.le6, self.le7, self.cb3, self.cb4, self.le8] + + except Exception as e: + print(e) + + def fun2(self): + if self.cb1.currentText() == 'Compound Molar Fraction' or self.cb1.currentText() == 'Compound Molar Flow (mol/s)': + self.cb2.setDisabled(False) + else: + self.cb2.setDisabled(True) + + def fun3(self): + if self.cb3.currentText() == 'Compound Molar Fraction' or self.cb3.currentText() == 'Compound Molar Flow (mol/s)': + self.cb4.setDisabled(False) + else: + self.cb4.setDisabled(True) + + def Show_Error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict= [] + print("param.input_dict ", self.input_dict) + self.dict = [self.input_dict[0].text(),self.input_dict[1].text(), self.input_dict[2].text(), self.input_dict[3].currentText(), + self.input_dict[4].text(), self.input_dict[5].currentText(), self.input_dict[6].currentText(), self.input_dict[7].text(), + self.input_dict[8].text(), self.input_dict[9].currentText(), self.input_dict[10].currentText(), self.input_dict[11].text()] + + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e) + + + @staticmethod + def showResult(lst): + #DockWidget1.flag = True + for i in lst: + i.resultsCategory(i.name) + #i.show() + + # result data tab + def resultsCategory(self,name): + pass
\ No newline at end of file diff --git a/DockWidgets/DockWidgetDistillationColumn.ui b/DockWidgets/DockWidgetDistillationColumn.ui new file mode 100644 index 0000000..0cb1043 --- /dev/null +++ b/DockWidgets/DockWidgetDistillationColumn.ui @@ -0,0 +1,270 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>30</y> + <width>361</width> + <height>621</height> + </rect> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Input Data</string> + </attribute> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>331</width> + <height>204</height> + </rect> + </property> + <property name="title"> + <string>Parameter Selection</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <widget class="QTabWidget" name="tabWidget_5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab1"> + <attribute name="title"> + <string>General</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <item> + <layout class="QGridLayout" name="lay1"> + <item row="1" column="0"> + <widget class="QLabel" name="l2"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="le1"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l1"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="le2"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="l3"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="le3"/> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab2"> + <attribute name="title"> + <string>Condensor</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <layout class="QGridLayout" name="lay2"> + <item row="3" column="0"> + <widget class="QLabel" name="l7"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l4"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="l5"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QComboBox" name="cb1"/> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="le5"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="l6"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QComboBox" name="cb2"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="u1"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="u2"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="4" column="2"> + <widget class="QLineEdit" name="le6"/> + </item> + <item row="0" column="2"> + <widget class="QComboBox" name="cb5"/> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab3"> + <attribute name="title"> + <string>Reboiler</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <item> + <layout class="QGridLayout" name="lay3"> + <item row="4" column="0"> + <widget class="QLabel" name="l9"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="l8"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="l10"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QComboBox" name="cb4"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="le7"/> + </item> + <item row="4" column="2"> + <widget class="QComboBox" name="cb3"/> + </item> + <item row="6" column="2"> + <widget class="QLineEdit" name="le8"/> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="u3"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QPushButton" name="pushButton_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>220</y> + <width>331</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Results</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3"/> + </widget> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetFlash.py b/DockWidgets/DockWidgetFlash.py new file mode 100644 index 0000000..6098b27 --- /dev/null +++ b/DockWidgets/DockWidgetFlash.py @@ -0,0 +1,74 @@ +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/DockWidgetFlash.ui') + +class DockWidgetFlash(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + print("constructor ", self.input_dict) + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = [] + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + self.l1.setText(self.obj.variables['thermoPackage']['name']+":") + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cb1.addItem(str(j)) + + self.check1.setText(self.obj.variables['Tdef']['name']+":") + self.le2.setText(str(self.obj.variables['Tdef']['value'])) + self.u2.setText(self.obj.variables['Tdef']['unit']) + self.check1.toggled.connect(self.fun) + self.check2.setText(self.obj.variables['Pdef']['name']+":") + self.le3.setText(str(self.obj.variables['Pdef']['value'])) + self.u3.setText(self.obj.variables['Pdef']['unit']) + self.check2.toggled.connect(self.fun) + + self.input_dict = [self.cb1, self.check1, self.le2, self.check2, self.le3] + + except Exception as e: + print(e) + + def fun(self): + if self.check1.isChecked(): + self.le2.setDisabled(False) + else: + self.le2.setDisabled(True) + if self.check2.isChecked(): + self.le3.setDisabled(False) + else: + self.le3.setDisabled(True) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict={} + print("param.input_dict ", self.input_dict) + self.dict = [self.input_dict[0].currentText(),self.input_dict[1].isChecked(), float(self.input_dict[2].text()), self.input_dict[3].isChecked(), float(self.input_dict[4].text())] + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetFlash.ui b/DockWidgets/DockWidgetFlash.ui new file mode 100644 index 0000000..c781aa6 --- /dev/null +++ b/DockWidgets/DockWidgetFlash.ui @@ -0,0 +1,161 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>341</width> + <height>141</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="styleSheet"> + <string notr="true">Q</string> + </property> + <property name="title"> + <string>Calculation Parameters</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="2" column="2"> + <widget class="QLineEdit" name="le3"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QLabel" name="u3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="le2"> + <property name="enabled"> + <bool>false</bool> + </property> + </widget> + </item> + <item row="1" column="3"> + <widget class="QLabel" name="u2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l1"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="check2"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QComboBox" name="cb1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="check1"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QPushButton" name="btn"> + <property name="geometry"> + <rect> + <x>10</x> + <y>190</y> + <width>341</width> + <height>23</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py new file mode 100644 index 0000000..78959fc --- /dev/null +++ b/DockWidgets/DockWidgetMaterialStream.py @@ -0,0 +1,332 @@ +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') + +class DockWidgetMaterialStream(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = {} + self.x_pclist = [] + self.modes() + self.comboBox.currentIndexChanged.connect(self.mode_selection) + + print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + self.dict = {} + + self.name_type = None + self.container = container + + header = QTreeWidgetItem(['Compound','Value','Unit']) + self.mTreeWidget.setHeaderItem(header) + 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())) + + + # 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 + if(modes_list): + for j in modes_list: + self.comboBox.addItem(str(j)) + self.mode_selection() + else: + self.input_dict= {} + self.input_dict = self.obj.param_getter() + self.input_params_list() + + def mode_selection(self): + self.input_dict= {} + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + self.input_dict = self.obj.param_getter(self.comboBox.currentText()) + self.input_params_list() + + 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") + 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=="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'])) + 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) + + gp.setLayout(lay) + 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) + if(i != 'MolFlow'): + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + else: + lay.addWidget(QLabel("mol/s"),0,2, alignment=Qt.AlignCenter) + self.formLayout.addRow(lay) + 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 param(self): + try: + self.dict={} + + 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=="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 = [] + total_moles = 0 + for mol_frac in self.x_pclist: + if (mol_frac.text()): + l.append(mol_frac.text()) + total_moles += float(l[-1]) + else: + self.show_error() + break + for c in range(len(compound_selected)): + mf.append(str(float(l[c])/total_moles)) + 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) + else: + if (self.input_dict[i].text()): + self.dict[i] = self.input_dict[i].text() + else: + print(self.input_dict[i].text()) + self.show_error() + break + + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + 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() + + # result data tab + def results_category(self,name): + flag = True + try: + print("Under result category name ", name) + 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()) + + p = {"Pressure":"P", "Temperature":"T","Vapour Phase Mole Fraction":"xvap", "Phase Molar Enthalpy":"H_p", + "Phase Molar Entropy":"S_p", "Molar Flow Rate":"F_p"} + + # Amounts Tab + if obj.type == 'MaterialStream': + l = [] # 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) + + j = 0 + t = 0 + namee = klst[j] + print("namee ", namee) + + for i,k in enumerate(l): + ind = result[0].index(k) + print("index ", ind) + print("str ", k) + resultval = str(result[-1][ind]) + print("######Resultsfetch####",resultval) + print(k[k.find(".")+1:k.find("[")]) + obj.variables[k.split('.')[1]]['value'] = resultval + if namee in k: + if i%3 == 0: + if(flag): + mroot = QTreeWidgetItem(self.mTreeWidget, [lst[j]]) + child = QTreeWidgetItem(mroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 1: + if(flag): + lroot = QTreeWidgetItem(self.lTreeWidget, [lst[j]]) + child = QTreeWidgetItem(lroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 2: + if (flag): + vroot = QTreeWidgetItem(self.vTreeWidget, [lst[j]]) + child = QTreeWidgetItem(vroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + t += 1 + flag = False + else: + j += 1 + t = 0 + namee = klst[j] + flag = True + if i%3 == 0: + if (flag): + mroot = QTreeWidgetItem(self.mTreeWidget, [lst[j]]) + child = QTreeWidgetItem(mroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 1: + if (flag): + lroot = QTreeWidgetItem(self.lTreeWidget, [lst[j]]) + child = QTreeWidgetItem(lroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']]) + elif i%3 == 2: + if (flag): + vroot = QTreeWidgetItem(self.vTreeWidget, [lst[j]]) + 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 = [] + for phase in p: + propertyname = name + '.' + p[phase] + print("phase ", phase, propertyname) + for i in result[0]: + if i.find('['): + if (propertyname == i[0:i.find('[')]): + phaseResLst.append(i) + if propertyname == i: + phaseResLst.append(i) + print(phaseResLst) + + self.mTableWidget.setRowCount(0) + self.lTableWidget.setRowCount(0) + self.vTableWidget.setRowCount(0) + + for i,val in enumerate(phaseResLst): + ind = result[0].index(val) + resultval = str(result[-1][ind]) + print(resultval, i, val) + obj.variables[val.split('.')[1]]['value'] = resultval + if '[' in val: + print(val) + temp = val[val.find('.')+1:val.find('[')] + print(temp) + if '1' in val.split('.')[1]: + print(obj.variables[val.split('.')[1]]['name']) + mrowPosition = self.mTableWidget.rowCount() + self.mTableWidget.insertRow(mrowPosition) + self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.mTableWidget.resizeColumnsToContents() + + if '2' in val.split('.')[1]: + lrowPosition = self.lTableWidget.rowCount() + self.lTableWidget.insertRow(lrowPosition) + self.lTableWidget.setItem(lrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.lTableWidget.setItem(lrowPosition , 1, QTableWidgetItem(resultval)) + self.lTableWidget.setItem(lrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.lTableWidget.resizeColumnsToContents() + if '3' in val.split('.')[1]: + vrowPosition = self.vTableWidget.rowCount() + self.vTableWidget.insertRow(vrowPosition) + self.vTableWidget.setItem(vrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.vTableWidget.setItem(vrowPosition , 1, QTableWidgetItem(resultval)) + 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) + self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name'])) + self.mTableWidget.setItem(mrowPosition , 1, QTableWidgetItem(resultval)) + self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.mTableWidget.resizeColumnsToContents() + + print(obj.variables) + + except Exception as e: + print(e) + + +
\ No newline at end of file diff --git a/DockWidgets/DockWidgetMaterialStream.ui b/DockWidgets/DockWidgetMaterialStream.ui new file mode 100644 index 0000000..8995ba6 --- /dev/null +++ b/DockWidgets/DockWidgetMaterialStream.ui @@ -0,0 +1,458 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>30</y> + <width>361</width> + <height>621</height> + </rect> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Input Data</string> + </attribute> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>9</x> + <y>9</y> + <width>331</width> + <height>71</height> + </rect> + </property> + <property name="title"> + <string>Mode Selection</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Mode : </string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QGroupBox" name="groupBox_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>100</y> + <width>331</width> + <height>321</height> + </rect> + </property> + <property name="title"> + <string>Parameter Selection</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"/> + </item> + </layout> + </widget> + <widget class="QPushButton" name="pushButton_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>430</y> + <width>331</width> + <height>21</height> + </rect> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Results</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QToolBox" name="toolBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + <pointsize>8</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">QToolBox{ + background: white; + border: 1px solid gray; + selection-background-color: rgb(255, 170, 127); +} +</string> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="mixtureTB"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>335</width> + <height>494</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QWidget{ + background: white; +}</string> + </property> + <attribute name="label"> + <string>Mixture</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QTabWidget" name="tabWidget_2"> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="styleSheet"> + <string notr="true">QTabWidget{ + background: rgb(240, 240, 240); +}</string> + </property> + <property name="tabPosition"> + <enum>QTabWidget::North</enum> + </property> + <property name="tabShape"> + <enum>QTabWidget::Triangular</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="elideMode"> + <enum>Qt::ElideNone</enum> + </property> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>Amounts</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QTreeWidget" name="mTreeWidget"> + <attribute name="headerCascadingSectionResizes"> + <bool>false</bool> + </attribute> + <attribute name="headerDefaultSectionSize"> + <number>150</number> + </attribute> + <attribute name="headerShowSortIndicator" stdset="0"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_4"> + <attribute name="title"> + <string>Phase Properties</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QTableWidget" name="mTableWidget"> + <property name="columnCount"> + <number>3</number> + </property> + <attribute name="horizontalHeaderCascadingSectionResizes"> + <bool>false</bool> + </attribute> + <attribute name="horizontalHeaderDefaultSectionSize"> + <number>100</number> + </attribute> + <attribute name="horizontalHeaderShowSortIndicator" stdset="0"> + <bool>false</bool> + </attribute> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <attribute name="verticalHeaderStretchLastSection"> + <bool>false</bool> + </attribute> + <column> + <property name="text"> + <string>Attribute</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string>Unit</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="liquidTB"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>335</width> + <height>494</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QWidget{ + background: white; +}</string> + </property> + <attribute name="label"> + <string>Liquid</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QTabWidget" name="tabWidget_3"> + <property name="styleSheet"> + <string notr="true">QTabWidget{ + background: rgb(240, 240, 240); +}</string> + </property> + <property name="tabShape"> + <enum>QTabWidget::Triangular</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab_5"> + <attribute name="title"> + <string>Amounts</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QTreeWidget" name="lTreeWidget"> + <attribute name="headerDefaultSectionSize"> + <number>150</number> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_6"> + <attribute name="title"> + <string>Phase Properties</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <item> + <widget class="QTableWidget" name="lTableWidget"> + <property name="columnCount"> + <number>3</number> + </property> + <attribute name="horizontalHeaderDefaultSectionSize"> + <number>100</number> + </attribute> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <column> + <property name="text"> + <string>Attribute</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string>Unit</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="vapourTB"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>335</width> + <height>494</height> + </rect> + </property> + <property name="styleSheet"> + <string notr="true">QWidget{ + background: white; + +}</string> + </property> + <attribute name="label"> + <string>Vapour</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_7"> + <item> + <widget class="QTabWidget" name="tabWidget_4"> + <property name="styleSheet"> + <string notr="true">QTabWidget{ + background: rgb(240, 240, 240); +}</string> + </property> + <property name="tabShape"> + <enum>QTabWidget::Triangular</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab_7"> + <attribute name="title"> + <string>Amounts</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout_8"> + <item> + <widget class="QTreeWidget" name="vTreeWidget"> + <attribute name="headerDefaultSectionSize"> + <number>150</number> + </attribute> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_8"> + <attribute name="title"> + <string>Phase Properties</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QTableWidget" name="vTableWidget"> + <property name="columnCount"> + <number>3</number> + </property> + <attribute name="horizontalHeaderDefaultSectionSize"> + <number>100</number> + </attribute> + <attribute name="horizontalHeaderStretchLastSection"> + <bool>true</bool> + </attribute> + <column> + <property name="text"> + <string>Attribute</string> + </property> + </column> + <column> + <property name="text"> + <string>Value</string> + </property> + </column> + <column> + <property name="text"> + <string>Unit</string> + </property> + </column> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetMixer.py b/DockWidgets/DockWidgetMixer.py new file mode 100644 index 0000000..28cbff0 --- /dev/null +++ b/DockWidgets/DockWidgetMixer.py @@ -0,0 +1,61 @@ +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/DockWidgetMixer.ui') + +class DockWidgetMixer(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + self.x_pclist = [] + print("constructor ", self.input_dict) + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = {} + + # input data tab + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + self.l1.setText(self.obj.variables['NI']['name']+":") + self.le1.setText(str(self.obj.variables['NI']['value'])) + self.u1.setText(self.obj.variables['NI']['unit']) + for i in self.obj.Pout_modes: + self.cb2.addItem(str(i)) + + self.l2.setText(self.obj.variables['outPress']['name']+":") + + + self.input_dict = [self.le1, self.cb2] + + except Exception as e: + print(e) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict={} + print("param.input_dict ", self.input_dict) + self.dict = [int(self.input_dict[0].text()),self.input_dict[1].currentText()] + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e)
\ No newline at end of file diff --git a/DockWidgets/DockWidgetMixer.ui b/DockWidgets/DockWidgetMixer.ui new file mode 100644 index 0000000..e039490 --- /dev/null +++ b/DockWidgets/DockWidgetMixer.ui @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>341</width> + <height>101</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="title"> + <string>Calculation Parameters</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="3"> + <widget class="QLabel" name="u1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="cb2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="le1"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="l2"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QPushButton" name="btn"> + <property name="geometry"> + <rect> + <x>10</x> + <y>150</y> + <width>341</width> + <height>23</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetShortcutColumn.py b/DockWidgets/DockWidgetShortcutColumn.py new file mode 100644 index 0000000..af81441 --- /dev/null +++ b/DockWidgets/DockWidgetShortcutColumn.py @@ -0,0 +1,97 @@ +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/DockWidgetShortcutColumn.ui') + +class DockWidgetShortcutColumn(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + print("constructor ", self.input_dict) + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = [] + + self.name_type = None + self.container = container + + # input data tab + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + self.l1.setText(self.obj.variables['HKey']['name']+":") + print(self.obj.compounds) + for i in self.obj.compounds: + self.cb1.addItem(str(i)) + self.cb2.addItem(str(i)) + + self.l2.setText(self.obj.variables['LKey']['name']+":") + + self.l3.setText(self.obj.variables['HKey_x_pc']['name']+":") + self.le3.setText(str(self.obj.variables['HKey_x_pc']['value'])) + self.u3.setText(self.obj.variables['HKey_x_pc']['unit']) + self.l4.setText(self.obj.variables['LKey_x_pc']['name']+":") + self.u4.setText(self.obj.variables['LKey_x_pc']['unit']) + self.le4.setText(str(self.obj.variables['LKey_x_pc']['value'])) + + self.l5.setText(self.obj.variables['Ctype']['name']+":") + self.cb5.addItem('Total') + self.cb5.addItem('Partial') + + self.l6.setText(self.obj.variables['Pcond']['name']+":") + self.le6.setText(str(self.obj.variables['Pcond']['value'])) + self.u6.setText(self.obj.variables['Pcond']['unit']) + self.l7.setText(self.obj.variables['Preb']['name']+":") + self.u7.setText(self.obj.variables['Preb']['unit']) + self.le7.setText(str(self.obj.variables['Preb']['value'])) + + self.l8.setText(self.obj.variables['RR']['name']+":") + self.le8.setText(str(self.obj.variables['RR']['value'])) + + self.input_dict = [self.cb1, self.cb2, self.le3, self.le4, self.cb5, self.le6, self.le7, self.le8] + + except Exception as e: + print(e) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict=[] + print("param.input_dict ", self.input_dict) + self.dict = [self.input_dict[0].currentText(),self.input_dict[1].currentText(),float(self.input_dict[2].text()), float(self.input_dict[3].text()), + self.input_dict[4].currentText(), float(self.input_dict[5].text()), float(self.input_dict[6].text()), float(self.input_dict[7].text())] + + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e) + + + @staticmethod + def show_result(lst): + #DockWidget1.flag = True + for i in lst: + i.resultsCategory(i.name) + #i.show() + + # result data tab + def results_category(self,name): + pass
\ No newline at end of file diff --git a/DockWidgets/DockWidgetShortcutColumn.ui b/DockWidgets/DockWidgetShortcutColumn.ui new file mode 100644 index 0000000..c66e699 --- /dev/null +++ b/DockWidgets/DockWidgetShortcutColumn.ui @@ -0,0 +1,295 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QTabWidget" name="tabWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>351</width> + <height>321</height> + </rect> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Input Data</string> + </attribute> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>8</x> + <y>13</y> + <width>331</width> + <height>237</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Calculation Parameters</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="4" column="2"> + <widget class="QComboBox" name="cb5"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="l4"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="u4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QLabel" name="u3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="l3"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="le3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="l5"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="l6"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="l2"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="5" column="2"> + <widget class="QLineEdit" name="le6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="l7"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="6" column="3"> + <widget class="QLabel" name="u7"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="cb2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="le4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="5" column="3"> + <widget class="QLabel" name="u6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="6" column="2"> + <widget class="QLineEdit" name="le7"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="l8"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="7" column="2"> + <widget class="QLineEdit" name="le8"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QComboBox" name="cb1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QPushButton" name="btn"> + <property name="geometry"> + <rect> + <x>10</x> + <y>250</y> + <width>331</width> + <height>23</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <widget class="QWidget" name="tab_2"> + <attribute name="title"> + <string>Results</string> + </attribute> + </widget> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/DockWidgetSplitter.py b/DockWidgets/DockWidgetSplitter.py new file mode 100644 index 0000000..262bd45 --- /dev/null +++ b/DockWidgets/DockWidgetSplitter.py @@ -0,0 +1,78 @@ +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/DockWidgetSplitter.ui') + +class DockWidgetSplitter(QDockWidget,ui_dialog): + + def __init__(self,name,comptype,obj,container,parent=None): + QDockWidget.__init__(self,parent) + self.setupUi(self) + self.setWindowTitle(obj.name) + self.name=name + self.obj=obj + self.type = comptype + self.input_dict = [] + print("constructor ", self.input_dict) + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = {} + + # input data tab + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + self.l1.setText(self.obj.variables['NOO']['name']+":") + self.le1.setText(str(self.obj.variables['NOO']['value'])) + self.u1.setText(self.obj.variables['NOO']['unit']) + + for i in self.obj.CalcType_modes: + self.cb2.addItem(str(i)) + + self.l2.setText(self.obj.variables['CalcType']['name']+":") + + self.l3.setText("Stream 1 :") + self.u3.setText('') + self.l4.setText("Stream 2 :") + self.u4.setText('') + self.cb2.currentIndexChanged.connect(self.fun) + + + self.input_dict = [self.le1, self.cb2, self.le3, self.le4] + + except Exception as e: + print(e) + + def fun(self): + if self.cb2.currentText() == 'Mole Flow Specs': + self.u3.setText('mol/s') + self.u4.setText('mol/s') + elif self.cb2.currentText() == 'Mass Flow Specs': + self.u3.setText('kg/s') + self.u4.setText('kg/s') + else: + self.u3.setText('') + self.u4.setText('') + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict={} + print("param.input_dict ", self.input_dict) + self.dict = [int(self.input_dict[0].text()),self.input_dict[1].currentText(), float(self.input_dict[2].text()), float(self.input_dict[3].text())] + print("param ", self.dict) + self.obj.param_setter(self.dict) + self.hide() + + except Exception as e: + print(e) diff --git a/DockWidgets/DockWidgetSplitter.ui b/DockWidgets/DockWidgetSplitter.ui new file mode 100644 index 0000000..02a865e --- /dev/null +++ b/DockWidgets/DockWidgetSplitter.ui @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>392</width> + <height>700</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>3200</width> + <height>5000</height> + </size> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QGroupBox" name="groupBox"> + <property name="geometry"> + <rect> + <x>10</x> + <y>40</y> + <width>341</width> + <height>161</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="styleSheet"> + <string notr="true">Q</string> + </property> + <property name="title"> + <string>Calculation Parameters</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="0"> + <widget class="QLabel" name="l2"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="l1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="le1"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="l3"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="le3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QComboBox" name="cb2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="0" column="3"> + <widget class="QLabel" name="u1"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="l4"> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QLineEdit" name="le4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="2" column="3"> + <widget class="QLabel" name="u3"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + <item row="3" column="3"> + <widget class="QLabel" name="u4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TextLabel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QPushButton" name="btn"> + <property name="geometry"> + <rect> + <x>10</x> + <y>210</y> + <width>341</width> + <height>23</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Submit</string> + </property> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/DockWidgets/__pycache__/DockWidget.cpython-36.pyc b/DockWidgets/__pycache__/DockWidget.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..1d47765 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidget.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..80d0ae1 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..1101a8e --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..e5023b1 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..ec04f1f --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..0584a29 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..387b27b --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..7eaaef7 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..90799f7 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..a99f092 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..f3fd8b1 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..52a0ca1 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..a56884a --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..85449f8 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..b0983a0 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc diff --git a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..19250d9 --- /dev/null +++ b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc |