summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpravindalve2020-08-11 19:08:57 +0530
committerGitHub2020-08-11 19:08:57 +0530
commitb31cf75d9362412e755fce76f61d73eab1e7da14 (patch)
tree0ab99a88893f8b0a7c18138c0eec0c806654cf1a
parentd3bed1ef7150f8e493ebaed3b841b1fe781e974d (diff)
parent4cffaf3d0d29ee1f2d31601dd1571c7de40a8c5f (diff)
downloadChemical-Simulator-GUI-b31cf75d9362412e755fce76f61d73eab1e7da14.tar.gz
Chemical-Simulator-GUI-b31cf75d9362412e755fce76f61d73eab1e7da14.tar.bz2
Chemical-Simulator-GUI-b31cf75d9362412e755fce76f61d73eab1e7da14.zip
Merge pull request #4 from pravindalve/master
Updates and Bug Fixes
-rw-r--r--.gitignore3
-rw-r--r--Container.py83
-rw-r--r--DockWidgets/DockWidget.py126
-rw-r--r--DockWidgets/DockWidget.ui4
-rw-r--r--DockWidgets/DockWidgetCompoundSeparator.py7
-rw-r--r--DockWidgets/DockWidgetCompressorExpander.py146
-rw-r--r--DockWidgets/DockWidgetCompressorExpander.ui214
-rw-r--r--DockWidgets/DockWidgetDistillationColumn.py64
-rw-r--r--DockWidgets/DockWidgetDistillationColumn.ui36
-rw-r--r--DockWidgets/DockWidgetFlash.py14
-rw-r--r--DockWidgets/DockWidgetMaterialStream.py139
-rw-r--r--DockWidgets/DockWidgetMaterialStream.ui57
-rw-r--r--DockWidgets/DockWidgetMixer.py14
-rw-r--r--DockWidgets/DockWidgetShortcutColumn.py64
-rw-r--r--DockWidgets/DockWidgetShortcutColumn.ui221
-rw-r--r--DockWidgets/DockWidgetSplitter.py27
-rw-r--r--DockWidgets/__pycache__/DockWidget.cpython-37.pycbin6125 -> 4323 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pycbin3187 -> 3047 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pycbin4204 -> 4893 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pycbin2913 -> 2719 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pycbin8757 -> 8308 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pycbin2233 -> 1983 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pycbin3382 -> 4417 bytes
-rw-r--r--DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pycbin2764 -> 2501 bytes
-rw-r--r--Graphics.py87
-rw-r--r--OMChem/Flowsheet.py31
-rw-r--r--Simulator/Simulator/UnitOperations/Splitter.mo4
-rw-r--r--Streams.py81
-rw-r--r--ToDoList.txt20
-rw-r--r--Undo.datbin64582 -> 24066 bytes
-rw-r--r--UnitOperations.py231
-rw-r--r--mainApp.py9
-rw-r--r--thermopackage.txt2
33 files changed, 992 insertions, 692 deletions
diff --git a/.gitignore b/.gitignore
index 7796682..f1134d7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@ Simulator/simulateEQN.mos
__pycache__/*
.idea/*
DockWidgets/__pycache__/*
-undo.dat \ No newline at end of file
+undo.dat
+test.py
diff --git a/Container.py b/Container.py
index 26f6250..c77d631 100644
--- a/Container.py
+++ b/Container.py
@@ -1,21 +1,10 @@
-from OMChem.Flowsheet import Flowsheet
-from ComponentSelector import *
from collections import defaultdict
-from PyQt5.QtCore import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtGui import *
-from PyQt5.uic import loadUiType
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsEllipseItem ,QGraphicsPixmapItem,QApplication, QGraphicsView, QGraphicsScene, QHBoxLayout, QWidget, QLabel
-from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent
-import PyQt5.QtCore as QtCore
-import PyQt5.QtWidgets as QtWidgets
import datetime
-import itertools
-import json
import pickle
import os
-import sys
+
+from OMChem.Flowsheet import Flowsheet
+from ComponentSelector import *
from Graphics import *
class Container():
@@ -40,41 +29,10 @@ class Container():
time = str(now.hour) + ":" + str(now.minute) + ":" +str(now.second)
return time
- # def updateConn(self,key,value):
- # self.conn[key].append(value)
- # self.msg.append("<span style=\"color:blue\">["+str(self.current_time())+"]<b> "+key.name+" </b> output is connected to input of<b> "+value.name +" </b></span>")
- #
- # def connection(self):
- # try:
- # self.op.clear()
- # self.ip.clear()
- # self.opl.clear()
- # stm = ['MaterialStream','EngStm']
- # for i in self.conn:
- # if i.type not in stm:
- # self.op[i]=self.conn[i]
- #
- # for j in range(len(self.conn[i])):
- # if self.conn[i][j].type not in stm:
- # self.ip[self.conn[i][j]].append(i)
- #
- # for i in self.op:
- # i.connect(InputStms=self.ip[i],OutputStms=self.op[i])
- #
- # self.opl.append([self.op[i] for i in self.op])
- # self.opl=flat_list(flat_list(self.opl))
- # except Exception as e:
- # print(e)
-
- # @staticmethod
- # def addUnitOpObj(obj):
- # self.unit_operations.append(obj)
-
def add_unit_operation(self, obj):
box = None
self.obj = obj
self.scene = self.graphics.get_scene()
- #self.graphicsView = graphicsView
box = self.graphics.create_node_item(self.obj, self)
self.scene.addItem(box)
box.setPos(2500-30, 2500-30)
@@ -93,19 +51,14 @@ class Container():
'''
def delete(self,l):
for item in l:
- print('deleted objects ', item)
self.scene.removeItem(item)
for i in dock_widget_lst:
if i.name == item.name:
i.hide()
del i
break
- for i in dock_widget_lst:
- print(i.name)
- print("delete ", dock_widget_lst)
+
if hasattr(item,'input'):
- print("In input ")
- print(item.input)
for x in item.input:
if x.new_line:
self.scene.removeItem(x.new_line)
@@ -114,8 +67,6 @@ class Container():
self.scene.removeItem(x.other_line)
del x.other_line
if hasattr(item,'output'):
- print("in output ")
- print(item.output)
for x in item.output:
if x.new_line:
self.scene.removeItem(x.new_line)
@@ -144,7 +95,7 @@ class Container():
if(i.name==name):
return i
- def add_aompounds(self,comp):
+ def add_compounds(self,comp):
self.compounds = comp
def add_thermo_package(self,thermo):
@@ -164,6 +115,14 @@ class Container():
self.msg.append("<span style=\"color:red\">"+stdout+"</span>")
def simulate(self,mode):
+
+ for i in self.graphics.scene.items():
+ if (isinstance(i, NodeItem)):
+ try:
+ i.dock_widget.clear_results()
+ except AttributeError:
+ pass
+
print("SIMULATE")
print(mode)
self.compounds = compound_selected
@@ -171,15 +130,15 @@ class Container():
self.flowsheet.add_compound_list(self.compounds)
print("######## connection master#########\n",self.conn)
for i in self.unit_operations :
- print("here",i)
- self.flowsheet.add_unit_operations(i)
+ self.flowsheet.add_unit_operations(i)
+
if mode=='SM':
self.msg.append("<span>["+str(self.current_time())+"] Simulating in <b>Sequential</b> mode ... </span>")
self.flowsheet.simulate_SM(self.ip,self.op)
self.msg_browser()
self.result=self.flowsheet.result_data
- print("under SEQ mode simulation")
+
elif mode=='EQN':
self.msg.append("<span>["+str(self.current_time())+"] Simulating in <b>equation</b> mode ... </span>")
self.flowsheet.simulate_EQN()
@@ -187,11 +146,11 @@ class Container():
self.result=self.flowsheet.result_data
print("under Eqn mode simulation")
- try:
- DockWidget.show_result(NodeItem.get_dock_widget())
- except AttributeError:
- print(NodeItem.name + ' does not have dockwidget')
- pass
+ DockWidget.show_result(NodeItem.get_dock_widget())
+
+ # for i in self.graphics.scene.items():
+ # if (isinstance(i, NodeItem)):
+ # i.update_tooltip()
def flat_list(lst):
flat_lst=[]
diff --git a/DockWidgets/DockWidget.py b/DockWidgets/DockWidget.py
index 6fc7731..b3845bb 100644
--- a/DockWidgets/DockWidget.py
+++ b/DockWidgets/DockWidget.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidget.ui')
@@ -20,15 +17,13 @@ class DockWidget(QDockWidget,ui_dialog):
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.dict = {} # a dictionary
self.container = container
# input data tab
@@ -61,72 +56,18 @@ class DockWidget(QDockWidget,ui_dialog):
try:
print("input_params_list ", self.input_dict)
for c,i in enumerate(self.input_dict):
+ print(i)
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
-
-
+ 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
except Exception as e:
print(e)
@@ -135,40 +76,11 @@ class DockWidget(QDockWidget,ui_dialog):
def param(self):
try:
- self.dict={}
+ 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()):
@@ -187,11 +99,15 @@ class DockWidget(QDockWidget,ui_dialog):
@staticmethod
def show_result(lst):
- #DockWidget1.flag = True
for i in lst:
- i.results_category(i.name)
- #i.show()
+ 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
@@ -217,4 +133,6 @@ class DockWidget(QDockWidget,ui_dialog):
self.tableWidget.resizeColumnsToContents()
except Exception as e:
- print(e) \ No newline at end of file
+ print(e)
+
+ \ No newline at end of file
diff --git a/DockWidgets/DockWidget.ui b/DockWidgets/DockWidget.ui
index 5851d71..ba6dc52 100644
--- a/DockWidgets/DockWidget.ui
+++ b/DockWidgets/DockWidget.ui
@@ -101,7 +101,7 @@
<x>10</x>
<y>100</y>
<width>331</width>
- <height>321</height>
+ <height>271</height>
</rect>
</property>
<property name="title">
@@ -117,7 +117,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>430</y>
+ <y>380</y>
<width>331</width>
<height>21</height>
</rect>
diff --git a/DockWidgets/DockWidgetCompoundSeparator.py b/DockWidgets/DockWidgetCompoundSeparator.py
index 1818290..6de61a5 100644
--- a/DockWidgets/DockWidgetCompoundSeparator.py
+++ b/DockWidgets/DockWidgetCompoundSeparator.py
@@ -21,18 +21,13 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
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')
@@ -81,7 +76,6 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
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
@@ -91,7 +85,6 @@ class DockWidgetCompoundSeparator(QDockWidget,ui_dialog):
self.dict.append(self.input_dict[j+i+1].text())
j += 1
- print("param ", self.dict)
self.obj.param_setter(self.dict)
self.hide()
diff --git a/DockWidgets/DockWidgetCompressorExpander.py b/DockWidgets/DockWidgetCompressorExpander.py
new file mode 100644
index 0000000..841b850
--- /dev/null
+++ b/DockWidgets/DockWidgetCompressorExpander.py
@@ -0,0 +1,146 @@
+from PyQt5.QtCore import *
+from PyQt5.QtWidgets import *
+from PyQt5.QtGui import *
+from PyQt5.uic import loadUiType
+from ComponentSelector import *
+from Graphics import *
+
+ui_dialog,_ = loadUiType('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)
+ 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)
+
+ \ No newline at end of file
diff --git a/DockWidgets/DockWidgetCompressorExpander.ui b/DockWidgets/DockWidgetCompressorExpander.ui
new file mode 100644
index 0000000..372fc0b
--- /dev/null
+++ b/DockWidgets/DockWidgetCompressorExpander.ui
@@ -0,0 +1,214 @@
+<?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>111</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>280</y>
+ <width>331</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Submit</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>220</y>
+ <width>331</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Thermo Package</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cbTP">
+ <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>
+ <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/DockWidgetDistillationColumn.py b/DockWidgets/DockWidgetDistillationColumn.py
index 65e9932..3255015 100644
--- a/DockWidgets/DockWidgetDistillationColumn.py
+++ b/DockWidgets/DockWidgetDistillationColumn.py
@@ -20,7 +20,6 @@ class DockWidgetDistillationColumn(QDockWidget,ui_dialog):
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()
@@ -34,10 +33,18 @@ class DockWidgetDistillationColumn(QDockWidget,ui_dialog):
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']+":")
+
+ l1 = QLineEdit()
+ self.lay1.addWidget(QLabel(self.obj.variables['Nt']['name'] + " :"), 0 ,0, alignment=Qt.AlignLeft)
+ self.lay1.addWidget(l1,0,1, alignment=Qt.AlignCenter)
+ self.input_dict.append(l1)
+
+ for i in range(self.obj.variables['Ni']['value']):
+ print(i)
+ l = QLineEdit()
+ self.lay1.addWidget(QLabel(self.obj.variables['InT_s']['name'] +" " + str(i+1) + " location :"),i+1,0, alignment=Qt.AlignLeft)
+ self.lay1.addWidget(l,i+1,1, alignment=Qt.AlignCenter)
+ self.input_dict.append(l)
# tab 2
self.l4.setText(self.obj.variables['Ctype']['name']+":")
@@ -55,8 +62,13 @@ class DockWidgetDistillationColumn(QDockWidget,ui_dialog):
for j in self.obj.compounds:
self.cb2.addItem(str(j))
self.cb2.setDisabled(True)
- self.cb1.currentIndexChanged.connect(self.fun2)
-
+ 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']+":")
@@ -72,7 +84,12 @@ class DockWidgetDistillationColumn(QDockWidget,ui_dialog):
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]
+ 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.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)
@@ -95,10 +112,35 @@ class DockWidgetDistillationColumn(QDockWidget,ui_dialog):
def param(self):
try:
self.dict= []
+ temp = 0
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()]
+ 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)
print("param ", self.dict)
self.obj.param_setter(self.dict)
diff --git a/DockWidgets/DockWidgetDistillationColumn.ui b/DockWidgets/DockWidgetDistillationColumn.ui
index 0cb1043..e603071 100644
--- a/DockWidgets/DockWidgetDistillationColumn.ui
+++ b/DockWidgets/DockWidgetDistillationColumn.ui
@@ -78,36 +78,12 @@
<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>
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
</layout>
</item>
</layout>
diff --git a/DockWidgets/DockWidgetFlash.py b/DockWidgets/DockWidgetFlash.py
index 6098b27..4e1c5e3 100644
--- a/DockWidgets/DockWidgetFlash.py
+++ b/DockWidgets/DockWidgetFlash.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidgetFlash.ui')
@@ -20,16 +17,13 @@ class DockWidgetFlash(QDockWidget,ui_dialog):
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.dict = [] # a list
def input_params_list(self):
- try:
- print("input_params_list ", self.input_dict)
-
- self.l1.setText(self.obj.variables['thermoPackage']['name']+":")
+ 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))
@@ -63,7 +57,7 @@ class DockWidgetFlash(QDockWidget,ui_dialog):
def param(self):
try:
- self.dict={}
+ 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)
diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py
index 78959fc..a661362 100644
--- a/DockWidgets/DockWidgetMaterialStream.py
+++ b/DockWidgets/DockWidgetMaterialStream.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidgetMaterialStream.ui')
@@ -24,9 +21,8 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.modes()
self.comboBox.currentIndexChanged.connect(self.mode_selection)
- print("constructor ", self.input_dict)
self.pushButton_2.clicked.connect(self.param)
- self.dict = {}
+ self.dict = {} # a dictionary
self.name_type = None
self.container = container
@@ -36,17 +32,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.lTreeWidget.setHeaderItem(header)
self.vTreeWidget.setHeaderItem(header)
- self.mTreeWidget.itemClicked.connect(lambda : self.printer(self.mTreeWidget.currentItem()))
- self.lTreeWidget.itemClicked.connect(lambda : self.printer(self.lTreeWidget.currentItem()))
- self.vTreeWidget.itemClicked.connect(lambda : self.printer(self.vTreeWidget.currentItem()))
-
-
- # 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
@@ -67,55 +52,33 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.input_params_list()
def input_params_list(self):
- try:
- print("input_params_list ", self.input_dict)
+ try:
for c,i in enumerate(self.input_dict):
- if(i=="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"):
+ if(i=="x_pc"):
noc = len(compound_selected)
print(noc)
self.x_pclist.clear()
-
+
gp = QGroupBox("Mole Fractions")
lay = QGridLayout()
for j in range(noc):
l = QLineEdit()
if self.input_dict[i] != '':
- l.setText(str(self.obj.variables[compound_selected[j]]['value']))
+ l.setText(str(self.obj.variables['x_pc']['value'][j]))
+ print('l = ', str(self.obj.variables['x_pc']['value'][j]))
+
self.input_dict[i] = "x_pc"
lay.addWidget(QLabel(str(compound_selected[j])+":"),j,0, alignment=Qt.AlignLeft)
lay.addWidget(l,j,1, alignment=Qt.AlignCenter)
- self.x_pclist.append(l)
-
+ self.x_pclist.append(l)
gp.setLayout(lay)
- self.formLayout.addRow(gp)
+ self.formLayout.addRow(gp)
else:
print("elseloop")
l = QLineEdit()
if self.input_dict[i] != None:
l.setText(str(self.input_dict[i]))
+
lay = QGridLayout()
lay.addWidget(QLabel(i+":"),0,0, alignment=Qt.AlignLeft)
lay.addWidget(l,0,1, alignment=Qt.AlignCenter)
@@ -124,8 +87,13 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
else:
lay.addWidget(QLabel("mol/s"),0,2, alignment=Qt.AlignCenter)
self.formLayout.addRow(lay)
- self.input_dict[i] = l
-
+ self.input_dict[i] = l
+
+ 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)
@@ -135,22 +103,10 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
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"):
+ print(i)
+ if(i =="x_pc"):
l=[]
mf = []
total_moles = 0
@@ -166,14 +122,16 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.obj.variables[compound_selected[c]]['value'] = str(float(l[c])/total_moles)
self.x_pclist[c].setText(mf[-1])
self.dict[i] = ",".join(mf)
+ elif (i == "Thermo Package"):
+ self.dict[i] = self.input_dict[i].currentText()
else:
if (self.input_dict[i].text()):
self.dict[i] = self.input_dict[i].text()
else:
- print(self.input_dict[i].text())
+ print(self.input_dict[i])
self.show_error()
break
-
+
print("param ", self.dict)
self.obj.param_setter(self.dict)
self.hide()
@@ -181,14 +139,19 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
except Exception as e:
print(e)
-
@staticmethod
def show_result(lst):
- #DockWidget1.flag = True
for i in lst:
i.results_category(i.name)
- #i.show()
-
+
+ def clear_results(self):
+ self.mTreeWidget.clear()
+ self.mTableWidget.setRowCount(0)
+ self.lTreeWidget.clear()
+ self.lTableWidget.setRowCount(0)
+ self.vTreeWidget.clear()
+ self.vTableWidget.setRowCount(0)
+
# result data tab
def results_category(self,name):
flag = True
@@ -197,6 +160,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
result=self.container.result
obj = self.container.fetch_object(name)
+
d = {"Mole Fraction":"x_pc", "Mass Fraction":"xm_pc", "Mole Flow":"F_pc", "Mass Flow":"Fm_pc"}
lst = list(d.keys())
klst = list(d.values())
@@ -206,21 +170,21 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
# Amounts Tab
if obj.type == 'MaterialStream':
- l = [] # list for basis names
+ ll = [] # list for basis names
for basis in d:
propertyname = name + '.' + d[basis]
print("basis ", basis, propertyname)
for i in result[0]:
if (propertyname in i):
- l.append(i)
- print(l)
+ ll.append(i)
+ print(ll)
j = 0
t = 0
namee = klst[j]
print("namee ", namee)
- for i,k in enumerate(l):
+ for i,k in enumerate(ll):
ind = result[0].index(k)
print("index ", ind)
print("str ", k)
@@ -262,7 +226,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
child = QTreeWidgetItem(vroot, [compound_selected[t], str(resultval),obj.variables[k.split('.')[1]]['unit']])
t += 1
flag = False
- #print(obj.variables)
# Phase Properties Tab
phaseResLst = []
@@ -314,7 +277,6 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.vTableWidget.setItem(vrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit']))
self.vTableWidget.resizeColumnsToContents()
if not '[' in val:
- #print(p[val.split('.')[1]])
print(obj.variables[val.split('.')[1]]['name'])
mrowPosition = self.mTableWidget.rowCount()
self.mTableWidget.insertRow(mrowPosition)
@@ -323,10 +285,27 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.mTableWidget.setItem(mrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit']))
self.mTableWidget.resizeColumnsToContents()
- print(obj.variables)
- except Exception as e:
- print(e)
-
+ # updating the input data from fetched results from simulation
+ print(self.comboBox.currentText())
+
+ self.input_dict = {}
+ self.input_dict = self.obj.param_getter(self.comboBox.currentText())
+ print("before", self.input_dict)
+ self.input_dict.pop("x_pc")
+ temp = self.input_dict.pop('thermo_package')
+ for i in range(len(compound_selected)):
+ print(i)
+ self.input_dict['x_pc[1,' + str(i+1) + ']'] = self.obj.variables['x_pc[1,' + str(i+1) +']']['value']
+ self.input_dict['thermo_package'] = temp
+ print("after", self.input_dict)
+
+ # chaning index for updating the input data
+ indexx = self.comboBox.currentIndex()
+ self.comboBox.setCurrentIndex(1)
+ self.comboBox.setCurrentIndex(indexx)
- \ No newline at end of file
+
+
+ except Exception as e:
+ print(e) \ No newline at end of file
diff --git a/DockWidgets/DockWidgetMaterialStream.ui b/DockWidgets/DockWidgetMaterialStream.ui
index 8995ba6..a442eee 100644
--- a/DockWidgets/DockWidgetMaterialStream.ui
+++ b/DockWidgets/DockWidgetMaterialStream.ui
@@ -98,7 +98,7 @@
<x>10</x>
<y>100</y>
<width>331</width>
- <height>321</height>
+ <height>221</height>
</rect>
</property>
<property name="title">
@@ -114,7 +114,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>430</y>
+ <y>390</y>
<width>331</width>
<height>21</height>
</rect>
@@ -123,6 +123,51 @@
<string>Submit</string>
</property>
</widget>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>330</y>
+ <width>331</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Thermo Package</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cbTP">
+ <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>
<widget class="QWidget" name="tab_2">
<attribute name="title">
@@ -273,8 +318,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>335</width>
- <height>494</height>
+ <width>151</width>
+ <height>128</height>
</rect>
</property>
<property name="styleSheet">
@@ -362,8 +407,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>335</width>
- <height>494</height>
+ <width>151</width>
+ <height>128</height>
</rect>
</property>
<property name="styleSheet">
diff --git a/DockWidgets/DockWidgetMixer.py b/DockWidgets/DockWidgetMixer.py
index 28cbff0..6c46c39 100644
--- a/DockWidgets/DockWidgetMixer.py
+++ b/DockWidgets/DockWidgetMixer.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidgetMixer.ui')
@@ -21,16 +18,13 @@ class DockWidgetMixer(QDockWidget,ui_dialog):
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)
-
+ 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'])
@@ -38,8 +32,6 @@ class DockWidgetMixer(QDockWidget,ui_dialog):
self.cb2.addItem(str(i))
self.l2.setText(self.obj.variables['outPress']['name']+":")
-
-
self.input_dict = [self.le1, self.cb2]
except Exception as e:
@@ -51,9 +43,7 @@ class DockWidgetMixer(QDockWidget,ui_dialog):
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.dict = [int(self.input_dict[0].text()), self.input_dict[1].currentText()]
self.obj.param_setter(self.dict)
self.hide()
diff --git a/DockWidgets/DockWidgetShortcutColumn.py b/DockWidgets/DockWidgetShortcutColumn.py
index af81441..2b7dfae 100644
--- a/DockWidgets/DockWidgetShortcutColumn.py
+++ b/DockWidgets/DockWidgetShortcutColumn.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidgetShortcutColumn.ui')
@@ -20,7 +17,6 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
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 = []
@@ -30,17 +26,15 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
# input data tab
def input_params_list(self):
- try:
- print("input_params_list ", self.input_dict)
-
+ 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.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'])
@@ -62,7 +56,13 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
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]
+ 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.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)
@@ -73,25 +73,49 @@ class DockWidgetShortcutColumn(QDockWidget,ui_dialog):
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.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)
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()
-
+ 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):
- 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()
+ except Exception as e:
+ print(e) \ No newline at end of file
diff --git a/DockWidgets/DockWidgetShortcutColumn.ui b/DockWidgets/DockWidgetShortcutColumn.ui
index c66e699..f79c27e 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">
@@ -50,7 +50,7 @@
<x>8</x>
<y>13</y>
<width>331</width>
- <height>237</height>
+ <height>261</height>
</rect>
</property>
<property name="sizePolicy">
@@ -65,8 +65,8 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="4" column="2">
- <widget class="QComboBox" name="cb5">
+ <item row="3" column="2">
+ <widget class="QLineEdit" name="le4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -75,15 +75,18 @@
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="l4">
- <property name="text">
- <string>TextLabel</string>
+ <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="3" column="3">
- <widget class="QLabel" name="u4">
+ <item row="6" column="3">
+ <widget class="QLabel" name="u7">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -95,21 +98,25 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="l1">
+ <item row="6" column="0">
+ <widget class="QLabel" name="l7">
+ <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="Preferred">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<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">
+ <item row="5" column="3">
+ <widget class="QLabel" name="u6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -121,15 +128,8 @@
</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">
+ <item row="7" column="2">
+ <widget class="QLineEdit" name="le8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -138,29 +138,25 @@
</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">
+ <item row="7" column="0">
+ <widget class="QLabel" name="l8">
<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>
+ <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="5" column="2">
- <widget class="QLineEdit" name="le6">
+ <item row="0" column="2">
+ <widget class="QComboBox" name="cb1">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -169,28 +165,25 @@
</property>
</widget>
</item>
- <item row="6" column="0">
- <widget class="QLabel" name="l7">
+ <item row="3" column="0">
+ <widget class="QLabel" name="l4">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
- <item row="6" column="3">
- <widget class="QLabel" name="u7">
+ <item row="4" column="2">
+ <widget class="QComboBox" name="cb5">
<property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<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">
+ <item row="2" column="2">
+ <widget class="QLineEdit" name="le3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -199,18 +192,28 @@
</property>
</widget>
</item>
- <item row="3" column="2">
- <widget class="QLineEdit" name="le4">
+ <item row="2" column="0">
+ <widget class="QLabel" name="l3">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="u3">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
</widget>
</item>
- <item row="5" column="3">
- <widget class="QLabel" name="u6">
+ <item row="3" column="3">
+ <widget class="QLabel" name="u4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -222,40 +225,37 @@
</property>
</widget>
</item>
- <item row="6" column="2">
- <widget class="QLineEdit" name="le7">
+ <item row="0" column="0">
+ <widget class="QLabel" name="l1">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
</widget>
</item>
- <item row="7" column="0">
- <widget class="QLabel" name="l8">
+ <item row="5" column="0">
+ <widget class="QLabel" name="l6">
<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>
+ <item row="4" column="0">
+ <widget class="QLabel" name="l5">
+ <property name="text">
+ <string>TextLabel</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>
+ <item row="1" column="0">
+ <widget class="QLabel" name="l2">
+ <property name="text">
+ <string>TextLabel</string>
</property>
</widget>
</item>
@@ -267,7 +267,7 @@
<property name="geometry">
<rect>
<x>10</x>
- <y>250</y>
+ <y>350</y>
<width>331</width>
<height>23</height>
</rect>
@@ -282,11 +282,76 @@
<string>Submit</string>
</property>
</widget>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>280</y>
+ <width>331</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="2" column="0">
+ <widget class="QLabel" name="l9">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="cb6"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</widget>
<widget class="QWidget" name="tab_2">
<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/DockWidgetSplitter.py b/DockWidgets/DockWidgetSplitter.py
index 262bd45..303d166 100644
--- a/DockWidgets/DockWidgetSplitter.py
+++ b/DockWidgets/DockWidgetSplitter.py
@@ -2,10 +2,7 @@ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
-import pandas as pd
-from functools import partial
from ComponentSelector import *
-from collections import defaultdict
from Graphics import *
ui_dialog,_ = loadUiType('DockWidgets/DockWidgetSplitter.ui')
@@ -20,23 +17,19 @@ class DockWidgetSplitter(QDockWidget,ui_dialog):
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'])
+ 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'])
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 :")
@@ -45,19 +38,18 @@ class DockWidgetSplitter(QDockWidget,ui_dialog):
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':
+ if self.cb2.currentText() == 'Molar_Flow':
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')
+ elif self.cb2.currentText() == 'Mass_Flow':
+ self.u3.setText('g/s')
+ self.u4.setText('g/s')
else:
self.u3.setText('')
self.u4.setText('')
@@ -68,11 +60,8 @@ class DockWidgetSplitter(QDockWidget,ui_dialog):
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/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc
index 80d0ae1..86045c1 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 e5023b1..08716b1 100644
--- a/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetCompoundSeparator.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc
index 0584a29..55be9b4 100644
--- a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc
index 7eaaef7..6828ab1 100644
--- a/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetFlash.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
index a99f092..a8c9f80 100644
--- a/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetMaterialStream.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc
index 52a0ca1..460aa1b 100644
--- a/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetMixer.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
index 85449f8..13f8328 100644
--- a/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetShortcutColumn.cpython-37.pyc
Binary files differ
diff --git a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc
index 19250d9..fea33a2 100644
--- a/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc
+++ b/DockWidgets/__pycache__/DockWidgetSplitter.cpython-37.pyc
Binary files differ
diff --git a/Graphics.py b/Graphics.py
index 0fa3306..8d7c220 100644
--- a/Graphics.py
+++ b/Graphics.py
@@ -1,20 +1,10 @@
-from functools import partial
-from collections import defaultdict
-import sys
-import numpy as np
-from OMChem.Flowsheet import Flowsheet
-import pandas as pd
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
-from PyQt5.QtGui import QTextDocument ,QTextCursor ,QTextCharFormat ,QFont ,QPixmap
-from PyQt5.uic import loadUiType
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsEllipseItem ,QGraphicsPixmapItem,QApplication, QGraphicsView, QGraphicsScene, QHBoxLayout, QWidget, QLabel
-from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent, QIcon
+from PyQt5.QtGui import *
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
-from ComponentSelector import *
+
from DockWidgets.DockWidget import *
from DockWidgets.DockWidgetMaterialStream import *
from DockWidgets.DockWidgetDistillationColumn import *
@@ -23,13 +13,12 @@ from DockWidgets.DockWidgetMixer import *
from DockWidgets.DockWidgetSplitter import *
from DockWidgets.DockWidgetFlash import *
from DockWidgets.DockWidgetCompoundSeparator import *
-
-import datetime
+from DockWidgets.DockWidgetCompressorExpander import *
from Container import *
-import Container
from Streams import *
from UnitOperations import *
+from ComponentSelector import *
class Graphics(QDialog, QtWidgets.QGraphicsItem):
@@ -49,49 +38,31 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem):
return ComponentSelector(self)
def create_node_item(self,unit_operation, container):
- print("in create node item function")
return NodeItem(unit_operation, container, self.graphicsView)
-
- # def boundingRect(self):
- # return QtCore.QRectF(self.rect)
def load_canvas(self, obj, container):
stm = ['MaterialStream','EngStm']
- print('in load canvas')
compounds = obj[-1]
obj.pop()
ComponentSelector.set_compounds(compounds)
for i in obj:
- print("in for loop", i)
if(i in self.unit_operations):
pass
else:
self.unit_operations.append(i)
print(self.unit_operations)
new_box = self.create_node_item(i, container)
- print('after createing node item')
new_box.setPos(i.pos.toPoint().x(), i.pos.toPoint().y())
self.scene.addItem(new_box)
for i in obj:
- print('in i obj line')
if i.type == "MaterialStream":
- print('in i obj line in if')
- # print(eval(i.type))
- # eval(i.type).counter += 1
- # print(eval(i.type).counter)
+ print(eval(i.type))
elif i.type not in stm:
- print('in i obj line in else')
ip = i.input_stms
op = i.output_stms
- print(ip)
- print(op)
- # print(eval(i.type))
- # eval(i.type).counter += 1
- # print(eval(i.type).counter)
for j in ip:
- print('in j in ip')
pointA = NodeItem.get_instances(j.name)
pointB = NodeItem.get_instances(i.name)
rect = pointA.output[0].boundingRect()
@@ -288,17 +259,16 @@ class NodeSocket(QtWidgets.QGraphicsItem):
self.new_line=None
self.other_line=None
- # Brush.
+ # Brush
self.brush = QtGui.QBrush()
self.brush.setStyle(QtCore.Qt.SolidPattern)
- self.brush.setColor(QtGui.QColor(220,220,220,220)) #180,20,90,255
- # Pen.
+ self.brush.setColor(QtGui.QColor(220,220,220,220))
+ # Pen
self.pen = QtGui.QPen()
self.pen.setStyle(QtCore.Qt.SolidLine)
self.pen.setWidth(1)
- self.pen.setColor(QtGui.QColor(0,70,70,255)) #20,20,20,255
-
- # Lines.
+ self.pen.setColor(QtGui.QColor(0,70,70,255))
+ # Lines
self.out_lines = []
self.in_lines = []
@@ -403,7 +373,7 @@ class NodeSocket(QtWidgets.QGraphicsItem):
Container.push('Undo', data)
except Exception as e:
print(e)
-
+
def get_center(self):
rect = self.boundingRect()
center = QtCore.QPointF(rect.x() + rect.width()/2, rect.y() + rect.height()/2)
@@ -411,7 +381,6 @@ class NodeSocket(QtWidgets.QGraphicsItem):
return center
def hoverEnterEvent(self, event):
- print("in hover enter")
cursor = QCursor( Qt.CrossCursor )
QApplication.instance().setOverrideCursor(cursor)
@@ -441,14 +410,12 @@ class NodeItem(QtWidgets.QGraphicsItem):
l = ['Splitter','Mixer', 'DistillationColumn', 'Flash', 'CompoundSeparator', 'ShortcutColumn']
stm = ['MaterialStream', 'EnergyStream']
super(NodeItem, self).__init__()
- print("in node item")
self.obj = unit_operation
self.container = container
self.graphicsView = graphicsView
self.name = self.obj.name
self.type = self.obj.type
- print('Before obj.modes_list')
if (self.obj.modes_list):
default_tooltip = f"{self.name}\n\n"
@@ -460,7 +427,6 @@ class NodeItem(QtWidgets.QGraphicsItem):
self.nin = self.obj.no_of_inputs
self.nop = self.obj.no_of_outputs
- print('Before mixer')
if self.obj.type == 'Mixer':
text, ok = QInputDialog.getText(self.container.graphicsView, 'Mixer', 'Enter number of input:')
if ok and text:
@@ -472,18 +438,24 @@ class NodeItem(QtWidgets.QGraphicsItem):
if ok and text:
self.nop = int(text)
self.obj.no_of_outputs = self.nop
- self.obj.variables['NOO']['value'] = self.nop
+ self.obj.variables['No']['value'] = self.nop
+ elif self.obj.type == 'DistillationColumn':
+ text, ok = QInputDialog.getText(self.container.graphicsView, 'DistillationColumn', 'Enter number of input:')
+ if ok and text:
+ self.nin = int(text)
+ self.obj.no_of_inputs = self.nin
+ self.obj.variables['Ni']['value'] = self.nin
self.dock_widget = None
lst.append(self)
- print("before DockWidget")
if self.obj.type in l:
self.dock_widget = eval("DockWidget"+self.obj.type)(self.obj.name,self.obj.type,self.obj,self.container)
elif self.obj.type in stm:
self.dock_widget = eval("DockWidget"+self.obj.type)(self.obj.name,self.obj.type,self.obj,self.container)
+ elif self.obj.type == "AdiabaticCompressor" or self.obj.type == "AdiabaticExpander":
+ self.dock_widget = eval("DockWidgetCompressorExpander")(self.obj.name,self.obj.type,self.obj,self.container)
else:
self.dock_widget = DockWidget(self.obj.name,self.obj.type,self.obj,self.container)
- print('in dockwidget')
dock_widget_lst.append(self.dock_widget)
self.main_window= findMainWindow(self)
self.dock_widget.setFixedWidth(360)
@@ -492,12 +464,8 @@ class NodeItem(QtWidgets.QGraphicsItem):
self.main_window.addDockWidget(Qt.LeftDockWidgetArea, self.dock_widget)
self.dock_widget.hide()
- print("after dockwidget")
-
self.pic=QtGui.QPixmap("Icons/"+self.type+".png")
- # self.pic = QIcon("svg/Cooler.svg")
self.rect = QtCore.QRect(0,0,self.pic.width(),self.pic.height())
- # self.rect = QtCore.QRect(0,0,100,100)
self.text = QGraphicsTextItem(self)
f = QFont()
f.setPointSize(8)
@@ -514,7 +482,7 @@ class NodeItem(QtWidgets.QGraphicsItem):
self.brush = QtGui.QBrush()
self.brush.setStyle(QtCore.Qt.SolidPattern)
self.brush.setColor(QtGui.QColor(80,0,90,255))
- # Pen.
+ # Pen
self.pen = QtGui.QPen()
self.pen.setStyle(QtCore.Qt.SolidLine)
self.pen.setWidth(1)
@@ -528,8 +496,6 @@ class NodeItem(QtWidgets.QGraphicsItem):
# initializing the node sockets
self.input , self.output = self.initialize_sockets(self.type)
- print('after ndoe item')
-
def shape(self):
path = QtGui.QPainterPath()
path.addRect(self.boundingRect())
@@ -545,10 +511,8 @@ class NodeItem(QtWidgets.QGraphicsItem):
else:
painter.setPen(self.pen)
painter.drawPixmap(self.rect,self.pic)
- # painter.drawPixmap(self.rect, self.pic.pixmap(QSize(1000,1000)))
def initialize_sockets(self,type):
- print("inside initialization")
if(self.type=="Flash" or self.type=="CompoundSeparator"):
input = [NodeSocket(QtCore.QRect(5,(self.rect.height()*x/(self.nin+1)-2),4,4), self, 'in') for x in range(1,self.nin+1) ]
output = [NodeSocket(QtCore.QRect(self.rect.width()-9,(self.rect.height()*x*1/(self.nop+1)),4,4), self, 'op') for x in range(1,self.nop+1)]
@@ -586,18 +550,23 @@ class NodeItem(QtWidgets.QGraphicsItem):
line.pointB = line.target.get_center()
self.pos = event.scenePos()
self.obj.set_pos(self.pos)
- #print(self.name, self.pos)
def mouseDoubleClickEvent(self, event):
self.graphicsView.setInteractive(False)
if len(stack):
- print(stack)
stack[-1].hide()
self.dock_widget.show()
stack.append(self.dock_widget)
self.graphicsView.setInteractive(True)
+ def update_tooltip(self):
+ default_tooltip = f"{self.name}\n\n"
+ default_tooltip_dict = self.obj.param_getter(self.obj.modes_list[0])
+ for i, j in default_tooltip_dict.items():
+ if j is not None:
+ default_tooltip = default_tooltip + f" {i} : {j}\n"
+ self.setToolTip(default_tooltip)
def findMainWindow(self):
'''
diff --git a/OMChem/Flowsheet.py b/OMChem/Flowsheet.py
index ab271af..ab4d729 100644
--- a/OMChem/Flowsheet.py
+++ b/OMChem/Flowsheet.py
@@ -57,26 +57,21 @@ class Flowsheet():
self.process = Popen([self.omc_path, '-s',simpath], stdout=PIPE, stderr=PIPE)
self.stdout, self.stderr = self.process.communicate()
- #s = subprocess.check_output([self.omc_path, '-s',simpath])
- #print(s)
- #print("############### StdOut ################")
- print(self.stdout)
+
os.chdir(self.root_dir)
- #os.system(self.omc_path + ' -s ' + simpath)
- print("Hello")
- if self.sim_method == 'Eqn':
- print("hhhh")
- csvpath = os.path.join(self.sim_dir_path,'Flowsheet_res.csv')
- print("csvPath",csvpath)
- with open (csvpath,'r') as resultFile:
+ if ('timeSimulation = 0.0,\n' in self.stdout.decode("utf-8")):
self.result_data = []
- print("opened")
- csvreader = csv.reader(resultFile,delimiter=',')
- for row in csvreader:
- print("124125")
- self.result_data.append(row)
- print(self.result_data)
- #self.ext_data()
+ else:
+ csvpath = os.path.join(self.sim_dir_path,'Flowsheet_res.csv')
+ print("csvPath",csvpath)
+ with open (csvpath,'r') as resultFile:
+ self.result_data = []
+ print("opened")
+ csvreader = csv.reader(resultFile,delimiter=',')
+ for row in csvreader:
+ print("in reading csvreader")
+ self.result_data.append(row)
+ print(self.result_data)
def send_for_simulation_SM(self,unitop):
diff --git a/Simulator/Simulator/UnitOperations/Splitter.mo b/Simulator/Simulator/UnitOperations/Splitter.mo
index 8b03997..9871ea7 100644
--- a/Simulator/Simulator/UnitOperations/Splitter.mo
+++ b/Simulator/Simulator/UnitOperations/Splitter.mo
@@ -5,7 +5,7 @@ model Splitter
//Header Files and Parameters
extends Simulator.Files.Icons.Splitter;
parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc];
- parameter Integer Nc = 2 "Number of Components", No = 2 "Number of outlet streams";
+ parameter Integer Nc = 3 "Number of Components", No = 2 "Number of outlet streams";
parameter String CalcType "Split_Ratio, Mass_Flow or Molar_Flow";
//=============================================================================
@@ -21,7 +21,7 @@ model Splitter
Real Pout_s[No](each min = 0, each start = Pg) "Outlet Pressure";
Real Tout_s[No](each min = 0, each start = Tg) "Outlet Temperature";
- Real xout_sc[No, Nc](each min = 0, each max = 1, start = xguess) "Outlet Mixture Molar Fraction";
+ Real xout_sc[No, Nc](each min = 0, each max = 1) "Outlet Mixture Molar Fraction";
Real Fout_c[No](each min = 0, start = Fg) "Outlet Mixture Molar Flow";
Real Fmout_c[No](each min = 0, start = Fg) "Outlet Mixture Mass Flow";
diff --git a/Streams.py b/Streams.py
index 81586f1..2142e8f 100644
--- a/Streams.py
+++ b/Streams.py
@@ -1,8 +1,6 @@
-# from OMPython import OMCSession
-from PyQt5.QtCore import *
import json
import sys
-from collections import defaultdict
+from PyQt5.QtCore import *
class MaterialStream():
counter = 1
@@ -32,13 +30,13 @@ class MaterialStream():
self.modes_list = ["PT","PH","PVF","TVF","PS"]
self.variables = {
- 'P' : {'name':'Pressure', 'value':101325, 'unit':'Pa'}, # {'Pa':1, 'mmHg':0, 'N/m^2':0}},
+ 'P' : {'name':'Pressure', 'value':101325, 'unit':'Pa'},
'T' : {'name':'Temperature', 'value':300, 'unit':'K'},
'xvap' : {'name':'Vapour Phase Mole Fraction', 'value':None, 'unit':'g/s'},
'H_p[1]' : {'name':'Mixture Phase Molar Entalpy', 'value':None, 'unit':'g/s'},
'S_p[1]' : {'name':'Mixture Phase Molar Entropy', 'value':None, 'unit':'g/s'},
- 'F_p[1]' : {'name':'Mixture Molar Flow Rate', 'value':None, 'unit':'g/s'},
+ 'F_p[1]' : {'name':'Mixture Molar Flow Rate', 'value':100, 'unit':'g/s'},
'H_p[2]' : {'name':'Liquid Phase Molar Entalpy', 'value':None, 'unit':'g/s'},
'S_p[2]' : {'name':'Liquid Phase Molar Entropy', 'value':None, 'unit':'g/s'},
@@ -48,7 +46,7 @@ class MaterialStream():
'S_p[3]' : {'name':'Vapour Phase Molar Entropy', 'value':None, 'unit':'g/s'},
'F_p[3]' : {'name':'Vapour Molar Flow Rate', 'value':None, 'unit':'g/s'},
- 'x_pc' : {'name':'Mole Fraction', 'value':1.0, 'unit':'mol/s'},
+ 'x_pc' : {'name':'Mole Fraction', 'value':[], 'unit':'mol/s'},
'xm_pc' : {'name':'Mass Fraction', 'value':None, 'unit':'g/s'},
'F_pc' : {'name':'Mole Flow', 'value':100, 'unit':'mol/s'},
@@ -57,8 +55,9 @@ class MaterialStream():
self.init_variables()
def init_variables(self):
+ Nc = len(self.compound_names)
for i, val in enumerate(self.compound_names):
- self.variables['x_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Fraction', 'value':None, 'unit':'mol/s'}
+ self.variables['x_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Fraction', 'value':round(1/Nc,4), 'unit':'mol/s'}
self.variables['xm_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mass Fraction', 'value':None, 'unit':'g/s'}
self.variables['F_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mole Flow', 'value':None, 'unit':'mol/s'}
self.variables['Fm_pc[1,'+ str(i+1)+']'] = {'name':val + ' Mixture Mass Flow', 'value':None, 'unit':'g/s'}
@@ -79,68 +78,58 @@ class MaterialStream():
def param_getter(self,mode):
dict = {}
+ temp = []
+ for i, val in enumerate(self.compound_names):
+ temp.append(self.variables['x_pc[1,' + str(i+1) + ']']['value'])
+ self.variables['x_pc']['value'] = temp
+
if(mode=="PT"):
self.mode1 = 'P'
self.mode2 = 'T'
+
dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['T']['value'],
- "MolFlow":self.variables['F_pc']['value'],"x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
+ "MolFlow":self.variables['F_p[1]']['value'],"x_pc":self.variables['x_pc']['value']}
+
elif(mode=="PH"):
self.mode1 = 'P'
self.mode2 = 'H_p[1]'
dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['H_p[1]']['value'],
- "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
+ "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value']}
elif(mode=="PVF"):
self.mode1 = 'P'
self.mode2 = 'xvap'
dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['xvap']['value'],
- "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
+ "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value']}
elif(mode=="TVF"):
self.mode1 = 'T'
self.mode2 = 'xvap'
dict = {self.mode1:self.variables['T']['value'], self.mode2:self.variables['xvap']['value'],
- "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
+ "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value']}
elif(mode=="PS"):
self.mode1 = 'P'
self.mode2 = 'S_p[1]'
dict = {self.mode1:self.variables['P']['value'], self.mode2: self.variables['S_p[1]']['value'],
- "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
+ "MolFlow":self.variables['F_p[1]']['value'], "x_pc":self.variables['x_pc']['value']}
return dict
def param_setter(self,dict):
- print("inside paramsetter ", dict)
-
self.variables['x_pc']['value'] = dict['x_pc'].split(",")
- self.thermo_package = dict['thermo_package']
+ self.thermo_package = dict['Thermo package']
self.variables['F_p[1]']['value'] = dict['MolFlow']
- print("inside")
- # self.Prop[self.mode2] = dict[self.mode2]
- # self.Prop[self.mode1] = dict[self.mode1]
self.variables[self.mode1]['value'] = dict[self.mode1]
self.variables[self.mode2]['value'] = dict[self.mode2]
-
- print(self.variables)
- print(self.variables['x_pc']['value'])
+
for i in range(len(self.compound_names)):
- print('####### x_pc #########\n',self.variables['x_pc']['value'][i])
- print('x_pc')
if self.variables['x_pc']['value'][i]:
self.variables['x_pc[1,'+str(i+1)+']']['value'] = self.variables['x_pc']['value'][i]
else:
self.variables['x_pc[1,'+str(i+1)+']']['value'] = None
- print('xm_pc')
- # if self.variables['xm_pc']['value'][i]:
- # self.variables['xm_pc[1,'+str(i+1)+']']['value'] = self.variables['xm_pc']['value'][i]
- # else:
self.variables['xm_pc[1,'+str(i+1)+']']['value'] = self.variables['xm_pc']['value']
- print('f_pc')
self.variables['F_pc[1,'+str(i+1)+']']['value'] = None
- print('fm_pc')
self.variables['Fm_pc[1,'+str(i+1)+']']['value'] = None
- print('first for')
- print('secnod for')
for i in range(0,len(self.compound_names)):
self.variables['x_pc[2,'+str(i+1)+']']['value'] = None
self.variables['xm_pc[2,'+str(i+1)+']']['value'] = None
@@ -158,22 +147,12 @@ class MaterialStream():
def get_min_eqn_values(self):
x_pclist = []
for i in range(0,len(self.compound_names)):
- #print(self.Prop['x_pc[1,'+str(i+1)+']'])
- #x_pclist.append(self.Prop['x_pc[1,'+str(i+1)+']'])
x_pclist.append(self.variables['x_pc[1,'+str(i+1)+']']['value'])
- print(x_pclist)
- #x_pclist = list(self.Prop(x_pc[1,1)])
x_pc = json.dumps(x_pclist)
- print(x_pc)
x_pc = x_pc.replace('[','{')
x_pc = x_pc.replace(']','}')
x_pc = x_pc.replace('"','')
- '''
- x_pcstr = json.dumps(self.x_pc)
- x_pcstr = x_pcstr.replace('[','{')
- x_pcstr = x_pcstr.replace(']','}')
- x_pcstr = x_pcstr.replace('"','')
- '''
+
if self.variables[self.mode1]['value']:
self.eqn_dict[self.mode1] = self.variables[self.mode1]['value']
if self.variables[self.mode2]['value']:
@@ -183,13 +162,6 @@ class MaterialStream():
if self.variables['F_pc']['value']:
self.eqn_dict['F_p[1]'] = self.variables['F_pc']['value']
- print("##############$GetMinVEqnValuesStart$##################")
- print("P:",self.variables[self.mode1]['value'])
- print("T:",self.variables[self.mode2]['value'])
- print("x_pc",self.variables['x_pc']['value'])
- print("F_p",self.variables['F_p[1]']['value'])
- print("##############$GetMinVEqnValuesEnd$##################")
-
def get_start_values(self):
try:
if self.variables[self.mode1]['value']:
@@ -325,16 +297,13 @@ class MaterialStream():
self.OM_data_init = self.OM_data_init + ("extends Simulator.Files.ThermodynamicPackages."+self.thermo_package+";\n")
self.OM_data_init = self.OM_data_init + ("end ms"+str(self.count)+";\n")
comp_count = len(addedcomp)
- # self.get_start_values()
-
- #self.OM_data_init = "Simulator.Streams.Mat_Stm_RL " + self.name +"(Nc = " + str(comp_count)
+
self.OM_data_init = self.OM_data_init + "ms"+str(self.count) +" " + self.name +"(Nc = " + str(comp_count)
self.OM_data_init = self.OM_data_init + ",C = {"
C = str(addedcomp).strip('[').strip(']')
C = C.replace("'","")
self.OM_data_init = self.OM_data_init + C + "},"
- #for key, value in self.start_dict.items():
- # self.OM_data_init = self.OM_data_init + key + '(start = ' + str(value) + '),'
+
self.OM_data_init = self.OM_data_init[:-1]
self.OM_data_init = self.OM_data_init + ');\n'
return self.OM_data_init
@@ -349,9 +318,7 @@ class MaterialStream():
if method == 'SM':
self.eqn_dict = {}
self.get_min_eqn_values()
- #self.GetEquationValues()
- #self.GetEquationValues()
-
+
for key,value in self.eqn_dict.items():
self.OM_data_eqn = self.OM_data_eqn + self.name + '.'+ key + ' = ' + str(value) + ';\n'
return self.OM_data_eqn
diff --git a/ToDoList.txt b/ToDoList.txt
deleted file mode 100644
index d5ea56d..0000000
--- a/ToDoList.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-Components with Energy Streams
-
-1. Heater
-2. Cooler
-3. CompSep
-4. Pump
-5. Adiabatic Compressor
-6. Adiabatic Expander
-7. Shortcut Column (x2)
-8. Distillation Column (x2)
-9. PFR
-10. Conversion Reactor
-
-Components having Thermo_Packages
-
-1. Adiabatic Compressor
-2. material stream
-3. Shortcut Column
-4. Adiabatic Expander
-5. flash \ No newline at end of file
diff --git a/Undo.dat b/Undo.dat
index 9adaab5..80038db 100644
--- a/Undo.dat
+++ b/Undo.dat
Binary files differ
diff --git a/UnitOperations.py b/UnitOperations.py
index 006c015..5c53f59 100644
--- a/UnitOperations.py
+++ b/UnitOperations.py
@@ -1,17 +1,8 @@
from OMChem.Flowsheet import Flowsheet
from OMChem.EngStm import EngStm
-from PyQt5.QtCore import *
-from PyQt5.QtWidgets import *
-from PyQt5.QtGui import QTextDocument ,QTextCursor ,QTextCharFormat ,QFont ,QPixmap
-from PyQt5.uic import loadUiType
-from PyQt5.QtCore import Qt
-from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsEllipseItem ,QGraphicsPixmapItem,QApplication, QGraphicsView, QGraphicsScene, QHBoxLayout, QWidget, QLabel
-from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent
-from PyQt5.QtGui import *
-import PyQt5.QtCore as QtCore
-import PyQt5.QtWidgets as QtWidgets
from ComponentSelector import *
from Container import *
+from PyQt5.QtCore import *
class UnitOperation():
counter = 1
@@ -38,7 +29,7 @@ class UnitOperation():
self.for_naming = []
self.multidict = []
self.thermo_pack_req = False
- self.thermo_package = None
+ self.thermo_package = 'RaoultsLaw'
def param_getter(self,mode=None):
params = {}
@@ -55,21 +46,20 @@ class UnitOperation():
def param_setter(self,params):
print("param_setter ", params)
for k,v in params.items():
- print(k,v)
- if k != self.mode:
+ if k == 'Thermo Package':
+ self.thermo_package = v
+ print('haha')
+ elif k != self.mode:
self.k = v
self.variables[k]['value'] = v
else:
self.variables[k]['value'] = v
self.mode_val = params[self.mode]
- print(self.variables)
def add_connection(self,flag,UnitOpr):
if flag==1: # Input stream if flag is 1
- print("INPUT CONNECTION")
self.input_stms.append(UnitOpr)
else :
- print("OUTPUT CONNECTION")
self.output_stms.append(UnitOpr)
def set_pos(self,pos):
@@ -116,11 +106,15 @@ class UnitOperation():
C = str(self.compounds).strip('[').strip(']')
C = C.replace("'", "")
self.OM_data_init += ',C = {' + C + '}'
-
- for k,v in self.parameters.items():
+
+ 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 + ' = ' + str(v)
- self.OM_data_init += ');\n'
+ 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('"', ''))
+
+ self.OM_data_init += ');\n'
else:
self.OM_data_init += 'Simulator.UnitOperations.' + self.type + ' ' + self.name + '(Nc = ' + str(len(self.compounds))
@@ -130,16 +124,17 @@ class UnitOperation():
for k in self.parameters:
self.OM_data_init += ', '
- self.OM_data_init += k + ' = ' + ('"' + self.variables[k]['value'] + '"' if isinstance(self.variables[k]['value'], str)
- else str(self.variables[k]['value']))
+ 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('"', ''))
self.OM_data_init += ');\n'
return self.OM_data_init
+
def OM_Flowsheet_Equation(self):
self.OM_data_eqn = ''
- if len(self.input_stms)>1:
+ if len(self.input_stms)>1 or self.type == 'Mixer':
strcount = 1
for strm in self.input_stms:
self.OM_data_eqn += ('connect(' + strm.name + '.Out,' + self.name + '.In[' + str(strcount) + ']);\n')
@@ -153,6 +148,7 @@ class UnitOperation():
self.OM_data_eqn += ('connect(' + strm.name + '.In,' + self.name + '.Out[' + str(strcount) + ']);\n')
strcount += 1
else:
+ print("self.output_stms ", self.output_stms)
self.OM_data_eqn += ('connect(' + self.name + '.Out,' + self.output_stms[0].name + '.In);\n')
if self.mode:
@@ -167,13 +163,16 @@ class ShortcutColumn(UnitOperation):
self.type = 'ShortcutColumn'
self.no_of_inputs = 1
self.no_of_outputs = 2
- self.input_stms = None
- self.output_stms = None
self.EngStm1 = EngStm(name='EngStm1'+self.name)
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 = {
@@ -182,31 +181,57 @@ 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]
self.variables['Pcond']['value'] = params[5]
self.variables['Preb']['value'] = params[6]
self.variables['RR']['value'] = params[7]
+ self.thermo_package = params[8]
- 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'):
+ UnitOperation.__init__(self)
self.name = name + str(DistillationColumn.counter)
self.type = 'DistillationColumn'
- self.no_of_inputs = 2
+ self.no_of_inputs = 1
self.no_of_outputs = 2
self.compounds = compound_selected
@@ -215,23 +240,21 @@ class DistillationColumn(UnitOperation):
self.EngStm2 = EngStm(name='EngStm2'+self.name)
self.count = DistillationColumn.counter
- self.input_stms = None
- self.output_stms = None
# self.modes_list = ['RR', 'Nout', 'T']
self.modes_list = []
- self.parameters = ['']
+ self.parameters = ['Nt', 'Ni', 'InT_s', 'Ctype']
#self.parameters = ['Nt', 'InT_s', 'In_s', 'thermo_package', 'Ctype', 'Pcond', 'Preb']
self.Cspec_list = ['Reflux Ratio','Product Molar Flow (mol/s)', 'Temperature (K)', 'Compound Molar Fraction', 'Compound Molar Flow (mol/s)']
self.Rspec_list = ['Product Molar Flow (mol/s)', 'Temperature (K)', 'Compound Molar Fraction', 'Compound Molar Flow (mol/s)']
type(self).counter += 1
self.variables = {
+ 'Ni' : {'name':'Number of Input', 'value':2, 'unit':''},
'RR' : {'name':'Reflux Ratio', 'value':None, 'unit':''},
'T' : {'name':'Temperature', 'value':300, 'unit':'K'},
'Nout' : {'name':'No of Sidedraws', 'value':None, 'unit':''},
'Nt' : {'name':'No of Stages', 'value':12, 'unit':''},
- 'InT_s' : {'name':'No of Feed Stages', 'value':None, 'unit':''},
- 'In_s' : {'name':'No of Feeds', 'value':None, 'unit':''},
+ 'InT_s' : {'name':'Feed Stage', 'value':[], 'unit':''},
'thermo_package' : {'name':'Thermo Package', 'value':'Raoults_Law', 'unit':''},
'Ctype' : {'name':'Condensor Type', 'value':'', 'unit':''},
'Pcond' : {'name':'Condensor Pressure', 'value':101325, 'unit':'Pa'},
@@ -239,22 +262,26 @@ class DistillationColumn(UnitOperation):
'C_Spec': {'name':'Condensor Specification', 'type':'Reflux Ratio', 'value':'', 'comp':'', 'unit':''},
'R_Spec': {'name':'Reboiler Specification', 'type':'', 'value':'', 'comp':'', 'unit':''},
}
+
def param_setter(self,params):
print("param_setter ", params)
+ temp = 0
self.variables['Nt']['value'] = params[0]
- self.variables['In_s']['value'] = params[1]
- self.variables['InT_s']['value'] = params[2]
- self.variables['Ctype']['value'] = params[3]
- self.variables['Pcond']['value'] = params[4]
- self.variables['C_Spec']['type'] = params[5]
+ for i in range(self.variables['Ni']['value']):
+ self.variables['InT_s']['value'].append(params[i+1])
+ temp = i + 1
+
+ self.variables['Ctype']['value'] = params[temp+1]
+ self.variables['Pcond']['value'] = params[temp+2]
+ self.variables['C_Spec']['type'] = params[temp+3]
if 'Compound' in self.variables['C_Spec']['type']:
- self.variables['C_Spec']['comp'] = params[6]
- self.variables['C_Spec']['value'] = params[7]
- self.variables['Preb']['value'] = params[8]
- self.variables['R_Spec']['type'] = params[9]
+ self.variables['C_Spec']['comp'] = params[temp+4]
+ self.variables['C_Spec']['value'] = params[temp+5]
+ self.variables['Preb']['value'] = params[temp+6]
+ self.variables['R_Spec']['type'] = params[temp+7]
if 'Compound' in self.variables['R_Spec']['type']:
- self.variables['R_Spec']['comp'] = params[10]
- self.variables['R_Spec']['value'] = params[11]
+ self.variables['R_Spec']['comp'] = params[temp+8]
+ self.variables['R_Spec']['value'] = params[temp+9]
print(self.variables)
class ConvertionReactor(UnitOperation):
@@ -284,40 +311,70 @@ class CompoundSeparator(UnitOperation):
type(self).counter += 1
self.variables = {
'SepStrm' : {'name':'Separation Stream', 'value':1, 'unit':''},
- #'SepVal' : {'name':'Separation Value', 'value':[], 'unit':''},
- #'SepFact' : {'name':'Separaction Factor', 'value':'', 'unit':''},
+ 'SepVal_c' : {'name':'Separation Value', 'value':[], 'unit':''},
+ 'SepFact_c' : {'name':'Separaction Factor', 'value':[], 'unit':''},
}
-
- for i in self.compounds:
- self.variables[i] = {'name':'SepVal_'+i, 'value':'', 'type':'', 'unit':''}
- # self.SepFact = json.dumps(self.variables['SepFact']['value']).replace('[','{').replace(']','}')
- # self.SepStrm = str(self.variables['SepStrm']['value'])
- # self.SepVal = json.dumps(self.variables['SepVal']['value']).replace('[','{').replace(']','}')
def param_setter(self,params):
- print("param_setter ", params)
- if params[0]:
+ print("param_setter CompSep ", params)
+
+ if (params[0]):
self.variables['SepStrm']['value'] = 1
- elif params[1]:
+ else:
self.variables['SepStrm']['value'] = 2
+ for index, i in enumerate(range(2, len(params))):
+ if (i %2 != 0):
+ self.variables['SepVal_c']['value'].append(float(params[i]))
+ else:
+ self.variables['SepFact_c']['value'].append(params[i].split(' ')[0])
- j = 2
- for i in self.compounds:
- self.variables[i]['type'] = params[j]
- self.variables[i]['value'] = float(params[j+1])
- j += 2
- print(self.variables)
+ self.variables['SepFact_c']['value'] = json.dumps(self.variables['SepFact_c']['value']).replace('[','{').replace(']','}')
+ self.variables['SepStrm']['value'] = str(self.variables['SepStrm']['value'])
+ self.variables['SepVal_c']['value'] = json.dumps(self.variables['SepVal_c']['value']).replace('[','{').replace(']','}')
+
+
+ def OM_Flowsheet_Initialize(self):
+ self.OM_data_init = ''
+ comp_count = len(self.compounds)
+ self.OM_data_init = self.OM_data_init + (
+ "Simulator.UnitOperations.CompoundSeparator " + self.name + "(Nc = " + str(comp_count))
+ self.OM_data_init = self.OM_data_init + (", C = {")
+ comp = str(self.compounds).strip('[').strip(']')
+ comp = comp.replace("'", "")
+ self.OM_data_init = self.OM_data_init + comp + ("},")
+ self.OM_data_init = self.OM_data_init + ("SepFact_c = "+self.variables['SepFact_c']['value']+",SepStrm = " + self.variables['SepStrm']['value'] + ");\n") #+ ", sepFactVal = " + self.variables['SepVal_c']['value']
+
+ return self.OM_data_init
+
+
+ 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 + '.SepVal_c ' + '=' + self.variables['SepVal_c']['value'] + ';\n')
+
+ return self.OM_data_eqn
class Flash(UnitOperation):
def __init__(self,name='Flash'):
UnitOperation.__init__(self)
self.name = name + str(Flash.counter)
self.type = 'Flash'
+ self.extra = ['Flash']
+ self.for_naming = ['Flash']
self.no_of_inputs = 1
self.no_of_outputs = 2
self.input_stms = []
self.output_stms = []
self.count = Flash.counter
+ self.thermo_pack_req = True
+ self.parameters = ['BTdef', 'Tdef', 'BPdef', 'Pdef']
type(self).counter += 1
self.variables = {
@@ -327,6 +384,7 @@ class Flash(UnitOperation):
'Tdef' : {'name':'Separation Temperature', 'value':298.15, 'unit':'K'},
'Pdef' : {'name':'Separation Pressure', 'value':101325, 'unit':'Pa'}
}
+
def param_setter(self,params):
print("param_setter ", params)
self.variables['thermo_package']['value'] = params[0]
@@ -334,7 +392,18 @@ class Flash(UnitOperation):
self.variables['Tdef']['value'] = params[2]
self.variables['BPdef']['value'] = params[3]
self.variables['Pdef']['value'] = params[4]
- 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
+
+ return self.OM_data_eqn
class Pump(UnitOperation):
def __init__(self,name='Pump'):
@@ -359,8 +428,6 @@ class Valve(UnitOperation):
UnitOperation.__init__(self)
self.name = name + str(Valve.counter)
self.type = 'Valve'
- self.input_stms = None
- self.output_stms = None
self.modes_list = ['Pdel', 'Pout']
type(self).counter += 1
@@ -376,31 +443,29 @@ class Splitter(UnitOperation):
self.type = 'Splitter'
self.no_of_outputs = 3
- # self.input_stms = None
- self.CalcType_modes = ['Split Ratios', 'Mole Flow Specs', 'Mass Flow Specs']
+ self.CalcType_modes = ['Split_Ratio', 'Molar_Flow', 'Mass_Flow']
- self.parameters = ['NOO', 'CalcType']#, 'SpecVal_s'
+ self.parameters = ['No', 'CalcType', 'SpecVal_s']
type(self).counter += 1
self.variables = {
- 'NOO' : {'name':'No. of Output', 'value':3, 'unit':''},
+ 'No' : {'name':'No. of Output', 'value':3, 'unit':''},
'CalcType' : {'name':'Calculation Type', 'value':self.CalcType_modes[0], 'unit':''},
'SpecVal_s' : {'name':'Specification Value', 'value':[50,50], 'unit':''}
}
- specval = self.variables['SpecVal_s']['value'] # [50,50]
+ specval = self.variables['SpecVal_s']['value']
self.specval = json.dumps(specval).replace('[','{').replace(']','}')
def param_setter(self,params):
print("param_setter ", params)
- self.variables['NOO']['value'] = int(params[0])
+ self.variables['No']['value'] = int(params[0])
self.variables['CalcType']['value'] = params[1]
self.variables['SpecVal_s']['value'] = [float(params[2]), float(params[3])]
- if self.variables['CalcType']['value'] == 'Mole Flow Specs':
+ if self.variables['CalcType']['value'] == 'Molar_Flow':
self.variables['SpecVal_s']['unit'] = 'mol/s'
- elif self.variables['CalcType']['value'] == 'Mass Flow Specs':
- self.variables['SpecVal_s']['unit'] = 'kg/s'
- print(self.variables)
+ elif self.variables['CalcType']['value'] == 'Mass_Flow':
+ self.variables['SpecVal_s']['unit'] = 'g/s'
class Mixer(UnitOperation):
@@ -410,25 +475,19 @@ class Mixer(UnitOperation):
self.type = 'Mixer'
self.no_of_inputs = 6
- self.Pout_modes = ['Inlet Minimum', 'Inlet Average', 'Inlet Maximum']
+ self.Pout_modes = ['Inlet_Minimum', 'Inlet_Average', 'Inlet_Maximum']
self.parameters = ['NI', 'outPress']
- # self.output_stms = None
type(self).counter += 1
self.variables = {
- 'NI' : {'name':'Number of Input', 'value':6, 'unit':''},
+ 'NI' : {'name':'Number of Input', 'value':6, 'unit':''},
'outPress' : {'name':'Outlet Pressure', 'value':'Inlet_Average', 'unit':''},
}
+
def param_setter(self, params):
- print(self.input_stms, self.output_stms)
- self.output_stms = []
- print(self.input_stms, self.output_stms)
- print("param_setter ", params)
self.variables['NI']['value'] = int(params[0])
self.variables['outPress']['value'] = params[1]
- print(self.variables)
-
class Heater(UnitOperation):
def __init__(self, name='Heater'):
@@ -491,7 +550,7 @@ class AdiabaticCompressor(UnitOperation):
self.parameters = ['Eff']
type(self).counter += 1
self.variables = {
- 'Pdel' : {'name':'Pressure Drop', 'value':0, 'unit':'Pa'},
+ 'Pdel' : {'name':'Pressure Increase', 'value':0, 'unit':'Pa'},
'Tdel' : {'name':'Temperature Increase', 'value':0, 'unit':'K'},
'Pout' : {'name':'Outlet Pressure', 'value':101325, 'unit':'Pa'},
'Tout' : {'name':'Outlet Temperature', 'value':298.15, 'unit':'K'},
diff --git a/mainApp.py b/mainApp.py
index e49d4e2..e2328dd 100644
--- a/mainApp.py
+++ b/mainApp.py
@@ -41,16 +41,13 @@ class MainApp(QMainWindow,ui):
# Loading and setting up style sheet
self.setupUi(self)
- # style = open('cyan.css','r')
- # style = style.read()
- # self.setStyleSheet(style)
# Initializing attributes
self.zoom_count = 0
self.thrd = None
# Creating instances of classes for the main app
- self.container = Container.Container(self.textBrowser, self.graphicsView)
+ self.container = Container(self.textBrowser, self.graphicsView)
self.comp = ComponentSelector(self)
# Setting up interactive canvas
@@ -227,7 +224,7 @@ class MainApp(QMainWindow,ui):
'''
def new(self):
self.undo_redo_helper()
- self.comp.tableWidget.setRowCount(0)
+ self.comp = ComponentSelector(self)
self.textBrowser.append("<span>[" + str(self.current_time()) + "] <b>New</b> flowsheet is created ... </span>")
dock_widget_lst.clear()
@@ -262,8 +259,6 @@ class MainApp(QMainWindow,ui):
self.graphicsView.setMouseTracking(True)
self.graphicsView.keyPressEvent=self.delete_call
-
-
'''
Function for undo
'''
diff --git a/thermopackage.txt b/thermopackage.txt
index 9ed6616..f9155f5 100644
--- a/thermopackage.txt
+++ b/thermopackage.txt
@@ -1,6 +1,6 @@
RaoultsLaw
NRTL
-INIQUAC
+UNIQUAC
UNIFAC
PengRobinson
GraysonStreed \ No newline at end of file