summaryrefslogtreecommitdiff
path: root/Streams.py
diff options
context:
space:
mode:
Diffstat (limited to 'Streams.py')
-rw-r--r--Streams.py55
1 files changed, 7 insertions, 48 deletions
diff --git a/Streams.py b/Streams.py
index bed975d..2142e8f 100644
--- a/Streams.py
+++ b/Streams.py
@@ -1,8 +1,6 @@
-# from OMPython import OMCSession
-from PyQt5.QtCore import *
import json
import sys
-from collections import defaultdict
+from PyQt5.QtCore import *
class MaterialStream():
counter = 1
@@ -32,7 +30,7 @@ class MaterialStream():
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}},
+ 'P' : {'name':'Pressure', 'value':101325, 'unit':'Pa'},
'T' : {'name':'Temperature', 'value':300, 'unit':'K'},
'xvap' : {'name':'Vapour Phase Mole Fraction', 'value':None, 'unit':'g/s'},
@@ -117,38 +115,21 @@ class MaterialStream():
def param_setter(self,dict):
- print("inside paramsetter ", dict)
-
self.variables['x_pc']['value'] = dict['x_pc'].split(",")
self.thermo_package = dict['Thermo package']
self.variables['F_p[1]']['value'] = dict['MolFlow']
- print("inside")
- # self.Prop[self.mode2] = dict[self.mode2]
- # self.Prop[self.mode1] = dict[self.mode1]
self.variables[self.mode1]['value'] = dict[self.mode1]
self.variables[self.mode2]['value'] = dict[self.mode2]
-
- print(self.variables)
- print(self.variables['x_pc']['value'])
+
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]:
self.variables['x_pc[1,'+str(i+1)+']']['value'] = self.variables['x_pc']['value'][i]
else:
self.variables['x_pc[1,'+str(i+1)+']']['value'] = None
- print('xm_pc')
- # if self.variables['xm_pc']['value'][i]:
- # self.variables['xm_pc[1,'+str(i+1)+']']['value'] = self.variables['xm_pc']['value'][i]
- # else:
self.variables['xm_pc[1,'+str(i+1)+']']['value'] = self.variables['xm_pc']['value']
- print('f_pc')
self.variables['F_pc[1,'+str(i+1)+']']['value'] = None
- print('fm_pc')
self.variables['Fm_pc[1,'+str(i+1)+']']['value'] = None
- print('first for')
- print('secnod for')
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
@@ -166,22 +147,12 @@ class MaterialStream():
def get_min_eqn_values(self):
x_pclist = []
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'])
- 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.variables[self.mode1]['value']:
self.eqn_dict[self.mode1] = self.variables[self.mode1]['value']
if self.variables[self.mode2]['value']:
@@ -191,13 +162,6 @@ class MaterialStream():
if 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'])
- print("T:",self.variables[self.mode2]['value'])
- print("x_pc",self.variables['x_pc']['value'])
- print("F_p",self.variables['F_p[1]']['value'])
- print("##############$GetMinVEqnValuesEnd$##################")
-
def get_start_values(self):
try:
if self.variables[self.mode1]['value']:
@@ -333,16 +297,13 @@ class MaterialStream():
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.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)
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.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'
return self.OM_data_init
@@ -357,9 +318,7 @@ class MaterialStream():
if method == 'SM':
self.eqn_dict = {}
self.get_min_eqn_values()
- #self.GetEquationValues()
- #self.GetEquationValues()
-
+
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