summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpravindalve2023-01-27 01:41:16 +0530
committerGitHub2023-01-27 01:41:16 +0530
commite10e1eebbf6927d5548ccb7bbb6563994cee0c35 (patch)
tree17cc1ae47d6151bbaf7d4761370e74909f21fe08
parent2bae254bfdb89e554a4f10c35a45011069376ac6 (diff)
parent9a90a5af1f7e57b25675416f7d90b1b62515a5a3 (diff)
downloadChemical-Simulator-GUI-e10e1eebbf6927d5548ccb7bbb6563994cee0c35.tar.gz
Chemical-Simulator-GUI-e10e1eebbf6927d5548ccb7bbb6563994cee0c35.tar.bz2
Chemical-Simulator-GUI-e10e1eebbf6927d5548ccb7bbb6563994cee0c35.zip
Merge pull request #42 from brenda-br/Fix-35
Fix -34, 38, 35, 43, 36
-rw-r--r--ComponentSelector.py4
-rw-r--r--DockWidgets/DockWidget.py7
-rw-r--r--DockWidgets/DockWidgetCompoundSeparator.py60
-rw-r--r--DockWidgets/DockWidgetCompressorExpander.py8
-rw-r--r--DockWidgets/DockWidgetMaterialStream.py9
-rw-r--r--DockWidgets/__pycache__/DockWidget.cpython-37.pycbin4730 -> 4849 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pycbin3614 -> 4104 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pycbin8986 -> 9127 bytes
-rw-r--r--Graphics.py2
-rw-r--r--Streams.py50
-rw-r--r--Undo.datbin1014 -> 115346 bytes
-rw-r--r--UnitOperations.py8
-rw-r--r--mainApp.py9
13 files changed, 111 insertions, 46 deletions
diff --git a/ComponentSelector.py b/ComponentSelector.py
index 60498cc..56c6078 100644
--- a/ComponentSelector.py
+++ b/ComponentSelector.py
@@ -173,4 +173,8 @@ class ComponentSelector(QDialog,ui_dialog):
self.f_mo.write('\n')
self.f_mo.write('\nend database;')
self.f_mo.close()
+
+ def accept(self):
+ #self.parent().container.update_compounds()
+ return super().accept()
\ No newline at end of file
diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py
index e7e5b8b..cc222db 100644
--- a/DockWidgets/DockWidget.py
+++ b/DockWidgets/DockWidget.py
@@ -92,6 +92,13 @@ class DockWidget(QDockWidget,ui_dialog):
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
+
self.hide()
except Exception as e:
diff --git a/DockWidgets/DockWidgetCompoundSeparator.py b/DockWidgets/DockWidgetCompoundSeparator.py
index 69b2770..8fcee39 100644
--- a/DockWidgets/DockWidgetCompoundSeparator.py
+++ b/DockWidgets/DockWidgetCompoundSeparator.py
@@ -20,15 +20,16 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
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':
- calculationGroupBox = QGroupBox('Calculation Parameters')
- calculationLayout = QGridLayout()
+ self.lst.clear()
+ self.calculationGroupBox = QGroupBox('Calculation Parameters')
+ self.calculationLayout = QGridLayout()
r1 = QRadioButton('Stream 1')
r1.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
@@ -42,37 +43,37 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
r2.setChecked(True)
- lst = [r1, r2]
- calculationLayout.addWidget(r1, 0, 1)
- calculationLayout.addWidget(r2, 0, 2)
+ 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")
+ #print("CompoundSeparator combo")
for j in self.obj.SepFact_modes:
combo.addItem(str(j))
- print(self.obj.variables['SepFact_c']['value'][k])
+ #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)
- 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)
+ 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)
- calculationLayout.setColumnStretch(3, len(self.obj.compounds)+1)
- calculationGroupBox.setLayout(calculationLayout)
+ 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(calculationGroupBox,0,0)
+ self.gridLayout.addWidget(self.calculationGroupBox,0,0)
self.gridLayout.addWidget(btn,1,0)
- self.input_dict = lst
+ self.input_dict = self.lst
except Exception as e:
print(e)
@@ -80,6 +81,22 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
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=[]
@@ -87,10 +104,13 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
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
+ 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)
self.hide()
diff --git a/DockWidgets/DockWidgetCompressorExpander.py b/DockWidgets/DockWidgetCompressorExpander.py
index 5309bba..cd0135c 100644
--- a/DockWidgets/DockWidgetCompressorExpander.py
+++ b/DockWidgets/DockWidgetCompressorExpander.py
@@ -100,6 +100,14 @@ class DockWidgetCompressorExpander(QDockWidget,ui_dialog):
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
+
self.hide()
except Exception as e:
diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py
index 09cddf4..64545be 100644
--- a/DockWidgets/DockWidgetMaterialStream.py
+++ b/DockWidgets/DockWidgetMaterialStream.py
@@ -128,6 +128,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
indexx = self.comboBox.currentIndex()
self.comboBox.setCurrentIndex(1)
self.comboBox.setCurrentIndex(indexx)
+ self.obj.init_variables()
except Exception as e:
print(e)
@@ -166,6 +167,14 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
#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
+
self.hide()
except Exception as e:
diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc
index b0cf5d3..5d0ec10 100644
--- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc
index db18769..f11f259 100644
--- a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
index 29c3683..e5bba23 100644
--- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
Binary files differ
diff --git a/Graphics.py b/Graphics.py
index 1472516..c527205 100644
--- a/Graphics.py
+++ b/Graphics.py
@@ -39,7 +39,7 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem):
return NodeItem(unit_operation, container, self.graphicsView)
def update_compounds(self):
- for i in self.scene.items():
+ for i in self.graphicsView.items():
if isinstance(i, NodeItem):
i.update_compounds()
diff --git a/Streams.py b/Streams.py
index a4cdeaf..0559831 100644
--- a/Streams.py
+++ b/Streams.py
@@ -93,34 +93,44 @@ class MaterialStream():
self.variables['x_pc']['value'] = temp
if(mode=="PT"):
- self.mode1 = self.variables['P']['name']
- self.mode2 = self.variables['T']['name']
- dict = {self.mode1:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
- self.mode2:str(self.variables['T']['value'])+' '+self.variables['T']['unit']}
+ self.mode1 = 'P'
+ self.mode2 = 'T'
+ mode1_n = self.variables['P']['name']
+ mode2_n = self.variables['T']['name']
+ dict = {mode1_n:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
+ mode2_n:str(self.variables['T']['value'])+' '+self.variables['T']['unit']}
elif(mode=="PH"):
- self.mode1 = self.variables['P']['name']
- self.mode2 = self.variables['H_p[1]']['name']
+ self.mode1 = 'P'
+ self.mode2 = 'H_p[1]'
+ mode1_n = self.variables['P']['name']
+ mode2_n = self.variables['H_p[1]']['name']
- dict = {self.mode1:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
- self.mode2:str(self.variables['H_p[1]']['value'])+' '+self.variables['H_p[1]']['unit']}
+ dict = {mode1_n:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
+ mode2_n:str(self.variables['H_p[1]']['value'])+' '+self.variables['H_p[1]']['unit']}
elif(mode=="PVF"):
- self.mode1 = self.variables['P']['name']
- self.mode2 = self.variables['xvap']['name']
+ self.mode1 = 'P'
+ self.mode2 = 'xvap'
+ mode1_n = self.variables['P']['name']
+ mode2_n = self.variables['xvap']['name']
- dict = {self.mode1:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
- self.mode2:str(self.variables['xvap']['value'])+' '+self.variables['xvap']['unit']}
+ dict = {mode1_n:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
+ mode2_n:str(self.variables['xvap']['value'])+' '+self.variables['xvap']['unit']}
elif(mode=="TVF"):
- self.mode1 = self.variables['T']['name']
- self.mode2 = self.variables['xvap']['name']
- dict = {self.mode1:str(self.variables['T']['value'])+' '+self.variables['T']['unit'],
- self.mode2:str(self.variables['xvap']['value'])+' '+self.variables['xvap']['unit']}
+ self.mode1 = 'T'
+ self.mode2 = 'xvap'
+ mode1_n = self.variables['T']['name']
+ mode2_n = self.variables['xvap']['name']
+ dict = {mode1_n:str(self.variables['T']['value'])+' '+self.variables['T']['unit'],
+ mode2_n:str(self.variables['xvap']['value'])+' '+self.variables['xvap']['unit']}
elif(mode=="PS"):
- self.mode1 = self.variables['P']['name']
- self.mode2 = self.variables['S_p[1]']['name']
+ self.mode1 = 'P'
+ self.mode2 = 'S_p[1]'
+ mode1_n = self.variables['P']['name']
+ mode2_n = self.variables['S_p[1]']['name']
- dict = {self.mode1:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
- self.mode2:str(self.variables['S_p[1]']['value'])+' '+self.variables['S_p[1]']['unit']}
+ dict = {mode1_n:str(self.variables['P']['value'])+' '+self.variables['P']['unit'],
+ mode2_n:str(self.variables['S_p[1]']['value'])+' '+self.variables['S_p[1]']['unit']}
dict['Mole Flow'] = str(self.variables['F_p[1]']['value'])+' '+self.variables['F_p[1]']['unit']
dict[self.variables['x_pc']['name']] = str(self.variables['x_pc']['value'])+' '+self.variables['x_pc']['unit']
diff --git a/Undo.dat b/Undo.dat
index 01eaa36..501e2fd 100644
--- a/Undo.dat
+++ b/Undo.dat
Binary files differ
diff --git a/UnitOperations.py b/UnitOperations.py
index da01df0..064b2da 100644
--- a/UnitOperations.py
+++ b/UnitOperations.py
@@ -447,7 +447,13 @@ class CompoundSeparator(UnitOperation):
'SepVal_c' : {'name':'Separation Value', 'value':['']*len(self.compounds), 'unit':''},
'SepFact_c' : {'name':'Separaction Factor', 'value':['']*len(self.compounds), 'unit':''},
}
-
+
+ def init_variables(self):
+ self.variables = {
+ 'SepStrm' : {'name':'Separation Stream', 'value':1, 'unit':''},
+ 'SepVal_c' : {'name':'Separation Value', 'value':['']*len(self.compounds), 'unit':''},
+ 'SepFact_c' : {'name':'Separaction Factor', 'value':['']*len(self.compounds), 'unit':''},
+ }
def update_compounds(self):
self.compounds = [c[:c.index('(')] for c in compound_selected]
diff --git a/mainApp.py b/mainApp.py
index 2458ce7..1430960 100644
--- a/mainApp.py
+++ b/mainApp.py
@@ -310,9 +310,8 @@ class MainApp(QMainWindow,ui):
for i in self.container.unit_operations:
data.append(i)
i.saved = True
- print(i.pos)
data.append(compound_selected)
- print(data)
+ data.append(self.container.result)
file_format = 'sim'
initial_path = QDir.currentPath() + 'untitled.' + file_format
@@ -341,14 +340,16 @@ class MainApp(QMainWindow,ui):
with open(file_name, 'rb') as f:
obj = pickle.load(f)
- print(obj)
+ temp_result = obj[-1]
+ obj.pop()
compound_selected = obj[-1]
obj.pop()
- print(compound_selected)
self.comp.set_compounds(compound_selected)
for i in compound_selected:
self.comp.compound_selection(self.comp, i)
self.container.graphics.load_canvas(obj, self.container)
+ self.container.result = temp_result
+ DockWidget.show_result(dock_widget_lst)
except Exception as e: