diff options
author | SaurabhAgarwala | 2019-12-24 18:41:45 +0530 |
---|---|---|
committer | SaurabhAgarwala | 2019-12-24 18:41:45 +0530 |
commit | 69b7cbf63b47cc5144626434ce9d0cfc17c5f5ad (patch) | |
tree | 3c9c95708ba7599e41230fbddf4282b949ecc5ba /helper.py | |
parent | e9b132bbfe89334e4656c2bb3a63693bf85c3ec5 (diff) | |
parent | 7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048 (diff) | |
download | Chemical-Simulator-GUI-69b7cbf63b47cc5144626434ce9d0cfc17c5f5ad.tar.gz Chemical-Simulator-GUI-69b7cbf63b47cc5144626434ce9d0cfc17c5f5ad.tar.bz2 Chemical-Simulator-GUI-69b7cbf63b47cc5144626434ce9d0cfc17c5f5ad.zip |
Merge conflicts resolved, threading and terminating simulation implemented
Diffstat (limited to 'helper.py')
-rw-r--r-- | helper.py | 330 |
1 files changed, 291 insertions, 39 deletions
@@ -1,45 +1,297 @@ from OMChem.Flowsheet import Flowsheet from OMChem.MatStm import MatStm -from OMChem.Mixer import Mixer +from OMChem.UnitOprns import UnitOpr from OMChem.EngStm import EngStm -from OMChem.Heater import Heater -from OMChem.Flash import Flash -from OMChem.Splitter import Splitter -from OMChem.Valve import Valve -from OMChem.Cooler import Cooler -from OMChem.CompSep import CompSep -from OMChem.adiabatic_comp import AdiaComp -from OMChem.DistCol import DistCol -from OMChem.adiabatic_exp import AdiaExp -from OMChem.Pump import Pump -from OMChem.ShortcutColumn import ShortcutColumn +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 * -def helperFunc(type,name1,count): - if(type=="Mixer"): - return Mixer(name=name1) - elif(type=="MatStm"): - return MatStm(name=(name1,count),CompNames=compound_selected) - elif(type=="Splitter"): - return Splitter(name=name1) - elif(type=="Flash"): - return Flash(name=(name1,count)) - elif(type=="Heater"): - return Heater(name=name1) - elif(type=="Valve"): - return Valve(name=name1) - elif(type=="Cooler"): - return Cooler(name=name1) - elif(type=="CompSep"): - return CompSep(name=name1) - elif(type=="AdiaComp"): - return AdiaComp(name=(name1,count)) - elif(type=="AdiaExp"): - return AdiaExp(name=(name1,count)) - elif(type=="DistCol"): - return DistCol(name=(name1,count)) - elif(type=="Pump"): - return Pump(name=name1) - elif(type=="ShortCol"): - return ShortcutColumn(name=(name1,count)) + +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 + + def modesList(self): + return ["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,addedcomp): + self.addedcomp = addedcomp + parameters = [['pressDrop',self.pressDrop],['eff',self.eff]] + Inst = UnitOpr(self.name,HeaterClass.counter,'Heater',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 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")() + + + |