diff options
author | pravindalve | 2020-12-18 21:04:50 +0530 |
---|---|---|
committer | pravindalve | 2020-12-18 21:04:50 +0530 |
commit | 95b08aa53ab6dad2be5f750bdc9b8845ef6cc633 (patch) | |
tree | 74aaf08f31ed1b38c6292f407354c92049c9ec9b | |
parent | 4e96691bc758904e05d0e03f0368dcbcd1efaec3 (diff) | |
download | Chemical-Simulator-GUI-95b08aa53ab6dad2be5f750bdc9b8845ef6cc633.tar.gz Chemical-Simulator-GUI-95b08aa53ab6dad2be5f750bdc9b8845ef6cc633.tar.bz2 Chemical-Simulator-GUI-95b08aa53ab6dad2be5f750bdc9b8845ef6cc633.zip |
Fixes for gernerating flowsheet.mo for Distillation Column
-rw-r--r-- | Container.py | 2 | ||||
-rw-r--r-- | DockWidgets/__pycache__/DockWidget.cpython-37.pyc | bin | 4329 -> 4329 bytes | |||
-rw-r--r-- | DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc | bin | 4911 -> 4911 bytes | |||
-rw-r--r-- | OMChem/Flowsheet.py | 4 | ||||
-rw-r--r-- | Simulator/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo | 2 | ||||
-rw-r--r-- | Simulator/Simulator/UnitOperations/DistillationColumn/DistCol.mo | 4 | ||||
-rw-r--r-- | UnitOperations.py | 80 |
7 files changed, 84 insertions, 8 deletions
diff --git a/Container.py b/Container.py index c77d631..397aaf0 100644 --- a/Container.py +++ b/Container.py @@ -127,7 +127,7 @@ class Container(): print(mode) self.compounds = compound_selected self.flowsheet = Flowsheet() - self.flowsheet.add_compound_list(self.compounds) + self.flowsheet.add_compound_list([c[:c.index('(')] for c in self.compounds]) print("######## connection master#########\n",self.conn) for i in self.unit_operations : self.flowsheet.add_unit_operations(i) diff --git a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc Binary files differindex 72623eb..d4cdec3 100644 --- a/DockWidgets/__pycache__/DockWidget.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidget.cpython-37.pyc diff --git a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc Binary files differindex f538f77..17ef882 100644 --- a/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc +++ b/DockWidgets/__pycache__/DockWidgetDistillationColumn.cpython-37.pyc diff --git a/OMChem/Flowsheet.py b/OMChem/Flowsheet.py index bc218c6..79608ec 100644 --- a/OMChem/Flowsheet.py +++ b/OMChem/Flowsheet.py @@ -105,6 +105,10 @@ class Flowsheet(): lcase = c.lower() self.data.append("parameter database." + ucase +' '+ ucase + "; \n") + self.data.append("parameter Integer Nc = " + str(len(self.compounds)) + ";\n") + self.data.append("parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc] = {" + + str(self.compounds).strip('[').strip(']').replace("'", "") + "};\n") + for unitop in self.unit_operations: if unitop.type != 'MaterialStream': self.data.append(unitop.OM_Flowsheet_Initialize()) diff --git a/Simulator/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo b/Simulator/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo index ff3d394..c318000 100644 --- a/Simulator/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo +++ b/Simulator/Simulator/Files/ThermodynamicPackages/RaoultsLaw.mo @@ -1,7 +1,7 @@ within Simulator.Files.ThermodynamicPackages; model RaoultsLaw - import Simulator.Files.Thermodynamic_Functions.*; + import Simulator.Files.ThermodynamicFunctions.*; Real K_c[Nc](each min = 0), Cpres_p[3], Hres_p[3], Sres_p[3]; Real gma_c[Nc], gmabubl_c[Nc], gmadew_c[Nc]; Real philiqbubl_c[Nc], phivapdew_c[Nc], Pvap_c[Nc]; diff --git a/Simulator/Simulator/UnitOperations/DistillationColumn/DistCol.mo b/Simulator/Simulator/UnitOperations/DistillationColumn/DistCol.mo index f413590..64e1cc9 100644 --- a/Simulator/Simulator/UnitOperations/DistillationColumn/DistCol.mo +++ b/Simulator/Simulator/UnitOperations/DistillationColumn/DistCol.mo @@ -2,8 +2,8 @@ within Simulator.UnitOperations.DistillationColumn; model DistCol extends Simulator.Files.Icons.DistillationColumn; - parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; parameter Integer Nc "Number of components"; + parameter Simulator.Files.ChemsepDatabase.GeneralProperties C[Nc]; import data = Simulator.Files.ChemsepDatabase; parameter Boolean Bin_t[Nt] = Simulator.Files.OtherFunctions.colBoolCalc(Nt, Ni, InT_s); parameter Integer Nt = 4 "Number of stages"; @@ -26,7 +26,7 @@ within Simulator.UnitOperations.DistillationColumn; Placement(visible = true, transformation(origin = {252, -588}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {250, -598}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); Simulator.Files.Interfaces.matConn Out_s[Nout](each Nc = Nc) annotation( Placement(visible = true, transformation(origin = {-36, 32}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, 60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); - Simulator.Files.Interfaces.enConn En[NQ](each Nc = Nc) annotation( + Simulator.Files.Interfaces.enConn En[NQ] annotation( Placement(visible = true, transformation(origin = {-34, -54}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-70, -60}, extent = {{-10, -10}, {10, 10}}, rotation = 0))); equation for i in 1:Ni loop diff --git a/UnitOperations.py b/UnitOperations.py index 08a871d..394c179 100644 --- a/UnitOperations.py +++ b/UnitOperations.py @@ -11,7 +11,7 @@ class UnitOperation(): self.OM_data_init = '' self.input_stms = [] self.output_stms = [] - self.compounds = compound_selected + self.compounds = [c[:c.index('(')] for c in compound_selected] self.name = '' self.mode = None self.mode_val = None @@ -232,9 +232,6 @@ class DistillationColumn(UnitOperation): self.type = 'DistillationColumn' self.no_of_inputs = 1 self.no_of_outputs = 2 - - self.compounds = compound_selected - self.EngStm1 = EngStm(name='EngStm1'+self.name) self.EngStm2 = EngStm(name='EngStm2'+self.name) self.count = DistillationColumn.counter @@ -276,12 +273,87 @@ class DistillationColumn(UnitOperation): if 'Compound' in self.variables['C_Spec']['type']: self.variables['C_Spec']['comp'] = params[temp+4] self.variables['C_Spec']['value'] = params[temp+5] + for var in self.variables: + if self.variables[var]['name'] == self.variables['C_Spec']['type']: + self.variables[var]['value'] = params[temp+5] + self.variables['Preb']['value'] = params[temp+6] + # R_Spec variable value won't be updated to class here. It will be updated in result self.variables['R_Spec']['type'] = params[temp+7] if 'Compound' in self.variables['R_Spec']['type']: self.variables['R_Spec']['comp'] = params[temp+8] self.variables['R_Spec']['value'] = params[temp+9] print(self.variables) + + def OM_Flowsheet_Initialize(self): + self.OM_data_init = '' + self.OM_data_init = self.OM_data_init + 'model Condenser\n' + self.OM_data_init = self.OM_data_init + 'extends Simulator.UnitOperations.DistillationColumn.Cond;\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 Condenser;\n' + self.OM_data_init = self.OM_data_init + 'model Tray\n' + self.OM_data_init = self.OM_data_init + 'extends Simulator.UnitOperations.DistillationColumn.DistTray;\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 Tray;\n' + self.OM_data_init = self.OM_data_init + 'model Reboiler\n' + self.OM_data_init = self.OM_data_init + 'extends Simulator.UnitOperations.DistillationColumn.Reb;\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 Reboiler;\n' + self.OM_data_init = self.OM_data_init + ("model distCol" + str(self.count) + "\n") + self.OM_data_init = self.OM_data_init + ("extends Simulator.UnitOperations.DistillationColumn.DistCol;\n") + self.OM_data_init = self.OM_data_init + ( + "Condenser condenser(Nc = Nc, C = C, Ctype =Ctype, Bin = Bin_t[1], T(start = 300));\n") + self.OM_data_init = self.OM_data_init + ( + "Reboiler reboiler(Nc = Nc, C = C, Bin = Bin_t[Nt]);\n") + self.OM_data_init = self.OM_data_init + ( + "Tray tray[Nt - 2](each Nc = Nc, each C = C, Bin = Bin_t[2:Nt - 1]);\n") + self.OM_data_init = self.OM_data_init + ("end distCol" + str(self.count) + ";\n") + comp_count = len(self.compounds) + self.OM_data_init = self.OM_data_init + ( + "distCol" + str(self.count) + " " + self.name + "(Nc = " + str(comp_count)) + self.OM_data_init = self.OM_data_init + (", C= C") + + self.OM_data_init = self.OM_data_init + "," + ( + "Nt=" + str(self.variables['Nt']['value']) + "," + "Ni=" + + str(self.variables['Ni']['value']) + ",InT_s=" + "{" + + str(self.variables['InT_s']['value']).strip('[').strip(']') + "}" + ',Ctype ="' + + self.variables['Ctype']['value'] + '");\n') + # self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStm1.name+';\n' + # self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStm2.name+';\n' + return self.OM_data_init + + def OM_Flowsheet_Equation(self): + self.OM_data_eqn = '' + # self.OM_data_eqn = self.name + '.pressDrop = ' + str(self.PressDrop) + ';\n' + # self.OM_data_eqn = self.OM_data_eqn + ( + # 'connect(' + self.name + '.' + 'condensor_duty' + ',' + self.EngStm1.name + '.inlet);\n') + # self.OM_data_eqn = self.OM_data_eqn + ( + # 'connect(' + self.name + '.reboiler_duty' + ', ' + self.EngStm2.name + '.inlet);\n') + self.OM_data_eqn = self.OM_data_eqn + ( + 'connect(' + self.name + '.Dist' + ", " + self.output_stms[0].name + '.In);\n') + self.OM_data_eqn = self.OM_data_eqn + ( + 'connect(' + self.name + '.Bot' + ", " + self.output_stms[1].name + '.In);\n') + for i in range(len(self.input_stms)): + self.OM_data_eqn = self.OM_data_eqn + ( + 'connect(' + self.input_stms[i].name + '.Out' + ", " + self.name + '.In_s[' + str( + i + 1) + ']);\n') + if self.variables['R_Spec']['type'] == "Product Molar Flow (mol/s)": + self.OM_data_eqn = self.OM_data_eqn + (self.output_stms[1].name + '.' + 'F_p[1] = ' + str( + self.variables['R_Spec']['value']) + ';\n') + if self.variables['C_Spec']['type'] == "Reflux Ratio": + self.OM_data_eqn = self.OM_data_eqn + ( + self.name + '.' + 'RR' + '=' + str(self.variables['RR']['value']) + ';\n') + else: + self.OM_data_eqn = self.OM_data_eqn + ( + self.name + '.Condenser.' + self.mode + '=' + str(self.modeVal) + ';\n') + + + + self.OM_data_eqn = self.OM_data_eqn + self.name + '.reboiler.P=' + str( + self.variables['Preb']['value']) + ';\n' + self.OM_data_eqn = self.OM_data_eqn + self.name + '.condenser.P=' + str( + self.variables['Pcond']['value']) + ';\n' + return self.OM_data_eqn class ConvertionReactor(UnitOperation): def __init__(self,name='',Nr=None,b=None,X=None,Z=None,a=[],operation=None,Tdef=None): |