summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyush Agrawal2020-01-01 20:15:46 +0530
committerAyush Agrawal2020-01-01 20:15:46 +0530
commit89abe5355295af8a6b5108086662bfcbdaa26708 (patch)
tree043a4e3533b5fa265e4ac6b170ef4046d68323b4
parent8f2efdc428919fbb800f8fad29c05bcfe2e97a24 (diff)
downloadChemical-Simulator-GUI-89abe5355295af8a6b5108086662bfcbdaa26708.tar.gz
Chemical-Simulator-GUI-89abe5355295af8a6b5108086662bfcbdaa26708.tar.bz2
Chemical-Simulator-GUI-89abe5355295af8a6b5108086662bfcbdaa26708.zip
Added Binary Phase Envelope
-rw-r--r--Bin_Phase_env.py325
-rw-r--r--Binary_Phase_Env.ui271
-rw-r--r--helper.py296
-rw-r--r--main.ui23
-rw-r--r--mainApp.py13
5 files changed, 623 insertions, 305 deletions
diff --git a/Bin_Phase_env.py b/Bin_Phase_env.py
new file mode 100644
index 0000000..60d5fc9
--- /dev/null
+++ b/Bin_Phase_env.py
@@ -0,0 +1,325 @@
+import sys
+import pandas as pd
+import numpy as np
+import os
+import csv
+from subprocess import Popen, PIPE
+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
+#import PyQt5.QtGuiApplication
+from PyQt5.QtGui import *
+import PyQt5.QtGui as QtGui
+import PyQt5.QtCore as QtCore
+import PyQt5.QtWidgets as QtWidgets
+import pyqtgraph as pg
+import pyqtgraph.exporters
+
+
+
+ui_dialog,_ = loadUiType('Binary_Phase_Env.ui')
+
+class Bin_Phase_env(QWidget,ui_dialog):
+ def __init__(self,comp):
+ QWidget.__init__(self)
+ self.setupUi(self)
+
+ self.comp = comp
+ self.compunds = self.comp.getComp()
+
+ for i in self.compunds:
+ self.comboBox.addItem(str(i))
+
+ for i in range(len(self.compunds)):
+ if i!=0:
+ self.comboBox_2.addItem(str(self.compunds[i]))
+
+ self.comboBox_2.addItem(str(self.compunds[0]))
+
+ self.lines = [line.rstrip('\n') for line in open('thermopackage.txt')]
+ for j in self.lines:
+ self.comboBox_3.addItem(str(j))
+
+ self.radioButton.setChecked(False)
+ self.radioButton_2.setChecked(False)
+
+ self.button_handler()
+
+ self.counter = 1
+
+
+
+
+
+ def button_handler(self):
+ self.radioButton.clicked.connect(lambda:self.T_xy())
+ self.radioButton_2.clicked.connect(lambda:self.P_xy())
+ self.pushButton_2.clicked.connect(lambda:self.plot())
+
+
+ def T_xy(self):
+ self.radioButton.setChecked(True)
+ self.radioButton_2.setChecked(False)
+ for i in reversed(range(self.formLayout.count())):
+ self.formLayout.itemAt(i).widget().setParent(None)
+
+ self.first = QLineEdit()
+ self.type = "P"
+ self.other = "T"
+ self.otherunit = "(K)"
+ self.formLayout.addRow(QLabel("P(Pa)"),self.first)
+ self.points = QLineEdit()
+ self.points.setText("40")
+ self.formLayout.addRow(QLabel("Number of data points"),self.points)
+ #print("T-XY")
+
+ def P_xy(self):
+ self.radioButton_2.setChecked(True)
+ self.radioButton.setChecked(False)
+ for i in reversed(range(self.formLayout.count())):
+ self.formLayout.itemAt(i).widget().setParent(None)
+
+ self.first = QLineEdit()
+ self.type = "T"
+ self.other = "P"
+ self.otherunit = "(Pa)"
+ self.points = QLineEdit()
+ self.points.setText("40")
+ self.formLayout.addRow(QLabel("T(K)"),self.first)
+ self.formLayout.addRow(QLabel("Number of data points"),self.points)
+ #print("")
+ def get_omc_path(self):
+ try:
+ if os.path.exists('/opt/local/bin/omc'):
+ self.omhome = '/opt/local'
+ elif os.path.exists('/usr/bin/omc'):
+ self.omhome = '/usr'
+ return os.path.join(self.omhome, 'bin', 'omc')
+ except BaseException:
+ print("The OpenModelica compiler is missing in the System path please install it" )
+ raise
+
+
+
+ def plot(self):
+ #print(self.type)
+
+ try:
+ val = int(self.first.text(),10)
+ except:
+ val = 0
+ try:
+ data_points = int(self.points.text(),10)
+ except:
+ data_points = 0
+
+ self.curr_path = os.getcwd()
+ self.sim_dir_path = os.path.join(self.curr_path,'Simulator')
+ self.Graphmo_path = os.path.join(self.sim_dir_path,'Graph.mo')
+ self.plot_mos_path = os.path.join(self.sim_dir_path,'PlotGraph.mos')
+
+ self.data = []
+
+ self.comp1 = self.comboBox.currentText()
+ self.comp2 = self.comboBox_2.currentText()
+ self.thermoPack = self.comboBox_3.currentText()
+
+ # print(val)
+ # print(data_points)
+ # print(self.comp1)
+ # print(self.comp2)
+ # print(self.thermoPack)
+
+ self.data.append("model Graph\n")
+ self.data.append("import data = Simulator.Files.Chemsep_Database;\n")
+ self.data.append("parameter data."+self.comp1+" comp1;\n")
+ self.data.append("parameter data."+self.comp2+" comp2;\n")
+ self.data.append("extends BinaryEnvelopes."+self.thermoPack+"(NOC = 2, data_points = "+str(data_points)+ ", comp = { comp1, comp2 }, "+self.type+" = fill( "+str(val)+", "+str(data_points)+"));\n")
+ self.data.append("end Graph;")
+
+ with open(self.Graphmo_path, 'w') as txtfile:
+ for d in self.data:
+ txtfile.write(str(d))
+
+ with open(self.plot_mos_path, 'w') as mosFile:
+ mosFile.write("loadModel(Modelica);\n")
+ mosFile.write("loadFile(\"Simulator/package.mo\");\n")
+ mosFile.write("loadFile(\"BinaryEnvelopes.mo\");\n")
+ mosFile.write("loadFile(\"Graph.mo\");\n")
+ mosFile.write("simulate(Graph, outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1);\n")
+
+
+ print(self.data)
+
+
+ self.resdata = []
+ self.omc_path = self.get_omc_path()
+ simpath = self.plot_mos_path
+ os.chdir(self.sim_dir_path)
+
+ process = Popen([self.omc_path, '-s',simpath], stdout=PIPE, stderr=PIPE)
+ self.stdout, self.stderr = process.communicate()
+
+ os.chdir(self.curr_path)
+
+ csvpath = os.path.join(self.sim_dir_path,'Graph_res.csv')
+
+ self.datay = []
+ self.datax1 = []
+ self.datax2 = []
+ self.rows = []
+
+ with open (csvpath,'r') as resultFile:
+ self.resdata = []
+ print("opened")
+ csvreader = csv.reader(resultFile,delimiter=',')
+ for row in csvreader:
+ print("124125")
+ self.resdata.append(row)
+ self.rows.append(row)
+
+ print("SIMULATION DONE")
+
+
+
+
+
+ if self.type=='T':
+ for k in range(len(self.rows[0])):
+ if self.rows[0][k][0]=='P':
+ self.datay.append(float(self.rows[1][k]))
+ #print(col)
+ length = len(self.rows[0][k])
+
+ if self.rows[0][k][0]=='x' and self.rows[0][k][length-2]=='1':
+ self.datax1.append(float(self.rows[1][k]))
+ # k+=1
+
+ if self.rows[0][k][0]=='y' and self.rows[0][k][length-2]=='1':
+ self.datax2.append(float(self.rows[1][k]))
+ #k+=1
+
+ #k+=1
+
+ else:
+
+ for k in range(len(self.rows[0])):
+ if self.rows[0][k][0]=='T':
+ self.datay.append(float(self.rows[1][k]))
+ #print(col)
+
+ #print(self.rows[0][k])
+ length = len(self.rows[0][k])
+ if self.rows[0][k][0]=='x' and self.rows[0][k][length-2]=='1':
+
+ self.datax1.append(float(self.rows[1][k]))
+ # k+=1
+
+ if self.rows[0][k][0]=='y' and self.rows[0][k][length-2]=='1':
+ self.datax2.append(float(self.rows[1][k]))
+ #k+=1
+
+ plt = pg.PlotWidget()
+ plt.showGrid(x=True,y=True)
+ plt.addLegend()
+ plt.setXRange(0,1)
+
+
+ # print("SIZE UP AHEAD")
+ # print(len(self.datay))
+ # print(len(self.datax1))
+ # print(len(self.datax2))
+ # print("SIZES DONE")
+
+ c1 = plt.plot(self.datax1, self.datay,pen=pg.mkPen('b',width = 1), name='dew points')
+ c2 = plt.plot(self.datax2, self.datay,pen=pg.mkPen('r',width = 1), name='bubble points')
+
+
+ view_box = plt.plotItem.vb
+
+
+
+ def pressEvent(evt):
+ #print("HELLO")
+ a = 10
+ pos = evt
+
+
+ mousepoint = view_box.mapSceneToView(pos)
+ roi = pg.ROI(pos)
+ find_color = plt.mapToGlobal(pos.toPoint())
+
+ screen = QGuiApplication.primaryScreen()
+ image = screen.grabWindow(QApplication.desktop().winId()).toImage()
+ colour = QtGui.QColor(image.pixel(find_color.x(),find_color.y()))
+ #print("red:{}, green:{}, blue:{}".format(colour.red(),colour.green(),colour.blue()))
+
+ if colour.red()==255 or colour.blue()==255:
+ self.lineEdit_x.setText(str(round(mousepoint.x(),3)))
+ self.lineEdit_y.setText(str(round(mousepoint.y(),3)))
+ QApplication.setOverrideCursor(QCursor(QtCore.Qt.CrossCursor))
+ else:
+ self.lineEdit_x.setText("")
+ self.lineEdit_y.setText("")
+ QApplication.setOverrideCursor(QCursor(QtCore.Qt.ArrowCursor))
+
+
+
+ #self.prev = None
+ def entered(items):
+ for i in items:
+ #print(i.__class__.__name__)
+ if i.__class__.__name__ =="LegendItem":
+ self.lineEdit_x.setText("")
+ self.lineEdit_y.setText("")
+ QApplication.setOverrideCursor(QCursor(QtCore.Qt.ArrowCursor))
+
+
+ # print(items)
+
+ #proxy = pg.SignalProxy(plt.scene().sigMouseMoved, rateLimit = 60, slot = pressEvent)
+ plt.scene().sigMouseMoved.connect(pressEvent)
+ plt.scene().sigMouseHover.connect(entered)
+ #c1.setAcceptHoverEvents(True)
+ #c2.setAcceptHoverEvents(True)
+
+
+
+
+
+ # def hoverEnterEvent(c1,event):
+ # print("Object ZONE")
+
+ # def hoverEnterEvent(c2,event):
+ # print("Object ZONE")
+
+ #c1.hoverMoveEvent.connect(item)
+ #c2.hoverMoveEvent.connect(item)
+
+
+ plt.setLabel('left',self.other+self.otherunit,units = '')
+ plt.setLabel('bottom',self.comp1+'(mol. frac.)',units = '')
+
+ self.new_tab = plt
+ self.new_tab.setObjectName("Plot "+str(self.counter))
+
+ self.tabWidget.addTab(self.new_tab,"Plot "+str(self.counter))
+ self.counter+=1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Binary_Phase_Env.ui b/Binary_Phase_Env.ui
new file mode 100644
index 0000000..d9efde7
--- /dev/null
+++ b/Binary_Phase_Env.ui
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1086</width>
+ <height>461</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QWidget" name="horizontalLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>10</y>
+ <width>281</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QComboBox" name="comboBox"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>131</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Compound 1</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_4">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>131</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Compound 2</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_2">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>50</y>
+ <width>281</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QComboBox" name="comboBox_2"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="formLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>180</y>
+ <width>421</width>
+ <height>91</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="formLayout"/>
+ </widget>
+ <widget class="QPushButton" name="pushButton_2">
+ <property name="geometry">
+ <rect>
+ <x>170</x>
+ <y>280</y>
+ <width>81</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Plot</string>
+ </property>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_5">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>140</y>
+ <width>71</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QRadioButton" name="radioButton">
+ <property name="text">
+ <string>T-xy</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_6">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>140</y>
+ <width>71</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QRadioButton" name="radioButton_2">
+ <property name="text">
+ <string>P-xy</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_7">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>90</y>
+ <width>131</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Thermo Pack</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_8">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>90</y>
+ <width>281</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <widget class="QComboBox" name="comboBox_3"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>0</y>
+ <width>631</width>
+ <height>451</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="currentIndex">
+ <number>-1</number>
+ </property>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_9">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>340</y>
+ <width>91</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>x-coordinate</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_10">
+ <property name="geometry">
+ <rect>
+ <x>180</x>
+ <y>380</y>
+ <width>91</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_10">
+ <item>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>y-coordinate</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_11">
+ <property name="geometry">
+ <rect>
+ <x>300</x>
+ <y>340</y>
+ <width>121</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLineEdit" name="lineEdit_x">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="horizontalLayoutWidget_12">
+ <property name="geometry">
+ <rect>
+ <x>300</x>
+ <y>380</y>
+ <width>121</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QLineEdit" name="lineEdit_y"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/helper.py b/helper.py
deleted file mode 100644
index d9e9890..0000000
--- a/helper.py
+++ /dev/null
@@ -1,296 +0,0 @@
-from OMChem.Flowsheet import Flowsheet
-from OMChem.MatStm import MatStm
-from OMChem.UnitOprns import UnitOpr
-from OMChem.EngStm import EngStm
-from Graphics import Graphics
-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 component_selector import *
-
-
-
-class HeaterClass():
- counter = 1
-
- def __init__(self,name='Heater',pressDrop = None, eff = None):
- self.OM_data_eqn = ''
- self.OM_data_init = ''
- self.InputStms = []
- self.OutputStms = []
- self.name = name + str(HeaterClass.counter)
- self.mode = None
- self.modeVal = None
- self.type = 'Heater'
- self.pressDrop = pressDrop
- self.eff = eff
- self.no_of_inputs = 1
- self.no_of_outputs = 1
- self.x = 2500-30
- self.y = 2500-30
- # self.addedcomp = None
- self.extra = None
- self.Prop = {
- 'pressDrop':None,
- 'eff':None,
- 'outT':None,
- 'tempInc':None,
- 'heatAdd':None,
- }
- HeaterClass.counter+=1
-
- self.modesList = ["heatAdd","outT","outVapPhasMolFrac","tempInc","enFlo"]
-
- def paramgetter(self,mode="heatAdd"):
- self.mode = mode
- dict = {"pressDrop":None,"eff":None,self.mode:None}
- return dict
-
- # def add_compounds(self,addedcomp):
- # self.addedcomp = addedcomp
-
-
-
- def paramsetter(self,dict):
-
- self.pressDrop = dict['pressDrop']
- self.eff = dict['eff']
- self.modeVal = dict[self.mode]
-
- def connect(self,InputStms,OutputStms):
- self.InputStms = InputStms
- self.OutputStms = OutputStms
-
- def add_connection(self,flag,UnitOpr):
- if flag==1:
- # Input stream if flag is 1
- self.InputStms.append(UnitOpr)
- print("INPUT CONNECTION")
- else :
- print("OUTPUT CONNECTION")
- self.OutputStms.append(UnitOpr)
-
-
-
- def send_to_flowsheet(self):
- # self.addedcomp = addedcomp
- parameters = [['pressDrop',self.pressDrop],['eff',self.eff]]
- Inst = UnitOpr(name=self.name,counter=HeaterClass.counter,Type='Heater',parameters=parameters,mode=self.mode,modeVal=self.modeVal,ThermoPackReq=False,thermoPack=None,extra=self.extra,multidict=None,inputs=self.no_of_inputs,outputs=self.no_of_outputs)
- Inst.connect(self.InputStms,self.OutputStms)
- return Inst
-
-
-class CoolerClass():
- counter = 1
-
- def __init__(self,name='Cooler',pressDrop = None, eff = None):
- self.OM_data_eqn = ''
- self.OM_data_init = ''
- self.InputStms = []
- self.OutputStms = []
- self.name = name + str(CoolerClass.counter)
- self.mode = None
- self.modeVal = None
- self.type = 'Cooler'
- self.pressDrop = pressDrop
- self.eff = eff
- self.no_of_inputs = 1
- self.no_of_outputs = 1
- self.x = 2500-30
- self.y = 2500-30
- # self.addedcomp = None
- self.extra = None
- self.Prop = {
- 'pressDrop':None,
- 'eff':None,
- 'outT':None,
- 'tempDrop':None,
- 'heatRem':None,
- }
- HeaterClass.counter+=1
-
- def modesList(self):
- return ["heatRem","outT","outVapPhasMolFrac","tempDrop","enFlo"]
-
- def paramgetter(self,mode="heatRem"):
- self.mode = mode
- dict = {"pressDrop":None,"eff":None,self.mode:None}
- return dict
-
- def add_compounds(self,addedcomp):
- self.addedcomp = addedcomp
-
-
-
- def paramsetter(self,dict):
-
- self.pressDrop = dict['pressDrop']
- self.eff = dict['eff']
- self.modeVal = dict[self.mode]
-
- def connect(self,InputStms,OutputStms):
- self.InputStms = InputStms
- self.OutputStms = OutputStms
-
- def add_connection(self,flag,UnitOpr):
- if flag==1:
- # Input stream if flag is 1
- self.InputStms.append(UnitOpr)
- print("INPUT CONNECTION")
- else :
- print("OUTPUT CONNECTION")
- self.OutputStms.append(UnitOpr)
-
-
-
- def send_to_flowsheet(self,addedcomp):
- self.addedcomp = addedcomp
- parameters = {'pressDrop': self.pressDrop, 'eff': self.eff }
- Inst = UnitOpr(self.name,CoolerClass.counter,'Cooler',parameters,self.mode,self.modeVal,False,None,self.extra,None,self.no_of_inputs,self.no_of_outputs)
- Inst.connect(self.InputStms,self.OutputStms)
- return Inst
-
-
-
-
-class AdiaCompClass():
- counter = 1
-
- def __init__(self,name='AdiaComp', eff = None):
- self.OM_data_eqn = ''
- self.OM_data_init = ''
- self.InputStms = []
- self.OutputStms = []
- self.name = name + str(AdiaCompClass.counter)
- self.mode = None
- self.modeVal = None
- self.type = 'AdiaComp'
- self.thermoPackage ="Raoults_Law"
- #self.pressDrop = pressDrop
- self.eff = eff
- self.no_of_inputs = 1
- self.no_of_outputs = 1
- self.x = 2500-30
- self.y = 2500-30
- # self.addedcomp = None
- self.extra = ['Adiabatic_Compressor']
- AdiaCompClass.counter+=1
-
- def modesList(self):
- return ["pressInc","outP","reqPow"]
-
- def add_compounds(self,addedcomp):
- self.addedcomp = addedcomp
-
- def paramgetter(self,mode="pressInc"):
- self.mode = mode
- dict = {"eff":None,self.mode:None,"thermoPackage":None}
- return dict
-
- def paramsetter(self,dict):
-
- self.eff = dict['eff']
- self.modeVal = dict[self.mode]
-
- def add_connection(self,flag,UnitOpr):
- if flag==1:
- # Input stream if flag is 1
- self.InputStms.append(UnitOpr)
- print("INPUT CONNECTION")
- else :
- print("OUTPUT CONNECTION")
- self.OutputStms.append(UnitOpr)
-
- def connect(self,InputStms = None,OutputStms = None):
- self.InputStms = InputStms
- self.OutputStms = OutputStms
-
- def send_to_flowsheet(self,addedcomp):
- self.addedcomp = addedcomp
- parameters = [['eff',self.eff]]
- Inst = UnitOpr(self.name,AdiaCompClass.counter,'AdiaComp',parameters,self.mode,self.modeVal,True,self.thermoPackage,self.extra,None,self.no_of_inputs,self.no_of_outputs)
- Inst.connect(self.InputStms,self.OutputStms)
- return Inst
-
-class AdiaExpClass():
- counter = 1
-
- def __init__(self,name='AdiaExp', eff = None):
- self.OM_data_eqn = ''
- self.OM_data_init = ''
- self.InputStms = []
- self.OutputStms = []
- self.name = name + str(AdiaExpClass.counter)
- self.mode = None
- self.modeVal = None
- self.type = 'AdiaExp'
- self.thermoPackage ="Raoults_Law"
- #self.pressDrop = pressDrop
- self.eff = eff
- self.no_of_inputs = 1
- self.no_of_outputs = 1
- self.x = 2500-30
- self.y = 2500-30
- self.addedcomp = None
- self.extra = ['Adiabatic_Expander']
- AdiaExpClass.counter+=1
-
- def modesList(self):
- return ["pressDrop","outP","genPow"]
-
- def add_compounds(self,addedcomp):
- self.addedcomp = addedcomp
-
- def paramgetter(self,mode="pressDrop"):
- self.mode = mode
- dict = {"eff":None,self.mode:None,"thermoPackage":None}
- return dict
-
- def paramsetter(self,dict):
-
- self.eff = dict['eff']
- self.modeVal = dict[self.mode]
-
- def add_connection(self,flag,UnitOpr):
- if flag==1:
- # Input stream if flag is 1
- self.InputStms.append(UnitOpr)
- print("INPUT CONNECTION")
- else:
- print("OUTPUT CONNECTION")
- self.OutputStms.append(UnitOpr)
-
- def connect(self,InputStms = None,OutputStms = None):
- self.InputStms = InputStms
- self.OutputStms = OutputStms
-
- def send_to_flowsheet(self,addedcomp):
- self.addedcomp = addedcomp
- parameters = [['eff',self.eff]]
- Inst = UnitOpr(self.name,AdiaExpClass.counter,'AdiaExp',parameters,self.mode,self.modeVal,True,self.thermoPackage,self.extra,None,self.no_of_inputs,self.no_of_outputs)
- Inst.connect(self.InputStms,self.OutputStms)
- return Inst
-
-
-
-
-
-
-
-
-
-def helperFunc(type):
- if(type=="MatStm"):
- return MatStm(CompNames=compound_selected)
- else:
- return eval(type+"Class")()
-
-
-
diff --git a/main.ui b/main.ui
index 7bff94e..da7c162 100644
--- a/main.ui
+++ b/main.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1068</width>
- <height>810</height>
+ <height>803</height>
</rect>
</property>
<property name="windowTitle">
@@ -148,7 +148,7 @@
<x>0</x>
<y>0</y>
<width>1068</width>
- <height>26</height>
+ <height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -178,8 +178,6 @@
</property>
<addaction name="actionEquation_oriented"/>
<addaction name="actionSequential_mode"/>
- <addaction name="separator"/>
- <addaction name="actionTerminate"/>
</widget>
<widget class="QMenu" name="menuComponds">
<property name="title">
@@ -193,12 +191,19 @@
</property>
<addaction name="actionHelp"/>
</widget>
+ <widget class="QMenu" name="menuUtility">
+ <property name="title">
+ <string>Utility</string>
+ </property>
+ <addaction name="actionBinary_Phase_Envelope"/>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuView"/>
<addaction name="menuSimulation"/>
<addaction name="menuComponds"/>
<addaction name="menuHelp"/>
+ <addaction name="menuUtility"/>
</widget>
<widget class="QDockWidget" name="dockWidget">
<property name="sizePolicy">
@@ -256,10 +261,10 @@
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
- <x>-5</x>
+ <x>0</x>
<y>0</y>
- <width>222</width>
- <height>978</height>
+ <width>238</width>
+ <height>878</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -1196,9 +1201,9 @@
<string>Open</string>
</property>
</action>
- <action name="actionTerminate">
+ <action name="actionBinary_Phase_Envelope">
<property name="text">
- <string>Terminate</string>
+ <string>Binary Phase Envelope</string>
</property>
</action>
</widget>
diff --git a/mainApp.py b/mainApp.py
index ca49c39..ab29b5b 100644
--- a/mainApp.py
+++ b/mainApp.py
@@ -20,6 +20,7 @@ import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from component_selector import *
from dockWidget import dockWidget
+from Bin_Phase_env import *
from resDockWidget import resdockWidget
from UnitOperations import *
import datetime
@@ -118,6 +119,7 @@ class MainApp(QMainWindow,ui):
self.actionOpen.setShortcut('Ctrl+O')
self.actionTerminate.triggered.connect(self.terminate)
self.actionTerminate.setShortcut('Ctrl+T')
+ self.actionBinary_Phase_Envelope.triggered.connect(self.BinPhaseEnv)
'''
@@ -149,6 +151,17 @@ class MainApp(QMainWindow,ui):
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec_()
+ def BinPhaseEnv(self):
+ #compounds = self.comp.getComp()
+ if len(self.comp.getComp())<2:
+ QMessageBox.about(self, 'Important', "Please select atleast 2 Compounds first")
+ self.comp.show()
+ #compunds = self.comp.getComp()
+ else:
+
+ self.bin_phase = Bin_Phase_env(self.comp)
+ self.bin_phase.show()
+
'''
Shows Compounds Selector Dialog
'''