summaryrefslogtreecommitdiff
path: root/Streams.py
diff options
context:
space:
mode:
Diffstat (limited to 'Streams.py')
-rw-r--r--Streams.py108
1 files changed, 54 insertions, 54 deletions
diff --git a/Streams.py b/Streams.py
index 1b76247..835abe5 100644
--- a/Streams.py
+++ b/Streams.py
@@ -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,14 +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