summaryrefslogtreecommitdiff
path: root/Streams.py
diff options
context:
space:
mode:
authorpravindalve2020-06-23 20:17:20 +0530
committerGitHub2020-06-23 20:17:20 +0530
commitd3bed1ef7150f8e493ebaed3b841b1fe781e974d (patch)
treef7da5c3e6437fb270a6cb6b5aedb3af1690fdbce /Streams.py
parenta80b6726f5f70d9a2ec1cbf361e7f607849343bf (diff)
parent781a2ca03807d166498c0d95ef8c62d9ef3404d6 (diff)
downloadChemical-Simulator-GUI-d3bed1ef7150f8e493ebaed3b841b1fe781e974d.tar.gz
Chemical-Simulator-GUI-d3bed1ef7150f8e493ebaed3b841b1fe781e974d.tar.bz2
Chemical-Simulator-GUI-d3bed1ef7150f8e493ebaed3b841b1fe781e974d.zip
Merge pull request #3 from pravindalve/master
Updates and some bug fixes
Diffstat (limited to 'Streams.py')
-rw-r--r--Streams.py498
1 files changed, 55 insertions, 443 deletions
diff --git a/Streams.py b/Streams.py
index f35a056..81586f1 100644
--- a/Streams.py
+++ b/Streams.py
@@ -1,4 +1,4 @@
-from OMPython import OMCSession
+# from OMPython import OMCSession
from PyQt5.QtCore import *
import json
import sys
@@ -6,19 +6,19 @@ from collections import defaultdict
class MaterialStream():
counter = 1
- def __init__(self, CompNames = []):
+ def __init__(self, compound_names = []):
self.name = 'MaterialStream' + str(MaterialStream.counter)
self.type = 'MaterialStream'
- self.CompNames = CompNames
+ self.compound_names = compound_names
self.count = MaterialStream.counter
- self.thermoPackage ="RaoultsLaw"
+ self.thermo_package ="RaoultsLaw"
self.mode1 = "P"
self.mode2 = "T"
- self.mode1val = ""
- self.mode2val = ""
+ self.mode1_val = ""
+ self.mode2_val = ""
self.OM_data_init = ''
self.OM_data_eqn = ''
self.no_of_inputs = 1
@@ -27,9 +27,9 @@ class MaterialStream():
self.y = 2500-30
self.pos = QPointF(self.x, self.y)
MaterialStream.counter+=1
- self.startDict = {}
- self.eqnDict = {}
- self.modesList = ["PT","PH","PVF","TVF","PS"]
+ self.start_dict = {}
+ self.eqn_dict = {}
+ 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}},
@@ -54,10 +54,10 @@ class MaterialStream():
'F_pc' : {'name':'Mole Flow', 'value':100, 'unit':'mol/s'},
'Fm_pc' : {'name':'Mass Flow', 'value':None, 'unit':'g/s'},
}
- self.initVariables()
+ self.init_variables()
- def initVariables(self):
- for i, val in enumerate(self.CompNames):
+ def init_variables(self):
+ 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['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'}
@@ -73,46 +73,46 @@ class MaterialStream():
self.variables['F_pc[3,'+ str(i+1)+']'] = {'name':[val + ' Vapour Mole Flow'], 'value':None, 'unit':'mol/s'}
self.variables['Fm_pc[3,'+ str(i+1)+']'] = {'name':[val + ' Vapour Mass Flow'], 'value':None, 'unit':'g/s'}
- for i in self.CompNames:
+ for i in self.compound_names:
self.variables[i] = {'value':''}
- def paramgetter(self,mode):
+ def param_getter(self,mode):
dict = {}
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'], "thermoPackage":self.thermoPackage}
+ "MolFlow":self.variables['F_pc']['value'],"x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
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'], "thermoPackage":self.thermoPackage}
+ "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
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'], "thermoPackage":self.thermoPackage}
+ "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
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'], "thermoPackage":self.thermoPackage}
+ "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
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'], "thermoPackage":self.thermoPackage}
+ "MolFlow":self.variables['F_pc']['value'], "x_pc":self.variables['x_pc']['value'], "thermo_package":self.thermo_package}
return dict
- def paramsetter(self,dict):
+ def param_setter(self,dict):
print("inside paramsetter ", dict)
self.variables['x_pc']['value'] = dict['x_pc'].split(",")
- self.thermoPackage = dict['thermoPackage']
+ self.thermo_package = dict['thermo_package']
self.variables['F_p[1]']['value'] = dict['MolFlow']
print("inside")
# self.Prop[self.mode2] = dict[self.mode2]
@@ -122,7 +122,7 @@ class MaterialStream():
print(self.variables)
print(self.variables['x_pc']['value'])
- for i in range(len(self.CompNames)):
+ 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]:
@@ -141,7 +141,7 @@ class MaterialStream():
self.variables['Fm_pc[1,'+str(i+1)+']']['value'] = None
print('first for')
print('secnod for')
- for i in range(0,len(self.CompNames)):
+ 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
self.variables['F_pc[2,'+str(i+1)+']']['value'] = None
@@ -152,12 +152,12 @@ class MaterialStream():
self.variables['F_pc[3,'+str(i+1)+']']['value'] = None
self.variables['Fm_pc[3,'+str(i+1)+']']['value'] = None
- def setPos(self,pos):
+ def set_pos(self,pos):
self.pos = pos
- def GetMinEqnValues(self):
+ def get_min_eqn_values(self):
x_pclist = []
- for i in range(0,len(self.CompNames)):
+ 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'])
@@ -175,13 +175,13 @@ class MaterialStream():
x_pcstr = x_pcstr.replace('"','')
'''
if self.variables[self.mode1]['value']:
- self.eqnDict[self.mode1] = self.variables[self.mode1]['value']
+ self.eqn_dict[self.mode1] = self.variables[self.mode1]['value']
if self.variables[self.mode2]['value']:
- self.eqnDict[self.mode2] = self.variables[self.mode2]['value']
+ self.eqn_dict[self.mode2] = self.variables[self.mode2]['value']
if self.variables['x_pc']['value']:
- self.eqnDict['x_pc[1,:]'] = x_pc
+ self.eqn_dict['x_pc[1,:]'] = x_pc
if self.variables['F_pc']['value']:
- self.eqnDict['F_p[1]'] = 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'])
@@ -190,66 +190,66 @@ class MaterialStream():
print("F_p",self.variables['F_p[1]']['value'])
print("##############$GetMinVEqnValuesEnd$##################")
- def GetStartValues(self):
+ def get_start_values(self):
try:
if self.variables[self.mode1]['value']:
- self.startDict[self.mode1] = self.variables[self.mode1]['value']
+ self.start_dict[self.mode1] = self.variables[self.mode1]['value']
if self.variables[self.mode2]['value']:
- self.startDict[self.mode2] = self.variables[self.mode2]['value']
+ self.start_dict[self.mode2] = self.variables[self.mode2]['value']
if self.variables['x_pc[2,1]']['value'] != None:
x_pcarr = []
for i in range(1,4):
cmf = []
- for j in range(1,len(self.CompNames)+1):
+ for j in range(1,len(self.compound_names)+1):
cmf.append(str(self.variables['x_pc['+str(i)+','+str(j)+']']['value']))
x_pcarr.append(cmf)
x_pcstr = json.dumps(x_pcarr)
x_pcstr = x_pcstr.replace('[','{')
x_pcstr = x_pcstr.replace(']','}')
x_pcstr = x_pcstr.replace('"','')
- self.startDict['x_pc'] = x_pcstr
+ self.start_dict['x_pc'] = x_pcstr
if self.variables['xm_pc[2,1]']['value'] != None:
xm_pcarr = []
for i in range(1,4):
cmf = []
- for j in range(1,len(self.CompNames)+1):
+ for j in range(1,len(self.compound_names)+1):
cmf.append(str(self.variables['xm_pc['+str(i)+','+str(j)+']']['value']))
xm_pcarr.append(cmf)
xm_pcstr = json.dumps(x_pcarr)
xm_pcstr = xm_pcstr.replace('[','{')
xm_pcstr = xm_pcstr.replace(']','}')
xm_pcstr = xm_pcstr.replace('"','')
- self.startDict['xm_pc'] = xm_pcstr
+ self.start_dict['xm_pc'] = xm_pcstr
if self.variables['Fm_pc[2,1]']['value'] != None:
Fm_pcarr = []
for i in range(1,4):
cmf = []
- for j in range(1,len(self.CompNames)+1):
+ for j in range(1,len(self.compound_names)+1):
cmf.append(str(self.variables['Fm_pc['+str(i)+','+str(j)+']']['value']))
Fm_pcarr.append(cmf)
Fm_pcstr = json.dumps(x_pcarr)
Fm_pcstr = Fm_pcstr.replace('[','{')
Fm_pcstr = Fm_pcstr.replace(']','}')
Fm_pcstr = Fm_pcstr.replace('"','')
- self.startDict['Fm_pc'] = Fm_pcstr
+ self.start_dict['Fm_pc'] = Fm_pcstr
if self.variables['F_pc[2,1]']['value'] != None:
F_pcarr = []
for i in range(1,4):
cmf = []
- for j in range(1,len(self.CompNames)+1):
+ for j in range(1,len(self.compound_names)+1):
cmf.append(str(self.variables['F_pc['+str(i)+','+str(j)+']']['value']))
F_pcarr.append(cmf)
F_pcstr = json.dumps(F_pcarr)
F_pcstr = F_pcstr.replace('[','{')
F_pcstr = F_pcstr.replace(']','}')
F_pcstr = F_pcstr.replace('"','')
- self.startDict['F_pc'] = F_pcstr
+ self.start_dict['F_pc'] = F_pcstr
if self.variables['MW_p[2]']['value'] != None:
MW_pArr = []
@@ -259,7 +259,7 @@ class MaterialStream():
MW_pStr = MW_pStr.replace('[','{')
MW_pStr = MW_pStr.replace(']','}')
MW_pStr = MW_pStr.replace('"','')
- self.startDict['MW_p'] = MW_pStr
+ self.start_dict['MW_p'] = MW_pStr
if self.variables['F_p[2]']['value'] != None:
F_pArr = []
@@ -269,7 +269,7 @@ class MaterialStream():
F_pStr = F_pStr.replace('[','{')
F_pStr = F_pStr.replace(']','}')
F_pStr = F_pStr.replace('"','')
- self.startDict['F_p'] = F_pStr
+ self.start_dict['F_p'] = F_pStr
if self.variables['Cp_p[2]']['value'] != None:
Cp_pArr = []
@@ -279,7 +279,7 @@ class MaterialStream():
Cp_pStr = Cp_pStr.replace('[','{')
Cp_pStr = Cp_pStr.replace(']','}')
Cp_pStr = Cp_pStr.replace('"','')
- self.startDict['Cp_p'] = Cp_pStr
+ self.start_dict['Cp_p'] = Cp_pStr
if self.variables['H_p[2]']['value'] != None:
H_pArr = []
@@ -289,7 +289,7 @@ class MaterialStream():
H_pStr = H_pStr.replace('[','{')
H_pStr = H_pStr.replace(']','}')
H_pStr = H_pStr.replace('"','')
- self.startDict['H_p'] = H_pStr
+ self.start_dict['H_p'] = H_pStr
if self.variables['S_p[2]']['value'] != None:
@@ -300,7 +300,7 @@ class MaterialStream():
S_pStr = S_pStr.replace('[','{')
S_pStr = S_pStr.replace(']','}')
S_pStr = S_pStr.replace('"','')
- self.startDict['S_p'] = S_pStr
+ self.start_dict['S_p'] = S_pStr
if self.variables['Fm_p[2]']['value'] != None:
Fm_pArr = []
@@ -310,7 +310,7 @@ class MaterialStream():
Fm_pStr = Fm_pStr.replace('[','{')
Fm_pStr = Fm_pStr.replace(']','}')
Fm_pStr = Fm_pStr.replace('"','')
- self.startDict['Fm_p'] = Fm_pStr
+ self.start_dict['Fm_p'] = Fm_pStr
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
@@ -322,10 +322,10 @@ class MaterialStream():
self.OM_data_init = ''
self.OM_data_init = self.OM_data_init + ("model ms"+str(self.count)+"\n")
self.OM_data_init = self.OM_data_init + ("extends Simulator.Streams.MaterialStream;\n" )
- self.OM_data_init = self.OM_data_init + ("extends Simulator.Files.ThermodynamicPackages."+self.thermoPackage+";\n")
+ 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.GetStartValues()
+ # 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)
@@ -333,7 +333,7 @@ class MaterialStream():
C = str(addedcomp).strip('[').strip(']')
C = C.replace("'","")
self.OM_data_init = self.OM_data_init + C + "},"
- #for key, value in self.startDict.items():
+ #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'
@@ -344,402 +344,14 @@ class MaterialStream():
self.OM_data_eqn = ''
self.comp_count = len(addedcomp)
if method == 'Eqn':
- self.eqnDict = {}
- self.GetMinEqnValues()
+ self.eqn_dict = {}
+ self.get_min_eqn_values()
if method == 'SM':
- self.eqnDict = {}
- self.GetMinEqnValues()
+ self.eqn_dict = {}
+ self.get_min_eqn_values()
#self.GetEquationValues()
#self.GetEquationValues()
- for key,value in self.eqnDict.items():
+ 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
-
-
-'''
-from OMPython import OMCSession
-from PyQt5.QtCore import *
-import json
-import sys
-from collections import defaultdict
-
-class MaterialStream():
- counter = 1
- def __init__(self,CompNames = [],Temperature=300,Pressure=101325,xvap=None,xmvap=None,xliq=None,xmliq=None,x_pc = [1.0], xm_pc = [], MolFlow=100, MasFlow=None,**kwargs):
- self.name = 'MaterialStream' + str(MaterialStream.counter)
- self.type = 'MaterialStream'
- self.T = Temperature
- self.P = Pressure
- self.xvap = xvap
- self.xmvap = xmvap
- self.xliq = xliq
- self.xmliq = xmliq
- self.CompNames = CompNames
- self.x_pc = x_pc
- self.xm_pc = xm_pc
- self.MolFlow = MolFlow
- self.MasFlow = MasFlow
- self.OM_data_init = ''
- self.OM_data_eqn = ''
- self.count = MaterialStream.counter
- self.thermoPackage ="RaoultsLaw"
- self.mode1 = "P"
- self.mode1val = ""
- self.mode2 = "T"
- self.mode2val = ""
- self.no_of_inputs = 1
- self.no_of_outputs = 1
- self.x = 2500-30
- self.y = 2500-30
- self.pos = QPointF(self.x, self.y)
- MaterialStream.counter+=1
- self.startDict = {}
- self.eqnDict = {}
- self.modesList = ["PT","PH","PVF","TVF","PS"]
-
- self.Prop = {
-
- self.mode1:self.mode1val,
- self.mode2:self.mode2val,
- 'xliq':xliq,
- 'xmliq':xmliq,
- 'xvap':xvap,
- 'xmvap':xmvap,
- 'F_p[1]':MolFlow,
- 'Fm_p[1]':MasFlow,
- 'MW_p[1]':None,
- 'MW_p[2]':None,
- 'MW_p[3]':None,
- 'Cp_p[1]':None,
- 'H_p[1]':None,
- 'S_p[1]':None,
- 'Cp_p[2]':None,
- 'H_p[2]':None,
- 'S_p[2]':None,
- 'Cp_p[3]':None,
- 'H_p[3]':None,
- 'S_p[3]':None,
- 'F_p[2]':None,
- 'Fm_p[2]':None,
- 'F_p[3]':None,
- 'Fm_p[3]':None
-
- }
-
- self.Prop1 = {
- self.mode1:self.mode1val,
- self.mode2:self.mode2val,
- 'xliq':xliq,
- 'xmliq':xmliq,
- 'xvap':xvap,
- 'xmvap':xmvap,
- 'F_p[1]':MolFlow,
- 'Fm_p[1]':MasFlow,
- 'MW_p[1]':None,
- 'MW_p[2]':None,
- 'MW_p[3]':None,
- 'Cp_p[1]':None,
- 'H_p[1]':None,
- 'S_p[1]':None,
- 'Cp_p[2]':None,
- 'H_p[2]':None,
- 'S_p[2]':None,
- 'Cp_p[3]':None,
- 'H_p[3]':None,
- 'S_p[3]':None,
- 'F_p[2]':None,
- 'Fm_p[2]':None,
- 'F_p[3]':None,
- 'Fm_p[3]':None
-
- }
-
- def paramgetter(self,mode):
- dict = {}
- # print("Hello hello ", mode)
- # if(mode == None):
- # mode = self.modesList[0]
- if(mode=="PT"):
- self.mode1 = 'P'
- self.mode2 = 'T'
- dict = {self.mode2:self.T,self.mode1:self.P,"x_pc":self.x_pc,"MolFlow":self.MolFlow,"thermoPackage":self.thermoPackage}
- elif(mode=="PH"):
- self.mode1 = 'P'
- self.mode2 = 'H_p[1]'
- dict = {self.mode1:self.P,self.mode2:self.Prop['H_p[1]'],"x_pc":self.x_pc,"MolFlow":self.MolFlow,"thermoPackage":self.thermoPackage}
- elif(mode=="PVF"):
- self.mode1 = 'P'
- self.mode2 = 'xvap'
- dict = {self.mode1:self.P,self.mode2:self.xvap,"x_pc":self.x_pc,"MolFlow":self.MolFlow,"thermoPackage":self.thermoPackage}
- elif(mode=="TVF"):
- self.mode1 = 'T'
- self.mode2 = 'xvap'
- dict = {self.mode1:self.T,self.mode2:self.xvap,"x_pc":self.x_pc,"MolFlow":self.MolFlow,"thermoPackage":self.thermoPackage}
- elif(mode=="PS"):
- self.mode1 = 'P'
- self.mode2 = 'S_p[1]'
- dict = {self.mode1:self.P,self.mode2:self.Prop['S_p[1]'],"x_pc":self.x_pc,"MolFlow":self.MolFlow,"thermoPackage":self.thermoPackage}
-
- return dict
-
- def paramsetter(self,dict):
- self.mode1val = dict[self.mode1]
- self.mode2val = dict[self.mode2]
- self.MolFlow = dict['MolFlow']
- self.x_pc = dict['x_pc'].split(",")
- self.thermoPackage = dict['thermoPackage']
- self.Prop['F_p[1]'] = self.MolFlow
- self.Prop[self.mode2] = dict[self.mode2]
- self.Prop[self.mode1] = dict[self.mode1]
- for i in range(len(self.CompNames)):
- print('####### x_pc #########\n',self.x_pc[i])
- if self.x_pc:
- self.Prop['x_pc[1,'+str(i+1)+']'] = self.x_pc[i]
- else:
- self.Prop['x_pc[1,'+str(i+1)+']'] = None
-
- if self.xm_pc:
- self.Prop['xm_pc[1,'+str(i+1)+']'] = self.xm_pc[i]
- else:
- self.Prop['xm_pc[1,'+str(i+1)+']'] = None
-
- self.Prop['F_pc[1,'+str(i+1)+']'] = None
- self.Prop['Fm_pc[1,'+str(i+1)+']'] = None
- for i in range(0,len(self.CompNames)):
- self.Prop['x_pc[2,'+str(i+1)+']'] = None
- self.Prop['xm_pc[2,'+str(i+1)+']'] = None
- self.Prop['F_pc[2,'+str(i+1)+']'] = None
- self.Prop['Fm_pc[2,'+str(i+1)+']'] = None
- self.Prop['x_pc[3,'+str(i+1)+']'] = None
- self.Prop['xm_pc[3,'+str(i+1)+']'] = None
- self.Prop['F_pc[3,'+str(i+1)+']'] = None
- self.Prop['Fm_pc[3,'+str(i+1)+']'] = None
-
- def setPos(self,pos):
- self.pos = pos
-
- def GetMinEqnValues(self):
- x_pclist = []
- for i in range(0,len(self.CompNames)):
- print(self.Prop['x_pc[1,'+str(i+1)+']'])
- x_pclist.append(self.Prop['x_pc[1,'+str(i+1)+']'])
- 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.Prop[self.mode1]:
- self.eqnDict[self.mode1] = self.Prop[self.mode1]
- if self.Prop[self.mode2]:
- self.eqnDict[self.mode2] = self.Prop[self.mode2]
- if self.x_pc:
- self.eqnDict['x_pc[1,:]'] = x_pc
- if self.MolFlow:
- self.eqnDict['F_p[1]'] = self.Prop['F_p[1]']#self.MolFlow
-
- print("##############$GetMinVEqnValuesStart$##################")
- print("P:",self.Prop[self.mode1])
- print("T:",self.Prop[self.mode2])
- print("x_pc",x_pc)
- print("F_p",self.Prop['F_p[1]'])
- print("##############$GetMinVEqnValuesEnd$##################")
-
- # def GetEquationValues(self): # Not being called anywhere
- # if self.Prop[self.mode1]:
- # self.eqnDict[self.mode1] = self.Prop[self.mode1]
-
- # if self.Prop[self.mode2]:
- # self.eqnDict[self.mode2] = self.Prop[self.mode2]
-
- # if self.Prop['x_pc[1,1]']:
- # cfa = []
- # for i in range(1,len(self.CompNames)+1):
- # cfa.append(self.Prop['x_pc[1,'+str(i)+']'])
- # cmpMolFracstr = json.dumps(cfa)
- # cmpMolFracstr = cmpMolFracstr.replace('[','{')
- # cmpMolFracstr = cmpMolFracstr.replace(']','}')
- # cmpMolFracstr = cmpMolFracstr.replace('"','')
- # self.eqnDict['x_pc[1,:]'] = cmpMolFracstr
-
- # if self.Prop['F_p[1]']:
- # self.eqnDict['F_p[1]'] = self.Prop['F_p[1]']
-
-
- def GetStartValues(self):
- try:
- if self.Prop[self.mode1]:
- self.startDict[self.mode1] = self.Prop[self.mode1]
-
- if self.Prop[self.mode2]:
- self.startDict[self.mode2] = self.Prop[self.mode2]
-
-
- if self.Prop['x_pc[2,1]'] != None:
- x_pcarr = []
- for i in range(1,4):
- cmf = []
- for j in range(1,len(self.CompNames)+1):
- cmf.append(str(self.Prop['x_pc['+str(i)+','+str(j)+']']))
- x_pcarr.append(cmf)
- x_pcstr = json.dumps(x_pcarr)
- x_pcstr = x_pcstr.replace('[','{')
- x_pcstr = x_pcstr.replace(']','}')
- x_pcstr = x_pcstr.replace('"','')
- self.startDict['x_pc'] = x_pcstr
-
- if self.Prop['xm_pc[2,1]'] != None:
- xm_pcarr = []
- for i in range(1,4):
- cmf = []
- for j in range(1,len(self.CompNames)+1):
- cmf.append(str(self.Prop['xm_pc['+str(i)+','+str(j)+']']))
- xm_pcarr.append(cmf)
- xm_pcstr = json.dumps(x_pcarr)
- xm_pcstr = xm_pcstr.replace('[','{')
- xm_pcstr = xm_pcstr.replace(']','}')
- xm_pcstr = xm_pcstr.replace('"','')
- self.startDict['xm_pc'] = xm_pcstr
-
- if self.Prop['Fm_pc[2,1]'] != None:
- Fm_pcarr = []
- for i in range(1,4):
- cmf = []
- for j in range(1,len(self.CompNames)+1):
- cmf.append(str(self.Prop['Fm_pc['+str(i)+','+str(j)+']']))
- Fm_pcarr.append(cmf)
- Fm_pcstr = json.dumps(x_pcarr)
- Fm_pcstr = Fm_pcstr.replace('[','{')
- Fm_pcstr = Fm_pcstr.replace(']','}')
- Fm_pcstr = Fm_pcstr.replace('"','')
- self.startDict['Fm_pc'] = Fm_pcstr
-
- if self.Prop['F_pc[2,1]'] != None:
- F_pcarr = []
- for i in range(1,4):
- cmf = []
- for j in range(1,len(self.CompNames)+1):
- cmf.append(str(self.Prop['F_pc['+str(i)+','+str(j)+']']))
- F_pcarr.append(cmf)
- F_pcstr = json.dumps(F_pcarr)
- F_pcstr = F_pcstr.replace('[','{')
- F_pcstr = F_pcstr.replace(']','}')
- F_pcstr = F_pcstr.replace('"','')
- self.startDict['F_pc'] = F_pcstr
-
- if self.Prop['MW_p[2]'] != None:
- MW_pArr = []
- for i in range(1,4):
- MW_pArr.append(self.Prop['MW_p['+str(i)+']'])
- MW_pStr = json.dumps(MW_pArr)
- MW_pStr = MW_pStr.replace('[','{')
- MW_pStr = MW_pStr.replace(']','}')
- MW_pStr = MW_pStr.replace('"','')
- self.startDict['MW_p'] = MW_pStr
-
- if self.Prop['F_p[2]'] != None:
- F_pArr = []
- for i in range(1,4):
- F_pArr.append(self.Prop['F_p['+str(i)+']'])
- F_pStr = json.dumps(F_pArr)
- F_pStr = F_pStr.replace('[','{')
- F_pStr = F_pStr.replace(']','}')
- F_pStr = F_pStr.replace('"','')
- self.startDict['F_p'] = F_pStr
-
- if self.Prop['Cp_p[2]'] != None:
- Cp_pArr = []
- for i in range(1,4):
- Cp_pArr.append(self.Prop['Cp_p['+str(i)+']'])
- Cp_pStr = json.dumps(Cp_pArr)
- Cp_pStr = Cp_pStr.replace('[','{')
- Cp_pStr = Cp_pStr.replace(']','}')
- Cp_pStr = Cp_pStr.replace('"','')
- self.startDict['Cp_p'] = Cp_pStr
-
- if self.Prop['H_p[2]'] != None:
- H_pArr = []
- for i in range(1,4):
- H_pArr.append(self.Prop['H_p['+str(i)+']'])
- H_pStr = json.dumps(H_pArr)
- H_pStr = H_pStr.replace('[','{')
- H_pStr = H_pStr.replace(']','}')
- H_pStr = H_pStr.replace('"','')
- self.startDict['H_p'] = H_pStr
-
-
- if self.Prop['S_p[2]'] != None:
- S_pArr = []
- for i in range(1,4):
- S_pArr.append(self.Prop['S_p['+str(i)+']'])
- S_pStr = json.dumps(S_pArr)
- S_pStr = S_pStr.replace('[','{')
- S_pStr = S_pStr.replace(']','}')
- S_pStr = S_pStr.replace('"','')
- self.startDict['S_p'] = S_pStr
-
- if self.Prop['Fm_p[2]'] != None:
- Fm_pArr = []
- for i in range(1,4):
- Fm_pArr.append(self.Prop['Fm_p['+str(i)+']'])
- Fm_pStr = json.dumps(Fm_pArr)
- Fm_pStr = Fm_pStr.replace('[','{')
- Fm_pStr = Fm_pStr.replace(']','}')
- Fm_pStr = Fm_pStr.replace('"','')
- self.startDict['Fm_p'] = Fm_pStr
-
- except Exception as e:
- exc_type, exc_obj, exc_tb = sys.exc_info()
- print(exc_type,exc_tb.tb_lineno)
- print(e)
- print('error')
-
-
- def OM_Flowsheet_Initialize(self,addedcomp):
- self.OM_data_init = ''
- self.OM_data_init = self.OM_data_init + ("model ms"+str(self.count)+"\n")
- self.OM_data_init = self.OM_data_init + ("extends Simulator.Streams.MaterialStream;\n" )
- self.OM_data_init = self.OM_data_init + ("extends Simulator.Files.ThermodynamicPackages."+self.thermoPackage+";\n")
- self.OM_data_init = self.OM_data_init + ("end ms"+str(self.count)+";\n")
- comp_count = len(addedcomp)
- # self.GetStartValues()
-
- #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.startDict.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
-
-
- def OM_Flowsheet_Equation(self,addedcomp,method):
- self.OM_data_eqn = ''
- self.comp_count = len(addedcomp)
- if method == 'Eqn':
- self.eqnDict = {}
- self.GetMinEqnValues()
- if method == 'SM':
- self.eqnDict = {}
- self.GetMinEqnValues()
- #self.GetEquationValues()
- #self.GetEquationValues()
-
- for key,value in self.eqnDict.items():
- self.OM_data_eqn = self.OM_data_eqn + self.name + '.'+ key + ' = ' + str(value) + ';\n'
- return self.OM_data_eqn
-
-
-''' \ No newline at end of file