diff options
author | brenda-br | 2023-02-23 22:14:39 +0530 |
---|---|---|
committer | brenda-br | 2023-02-23 22:14:39 +0530 |
commit | d476d2e053f937c0060f696312f301591e4f43ea (patch) | |
tree | 5d1643ba487082f986d8cc1868fba482293f1e37 /src/main/python/DockWidgets | |
parent | c5f533673ea9ab4315e76940f6d014e349f97884 (diff) | |
download | Chemical-Simulator-GUI-d476d2e053f937c0060f696312f301591e4f43ea.tar.gz Chemical-Simulator-GUI-d476d2e053f937c0060f696312f301591e4f43ea.tar.bz2 Chemical-Simulator-GUI-d476d2e053f937c0060f696312f301591e4f43ea.zip |
Restructure Code -1
Diffstat (limited to 'src/main/python/DockWidgets')
32 files changed, 1617 insertions, 0 deletions
diff --git a/src/main/python/DockWidgets/DistillationColumnStagewiseResults.py b/src/main/python/DockWidgets/DistillationColumnStagewiseResults.py new file mode 100644 index 0000000..65527dc --- /dev/null +++ b/src/main/python/DockWidgets/DistillationColumnStagewiseResults.py @@ -0,0 +1,18 @@ +import os, sys +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.uic import loadUiType +from PyQt5.QtWidgets import QWidget + +ui_dialog,_ = loadUiType(parentPath+'/ui/DockWidgets/DistillationColumnStagewiseResults.ui') + + +class DistillationColumnStagewiseResults(QWidget,ui_dialog): + + def __init__(self, parent=None): + QWidget.__init__(self, parent) + self.setupUi(self) + # self.setWindowTitle(self.parent.obj.name) diff --git a/src/main/python/DockWidgets/DockWidget.py b/src/main/python/DockWidgets/DockWidget.py new file mode 100644 index 0000000..a97212a --- /dev/null +++ b/src/main/python/DockWidgets/DockWidget.py @@ -0,0 +1,167 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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.modes() + self.comboBox.currentIndexChanged.connect(self.mode_selection) + + print("constructor ", self.input_dict) + self.pushButton_2.clicked.connect(self.param) + + self.dict = {} # a dictionary + 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.comboBox.setCurrentText(self.obj.variables[self.obj.mode]['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): + #print(i) + if i == None: + continue + l = QLineEdit(str(self.obj.variables[i]['value'])) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),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 (self.input_dict[i] == None): + continue + 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) + for i in self.container.graphics.graphicsView.items(): + try: + if(i.name == self.name): + i.update_tooltip() + except: + pass + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + @staticmethod + def show_result(lst): + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + + # 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() + + # Updating result in class + obj.variables[val]['value'] = resultval + # try: + # if obj.type == "Heater": + # print(obj.variables[val]['name'] + str(obj.variables[val]['value'])) + # except Exception as e: + # print(e) + + + + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetCompoundSeparator.py b/src/main/python/DockWidgets/DockWidgetCompoundSeparator.py new file mode 100644 index 0000000..4ae503a --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetCompoundSeparator.py @@ -0,0 +1,133 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +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 python.utils.ComponentSelector import * +from collections import defaultdict +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + self.lst = [] + self.input_params_list() + self.dict = [] + + def input_params_list(self): + try: + if self.type == 'CompoundSeparator': + self.lst.clear() + self.calculationGroupBox = QGroupBox('Calculation Parameters') + self.calculationLayout = QGridLayout() + + r1 = QRadioButton('Stream 1') + r1.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + r2 = QRadioButton('Stream 2') + r2.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + if self.obj.variables['SepStrm']['value'] == 1: + r1.setChecked(True) + r2.setChecked(False) + else: + r1.setChecked(False) + r2.setChecked(True) + + + self.lst = [r1, r2] + self.calculationLayout.addWidget(r1, 0, 1) + self.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)) + #print(self.obj.variables['SepFact_c']['value'][k]) + combo.setCurrentText(self.obj.variables['SepFact_c']['value'][k]) + combo.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + l = QLineEdit(str(self.obj.variables['SepVal_c']['value'][k])) + l.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) + self.calculationLayout.addWidget(QLabel(val+" :"), k+1,0, alignment=Qt.AlignLeft) + self.calculationLayout.addWidget(combo, k+1, 1, alignment=Qt.AlignCenter) + self.calculationLayout.addWidget(l,k+1,2, alignment=Qt.AlignCenter) + self.lst.append(combo) + self.lst.append(l) + + self.calculationLayout.setColumnStretch(3, len(self.obj.compounds)+1) + self.calculationGroupBox.setLayout(self.calculationLayout) + + btn = QPushButton('Submit') + btn.clicked.connect(self.param) + + self.gridLayout.setVerticalSpacing(5) + self.gridLayout.addWidget(self.calculationGroupBox,0,0) + self.gridLayout.addWidget(btn,1,0) + + self.input_dict = self.lst + + except Exception as e: + print(e) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def update_compounds(self): + try: + self.obj.init_variables() + t_item = self.calculationGroupBox.layout().itemAt(0) + self.calculationGroupBox.layout().removeItem(t_item) + while(t_item): + t_widget = t_item.widget() + if(t_widget): + t_widget.setHidden(True) + self.calculationGroupBox.layout().removeWidget(t_widget) + t_item = self.calculationGroupBox.layout().itemAt(0) + self.input_params_list() + except Exception as e: + print(e) + + + def param(self): + try: + self.dict=[] + + self.dict = [self.input_dict[0].isChecked(), self.input_dict[1].isChecked()] + j = 2 + for i in range(len(self.obj.compounds)): + self.dict.append(self.input_dict[j+i].currentText()) + if(self.input_dict[j+i+1].text()): + self.dict.append(self.input_dict[j+i+1].text()) + j += 1 + else: + self.show_error() + + + self.obj.param_setter(self.dict) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetCompressorExpander.py b/src/main/python/DockWidgets/DockWidgetCompressorExpander.py new file mode 100644 index 0000000..2439801 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetCompressorExpander.py @@ -0,0 +1,166 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/DockWidgets/DockWidgetCompressorExpander.ui') + +class DockWidgetCompressorExpander(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) + + 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 + + l = QLineEdit() + if self.input_dict[i] != None: + l.setText(str(self.input_dict[i])) + lay = QGridLayout() + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + lay.addWidget(l,0,1, alignment=Qt.AlignCenter) + lay.addWidget(QLabel(self.obj.variables[i]['unit']),0,2, alignment=Qt.AlignCenter) + + self.formLayout.addRow(lay) + self.input_dict[i] = l + + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cbTP.addItem(str(j)) + self.input_dict['Thermo Package'] = self.cbTP + + except Exception as e: + print(e) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.dict={} + for i in self.input_dict: + if (self.input_dict[i] == None): + continue + elif (i == "Thermo Package"): + 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 + + self.obj.param_setter(self.dict) + + for i in self.container.graphics.graphicsView.items(): + try: + if(i.name == self.name): + i.update_tooltip() + except: + pass + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + @staticmethod + def show_result(lst): + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + + # 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) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetDistillationColumn.py b/src/main/python/DockWidgets/DockWidgetDistillationColumn.py new file mode 100644 index 0000000..cf71f58 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetDistillationColumn.py @@ -0,0 +1,375 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +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 collections import defaultdict + +from python.utils.ComponentSelector import * +from python.DockWidgets.DistillationColumnStagewiseResults import DistillationColumnStagewiseResults +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + self.pushButton_2.clicked.connect(self.param) + self.dict = [] + self.input_params_list() + self.name_type = None + self.container = container + self.stage_res_table = DistillationColumnStagewiseResults() + self.stageResultsButton.clicked.connect(self.showStagewiseResults) + + # input data tab + + def input_params_list(self): + try: + print("input_params_list ", self.input_dict) + + # tab 1 + + l1 = QLineEdit() + l1.setText(str(self.obj.variables['Nt']['value'])) + self.lay1.addWidget(QLabel(self.obj.variables['Nt']['name'] + " :"), 0 ,0, alignment=Qt.AlignLeft) + self.lay1.addWidget(l1,0,1, alignment=Qt.AlignLeft) + self.input_dict.append(l1) + + for i in range(self.obj.variables['Ni']['value']): + print(i) + l = QLineEdit() + if len(self.obj.variables['InT_s']['value']) is not 0: + l.setText(str(self.obj.variables['InT_s']['value'][i])) + self.lay1.addWidget(QLabel(self.obj.variables['InT_s']['name'] +" " + str(i+1) + " location :"),2*(i+1),0, alignment=Qt.AlignLeft) + self.lay1.addWidget(l,2*(i+1),1, alignment=Qt.AlignLeft) + self.input_dict.append(l) + + # 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.le6.setText(str(self.obj.variables['C_Spec']['value'])) + self.l7.setText("Compounds :") + + self.cb5.addItem("Total") + self.cb5.addItem("Partial") + self.cb5.setCurrentText(self.obj.variables['Ctype']['value']) + for j in self.obj.Cspec_list: + self.cb1.addItem(str(j)) + self.cb1.setCurrentText(self.obj.variables['C_Spec']['type']) + for j in self.obj.compounds: + self.cb2.addItem(str(j)) + self.cb2.setCurrentText(self.obj.variables['C_Spec']['comp']) + + self.cb2.setDisabled(True) + self.cb1.currentIndexChanged.connect(self.fun2) + + self.input_dict.append(self.cb5) + self.input_dict.append(self.le5) + self.input_dict.append(self.cb1) + self.input_dict.append(self.cb2) + self.input_dict.append(self.le6) + + # 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.le8.setText(str(self.obj.variables['R_Spec']['value'])) + self.l10.setText('Compounds') + + for j in self.obj.Rspec_list: + self.cb3.addItem(str(j)) + self.cb3.setCurrentText(self.obj.variables['R_Spec']['type']) + for j in self.obj.compounds: + self.cb4.addItem(str(j)) + self.cb4.setCurrentText(self.obj.variables['R_Spec']['comp']) + self.cb4.setDisabled(True) + self.cb3.currentIndexChanged.connect(self.fun3) + + self.input_dict.append(self.le7) + self.input_dict.append(self.cb3) + self.input_dict.append(self.cb4) + self.input_dict.append(self.le8) + + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cbTP.addItem(str(j)) + self.cbTP.setCurrentText(self.obj.variables['thermo_package']['value']) + + self.input_dict.append(self.cbTP) + + # 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 update_compounds(self): + self.cb2.clear() + self.cb4.clear() + for j in self.obj.compounds: + self.cb2.addItem(str(j)) + self.cb2.setCurrentText(self.obj.variables['C_Spec']['comp']) + for j in self.obj.compounds: + self.cb4.addItem(str(j)) + self.cb4.setCurrentText(self.obj.variables['R_Spec']['comp']) + + def fun2(self): + if self.cb1.currentText() == 'Compound Molar Fraction' or self.cb1.currentText() == 'Compound Molar Flow (mol/s)': + self.cb2.setDisabled(False) + 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= [] + temp = 0 + print("param.input_dict ", self.input_dict) + self.dict.append(int(self.input_dict[0].text())) + + for i in range(self.obj.variables['Ni']['value']): + self.dict.append(int(self.input_dict[i+1].text())) + temp = i + 1 + print(temp) + + print(temp) + print(self.input_dict[temp+1]) + self.dict.append(self.input_dict[temp+1].currentText()) + print(temp+1) + self.dict.append(int(self.input_dict[temp+2].text())) + print(temp+2) + self.dict.append(self.input_dict[temp+3].currentText()) + print(temp+3) + self.dict.append(self.input_dict[temp+4].currentText()) + print(temp+4) + self.dict.append(int(self.input_dict[temp+5].text())) + print(temp+5) + self.dict.append(int(self.input_dict[temp+6].text())) + print(temp+6) + self.dict.append(self.input_dict[temp+7].currentText()) + print(temp+7) + self.dict.append(self.input_dict[temp+8].currentText()) + print(temp+8) + self.dict.append(int(self.input_dict[temp+9].text())) + print(temp+9) + self.dict.append(self.input_dict[temp+10].currentText()) + print(temp + 10) + + print("param ", self.dict) + self.obj.param_setter(self.dict) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + def showStagewiseResults(self): + self.stage_res_table.show() + + @staticmethod + def showResult(lst): + # DockWidget1.flag = True + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + self.stage_res_table.T_table.setRowCount(0) + self.stage_res_table.T_table.setColumnCount(0) + self.stage_res_table.x_pc_table.setRowCount(0) + self.stage_res_table.x_pc_table.setColumnCount(0) + + # 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 = obj.result_parameters + 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]) + obj.variables[val]['value'] = 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() + + # Stagewise Results + Nt = self.obj.variables['Nt']['value'] + Nc = len(self.obj.compounds) + # initializing temporary arrays + Stages_T = [None for i in range(Nt)] + # Can be uncommented when F_p and F_pc implemented in modelica table + # Stages_F_p = [[None for i in range(3)] for j in range(Nt)] + # Stages_F_pc = [[[None for i in range(3)] for j in range(Nc)] for k in range(Nt)] + Stages_x_pc = [[[None for i in range(3)] for j in range(Nc)] for k in range(Nt)] + + Stages_res_varikeys = ['T'] + for i in range(Nc): + for j in range(3): + Stages_res_varikeys.append('x_pc[' + str(j + 1) + ',' + str(i + 1) + ']') + + for v in Stages_res_varikeys: + propertyname = name + '.condenser.' + v + if propertyname in result[0]: + ind = result[0].index(propertyname) + if v == 'T': + Stages_T[0] = result[-1][ind] + # Can be uncommented when F_p is implemented in modelica model + # elif v == 'F_p': + # if result[0][ind][result[0][ind].index('[') + 1] == '1': + # Stages_F_p[0][0] = result[-1][ind] + # elif result[0][ind][result[0][ind].index('[') + 1] == '2': + # Stages_F_p[0][1] = result[-1][ind] + # else: + # Stages_F_p[0][2] = result[-1][ind] + else: + print(ind) + phase_no = int(result[0][ind][result[0][ind].index('[') + 1]) + comp_no = int(result[0][ind][result[0][ind].index(']') - 1]) + Stages_x_pc[0][comp_no - 1][phase_no - 1] = result[-1][ind] + # Can be uncommented and improved when F_pc implemented in modelica model + # if v == 'F_pc': + # Stages_F_pc[0][comp_no - 1][phase_no - 1] = result[-1][ind] + # else: + # Stages_x_pc[0][comp_no - 1][phase_no - 1] = result[-1][ind] + + for i in range(1, Nt - 1): + propertyname = name + '.tray[' + str(i) + '].' + v + if propertyname in result[0]: + ind = result[0].index(propertyname) + if v == 'T': + Stages_T[i] = result[-1][ind] + # Can be uncommented when F_p implemented in modelica model + # elif v == 'F_p': + # if result[0][ind][result[0][ind].index('[') + 1] == '1': + # Stages_F_p[i][0] = result[-1][ind] + # elif result[0][ind][result[0][ind].index('[') + 1] == '2': + # Stages_F_p[i][1] = result[-1][ind] + # else: + # Stages_F_p[i][2] = result[-1][ind] + else: + print(ind) + print(result[0][ind]) + phase_no = int(result[0][ind].split('.')[-1][result[0][ind].split('.')[-1].index('[') + 1]) + comp_no = int(result[0][ind].split('.')[-1][result[0][ind].split('.')[-1].index(']') - 1]) + Stages_x_pc[i][comp_no - 1][phase_no - 1] = result[-1][ind] + # Can be uncommented when F_pc implemented in modelica model + # if v == 'F_pc': + # Stages_F_pc[i][comp_no - 1][phase_no - 1] = result[-1][ind] + # else: + # Stages_x_pc[i][comp_no - 1][phase_no - 1] = result[-1][ind] + + propertyname = name + '.reboiler.' + v + if propertyname in result[0]: + ind = result[0].index(propertyname) + if v == 'T': + Stages_T[-1] = result[-1][ind] + # Can be uncommented when F_p implemented in modelica model + # elif v == 'F_p': + # if result[0][ind][result[0][ind].index('[') + 1] == '1': + # Stages_F_p[-1][0] = result[-1][ind] + # elif result[0][ind][result[0][ind].index('[') + 1] == '2': + # Stages_F_p[-1][1] = result[-1][ind] + # else: + # Stages_F_p[-1][2] = result[-1][ind] + else: + print(ind) + phase_no = int(result[0][ind][result[0][ind].index('[') + 1]) + comp_no = int(result[0][ind][result[0][ind].index(']') - 1]) + Stages_x_pc[-1][comp_no - 1][phase_no - 1] = result[-1][ind] + # Can be uncommented when F_pc implemented in modelica model + # if v == 'F_pc': + # Stages_F_pc[-1][comp_no - 1][phase_no - 1] = result[-1][ind] + # else: + # Stages_x_pc[-1][comp_no - 1][phase_no - 1] = result[-1][ind] + + # Assigning temp variables to obj variabes + self.obj.variables['Stages.T']['value'] = Stages_T + # Can be uncommented when F_p and F_pc implemented in modelica model + # self.obj.variables['Stages.F_p']['value'] = Stages_F_p + # self.obj.variables['Stages.F_pc']['value'] = Stages_F_pc + self.obj.variables['Stages.x_pc']['value'] = Stages_x_pc + + # filling stagewise result table + tables = [self.stage_res_table.T_table, self.stage_res_table.x_pc_table] + # Can be uncommented when F_p and F_pc implemented in modelica model + # tables = [self.stage_res_table.T_table, self.stage_res_table.F_p_table, self.stage_res_table.F_pc_table, self.stage_res_table.x_pc_table] + + for t in tables: + t.setRowCount(Nt) + t.setVerticalHeaderItem(0, QTableWidgetItem('Condenser')) + t.setVerticalHeaderItem(Nt -1, QTableWidgetItem('Reboiler')) + for i in range(1, Nt - 1): + t.setVerticalHeaderItem(i, QTableWidgetItem('Stage ' + str(i))) + + T_table = self.stage_res_table.T_table + T_table.setColumnCount(1) + for i in range(Nt): + T_table.setItem(i, 0, QTableWidgetItem(Stages_T[i])) + + x_pc_table = self.stage_res_table.x_pc_table + x_pc_table.setColumnCount(2*Nc) + for i in range(Nc): + x_pc_table.setHorizontalHeaderItem(2*i, QTableWidgetItem(self.obj.compounds[i] + '(Vapor)')) + x_pc_table.setHorizontalHeaderItem(2*i + 1, QTableWidgetItem(self.obj.compounds[i] + '(Liquid)')) + + for i in range(Nt): + for j in range(Nc): + x_pc_table.setItem(i, 2*j, QTableWidgetItem(Stages_x_pc[i][j][1])) + x_pc_table.setItem(i, 2 * j + 1, QTableWidgetItem(Stages_x_pc[i][j][2])) + + for t in tables: + t.resizeColumnsToContents() + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetFlash.py b/src/main/python/DockWidgets/DockWidgetFlash.py new file mode 100644 index 0000000..7742e62 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetFlash.py @@ -0,0 +1,86 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = [] # a list + + def input_params_list(self): + try: + self.l1.setText(self.obj.variables['thermo_package']['name']+":") + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cb1.addItem(str(j)) + self.cb1.setCurrentText(self.obj.variables['thermo_package']['value']) + + 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.check1.setChecked(self.obj.variables['BTdef']['value']) + 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.check2.setChecked(self.obj.variables['BPdef']['value']) + + 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) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetMaterialStream.py b/src/main/python/DockWidgets/DockWidgetMaterialStream.py new file mode 100644 index 0000000..5bc77c5 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetMaterialStream.py @@ -0,0 +1,373 @@ +import os, sys +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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.comboBox.currentIndexChanged.connect(self.mode_selection) + + self.pushButton_2.clicked.connect(self.param) + self.dict = {} # a dictionary + + self.name_type = None + self.container = container + + header = QTreeWidgetItem(['Compound','Value','Unit']) + self.mTreeWidget.setHeaderItem(header) + self.lTreeWidget.setHeaderItem(header) + self.vTreeWidget.setHeaderItem(header) + lines = [line.rstrip('\n') for line in open(parentPath+'/python/utils/thermopackage.txt')] + for j in lines: + self.cbTP.addItem(str(j)) + self.modes() + + # 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.comboBox.setCurrentText(self.obj.mode) + 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= {} + try: # removing existing rows while changing modes + for i in reversed(range(self.formLayout.count())): + self.formLayout.removeRow(i) + except Exception as e: + print(e) + self.input_dict = self.obj.param_getter(self.comboBox.currentText()) + self.obj.mode = self.comboBox.currentText() + self.input_params_list() + + def input_params_list(self): + try: + for c,i in enumerate(self.input_dict): + if(i=="x_pc"): + noc = len(compound_selected) + #print(noc) + self.x_pclist.clear() + + self.comp_gb = QGroupBox("Mole Fractions") + lay = QGridLayout() + for j in range(noc): + try: + l = QLineEdit(str(self.obj.variables['x_pc']['value'][j])) + except: + l = QLineEdit() + # if self.input_dict[i] != '': + # l.setText(str(self.obj.variables['x_pc']['value'][j])) + # print('l = ', str(self.obj.variables['x_pc']['value'][j])) + + 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) + lay.setSizeConstraint(QLayout.SetFixedSize) + self.comp_gb.setLayout(lay) + self.formLayout.addRow(self.comp_gb) + elif i == "Thermo Package": + self.cbTP.setCurrentText(self.input_dict[i]) + else: + #print("elseloop") + l = QLineEdit() + if self.input_dict[i] != None: + l.setText(str(self.input_dict[i])) + + lay = QGridLayout() + if i !='MolFlow': + lay.addWidget(QLabel(self.obj.variables[i]['name']+":"),0,0, alignment=Qt.AlignLeft) + else: + 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 update_compounds(self): + try: + noc = len(compound_selected) + #print(noc) + self.x_pclist.clear() + + lay = QGridLayout() + for j in range(noc): + l = QLineEdit() + lay.addWidget(QLabel(str(compound_selected[j]) + ":"), j, 0, alignment=Qt.AlignLeft) + lay.addWidget(l, j, 1, alignment=Qt.AlignCenter) + self.x_pclist.append(l) + lay.setSizeConstraint(QLayout.SetFixedSize) + self.comp_gb.setLayout(lay) + indexx = self.comboBox.currentIndex() + self.comboBox.setCurrentIndex(1) + self.comboBox.setCurrentIndex(indexx) + self.obj.init_variables() + except Exception as e: + print(e) + + def param(self): + try: + self.dict={} + #print("param.input_dict ", self.input_dict) + for i in self.input_dict: + #print(i) + if(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) + elif (i == "Thermo Package"): + self.dict[i] = self.cbTP.currentText() + else: + if (self.input_dict[i].text()): + self.dict[i] = self.input_dict[i].text() + else: + #print(self.input_dict[i]) + self.show_error() + break + + #print("param ", self.dict) + + self.obj.param_setter(self.dict) + + for i in self.container.graphics.graphicsView.items(): + try: + if(i.name == self.name): + i.update_tooltip() + except: + pass + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + def update_input_values(self): + self.init() + + @staticmethod + def show_result(ms_lst): + for i in ms_lst: + i.results_category(i.name) + + def clear_results(self): + self.mTreeWidget.clear() + self.mTableWidget.setRowCount(0) + self.lTreeWidget.clear() + self.lTableWidget.setRowCount(0) + self.vTreeWidget.clear() + self.vTableWidget.setRowCount(0) + + # result data tab + def results_category(self,name): + 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"} + ms_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","Mass Flow Rate":"Fm_p"} + + # Amounts Tab + if obj.type == 'MaterialStream': + ll = [] # list for basis names + for basis in d: + propertyname = name + '.' + d[basis] + #print("basis ", basis, propertyname) + for i in result[0]: + if (propertyname in i): + ll.append(i) + #print(ll) + + j = 0 + namee = 'none' + #print("namee ", namee) + #initialization for treewidgets + lroot = 1 + mroot = 1 + vroot = 1 + + + for i,k in enumerate(ll): + 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 not in k: + mroot = QTreeWidgetItem(self.mTreeWidget, [ms_lst[j]]) + lroot = QTreeWidgetItem(self.lTreeWidget, [ms_lst[j]]) + vroot = QTreeWidgetItem(self.vTreeWidget, [ms_lst[j]]) + namee = klst[j] + + phase_no = int(k[k.index(',') - 1]) # phase no is from modelica list + compound_no = int(k[k.index(',') + 1]) - 1 # compound is from python list + + if phase_no == 1: + child = QTreeWidgetItem(mroot, [compound_selected[compound_no], str(round(float(resultval),4)), + obj.variables[k.split('.')[1]]['unit']]) + elif phase_no == 2: + child = QTreeWidgetItem(lroot, [compound_selected[compound_no], str(round(float(resultval),4)), + obj.variables[k.split('.')[1]]['unit']]) + elif phase_no == 3: + child = QTreeWidgetItem(vroot, [compound_selected[compound_no], str(round(float(resultval),4)), + obj.variables[k.split('.')[1]]['unit']]) + if (compound_no + 1) == len(compound_selected): + j += 1 + + + + # 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(str(round(float(resultval),4)))) + 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(str(round(float(resultval),4)))) + 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(str(round(float(resultval),4)))) + self.vTableWidget.setItem(vrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.vTableWidget.resizeColumnsToContents() + if not '[' in val: + #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(str(round(float(resultval),4)))) + self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit'])) + self.mTableWidget.resizeColumnsToContents() + + + # updating the input data from fetched results from simulation + #print(self.comboBox.currentText()) + + self.input_dict = {} + self.input_dict = self.obj.param_getter(self.comboBox.currentText()) + # print("before", self.input_dict) + #self.input_dict.pop("x_pc") + # temp = self.input_dict.pop('thermo_package') + for i in range(len(compound_selected)): + #print(i) + self.input_dict['x_pc[1,' + str(i+1) + ']'] = self.obj.variables['x_pc[1,' + str(i+1) +']']['value'] + # self.input_dict['thermo_package'] = temp + # print("after", self.input_dict) + + # changing index for updating the input data + indexx = self.comboBox.currentIndex() + self.comboBox.setCurrentIndex(1) + self.comboBox.setCurrentIndex(indexx) + + try: + + for i in self.parent().container.graphics.graphicsView.items(): + try: + if i.obj == self.obj: + i.update_tooltip() + except Exception as e: + pass + except Exception as e: + print(e) + + + except Exception as e: + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) +
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetMixer.py b/src/main/python/DockWidgets/DockWidgetMixer.py new file mode 100644 index 0000000..5d89589 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetMixer.py @@ -0,0 +1,66 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = {} + + # input data tab + def input_params_list(self): + try: + 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.cb2.setCurrentText(self.obj.variables['outPress']['value']) + + 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={} + self.dict = [int(self.input_dict[0].text()), self.input_dict[1].currentText()] + self.obj.param_setter(self.dict) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetShortcutColumn.py b/src/main/python/DockWidgets/DockWidgetShortcutColumn.py new file mode 100644 index 0000000..43d01e9 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetShortcutColumn.py @@ -0,0 +1,148 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + 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: + self.l1.setText(self.obj.variables['HKey']['name']+":") + self.l2.setText(self.obj.variables['LKey']['name']+":") + + print(self.obj.compounds) + for i in self.obj.compounds: + self.cb1.addItem(str(i)) + self.cb2.addItem(str(i)) + self.cb1.setCurrentText(self.obj.compounds[int(self.obj.variables['HKey']['value'])-1]) + self.cb2.setCurrentText(self.obj.compounds[int(self.obj.variables['LKey']['value'])-1]) + + 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.cb5.setCurrentText(self.obj.variables['Ctype']['value']) + + 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.l9.setText("Thermo Package :") + + self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')] + for j in self.lines: + self.cb6.addItem(str(j)) + self.cb6.setCurrentText(self.obj.variables['thermo_package']['value']) + + self.input_dict = [self.cb1, self.cb2, self.le3, self.le4, self.cb5, self.le6, self.le7, self.le8, self.cb6] + + except Exception as e: + print(e) + + def update_compounds(self): + self.cb1.clear() + self.cb2.clear() + for i in self.obj.compounds: + self.cb1.addItem(str(i)) + self.cb2.addItem(str(i)) + self.cb1.setCurrentText(self.obj.compounds[int(self.obj.variables['HKey']['value']) - 1]) + self.cb2.setCurrentText(self.obj.compounds[int(self.obj.variables['LKey']['value']) - 1]) + + def show_error(self): + QMessageBox.about(self, 'Important', "Please fill all fields with data") + + def param(self): + try: + self.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()), + self.input_dict[8].currentText()] + self.obj.param_setter(self.dict) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + + except Exception as e: + print(e) + + @staticmethod + def show_result(lst): + for i in lst: + try: + i.results_category(i.name) + except AttributeError: + pass + + def clear_results(self): + self.tableWidget.setRowCount(0) + + # 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 = obj.result_parameters + 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]) + obj.variables[val]['value']= 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) + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/DockWidgetSplitter.py b/src/main/python/DockWidgets/DockWidgetSplitter.py new file mode 100644 index 0000000..296e111 --- /dev/null +++ b/src/main/python/DockWidgets/DockWidgetSplitter.py @@ -0,0 +1,85 @@ +import os, sys + +current = os.path.dirname(os.path.realpath(__file__)) +parent = os.path.dirname(current) +parentPath = os.path.dirname(parent) +sys.path.append(parentPath) + +from PyQt5.QtCore import * +from PyQt5.QtWidgets import * +from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from python.utils.ComponentSelector import * +from python.utils.Graphics import * + +ui_dialog,_ = loadUiType(parentPath+'/ui/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 = [] + self.input_params_list() + self.btn.clicked.connect(self.param) + self.dict = {} + + # input data tab + def input_params_list(self): + try: + self.l1.setText(self.obj.variables['No']['name']+":") + self.le1.setText(str(self.obj.variables['No']['value'])) + self.u1.setText(self.obj.variables['No']['unit']) + + self.l2.setText(self.obj.variables['CalcType']['name'] + ":") + for i in self.obj.CalcType_modes: + self.cb2.addItem(str(i)) + self.cb2.setCurrentText(self.obj.variables['CalcType']['value']) + + self.l3.setText("Stream 1 :") + self.le3.setText(str(self.obj.variables['SpecVal_s']['value'][0])) + self.u3.setText(self.obj.variables['SpecVal_s']['unit']) + self.l4.setText("Stream 2 :") + self.le4.setText(str(self.obj.variables['SpecVal_s']['value'][1])) + self.u4.setText(str(self.obj.variables['SpecVal_s']['unit'])) + 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() == 'Molar_Flow': + self.u3.setText('mol/s') + self.u4.setText('mol/s') + elif self.cb2.currentText() == 'Mass_Flow': + self.u3.setText('g/s') + self.u4.setText('g/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={} + 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())] + self.obj.param_setter(self.dict) + if(self.isVisible()): + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189) + self.hide() + except Exception as e: + print(e) + + def closeEvent(self,event): + scrollHVal = self.parent().container.graphics.graphicsView.horizontalScrollBarVal + currentVal = self.parent().container.graphics.graphicsView.horizontalScrollBar().value() + self.parent().container.graphics.graphicsView.horizontalScrollBar().setValue(currentVal-189)
\ No newline at end of file diff --git a/src/main/python/DockWidgets/__init__.py b/src/main/python/DockWidgets/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/main/python/DockWidgets/__init__.py diff --git a/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..0b8a850 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..98f972c --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DistillationColumnStagewiseResults.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..362d798 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..16d524f --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..35f8cc8 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..ddb230a --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..922d625 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..b50fc09 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetCompressorExpander.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..b2d28ee --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..7b8ffd6 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..5d96e15 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..9bb461c --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..dcdd91b --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..426a9a7 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..7ce7bc5 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..05e5d7f --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..a43a296 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..e6c7383 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc Binary files differnew file mode 100644 index 0000000..ddefbdd --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-36.pyc diff --git a/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..9461f0b --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc diff --git a/src/main/python/DockWidgets/__pycache__/__init__.cpython-37.pyc b/src/main/python/DockWidgets/__pycache__/__init__.cpython-37.pyc Binary files differnew file mode 100644 index 0000000..afad453 --- /dev/null +++ b/src/main/python/DockWidgets/__pycache__/__init__.cpython-37.pyc |