diff options
author | lucaszhao19 | 2020-07-27 21:08:14 +0630 |
---|---|---|
committer | lucaszhao19 | 2020-07-27 21:08:14 +0630 |
commit | d2cb7dadd3554586ccd0b88af7418b24877991e8 (patch) | |
tree | e69398907244dcb3e28434910dac6b1c25676573 | |
parent | 8b296f3d098669a6cb4f20511aaa3b42ac4510ba (diff) | |
download | Chemical-Simulator-GUI-d2cb7dadd3554586ccd0b88af7418b24877991e8.tar.gz Chemical-Simulator-GUI-d2cb7dadd3554586ccd0b88af7418b24877991e8.tar.bz2 Chemical-Simulator-GUI-d2cb7dadd3554586ccd0b88af7418b24877991e8.zip |
Partially fixed DistillationColumn
-rw-r--r-- | Container.py | 12 | ||||
-rw-r--r-- | DockWidgets/DockWidgetDistillationColumn.py | 65 | ||||
-rw-r--r-- | DockWidgets/DockWidgetDistillationColumn.ui | 36 | ||||
-rw-r--r-- | DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc | bin | 4186 -> 4926 bytes | |||
-rw-r--r-- | Graphics.py | 27 | ||||
-rw-r--r-- | Undo.dat | bin | 31950 -> 1641 bytes | |||
-rw-r--r-- | UnitOperations.py | 47 |
7 files changed, 84 insertions, 103 deletions
diff --git a/Container.py b/Container.py index e2b1f29..6da3b25 100644 --- a/Container.py +++ b/Container.py @@ -93,19 +93,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 +109,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) @@ -171,7 +164,6 @@ 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) if mode=='SM': @@ -186,8 +178,6 @@ class Container(): self.msg_browser() self.result=self.flowsheet.result_data print("under Eqn mode simulation") - print("710 ") - print("under SEQ mode simulation") DockWidget.show_result(NodeItem.get_dock_widget()) diff --git a/DockWidgets/DockWidgetDistillationColumn.py b/DockWidgets/DockWidgetDistillationColumn.py index 65e9932..a3650e0 100644 --- a/DockWidgets/DockWidgetDistillationColumn.py +++ b/DockWidgets/DockWidgetDistillationColumn.py @@ -34,10 +34,20 @@ 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']+":") + # self.l1.setText(self.obj.variables['Nt']['name']+":") + # self.le1.setText(str(self.obj.variables['Nt']['value'])) + # self.l2.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 +65,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 +87,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 +115,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/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differindex e5f9002..e3b2d9e 100644 --- a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/Graphics.py b/Graphics.py index f013691..4b5a3e8 100644 --- a/Graphics.py +++ b/Graphics.py @@ -50,7 +50,6 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): return ComponentSelector(self) def create_node_item(self,unit_operation, container): - print("in create node item function") # node_item = NodeItem(unit_operation, container, self.graphicsView) # self.node_item_list.append(node_item) # return node_item @@ -61,32 +60,26 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): 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)) + print(eval(i.type)) # eval(i.type).counter += 1 # print(eval(i.type).counter) elif i.type not in stm: - print('in i obj line in else') ip = i.input_stms op = i.output_stms print(ip) @@ -95,7 +88,6 @@ class Graphics(QDialog, QtWidgets.QGraphicsItem): # 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() @@ -407,7 +399,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) @@ -415,7 +407,6 @@ class NodeSocket(QtWidgets.QGraphicsItem): return center def hoverEnterEvent(self, event): - print("in hover enter") cursor = QCursor( Qt.CrossCursor ) QApplication.instance().setOverrideCursor(cursor) @@ -445,14 +436,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" @@ -464,7 +453,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: @@ -482,18 +470,16 @@ class NodeItem(QtWidgets.QGraphicsItem): if ok and text: self.nin = int(text) self.obj.no_of_inputs = self.nin - self.obj.variables['NI']['value'] = 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) 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) @@ -502,8 +488,6 @@ 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()) @@ -538,7 +522,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() @@ -558,7 +541,6 @@ class NodeItem(QtWidgets.QGraphicsItem): # 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)] @@ -596,13 +578,11 @@ 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) @@ -614,7 +594,6 @@ class NodeItem(QtWidgets.QGraphicsItem): for i, j in default_tooltip_dict.items(): if j is not None: default_tooltip = default_tooltip + f" {i} : {j}\n" - print("default tooltip ", default_tooltip_dict) self.setToolTip(default_tooltip) diff --git a/UnitOperations.py b/UnitOperations.py index 54f9334..fbbcce1 100644 --- a/UnitOperations.py +++ b/UnitOperations.py @@ -55,7 +55,6 @@ class UnitOperation(): def param_setter(self,params): print("param_setter ", params) for k,v in params.items(): - print(k,v) if k != self.mode: self.k = v self.variables[k]['value'] = v @@ -66,10 +65,8 @@ class UnitOperation(): 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): @@ -163,8 +160,6 @@ class UnitOperation(): self.OM_data_eqn += ('connect(' + strm.name + '.In,' + self.name + '.Out[' + str(strcount) + ']);\n') strcount += 1 else: - print(self.input_stms) - print(self.output_stms) self.OM_data_eqn += ('connect(' + self.name + '.Out,' + self.output_stms[0].name + '.In);\n') if self.mode: @@ -246,6 +241,7 @@ class ShortcutColumn(UnitOperation): class DistillationColumn(UnitOperation): def __init__(self,name='DistillationColumn'): + UnitOperation.__init__(self) self.name = name + str(DistillationColumn.counter) self.type = 'DistillationColumn' self.no_of_inputs = 1 @@ -259,20 +255,19 @@ class DistillationColumn(UnitOperation): # 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':''}, + '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'}, @@ -280,22 +275,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): @@ -338,20 +337,15 @@ class CompoundSeparator(UnitOperation): self.variables['SepStrm']['value'] = 2 for index, i in enumerate(range(2, len(params))): - print(index, i) if (i %2 != 0): self.variables['SepVal_c']['value'].append(float(params[i])) else: self.variables['SepFact_c']['value'].append(params[i].split(' ')[0]) - - print(self.variables['SepStrm']['value'], self.variables['SepFact_c']['value'], self.variables['SepVal_c']['value']) 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(']','}') - print(self.variables['SepStrm']['value'], self.variables['SepFact_c']['value'], self.variables['SepVal_c']['value']) - def OM_Flowsheet_Initialize(self): self.OM_data_init = '' @@ -478,7 +472,6 @@ class Splitter(UnitOperation): specval = self.variables['SpecVal_s']['value'] # [50,50] self.specval = json.dumps(specval).replace('[','{').replace(']','}') - print(self.specval) def param_setter(self,params): print("param_setter ", params) @@ -509,9 +502,7 @@ class Mixer(UnitOperation): '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] |