summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlucaszhao192020-07-17 21:30:55 +0630
committerlucaszhao192020-07-17 21:30:55 +0630
commitb43d2c8eef88b48f2db6f118805a3f621a0a13d3 (patch)
tree2c03efb85357acbdb2159e4493ab15c8023251a3
parentbadd3b0787acaf3cbecdd9a9935d34de886fb5c2 (diff)
downloadChemical-Simulator-GUI-b43d2c8eef88b48f2db6f118805a3f621a0a13d3.tar.gz
Chemical-Simulator-GUI-b43d2c8eef88b48f2db6f118805a3f621a0a13d3.tar.bz2
Chemical-Simulator-GUI-b43d2c8eef88b48f2db6f118805a3f621a0a13d3.zip
Fixed ShortcutColumn
-rw-r--r--DockWidgets/DockWidgetShortcutColumn.py39
-rw-r--r--DockWidgets/DockWidgetShortcutColumn.ui34
-rw-r--r--DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pycbin3364 -> 4160 bytes
-rw-r--r--Undo.datbin31950 -> 70485 bytes
-rw-r--r--UnitOperations.py40
5 files changed, 102 insertions, 11 deletions
diff --git a/DockWidgets/DockWidgetShortcutColumn.py b/DockWidgets/DockWidgetShortcutColumn.py
index af81441..fc5c34f 100644
--- a/DockWidgets/DockWidgetShortcutColumn.py
+++ b/DockWidgets/DockWidgetShortcutColumn.py
@@ -34,12 +34,13 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
print("input_params_list ", self.input_dict)
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.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']))
@@ -84,14 +85,40 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
except Exception as e:
print(e)
-
@staticmethod
def show_result(lst):
- #DockWidget1.flag = True
for i in lst:
- i.resultsCategory(i.name)
- #i.show()
+ try:
+ i.results_category(i.name)
+ except AttributeError:
+ pass
# result data tab
def results_category(self,name):
- pass \ No newline at end of file
+ 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()
+
+ print(obj.variables)
+
+ except Exception as e:
+ print(e) \ No newline at end of file
diff --git a/DockWidgets/DockWidgetShortcutColumn.ui b/DockWidgets/DockWidgetShortcutColumn.ui
index c66e699..47595ec 100644
--- a/DockWidgets/DockWidgetShortcutColumn.ui
+++ b/DockWidgets/DockWidgetShortcutColumn.ui
@@ -33,8 +33,8 @@
<rect>
<x>10</x>
<y>40</y>
- <width>351</width>
- <height>321</height>
+ <width>381</width>
+ <height>611</height>
</rect>
</property>
<property name="currentIndex">
@@ -287,6 +287,36 @@
<attribute name="title">
<string>Results</string>
</attribute>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <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>
diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
index 1c34a04..560bdac 100644
--- a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
Binary files differ
diff --git a/Undo.dat b/Undo.dat
index 0c1911d..b2f107b 100644
--- a/Undo.dat
+++ b/Undo.dat
Binary files differ
diff --git a/UnitOperations.py b/UnitOperations.py
index 7105606..54f9334 100644
--- a/UnitOperations.py
+++ b/UnitOperations.py
@@ -123,6 +123,8 @@ class UnitOperation():
# self.OM_data_init += k + ' = ' + str(v)
for k in self.parameters:
+ if(k == 'HKey_x_pc' or k == 'LKey_x_pc'):
+ continue
self.OM_data_init += ', '
self.OM_data_init += k + ' = ' + (json.dumps(self.variables[k]['value']) if json.dumps(self.variables[k]['value']).replace('"', '').replace('_', '').isalpha()
else json.dumps(self.variables[k]['value']).replace('[', '{').replace(']', '}').replace('"', ''))
@@ -181,7 +183,12 @@ class ShortcutColumn(UnitOperation):
self.EngStm2 = EngStm(name='EngStm2'+self.name)
self.count = ShortcutColumn.counter
+ self.extra = ['ShortcutColumn']
+ self.for_naming = ['ShortcutColumn']
+ self.thermo_pack_req = True
+
self.parameters = ['HKey', 'LKey', 'HKey_x_pc', 'LKey_x_pc', 'Ctype', 'Pcond', 'Preb', 'RR']
+ self.result_parameters = ['RRmin', 'Ntmin', 'Nt', 'Intray', 'Fliqstrip', 'Fliqrec', 'Fvapstrip', 'Fvaprec', 'Qc', 'Qr']
type(self).counter += 1
self.variables = {
@@ -190,16 +197,28 @@ class ShortcutColumn(UnitOperation):
'HKey_x_pc' : {'name':'Heavy Key Mole Fraction', 'value':0.01, 'unit':'mol/s'},
'LKey_x_pc' : {'name':'Light Key Mole Fraction', 'value':0.01, 'unit':'mol/s'},
'Ctype' : {'name':'Condensor Type', 'value':None, 'unit':''},
- 'thermo_package' : {'name':'Thermo Package', 'value':'Raoults_Law', 'unit':''},
+ 'thermo_package' : {'name':'Thermo Package', 'value':'Raoults_Law', 'unit':''},
'Pcond' : {'name':'Condensor Pressure', 'value':101325, 'unit':'Pa'},
'Preb' : {'name':'Reboiler Pressure', 'value':101325, 'unit':'Pa'},
'RR' : {'name':'Reflux Ratio', 'value':1.5, 'unit':''},
+
+ 'RRmin' : {'name':'Minimum Reflux Ratio', 'value': None , 'unit':''},
+ 'Ntmin' : {'name':'Minimum Number of Stages', 'value': None, 'unit':''},
+ 'Nt' : {'name':'Actual Number of Stages', 'value': None, 'unit':''},
+ 'Intray' : {'name':'Optimal Feed Stage', 'value': None, 'unit':''},
+ 'Fliqstrip' : {'name':'Stripping Liquid', 'value': None, 'unit':'mol/s'},
+ 'Fliqrec' : {'name':'Rectification Liquid', 'value': None, 'unit':'mol/s'},
+ 'Fvapstrip' : {'name':'Stripping Vapor', 'value': None, 'unit':'mol/s'},
+ 'Fvaprec' : {'name':'Recification Vapour', 'value': None, 'unit':'mol/s'},
+ 'Qc' : {'name':'Conderser Duty', 'value': None, 'unit':'W'},
+ 'Qr' : {'name':'Reboiler Duty', 'value': None, 'unit':'W'},
+
}
def param_setter(self,params):
print("param_setter ", params)
- self.variables['HKey']['value'] = params[0]
- self.variables['LKey']['value'] = params[1]
+ self.variables['HKey']['value'] = self.compounds.index(params[0]) + 1
+ self.variables['LKey']['value'] = self.compounds.index(params[1]) + 1
self.variables['HKey_x_pc']['value'] = params[2]
self.variables['LKey_x_pc']['value'] = params[3]
self.variables['Ctype']['value'] = params[4]
@@ -209,6 +228,21 @@ class ShortcutColumn(UnitOperation):
print(self.variables)
+ def OM_Flowsheet_Equation(self):
+ self.OM_data_eqn = ''
+
+ self.OM_data_eqn += ('connect(' + self.name + '.In,' + self.input_stms[0].name + '.Out);\n')
+
+ strcount = 1
+ for strm in self.output_stms:
+ self.OM_data_eqn += ('connect(' + strm.name + '.In,' + self.name + '.Out' + str(strcount) + ');\n')
+ strcount += 1
+
+ self.OM_data_eqn += (self.name + '.x_pc[2, ' + self.name + '.HKey] = ' + str(self.variables['HKey_x_pc']['value']) + ';\n')
+ self.OM_data_eqn += (self.name + '.x_pc[3, ' + self.name + '.LKey] = ' + str(self.variables['LKey_x_pc']['value']) + ';\n')
+
+ return self.OM_data_eqn
+
class DistillationColumn(UnitOperation):
def __init__(self,name='DistillationColumn'):