diff options
author | SaurabhAgarwala | 2020-01-03 15:54:24 +0530 |
---|---|---|
committer | SaurabhAgarwala | 2020-01-03 15:54:24 +0530 |
commit | 8dfb7d836e438035be2284e49554dac36d0af7bf (patch) | |
tree | 0a14314f4a248fe5ad4627e2f6cd11068e689673 /OMChem | |
parent | 4138fd762a45b15dc7dfea661a93a047a0eba4a0 (diff) | |
download | Chemical-Simulator-GUI-8dfb7d836e438035be2284e49554dac36d0af7bf.tar.gz Chemical-Simulator-GUI-8dfb7d836e438035be2284e49554dac36d0af7bf.tar.bz2 Chemical-Simulator-GUI-8dfb7d836e438035be2284e49554dac36d0af7bf.zip |
Made GUI compatible with the new Simulator, abbreviations updated to new convention and few bugs eliminated with code clean up at places
Diffstat (limited to 'OMChem')
-rw-r--r-- | OMChem/CompSep.py | 2 | ||||
-rw-r--r-- | OMChem/Cooler.py | 2 | ||||
-rw-r--r-- | OMChem/DistCol.py | 8 | ||||
-rw-r--r-- | OMChem/Flash.py | 2 | ||||
-rw-r--r-- | OMChem/Flowsheet.py | 91 | ||||
-rw-r--r-- | OMChem/Heater.py | 2 | ||||
-rw-r--r-- | OMChem/MatStm.py | 375 | ||||
-rw-r--r-- | OMChem/Mixer.py | 2 | ||||
-rw-r--r-- | OMChem/Pump.py | 2 | ||||
-rw-r--r-- | OMChem/ShortcutColumn.py | 2 | ||||
-rw-r--r-- | OMChem/Splitter.py | 2 | ||||
-rw-r--r-- | OMChem/Valve.py | 2 | ||||
-rw-r--r-- | OMChem/adiabatic_comp.py | 16 | ||||
-rw-r--r-- | OMChem/adiabatic_exp.py | 16 |
14 files changed, 75 insertions, 449 deletions
diff --git a/OMChem/CompSep.py b/OMChem/CompSep.py index 5bdfd51..9579498 100644 --- a/OMChem/CompSep.py +++ b/OMChem/CompSep.py @@ -40,7 +40,7 @@ class CompSep(): comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStms.name+';\n' self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Compound_Separator " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Compound_Separator " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Cooler.py b/OMChem/Cooler.py index 32fe594..9a44033 100644 --- a/OMChem/Cooler.py +++ b/OMChem/Cooler.py @@ -54,7 +54,7 @@ class Cooler(): comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStms.name+';\n' self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Cooler " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Cooler " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/DistCol.py b/OMChem/DistCol.py index 4f9f2fb..1492bc2 100644 --- a/OMChem/DistCol.py +++ b/OMChem/DistCol.py @@ -68,13 +68,13 @@ class DistCol(): 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.Unit_Operations.Distillation_Column.DistCol;\n" ) - self.OM_data_init = self.OM_data_init + ("Condensor condensor(NOC = NOC, comp = comp, condType =condType, boolFeed = boolFeed[1], T(start = 300));\n" ) - self.OM_data_init = self.OM_data_init + ("Reboiler reboiler(NOC = NOC, comp = comp, boolFeed = boolFeed[noOfStages]);\n" ) - self.OM_data_init = self.OM_data_init + ("Tray tray[noOfStages - 2](each NOC = NOC, each comp = comp, boolFeed = boolFeed[2:noOfStages -1]);\n" ) + self.OM_data_init = self.OM_data_init + ("Condensor condensor(Nc = Nc, comp = comp, condType =condType, boolFeed = boolFeed[1], T(start = 300));\n" ) + self.OM_data_init = self.OM_data_init + ("Reboiler reboiler(Nc = Nc, comp = comp, boolFeed = boolFeed[noOfStages]);\n" ) + self.OM_data_init = self.OM_data_init + ("Tray tray[noOfStages - 2](each Nc = Nc, each comp = comp, boolFeed = boolFeed[2:noOfStages -1]);\n" ) self.OM_data_init = self.OM_data_init + ("end distCol"+str(self.count)+";\n") comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "distCol"+str(self.count)+" "+ self.name + "(NOC = " + str(comp_count)) + "distCol"+str(self.count)+" "+ self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Flash.py b/OMChem/Flash.py index 68294ea..a3bf5dc 100644 --- a/OMChem/Flash.py +++ b/OMChem/Flash.py @@ -41,7 +41,7 @@ class Flash(): self.OM_data_init = self.OM_data_init + ("end fls"+str(self.count)+";\n") comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "fls"+str(self.count)+" "+ self.name + "(NOC = " + str(comp_count)) + "fls"+str(self.count)+" "+ self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Flowsheet.py b/OMChem/Flowsheet.py index 78552ae..3200b7a 100644 --- a/OMChem/Flowsheet.py +++ b/OMChem/Flowsheet.py @@ -41,32 +41,32 @@ class Flowsheet(): if len(unitOpr.extra)==1: for i in unitOpr.extra: unitOpr.OM_data_init += ('model '+i+str(unitOpr.counter)+'\n') - unitOpr.OM_data_init += ('extends Simulator.Unit_Operations.'+i+';\n') - unitOpr.OM_data_init += ('extends Simulator.Files.Thermodynamic_Packages.'+unitOpr.thermoPackage+';\n') + unitOpr.OM_data_init += ('extends Simulator.UnitOperations.'+i+';\n') + unitOpr.OM_data_init += ('extends Simulator.Files.ThermodynamicPackages.'+unitOpr.thermoPackage+';\n') unitOpr.OM_data_init += ('end '+i+str(unitOpr.counter)+';\n') - unitOpr.OM_data_init += i+str(unitOpr.counter) + ' ' + unitOpr.name + '(NOC = ' + str(len(self.compounds)) + unitOpr.OM_data_init += i+str(unitOpr.counter) + ' ' + unitOpr.name + '(Nc = ' + str(len(self.compounds)) else: for i in range(len(unitOpr.extra)): if i!=(len(unitOpr.extra)-1): unitOpr.OM_data_init += ('model '+unitOpr.ForNaming[i]+str(unitOpr.counter)+'\n') - unitOpr.OM_data_init += ('extends Simulator.Unit_Operations.'+unitOpr.extra[i]+';\n') - unitOpr.OM_data_init += ('extends Simulator.Files.Thermodynamic_Packages.'+unitOpr.thermoPackage+';\n') + unitOpr.OM_data_init += ('extends Simulator.UnitOperations.'+unitOpr.extra[i]+';\n') + unitOpr.OM_data_init += ('extends Simulator.Files.ThermodynamicPackages.'+unitOpr.thermoPack+';\n') unitOpr.OM_data_init += ('end '+unitOpr.ForNaming[i]+str(unitOpr.counter)+';\n') else: unitOpr.OM_data_init += ('model '+unitOpr.ForNaming[i]+str(unitOpr.counter)+'\n') - unitOpr.OM_data_init += ('extends Simulator.Unit_Operations.'+unitOpr.extra[i]+';\n') + unitOpr.OM_data_init += ('extends Simulator.UnitOperations.'+unitOpr.extra[i]+';\n') for j in range(len(unitOpr.extra)-1): unitOpr.OM_data_init += (unitOpr.ForNaming[j] + str(unitOpr.counter) +' ' + unitOpr.ForNaming[j] + '#' + unitOpr.multidict[j] + ';\n') unitOpr.OM_data_init += ('end '+unitOpr.ForNaming[i]+str(unitOpr.counter)+';\n') - unitOpr.OM_data_init += unitOpr.ForNaming[i] + str(unitOpr.counter) + ' ' + unitOpr.ForNaming + '(NOC = ' + str(len(self.compounds)) + unitOpr.OM_data_init += unitOpr.ForNaming[i] + str(unitOpr.counter) + ' ' + unitOpr.ForNaming + '(Nc = ' + str(len(self.compounds)) - comp = str(self.compounds).strip('[').strip(']') - comp = comp.replace("'", "") - unitOpr.OM_data_init += ',comp = {' + comp + '}' + C = str(self.compounds).strip('[').strip(']') + C = C.replace("'", "") + unitOpr.OM_data_init += ',C = {' + C + '}' @@ -76,10 +76,10 @@ class Flowsheet(): unitOpr.OM_data_init += ');\n' else: - unitOpr.OM_data_init += 'Simulator.Unit_Operations.' + unitOpr.type + ' ' + unitOpr.name + '(NOC = ' + str(len(self.compounds)) - comp = str(self.compounds).strip('[').strip(']') - comp = comp.replace("'", "") - unitOpr.OM_data_init += ',comp = {' + comp + '}' + unitOpr.OM_data_init += 'Simulator.UnitOperations.' + unitOpr.type + ' ' + unitOpr.name + '(Nc = ' + str(len(self.compounds)) + C = str(self.compounds).strip('[').strip(']') + C = C.replace("'", "") + unitOpr.OM_data_init += ',C = {' + C + '}' for k,v in unitOpr.parameters.items(): unitOpr.OM_data_init += ', ' @@ -101,18 +101,18 @@ class Flowsheet(): if len(unitOpr.InputStms)>1: strcount = 1 for strm in unitOpr.InputStms: - unitOpr.OM_data_eqn += ('connect(' + strm.name + '.outlet,' + unitOpr.name + '.inlet[' + str(strcount) + ']);\n') + unitOpr.OM_data_eqn += ('connect(' + strm.name + '.Out,' + unitOpr.name + '.In[' + str(strcount) + ']);\n') strcount += 1 else: - unitOpr.OM_data_eqn += ('connect(' + unitOpr.name + '.inlet,' + unitOpr.InputStms[0].name + '.outlet);\n') + unitOpr.OM_data_eqn += ('connect(' + unitOpr.name + '.In,' + unitOpr.InputStms[0].name + '.Out);\n') if len(unitOpr.OutputStms)>1: strcount = 1 for strm in unitOpr.OutputStms: - unitOpr.OM_data_eqn += ('connect(' + strm.name + '.inlet,' + unitOpr.name + '.outlet[' + str(strcount) + ']);\n') + unitOpr.OM_data_eqn += ('connect(' + strm.name + '.In,' + unitOpr.name + '.Out[' + str(strcount) + ']);\n') strcount += 1 else: - unitOpr.OM_data_eqn += ('connect(' + unitOpr.name + '.outlet,' + unitOpr.OutputStms[0].name + '.inlet);\n') + unitOpr.OM_data_eqn += ('connect(' + unitOpr.name + '.Out,' + unitOpr.OutputStms[0].name + '.In);\n') if unitOpr.mode: unitOpr.OM_data_eqn += (unitOpr.name + '.' + unitOpr.mode + '=' + unitOpr.modeVal + ';\n') @@ -140,8 +140,8 @@ class Flowsheet(): def remove_UnitOpn(self,unitop): self.UnitOpn.remove(unitop) - def add_comp_list(self,comp): - self.compounds = comp + def add_comp_list(self,C): + self.compounds = C def send_for_simulationEqn(self): self.resdata = [] @@ -203,7 +203,7 @@ class Flowsheet(): # if self.sim_method == 'SM': # for unitop in self.UnitOpn: # self.resdata = [] - # if unitop.type != 'MatStm': + # if unitop.type != 'MaterialStream': # print 'Simulating '+unitop.name+'...' # csvpath = os.path.join(self.sim_dir_path,unitop.name+'_res.csv') # with open(csvpath,'r') as resultFile: @@ -228,7 +228,7 @@ class Flowsheet(): def ExtData(self): for unit in self.UnitOpn: - if unit[0].type == 'MatStm': + if unit[0].type == 'MaterialStream': for key, value in unit[0].Prop.items(): propertyname = unit[0].name + '.' + key if propertyname in self.resdata[0]: @@ -325,19 +325,19 @@ class Flowsheet(): for c in self.compounds: ucase = c.title() lcase = c.lower() - self.data.append("parameter Simulator.Files.Chemsep_Database." + ucase +' '+ ucase + "; \n") + self.data.append("parameter database." + ucase +' '+ ucase + "; \n") for unitop in self.UnitOpn: - if unitop.type != 'MatStm': + if unitop.type != 'MaterialStream': self.data.append(self.OM_Flowsheet_Initialize(unitop)) else: - self.data.append(unitop.OM_Flowsheet_Init(self.compounds)) + self.data.append(unitop.OM_Flowsheet_Initialize(self.compounds)) self.data.append("equation\n") self.outlist = [] - self.stm = ['MatStm','EngStm'] + self.stm = ['MaterialStream','EngStm'] for unitop in self.UnitOpn: if unitop.type not in self.stm: for j in unitop.OutputStms: @@ -349,10 +349,10 @@ class Flowsheet(): for unitop in self.UnitOpn: if unitop not in self.outlist: - if unitop.type == 'MatStm': - self.data.append(unitop.OM_Flowsheet_Eqn(self.compounds,'Eqn')) + if unitop.type == 'MaterialStream': + self.data.append(unitop.OM_Flowsheet_Equation(self.compounds,'Eqn')) else: - self.data.append(self.OM_Flowsheet_Equation(unitop)) + self.data.append(unitop.OM_Flowsheet_Equation()) else: pass with open(self.Flomo_path, 'w') as txtfile: @@ -362,9 +362,10 @@ class Flowsheet(): with open(self.eqn_mos_path, 'w') as mosFile: mosFile.write('loadModel(Modelica);\n') - mosFile.write("loadFile(\"Simulator/package.mo\");\n") - mosFile.write("loadFile(\"Flowsheet.mo\");\n") - mosFile.write("simulate(Flowsheet, outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1);\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') @@ -409,7 +410,7 @@ class Flowsheet(): for unitop in self.unit: os.chdir(self.root_dir) self.data = [] - if unitop.type not in ['MatStm','EngStm']: + if unitop.type not in ['MaterialStream','EngStm']: inpstms = unitop.InputStms outstms = unitop.OutputStms @@ -426,43 +427,43 @@ class Flowsheet(): self.data.append("parameter Simulator.Files.Chemsep_Database." + ucase +' '+ ucase + "; \n") print("##############compounds added") - self.data.append(self.OM_Flowsheet_Initialize(unitop)) + self.data.append(unitop.OM_Flowsheet_Initialize()) if type(outstms) is list: for stm in outstms: - self.data.append(self.OM_Flowsheet_Initialize(stm)) + self.data.append(stm.OM_Flowsheet_Initialize()) else: - self.data.append(self.OM_Flowsheet_Initialize(outstms)) + self.data.append(outstms.OM_Flowsheet_Initialize()) if engstms: - self.data.append(self.OM_Flowsheet_Initialize(engstms)) + self.data.append(engstms.OM_Flowsheet_Initialize()) if type(inpstms) is list: for stm in inpstms: - self.data.append(self.OM_Flowsheet_Initialize(stm)) + self.data.append(stm.OM_Flowsheet_Initialize()) else: - self.data.append(self.OM_Flowsheet_Initialize(inpstms)) + self.data.append(inpstms.OM_Flowsheet_Initialize()) self.data.append('equation\n') print("##################equation") - self.data.append(self.OM_Flowsheet_Equation(unitop)) + self.data.append(unitop.OM_Flowsheet_Equation()) ''' if type(outstms) is list: for stm in outstms: #stm.GetEquationValues() - self.data.append(stm.OM_Flowsheet_Eqn(self.compounds,'SM')) + self.data.append(stm.OM_Flowsheet_Equation(self.compounds,'SM')) else: #outstms.GetEquationValues() - self.data.append(outstms.OM_Flowsheet_Eqn(self.compounds,'SM')) + self.data.append(outstms.OM_Flowsheet_Equation(self.compounds,'SM')) ''' if type(inpstms) is list: for stm in inpstms: #stm.GetEquationValues() - self.data.append(self.OM_Flowsheet_Equation(stm)) + self.data.append(stm.OM_Flowsheet_Equation()) else: #inpstms.GetEquationValues() - self.data.append(self.OM_Flowsheet_Equation(inpstms)) + self.data.append(inpstms.OM_Flowsheet_Equation()) # os.chdir(self.sim_dir_path) unitmofile = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mo') @@ -509,7 +510,7 @@ class Flowsheet(): os.chdir(self.root_dir) if type(inpstms) is list: for stm in inpstms: - for key, value in stm.Prop.items(): + for key,value in stm.Prop.items(): propertyname = stm.name + '.' + key if propertyname in self.resdata[0]: ind = self.resdata[0].index(propertyname) diff --git a/OMChem/Heater.py b/OMChem/Heater.py index ebdae9e..cf9b8f1 100644 --- a/OMChem/Heater.py +++ b/OMChem/Heater.py @@ -56,7 +56,7 @@ class Heater(): comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStms.name+';\n' self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Heater " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Heater " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/MatStm.py b/OMChem/MatStm.py deleted file mode 100644 index 686231f..0000000 --- a/OMChem/MatStm.py +++ /dev/null @@ -1,375 +0,0 @@ -from OMPython import OMCSession -import json -import sys -from collections import defaultdict - -class MatStm(): - counter = 1; - def __init__(self,CompNames = [],Temperature=300,Pressure=101325,VapPhasMolFrac=None,VapPhasMasFrac=None,LiqPhasMolFrac=None,LiqPhasMasFrac=None,CompMolFrac = [1.0], CompMasFrac = [], MolFlow=100, MasFlow=None,**kwargs): - self.name = 'MatStm' + str(MatStm.counter) - self.type = 'MatStm' - self.T = Temperature - self.P = Pressure - self.VapPhasMolFrac = VapPhasMolFrac - self.VapPhasMasFrac = VapPhasMasFrac - self.LiqPhasMolFrac = LiqPhasMolFrac - self.LiqPhasMasFrac = LiqPhasMasFrac - self.CompNames = CompNames - self.CompMolFrac = CompMolFrac - self.CompMasFrac = CompMasFrac - self.MolFlow = MolFlow - self.MasFlow = MasFlow - self.OM_data_init = '' - self.OM_data_eqn = '' - self.count = MatStm.counter - self.thermoPackage ="Raoults_Law" - 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 - MatStm.counter+=1 - self.startDict = {} - self.eqnDict = {} - self.modesList = ["PT","PH","PVF","TVF","PS"] - - - self.Prop = { - - self.mode1:self.mode1val, - self.mode2:self.mode2val, - 'liqPhasMolFrac':LiqPhasMolFrac, - 'liqPhasMasFrac':LiqPhasMasFrac, - 'vapPhasMolFrac':VapPhasMolFrac, - 'vapPhasMasFrac':VapPhasMasFrac, - 'totMolFlo[1]':MolFlow, - 'totMasFlo[1]':MasFlow, - 'MW[1]':None, - 'MW[2]':None, - 'MW[3]':None, - 'phasMolSpHeat[1]':None, - 'phasMolEnth[1]':None, - '[1]':None, - 'phasMolSpHeat[2]':None, - 'phasMolEnth[2]':None, - 'phasMolEntr[2]':None, - 'phasMolSpHeat[3]':None, - 'phasMolEnth[3]':None, - 'phasMolEntr[3]':None, - 'totMolFlo[2]':None, - 'totMasFlo[2]':None, - 'totMolFlo[3]':None, - 'totMasFlo[3]':None - - } - - self.Prop1 = { - self.mode1:self.mode1val, - self.mode2:self.mode2val, - 'liqPhasMolFrac':LiqPhasMolFrac, - 'liqPhasMasFrac':LiqPhasMasFrac, - 'vapPhasMolFrac':VapPhasMolFrac, - 'vapPhasMasFrac':VapPhasMasFrac, - 'totMolFlo[1]':MolFlow, - 'totMasFlo[1]':MasFlow, - 'MW[1]':None, - 'MW[2]':None, - 'MW[3]':None, - 'phasMolSpHeat[1]':None, - 'phasMolEnth[1]':None, - 'phasMolEntr[1]':None, - 'phasMolSpHeat[2]':None, - 'phasMolEnth[2]':None, - 'phasMolEntr[2]':None, - 'phasMolSpHeat[3]':None, - 'phasMolEnth[3]':None, - 'phasMolEntr[3]':None, - 'totMolFlo[2]':None, - 'totMasFlo[2]':None, - 'totMolFlo[3]':None, - 'totMasFlo[3]':None - - } - - def paramgetter(self,mode): - dict = {} - if(mode=="PT"): - self.mode1 = 'P' - self.mode2 = 'T' - dict = {self.mode2:None,self.mode1:None,"CompMolFrac":None,"MolFlow":None,"thermoPackage":None} - elif(mode=="PH"): - self.mode1 = 'P' - self.mode2 = 'phasMolEnth[1]' - dict = {self.mode1:None,self.mode2:None,"CompMolFrac":None,"MolFlow":None,"thermoPackage":None} - elif(mode=="PVF"): - self.mode1 = 'P' - self.mode2 = 'vapPhasMolFrac' - dict = {self.mode1:None,self.mode2:None,"CompMolFrac":None,"MolFlow":None,"thermoPackage":None} - elif(mode=="TVF"): - self.mode1 = 'T' - self.mode2 = 'vapPhasMolFrac' - dict = {self.mode1:None,self.mode2:None,"CompMolFrac":None,"MolFlow":None,"thermoPackage":None} - elif(mode=="PS"): - self.mode1 = 'P' - self.mode2 = 'phasMolEntr[1]' - dict = {self.mode1:None,self.mode2:None,"CompMolFrac":None,"MolFlow":None,"thermoPackage":None} - - return dict - def paramsetter(self,dict): - self.mode1val = dict[self.mode1] - self.mode2val = dict[self.mode2] - self.MolFlow = dict['MolFlow'] - self.CompMolFrac = dict['CompMolFrac'].split(",") - self.thermoPackage = dict['thermoPackage'] - self.Prop['totMolFlo[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('####### compmolfrac #########\n',self.CompMolFrac[i]) - if self.CompMolFrac: - self.Prop['compMolFrac[1,'+str(i+1)+']'] = self.CompMolFrac[i] - else: - self.Prop['compMolFrac[1,'+str(i+1)+']'] = None - - if self.CompMasFrac: - self.Prop['compMasFrac[1,'+str(i+1)+']'] = self.CompMasFrac[i] - else: - self.Prop['compMasFrac[1,'+str(i+1)+']'] = None - self.Prop['compMolFlo[1,'+str(i+1)+']'] = None - self.Prop['compMasFlo[1,'+str(i+1)+']'] = None - for i in range(0,len(self.CompNames)): - self.Prop['compMolFrac[2,'+str(i+1)+']'] = None - self.Prop['compMasFrac[2,'+str(i+1)+']'] = None - self.Prop['compMolFlo[2,'+str(i+1)+']'] = None - self.Prop['compMasFlo[2,'+str(i+1)+']'] = None - self.Prop['compMolFrac[3,'+str(i+1)+']'] = None - self.Prop['compMasFrac[3,'+str(i+1)+']'] = None - self.Prop['compMolFlo[3,'+str(i+1)+']'] = None - self.Prop['compMasFlo[3,'+str(i+1)+']'] = None - - def GetMinEqnValues(self): - compmolfraclist = [] - for i in range(0,len(self.CompNames)): - print(self.Prop['compMolFrac[1,'+str(i+1)+']']) - compmolfraclist.append(self.Prop['compMolFrac[1,'+str(i+1)+']']) - print(compmolfraclist) - #compmolfraclist = list(self.Prop(compMolFrac[1,1)]) - compmolfrac = json.dumps(compmolfraclist) - print(compmolfrac) - compmolfrac = compmolfrac.replace('[','{') - compmolfrac = compmolfrac.replace(']','}') - compmolfrac = compmolfrac.replace('"','') - ''' - compmolfracstr = json.dumps(self.CompMolFrac) - compmolfracstr = compmolfracstr.replace('[','{') - compmolfracstr = compmolfracstr.replace(']','}') - compmolfracstr = compmolfracstr.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.CompMolFrac: - self.eqnDict['compMolFrac[1,:]'] = compmolfrac - if self.MolFlow: - self.eqnDict['totMolFlo[1]'] = self.Prop['totMolFlo[1]']#self.MolFlow - - print("##############$GetMinVEqnValuesStart$##################") - print("P:",self.Prop[self.mode1]) - print("T:",self.Prop[self.mode2]) - print("CompMolFrac",compmolfrac) - print("totMolFlo",self.Prop['totMolFlo[1]']) - print("##############$GetMinVEqnValuesEnd$##################") - - def GetEquationValues(self): - 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['compMolFrac[1,1]']: - cfa = [] - for i in range(1,len(self.CompNames)+1): - cfa.append(self.Prop['compMolFrac[1,'+str(i)+']']) - cmpMolFracstr = json.dumps(cfa) - cmpMolFracstr = cmpMolFracstr.replace('[','{') - cmpMolFracstr = cmpMolFracstr.replace(']','}') - cmpMolFracstr = cmpMolFracstr.replace('"','') - self.eqnDict['compMolFrac[1,:]'] = cmpMolFracstr - - if self.Prop['totMolFlo[1]']: - self.eqnDict['totMolFlo[1]'] = self.Prop['totMolFlo[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['compMolFrac[2,1]'] != None: - compMolFracarr = [] - for i in range(1,4): - cmf = [] - for j in range(1,len(self.CompNames)+1): - cmf.append(str(self.Prop['compMolFrac['+str(i)+','+str(j)+']'])) - compMolFracarr.append(cmf) - compMolFracstr = json.dumps(compMolFracarr) - compMolFracstr = compMolFracstr.replace('[','{') - compMolFracstr = compMolFracstr.replace(']','}') - compMolFracstr = compMolFracstr.replace('"','') - self.startDict['compMolFrac'] = compMolFracstr - - if self.Prop['compMasFrac[2,1]'] != None: - compMasFracarr = [] - for i in range(1,4): - cmf = [] - for j in range(1,len(self.CompNames)+1): - cmf.append(str(self.Prop['compMasFrac['+str(i)+','+str(j)+']'])) - compMasFracarr.append(cmf) - compMasFracstr = json.dumps(compMolFracarr) - compMasFracstr = compMasFracstr.replace('[','{') - compMasFracstr = compMasFracstr.replace(']','}') - compMasFracstr = compMasFracstr.replace('"','') - self.startDict['compMasFrac'] = compMasFracstr - - if self.Prop['compMasFlo[2,1]'] != None: - compMasFloarr = [] - for i in range(1,4): - cmf = [] - for j in range(1,len(self.CompNames)+1): - cmf.append(str(self.Prop['compMasFlo['+str(i)+','+str(j)+']'])) - compMasFloarr.append(cmf) - compMasFlostr = json.dumps(compMolFracarr) - compMasFlostr = compMasFlostr.replace('[','{') - compMasFlostr = compMasFlostr.replace(']','}') - compMasFlostr = compMasFlostr.replace('"','') - self.startDict['compMasFlo'] = compMasFlostr - - if self.Prop['compMolFlo[2,1]'] != None: - compMolFloarr = [] - for i in range(1,4): - cmf = [] - for j in range(1,len(self.CompNames)+1): - cmf.append(str(self.Prop['compMolFlo['+str(i)+','+str(j)+']'])) - compMolFloarr.append(cmf) - compMolFlostr = json.dumps(compMolFloarr) - compMolFlostr = compMolFlostr.replace('[','{') - compMolFlostr = compMolFlostr.replace(']','}') - compMolFlostr = compMolFlostr.replace('"','') - self.startDict['compMolFlo'] = compMolFlostr - - if self.Prop['MW[2]'] != None: - MWArr = [] - for i in range(1,4): - MWArr.append(self.Prop['MW['+str(i)+']']) - MWStr = json.dumps(MWArr) - MWStr = MWStr.replace('[','{') - MWStr = MWStr.replace(']','}') - MWStr = MWStr.replace('"','') - self.startDict['MW'] = MWStr - - if self.Prop['totMolFlo[2]'] != None: - totMolFloArr = [] - for i in range(1,4): - totMolFloArr.append(self.Prop['totMolFlo['+str(i)+']']) - totMolFloStr = json.dumps(totMolFloArr) - totMolFloStr = totMolFloStr.replace('[','{') - totMolFloStr = totMolFloStr.replace(']','}') - totMolFloStr = totMolFloStr.replace('"','') - self.startDict['totMolFlo'] = totMolFloStr - - if self.Prop['phasMolSpHeat[2]'] != None: - phasMolSpHeatArr = [] - for i in range(1,4): - phasMolSpHeatArr.append(self.Prop['phasMolSpHeat['+str(i)+']']) - phasMolSpHeatStr = json.dumps(phasMolSpHeatArr) - phasMolSpHeatStr = phasMolSpHeatStr.replace('[','{') - phasMolSpHeatStr = phasMolSpHeatStr.replace(']','}') - phasMolSpHeatStr = phasMolSpHeatStr.replace('"','') - self.startDict['phasMolSpHeat'] = phasMolSpHeatStr - - if self.Prop['phasMolEnth[2]'] != None: - phasMolEnthArr = [] - for i in range(1,4): - phasMolEnthArr.append(self.Prop['phasMolEnth['+str(i)+']']) - phasMolEnthStr = json.dumps(phasMolEnthArr) - phasMolEnthStr = phasMolEnthStr.replace('[','{') - phasMolEnthStr = phasMolEnthStr.replace(']','}') - phasMolEnthStr = phasMolEnthStr.replace('"','') - self.startDict['phasMolEnth'] = phasMolEnthStr - - - if self.Prop['phasMolEntr[2]'] != None: - phasMolEntrArr = [] - for i in range(1,4): - phasMolEntrArr.append(self.Prop['phasMolEntr['+str(i)+']']) - phasMolEntrStr = json.dumps(phasMolEntrArr) - phasMolEntrStr = phasMolEntrStr.replace('[','{') - phasMolEntrStr = phasMolEntrStr.replace(']','}') - phasMolEntrStr = phasMolEntrStr.replace('"','') - self.startDict['phasMolEntr'] = phasMolEntrStr - - if self.Prop['totMasFlo[2]'] != None: - totMasFloArr = [] - for i in range(1,4): - totMasFloArr.append(self.Prop['totMasFlo['+str(i)+']']) - totMasFloStr = json.dumps(totMasFloArr) - totMasFloStr = totMasFloStr.replace('[','{') - totMasFloStr = totMasFloStr.replace(']','}') - totMasFloStr = totMasFloStr.replace('"','') - self.startDict['totMasFlo'] = totMasFloStr - - 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_Init(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.Material_Stream;\n" ) - self.OM_data_init = self.OM_data_init + ("extends Simulator.Files.Thermodynamic_Packages."+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 +"(NOC = " + str(comp_count) - self.OM_data_init = self.OM_data_init + "ms"+str(self.count) +" " + self.name +"(NOC = " + str(comp_count) - self.OM_data_init = self.OM_data_init + ",comp = {" - comp = str(addedcomp).strip('[').strip(']') - comp = comp.replace("'","") - self.OM_data_init = self.OM_data_init + comp + "}," - #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_Eqn(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 diff --git a/OMChem/Mixer.py b/OMChem/Mixer.py index b0e0a66..c726cdc 100644 --- a/OMChem/Mixer.py +++ b/OMChem/Mixer.py @@ -33,7 +33,7 @@ class Mixer(): comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Mixer " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Mixer " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Pump.py b/OMChem/Pump.py index a63c9f0..3b6ed2c 100644 --- a/OMChem/Pump.py +++ b/OMChem/Pump.py @@ -44,7 +44,7 @@ class Pump(): comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + 'Simulator.Streams.Energy_Stream '+self.EngStms.name+';\n' self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Centrifugal_Pump " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Centrifugal_Pump " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/ShortcutColumn.py b/OMChem/ShortcutColumn.py index 5c42545..a018873 100644 --- a/OMChem/ShortcutColumn.py +++ b/OMChem/ShortcutColumn.py @@ -59,7 +59,7 @@ class ShortcutColumn(): self.OM_data_init = self.OM_data_init + ("extends Simulator.Files.Thermodynamic_Packages."+self.thermoPackage+";\n") self.OM_data_init = self.OM_data_init + ("end sc"+str(self.count)+";\n") comp_count = len(addedcomp) - self.OM_data_init = self.OM_data_init + "sc"+str(self.count)+ " " + self.name + "(NOC = " + str(comp_count) + self.OM_data_init = self.OM_data_init + "sc"+str(self.count)+ " " + self.name + "(Nc = " + str(comp_count) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Splitter.py b/OMChem/Splitter.py index ed79c9d..f873146 100644 --- a/OMChem/Splitter.py +++ b/OMChem/Splitter.py @@ -33,7 +33,7 @@ class Splitter(): self.OM_data_init = '' comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Splitter " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Splitter " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/Valve.py b/OMChem/Valve.py index f1f8ac3..9e8494b 100644 --- a/OMChem/Valve.py +++ b/OMChem/Valve.py @@ -44,7 +44,7 @@ class Valve(): self.OM_data_init = '' comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "Simulator.Unit_Operations.Valve " + self.name + "(NOC = " + str(comp_count)) + "Simulator.Unit_Operations.Valve " + self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/adiabatic_comp.py b/OMChem/adiabatic_comp.py index 5399ed0..d0a6b72 100644 --- a/OMChem/adiabatic_comp.py +++ b/OMChem/adiabatic_comp.py @@ -1,10 +1,10 @@ from OMChem.EngStm import EngStm -class AdiaComp(): +class AdiabaticCompressor(): counter = 1 - def __init__(self,name='AdiaComp', eff = None): + def __init__(self,name='AdiabaticCompressor', eff = None): self.eff = eff #self.name = name[0] - self.name = name + str(AdiaComp.counter) + self.name = name + str(AdiabaticCompressor.counter) self.OM_data_eqn = '' self.OM_data_init = '' @@ -12,15 +12,15 @@ class AdiaComp(): self.OutputStms = None self.EngStms = EngStm(name='EngStm'+self.name) #self.count = name[1] - self.count = AdiaComp.counter - self.type = 'AdiaComp' - self.thermoPackage ="Raoults_Law" + self.count = AdiabaticCompressor.counter + self.type = 'AdiabaticCompressor' + self.thermoPackage ="RaoultsLaw" self.mode = None self.modeVal = None # new self.no_of_input = 1 self.no_of_output = 1 - AdiaComp.counter += 1 + AdiabaticCompressor.counter += 1 def getname(self): return self.name @@ -50,7 +50,7 @@ class AdiaComp(): self.OM_data_init = self.OM_data_init + ("end adiaComp"+str(self.count)+";\n") comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "adiaComp"+str(self.count)+" "+ self.name + "(NOC = " + str(comp_count)) + "adiaComp"+str(self.count)+" "+ self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") diff --git a/OMChem/adiabatic_exp.py b/OMChem/adiabatic_exp.py index 0dfb541..2754f0a 100644 --- a/OMChem/adiabatic_exp.py +++ b/OMChem/adiabatic_exp.py @@ -1,26 +1,26 @@ from OMChem.EngStm import EngStm -class AdiaExp(): +class AdiabaticExpander(): counter = 1 - def __init__(self,name='AdiaExp', eff = None): + def __init__(self,name='AdiabaticExpander', eff = None): self.eff = eff #self.name = name[0] - self.name = name + str(AdiaExp.counter) + self.name = name + str(AdiabaticExpander.counter) self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None self.OutputStms = None self.EngStms = EngStm(name='EngStm'+self.name) #self.count = name[1] - self.count = AdiaExp.counter - self.type = 'AdiaExp' - self.thermoPackage ="Raoults_Law" + self.count = AdiabaticExpander.counter + self.type = 'AdiabaticExpander' + self.thermoPackage ="RaoultsLaw" self.mode = None self.modeVal = None # new self.no_of_input = 1 self.no_of_output = 1 - AdiaExp.counter += 1 + AdiabaticExpander.counter += 1 def getname(self): return self.name @@ -50,7 +50,7 @@ class AdiaExp(): self.OM_data_init = self.OM_data_init + ("end adiaComp"+str(self.count)+";\n") comp_count = len(addedcomp) self.OM_data_init = self.OM_data_init + ( - "adiaComp"+str(self.count)+" "+ self.name + "(NOC = " + str(comp_count)) + "adiaComp"+str(self.count)+" "+ self.name + "(Nc = " + str(comp_count)) self.OM_data_init = self.OM_data_init + (",comp = {") comp = str(addedcomp).strip('[').strip(']') comp = comp.replace("'", "") |