summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrenda-br2023-01-03 11:54:35 -0800
committerbrenda-br2023-01-03 15:55:57 -0800
commit6640cdfac4c954a19a2e01988b34e7777bd9e39f (patch)
tree75e8765e5f390bc8d7255b04c4c590734cee8d95
parentecf089991f8f3c15c3c99f376be3b954ec5b3545 (diff)
downloadChemical-Simulator-GUI-6640cdfac4c954a19a2e01988b34e7777bd9e39f.tar.gz
Chemical-Simulator-GUI-6640cdfac4c954a19a2e01988b34e7777bd9e39f.tar.bz2
Chemical-Simulator-GUI-6640cdfac4c954a19a2e01988b34e7777bd9e39f.zip
message box (unedit)
-rw-r--r--ComponentSelector.py8
-rw-r--r--Container.py6
-rw-r--r--DockWidgets/DockWidgetMaterialStream.py50
-rw-r--r--OMChem/Flowsheet.py9
-rw-r--r--Simulator/BinaryEnvelopes.mo19
-rw-r--r--Simulator/Simulator/Examples/MaterialStream.mo2
-rw-r--r--Simulator/Simulator/Streams/MaterialStream.mo2
-rw-r--r--Streams.py4
-rw-r--r--main.ui20
-rw-r--r--pycflags0
-rw-r--r--pyldflags0
11 files changed, 72 insertions, 48 deletions
diff --git a/ComponentSelector.py b/ComponentSelector.py
index e8f282c..60498cc 100644
--- a/ComponentSelector.py
+++ b/ComponentSelector.py
@@ -27,7 +27,7 @@ class ComponentSelector(QDialog,ui_dialog):
x=i.get_comp_name_list()
self.dict1[i]=x
self.lines+=x
- print(self.lines)
+ #print(self.lines)
#self.DB1_list=self.DB1.get_comp_name_list()
@@ -107,7 +107,7 @@ class ComponentSelector(QDialog,ui_dialog):
self.final_mo()
self.lineEdit.clear()
- print(compound_selected)
+ #print(compound_selected)
self.CAS=self.obj.get_value(self.comp,'CAS')
self.name=self.comp
@@ -117,7 +117,7 @@ class ComponentSelector(QDialog,ui_dialog):
dict={'CAS':self.CAS,'Name':self.name,'Molecular Formula':self.molecular_formula,'Molecular Weight':self.molecular_weight}
#converted everything to a dictionary which will be passes to addtable
#function as a parameter.
- print(dict)
+ #print(dict)
self.add_to_table(dict)
else:
self.show_error()
@@ -139,7 +139,7 @@ class ComponentSelector(QDialog,ui_dialog):
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
- print(exc_type, fname, exc_tb.tb_lineno)
+ #print(exc_type, fname, exc_tb.tb_lineno)
def add_compounds_to_list(self,comp): # which list?
self.item = QListWidgetItem()
diff --git a/Container.py b/Container.py
index 3068c78..ded17da 100644
--- a/Container.py
+++ b/Container.py
@@ -126,12 +126,12 @@ class Container():
except AttributeError:
pass
- print("SIMULATE")
- print(mode)
+ #print("SIMULATE")
+ #print(mode)
self.compounds = compound_selected
self.flowsheet = Flowsheet()
self.flowsheet.add_compound_list([c[:c.index('(')] for c in self.compounds])
- print("######## connection master#########\n",self.conn)
+ #print("######## connection master#########\n",self.conn)
for i in self.unit_operations :
self.flowsheet.add_unit_operations(i)
diff --git a/DockWidgets/DockWidgetMaterialStream.py b/DockWidgets/DockWidgetMaterialStream.py
index 2e5f303..54d57b9 100644
--- a/DockWidgets/DockWidgetMaterialStream.py
+++ b/DockWidgets/DockWidgetMaterialStream.py
@@ -65,7 +65,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
for c,i in enumerate(self.input_dict):
if(i=="x_pc"):
noc = len(compound_selected)
- print(noc)
+ #print(noc)
self.x_pclist.clear()
self.comp_gb = QGroupBox("Mole Fractions")
@@ -89,7 +89,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
elif i == "Thermo Package":
self.cbTP.setCurrentText(self.input_dict[i])
else:
- print("elseloop")
+ #print("elseloop")
l = QLineEdit()
if self.input_dict[i] != None:
l.setText(str(self.input_dict[i]))
@@ -114,7 +114,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
def update_compounds(self):
try:
noc = len(compound_selected)
- print(noc)
+ #print(noc)
self.x_pclist.clear()
lay = QGridLayout()
@@ -134,9 +134,9 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
def param(self):
try:
self.dict={}
- print("param.input_dict ", self.input_dict)
+ #print("param.input_dict ", self.input_dict)
for i in self.input_dict:
- print(i)
+ #print(i)
if(i =="x_pc"):
l=[]
mf = []
@@ -159,11 +159,11 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
if (self.input_dict[i].text()):
self.dict[i] = self.input_dict[i].text()
else:
- print(self.input_dict[i])
+ #print(self.input_dict[i])
self.show_error()
break
- print("param ", self.dict)
+ #print("param ", self.dict)
self.obj.param_setter(self.dict)
self.hide()
@@ -190,7 +190,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
# result data tab
def results_category(self,name):
try:
- print("Under result category name ", name)
+ #print("Under result category name ", name)
result=self.container.result
obj = self.container.fetch_object(name)
@@ -207,15 +207,15 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
ll = [] # list for basis names
for basis in d:
propertyname = name + '.' + d[basis]
- print("basis ", basis, propertyname)
+ #print("basis ", basis, propertyname)
for i in result[0]:
if (propertyname in i):
ll.append(i)
- print(ll)
+ #print(ll)
j = 0
namee = 'none'
- print("namee ", namee)
+ #print("namee ", namee)
#initialization for treewidgets
lroot = 1
mroot = 1
@@ -224,11 +224,11 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
for i,k in enumerate(ll):
ind = result[0].index(k)
- print("index ", ind)
- print("str ", k)
+ #print("index ", ind)
+ #print("str ", k)
resultval = str(result[-1][ind])
- print("######Resultsfetch####",resultval)
- print(k[k.find(".")+1:k.find("[")])
+ #print("######Resultsfetch####",resultval)
+ #print(k[k.find(".")+1:k.find("[")])
obj.variables[k.split('.')[1]]['value'] = resultval
if namee not in k:
@@ -258,14 +258,14 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
phaseResLst = []
for phase in p:
propertyname = name + '.' + p[phase]
- print("phase ", phase, propertyname)
+ #print("phase ", phase, propertyname)
for i in result[0]:
if i.find('['):
if (propertyname == i[0:i.find('[')]):
phaseResLst.append(i)
if propertyname == i:
phaseResLst.append(i)
- print(phaseResLst)
+ #print(phaseResLst)
self.mTableWidget.setRowCount(0)
self.lTableWidget.setRowCount(0)
@@ -274,14 +274,14 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
for i,val in enumerate(phaseResLst):
ind = result[0].index(val)
resultval = str(result[-1][ind])
- print(resultval, i, val)
+ #print(resultval, i, val)
obj.variables[val.split('.')[1]]['value'] = resultval
if '[' in val:
- print(val)
+ #print(val)
temp = val[val.find('.')+1:val.find('[')]
- print(temp)
+ #print(temp)
if '1' in val.split('.')[1]:
- print(obj.variables[val.split('.')[1]]['name'])
+ #print(obj.variables[val.split('.')[1]]['name'])
mrowPosition = self.mTableWidget.rowCount()
self.mTableWidget.insertRow(mrowPosition)
self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name']))
@@ -304,7 +304,7 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
self.vTableWidget.setItem(vrowPosition , 2, QTableWidgetItem(obj.variables[val.split('.')[1]]['unit']))
self.vTableWidget.resizeColumnsToContents()
if not '[' in val:
- print(obj.variables[val.split('.')[1]]['name'])
+ #print(obj.variables[val.split('.')[1]]['name'])
mrowPosition = self.mTableWidget.rowCount()
self.mTableWidget.insertRow(mrowPosition)
self.mTableWidget.setItem(mrowPosition , 0, QTableWidgetItem(obj.variables[val.split('.')[1]]['name']))
@@ -314,15 +314,15 @@ class DockWidgetMaterialStream(QDockWidget,ui_dialog):
# updating the input data from fetched results from simulation
- print(self.comboBox.currentText())
+ #print(self.comboBox.currentText())
self.input_dict = {}
self.input_dict = self.obj.param_getter(self.comboBox.currentText())
# print("before", self.input_dict)
- # self.input_dict.pop("x_pc")
+ #self.input_dict.pop("x_pc")
# temp = self.input_dict.pop('thermo_package')
for i in range(len(compound_selected)):
- print(i)
+ #print(i)
self.input_dict['x_pc[1,' + str(i+1) + ']'] = self.obj.variables['x_pc[1,' + str(i+1) +']']['value']
# self.input_dict['thermo_package'] = temp
# print("after", self.input_dict)
diff --git a/OMChem/Flowsheet.py b/OMChem/Flowsheet.py
index a61cd52..ce0da55 100644
--- a/OMChem/Flowsheet.py
+++ b/OMChem/Flowsheet.py
@@ -47,8 +47,8 @@ class Flowsheet():
def send_for_simulation_Eqn(self):
self.result_data = []
self.omc_path = self.get_omc_path()
- print(self.omc_path)
-
+ #print(self.omc_path)
+
if self.sim_method == 'Eqn':
simpath = self.eqn_mos_path
os.chdir(self.sim_dir_path)
@@ -68,7 +68,6 @@ class Flowsheet():
self.result_data.append(row)
def send_for_simulation_SM(self,unitop):
-
self.result_data = []
self.omc_path = self.get_omc_path()
os.chdir(self.sim_dir_path)
@@ -145,14 +144,14 @@ class Flowsheet():
for d in self.data:
txtfile.write(str(d))
txtfile.write('end Flowsheet;\n')
-
+ #print(self.eqn_mos_path)
with open(self.eqn_mos_path, 'w') as mosFile:
mosFile.write('loadModel(Modelica);\n')
mosFile.write('loadFile(\"Simulator/package.mo\");\n')
mosFile.write('loadFile(\"database.mo\");\n')
mosFile.write('loadFile(\"Flowsheet.mo\");\n')
mosFile.write('simulate(Flowsheet, outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1);\n')
-
+
print('Initiating Simulation in Equation Oriented Mode')
self.send_for_simulation_Eqn()
diff --git a/Simulator/BinaryEnvelopes.mo b/Simulator/BinaryEnvelopes.mo
new file mode 100644
index 0000000..9eed56a
--- /dev/null
+++ b/Simulator/BinaryEnvelopes.mo
@@ -0,0 +1,19 @@
+package BinaryEnvelopes
+ model NRTL
+ parameter Integer NOC;
+ parameter Integer data_points;
+ parameter Real BIP[NOC, NOC, 2] = Simulator.Files.Thermodynamic_Functions.BIPNRTL(NOC, comp.CAS);
+ parameter Simulator.Files.Chemsep_Database.General_Properties comp[NOC];
+ Simulator.Binary_Phase_Envelope.Binary_Phase_Envelope_NRTL.base points[data_points](each NOC = NOC, each comp = comp, each BIP = BIP);
+ Real x[data_points, NOC], y[data_points, NOC], P[data_points], T[data_points];
+ equation
+ points[:].x = x;
+ points[:].y = y;
+ points[:].P = P;
+ points[:].T = T;
+ for i in 1:data_points loop
+ x[i, 1] = 0 + (i - 1) * 1/(data_points-1);
+ end for;
+ end NRTL;
+
+end BinaryEnvelopes;
diff --git a/Simulator/Simulator/Examples/MaterialStream.mo b/Simulator/Simulator/Examples/MaterialStream.mo
index 04c57d7..73d749c 100644
--- a/Simulator/Simulator/Examples/MaterialStream.mo
+++ b/Simulator/Simulator/Examples/MaterialStream.mo
@@ -59,6 +59,8 @@ package MaterialStream
F_p[1] = 100;
end PVFflash;
+
+
model PHflash
//we have to first instance components to give to material stream model.
import data = Simulator.Files.ChemsepDatabase;
diff --git a/Simulator/Simulator/Streams/MaterialStream.mo b/Simulator/Simulator/Streams/MaterialStream.mo
index 73cbafe..6d78e99 100644
--- a/Simulator/Simulator/Streams/MaterialStream.mo
+++ b/Simulator/Simulator/Streams/MaterialStream.mo
@@ -33,7 +33,7 @@ model MaterialStream "Model representing Material Stream"
Simulator.Files.Interfaces.matConn Out(Nc = Nc) annotation(
Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
- extends GuessModels.InitialGuess;
+ extends GuessModels.InitialGuess(Nc = Nc);
equation
//Connector equations
diff --git a/Streams.py b/Streams.py
index ed35261..5f1b840 100644
--- a/Streams.py
+++ b/Streams.py
@@ -99,7 +99,7 @@ class MaterialStream():
dict = {self.mode1:self.variables['P']['value'], self.mode2:self.variables['T']['value'],
"MolFlow":self.variables['F_p[1]']['value'],"x_pc":self.variables['x_pc']['value'],
"Thermo Package": self.thermo_package}
- print('dictionary is :' + str(dict))
+ #print('dictionary is :' + str(dict))
elif(mode=="PH"):
self.mode1 = 'P'
@@ -130,7 +130,7 @@ class MaterialStream():
def param_setter(self,dict):
self.variables['x_pc']['value'] = dict['x_pc'].split(",")
- print('xpc is :' + str(self.variables['x_pc']['value']))
+ #print('xpc is :' + str(self.variables['x_pc']['value']))
self.thermo_package = dict['Thermo Package']
self.variables['F_p[1]']['value'] = dict['MolFlow']
self.variables[self.mode1]['value'] = dict[self.mode1]
diff --git a/main.ui b/main.ui
index b671aa5..25c85d4 100644
--- a/main.ui
+++ b/main.ui
@@ -108,7 +108,7 @@
<item row="1" column="0">
<widget class="QDockWidget" name="dockWidget_2">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -134,7 +134,11 @@
<widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QTextEdit" name="textBrowser"/>
+ <widget class="QTextEdit" name="textBrowser">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -311,7 +315,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Streams</string>
@@ -818,7 +822,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Mixer/Splitter</string>
@@ -1367,7 +1371,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Exchangers</string>
@@ -1513,7 +1517,7 @@
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Separator</string>
@@ -1644,7 +1648,7 @@
</font>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Pressure Changers</string>
@@ -1870,7 +1874,7 @@
</font>
</property>
<property name="styleSheet">
- <string notr="true">color:rgb(73,36,73,255)</string>
+ <string notr="true">color:rgba(73,36,73,255)</string>
</property>
<property name="text">
<string>Columns</string>
diff --git a/pycflags b/pycflags
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pycflags
diff --git a/pyldflags b/pyldflags
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/pyldflags