diff options
Diffstat (limited to 'OMChem')
30 files changed, 507 insertions, 1048 deletions
diff --git a/OMChem/CompSep.py b/OMChem/CompSep.py index 54b6415..9579498 100644 --- a/OMChem/CompSep.py +++ b/OMChem/CompSep.py @@ -1,11 +1,12 @@ from OMChem.EngStm import EngStm import json class CompSep(): - def __init__(self,CompNames = [],name='compoundseparator',SepFact=['Molar_Flow','Mass_Flow'],SepStrm=1,SepFactValue=[]): + counter = 1 + def __init__(self,CompNames = [],name='CompSep',SepFact=['Molar_Flow','Mass_Flow'],SepStrm=1,SepFactValue=[]): self.SepFact = json.dumps(SepFact).replace('[','{').replace(']','}') self.SepStrm = str(SepStrm) self.SepFactValue = json.dumps(SepFactValue).replace('[','{').replace(']','}') - self.name = name + #self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = [] @@ -13,8 +14,18 @@ class CompSep(): self.type = 'CompSep' self.EngStms = EngStm(name='EngStm') + # new + self.name = name + str(CompSep.counter) + self.no_of_input = 1 + self.no_of_output = 2 + CompSep.counter += 1 + + def getname(self): + return self.name + def modesList(self): - return [] + return [] + def paramgetter(self,mode=None): dict = {"SepStrm":None,"SepFactValue":None,"SepFact":None} return dict @@ -29,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("'", "") @@ -42,7 +53,6 @@ class CompSep(): self.InputStms = InputStms self.OutputStms = OutputStms - def OM_Flowsheet_Eqn(self, addedcomp): self.OM_data_eqn = '' comp_count = len(addedcomp) @@ -57,7 +67,6 @@ class CompSep(): sepFac = str(self.SepFactValue).strip('[').strip(']') self.OM_data_eqn = self.OM_data_eqn + (self.name+'.sepFactVal= {'+ sepFac + '};\n') - return self.OM_data_eqn diff --git a/OMChem/ConvReactor.py b/OMChem/ConvReactor.py index b9958a9..9ad35da 100644 --- a/OMChem/ConvReactor.py +++ b/OMChem/ConvReactor.py @@ -41,40 +41,3 @@ class ConvReactor(): self.OM_data_eqn = self.OM_data_eqn + ('connect(' + self.EngStms.name + '.inlet,' + self.name + '.EnergyStream);\n') return self.OM_data_eqn - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OMChem/Cooler.py b/OMChem/Cooler.py index 577b181..9a44033 100644 --- a/OMChem/Cooler.py +++ b/OMChem/Cooler.py @@ -1,9 +1,10 @@ from OMChem.EngStm import EngStm class Cooler(): - def __init__(self,name='cooler',PressureDrop = None, eff = None): + counter = 1 + def __init__(self,name='Cooler',PressureDrop = None, eff = None): self.PressureDrop = PressureDrop self.eff = eff - self.name = name + # self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None @@ -21,6 +22,15 @@ class Cooler(): 'tempDrop':None, 'heatRem':None, } + # new + self.name = name + str(Cooler.counter) + self.no_of_input = 1 + self.no_of_output = 1 + Cooler.counter += 1 + + def getname(self): + return self.name + def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms self.OutputStms = OutputStms @@ -44,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 35054da..1492bc2 100644 --- a/OMChem/DistCol.py +++ b/OMChem/DistCol.py @@ -1,17 +1,20 @@ from OMChem.EngStm import EngStm class DistCol(): - def __init__(self,name=('DistCol',1), numStage = None,numFeeds = None,feedStages = None): + counter = 1 + def __init__(self,name='DistCol', numStage = None,numFeeds = None,feedStages = None): self.numStage = numStage self.numFeeds=numFeeds self.feedStages=feedStages - self.name = name[0] + #self.name = name[0] + self.name = name + str(DistCol.counter) self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None self.OutputStms = None self.EngStm1 = EngStm(name='EngStm1'+self.name) self.EngStm2 = EngStm(name='EngStm2'+self.name) - self.count = name[1] + #self.count = name[1] + self.count = DistCol.counter self.thermoPackage='Raoults_Law' self.type = 'DistCol' self.mode = None @@ -20,6 +23,14 @@ class DistCol(): self.condP=None self.rebP=None + # new + self.no_of_input = 2 + self.no_of_output = 2 + DistCol.counter += 1 + + def getname(self): + return self.name + def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms self.OutputStms = OutputStms @@ -57,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 22335a5..a3bf5dc 100644 --- a/OMChem/Flash.py +++ b/OMChem/Flash.py @@ -1,13 +1,25 @@ class Flash(): - def __init__(self,name=("flash",1)): - self.name = name[0] + counter = 1 + def __init__(self,name='Flash'): + #self.name = name[0] self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None self.OutputStms = None self.type = 'flash' - self.count = name[1] + #self.count = name[1] + self.count = Flash.counter self.thermoPackage =None + + # new + self.name = name + str(Flash.counter) + self.no_of_input = 1 + self.no_of_output = 2 + Flash.counter += 1 + + def getname(self): + return self.name + def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms self.OutputStms = OutputStms @@ -29,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 cfd9bae..25143ce 100644 --- a/OMChem/Flowsheet.py +++ b/OMChem/Flowsheet.py @@ -6,460 +6,336 @@ from subprocess import Popen, PIPE import pandas as pd class Flowsheet(): - def __init__(self): - self.sim_name = 'Simulator' - self.sim_method = '' - self.UnitOpn = [] - self.data = [] - self.compounds = [] - self.interface = '' - self.omc_path = None - self.curr_path = os.getcwd() # Chemical-Simulator-GUI - self.sim_dir_path = os.path.join(self.curr_path, self.sim_name) # Chemical-Simulator-GUI/Simulator - self.Flomo_path = os.path.join(self.sim_dir_path,'Flowsheet.mo') - self.eqn_mos_path = os.path.join(self.sim_dir_path,'simulateEQN.mos') - self.sm_mos_path = os.path.join(self.sim_dir_path,'simulateSM.mos') - self.resdata = [] - self.stdout=None - self.stderr=None - - - def get_omc_path(self): - try: - self.omhome = os.environ.get('OPENMODELICAHOME') - if self.omhome is None: - self.omhome = os.path.split(os.path.split(os.path.realpath(spawn.find_executable("omc")))[0])[0] - elif os.path.exists('/opt/local/bin/omc'): - self.omhome = '/opt/local' - return os.path.join(self.omhome, 'bin', 'omc') - except BaseException: - print("The OpenModelica compiler is missing in the System path please install it" ) - raise - - def add_UnitOpn(self,unitop,flag): - f=(unitop,flag) - self.UnitOpn.append(f) - - def remove_UnitOpn(self,unitop): - self.UnitOpn.remove(unitop) - - def add_comp_list(self,comp): - self.compounds = comp - - def send_for_simulationEqn(self): - self.resdata = [] - self.omc_path = self.get_omc_path() - print(self.omc_path) - - if self.sim_method == 'Eqn': - simpath = self.eqn_mos_path - os.chdir(self.sim_dir_path) - - process = Popen([self.omc_path, '-s',simpath], stdout=PIPE, stderr=PIPE) - self.stdout, self.stderr = process.communicate() - #s = subprocess.check_output([self.omc_path, '-s',simpath]) - #print(s) - #print("############### StdOut ################") - print(self.stdout) - os.chdir(self.curr_path) - #os.system(self.omc_path + ' -s ' + simpath) - print("Hello") - if self.sim_method == 'Eqn': - print("hhhh") - csvpath = os.path.join(self.sim_dir_path,'Flowsheet_res.csv') - print("csvPath",csvpath) - with open (csvpath,'r') as resultFile: - self.resdata = [] - print("opened") - csvreader = csv.reader(resultFile,delimiter=',') - for row in csvreader: - print("124125") - self.resdata.append(row) - #self.ExtData() - - - def send_for_simulationSM(self,unitop): - - self.resdata = [] - self.omc_path = self.get_omc_path() - os.chdir(self.sim_dir_path) - #os.system(self.omc_path + ' -s ' + unitop.name+'.mos') - process = Popen([self.omc_path, '-s',unitop.name,'.mos'], stdout=PIPE, stderr=PIPE) - stdout, stderr = process.communicate() - #s = subprocess.check_output([self.omc_path, '-s',simpath]) - #print(s) - print("############### StdOut ################") - print(stdout) - self.resdata = [] - print('Simulating '+unitop.name+'...') - csvpath = os.path.join(self.sim_dir_path,unitop.name+'_res.csv') - with open(csvpath,'r') as resultFile: - csvreader = csv.reader(resultFile,delimiter=',') - for row in csvreader: - self.resdata.append(row) - self.ExtData() - - - - - - # if self.sim_method == 'SM': - # for unitop in self.UnitOpn: - # self.resdata = [] - # if unitop.type != 'MatStm': - # print 'Simulating '+unitop.name+'...' - # csvpath = os.path.join(self.sim_dir_path,unitop.name+'_res.csv') - # with open(csvpath,'r') as resultFile: - # csvreader = csv.reader(resultFile,delimiter=',') - # for row in csvreader: - # self.resdata.append(row) - # self.ExtData() - - - - - - # if self.interface == 'OMPython': - # omc = OMCSession() - # omc.sendExpression("loadModel(Modelica)") - # omc.sendExpression("loadFile(\"Simulator.mo\")") - # omc.sendExpression("loadFile(\"Flowsheet.mo\")") - # execsim = omc.sendExpression("simulate(Flowsheet, outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1)") - - # else: - # os.system(self.omc_path + ' -s ') - - def ExtData(self): - for unit in self.UnitOpn: - if unit[0].type == 'MatStm': -# - for key, value in unit[0].Prop.items(): - - - propertyname = unit[0].name + '.' + key - if propertyname in self.resdata[0]: - ind = self.resdata[0].index(propertyname) - resultval = str(self.resdata[-1][ind]) - #resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) - print(resultval) - unit[0].Prop[key] = resultval - #print(unit[0].Prop) - # else: - # for v in value: - # propertyname = unit.name + '.' + v - # if propertyname in self.resdata[0]: - # ind = self.resdata[0].index(propertyname) - # resultval = str(self.resdata[-1][ind]) - # # resultval = str(omc.sendExpression("val("+unit.name+ "." + v + ", 0.5)")) - # unit.Prop[key][i] = resultval - # i = i + 1 - - # for key, value in unit.OMVapProp.iteritems(): - # i = 0 - - # if type(value) is str: - # propertyname = unit.name + '.' + value - # if propertyname in self.resdata[0]: - # ind = self.resdata[0].index(propertyname) - # resultval = str(self.resdata[-1][ind]) - # # resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) - # unit.VapProp[key] = resultval - # else: - # for v in value: - # propertyname = unit.name + '.' + v - # if propertyname in self.resdata[0]: - # ind = self.resdata[0].index(propertyname) - # resultval = str(self.resdata[-1][ind]) - # # resultval = str(omc.sendExpression("val("+unit.name+ "." + v + ", 0.5)")) - # unit.VapProp[key][i] = resultval - # i = i + 1 - - - # for key, value in unit.OMLiqProp.iteritems(): - # i = 0 - - # if type(value) is str: - # propertyname = unit.name + '.' + value - # if propertyname in self.resdata[0]: - # ind = self.resdata[0].index(propertyname) - # resultval = str(self.resdata[-1][ind]) - # # resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) - # unit.LiqProp[key] = resultval - # else: - # for v in value: - # propertyname = unit.name + '.' + v - # if propertyname in self.resdata[0]: - # ind = self.resdata[0].index(propertyname) - # resultval = str(self.resdata[-1][ind]) - # # resultval = str(omc.sendExpression("val("+unit.name+ "." + v + ", 0.5)")) - # unit.LiqProp[key][i] = resultval - # i = i + 1 - # for key, value in unit.OMVapProp.iteritems(): - # i = 0 - - # if type(value) is str: - # resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) - # unit.VapProp[key] = resultval - # else: - # for v in value: - # resultval = str(omc.sendExpression("val("+unit.name+ "." + v + ", 0.5)")) - # unit.VapProp[key][i] = resultval - # i = i + 1 - - - # for key, value in unit.OMLiqProp.iteritems(): - # i = 0 - - # if type(value) is str: - # resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) - # unit.LiqProp[key] = resultval - # else: - # for v in value: - # resultval = str(omc.sendExpression("val("+unit.name+ "." + v + ", 0.5)")) - # unit.LiqProp[key][i] = resultval - # i = i + 1 - - - - def simulateEQN(self): - self.data = [] - print("##################################################") - print("##################################################") - self.sim_method = 'Eqn' - self.data.append("model Flowsheet\n") - - for c in self.compounds: - ucase = c.title() - lcase = c.lower() - self.data.append("parameter Simulator.Files.Chemsep_Database." + ucase +' '+ ucase + "; \n") - - for unitop in self.UnitOpn: - self.data.append(unitop[0].OM_Flowsheet_Init(self.compounds)) - - self.data.append("equation\n") + def __init__(self): + self.sim_name = 'Simulator' + self.sim_method = '' + self.UnitOpn = [] + self.data = [] + self.compounds = [] + self.interface = '' + self.omc_path = None + self.root_dir = os.getcwd() # Chemical-Simulator-GUI + self.sim_dir_path = os.path.join(self.root_dir, self.sim_name) # Chemical-Simulator-GUI/Simulator + self.Flomo_path = os.path.join(self.sim_dir_path,'Flowsheet.mo') + self.eqn_mos_path = os.path.join(self.sim_dir_path,'simulateEQN.mos') + self.sm_mos_path = os.path.join(self.sim_dir_path,'simulateSM.mos') + self.resdata = [] + self.stdout=None + self.stderr=None + + def get_omc_path(self): + try: + self.omhome = os.environ.get('OPENMODELICAHOME') + if self.omhome is None: + self.omhome = os.path.split(os.path.split(os.path.realpath(spawn.find_executable("omc")))[0])[0] + elif os.path.exists('/opt/local/bin/omc'): + self.omhome = '/opt/local' + elif os.path.exists('/usr/bin/omc'): + self.omhome = '/usr' + return os.path.join(self.omhome, 'bin', 'omc') + except BaseException: + print("The OpenModelica compiler is missing in the System path please install it" ) + raise + + def add_UnitOpn(self,unitop): + self.UnitOpn.append(unitop) + + def remove_UnitOpn(self,unitop): + self.UnitOpn.remove(unitop) + + def add_comp_list(self,C): + self.compounds = C + + def send_for_simulationEqn(self): + self.resdata = [] + self.omc_path = self.get_omc_path() + print(self.omc_path) + + if self.sim_method == 'Eqn': + simpath = self.eqn_mos_path + os.chdir(self.sim_dir_path) + + self.process = Popen([self.omc_path, '-s',simpath], stdout=PIPE, stderr=PIPE) + self.stdout, self.stderr = self.process.communicate() + #s = subprocess.check_output([self.omc_path, '-s',simpath]) + #print(s) + #print("############### StdOut ################") + print(self.stdout) + os.chdir(self.root_dir) + #os.system(self.omc_path + ' -s ' + simpath) + print("Hello") + if self.sim_method == 'Eqn': + print("hhhh") + csvpath = os.path.join(self.sim_dir_path,'Flowsheet_res.csv') + print("csvPath",csvpath) + with open (csvpath,'r') as resultFile: + self.resdata = [] + print("opened") + csvreader = csv.reader(resultFile,delimiter=',') + for row in csvreader: + print("124125") + self.resdata.append(row) + print(self.resdata) + #self.ExtData() + + def send_for_simulationSM(self,unitop): + + self.resdata = [] + self.omc_path = self.get_omc_path() + os.chdir(self.sim_dir_path) + #os.system(self.omc_path + ' -s ' + unitop.name+'.mos') + self.process = Popen([self.omc_path, '-s',unitop.name,'.mos'], stdout=PIPE, stderr=PIPE) + stdout, stderr = self.process.communicate() + #s = subprocess.check_output([self.omc_path, '-s',simpath]) + #print(s) + print("############### StdOut ################") + print(stdout) + self.resdata = [] + print('Simulating '+unitop.name+'...') + csvpath = os.path.join(self.sim_dir_path,unitop.name+'_res.csv') + with open(csvpath,'r') as resultFile: + csvreader = csv.reader(resultFile,delimiter=',') + for row in csvreader: + self.resdata.append(row) + self.ExtData() + + def ExtData(self): + for unit in self.UnitOpn: + if unit[0].type == 'MaterialStream': + for key, value in unit[0].Prop.items(): + propertyname = unit[0].name + '.' + key + if propertyname in self.resdata[0]: + ind = self.resdata[0].index(propertyname) + resultval = str(self.resdata[-1][ind]) + #resultval = str(omc.sendExpression("val("+unit.name+ "." + value + ", 0.5)")) + print(resultval) + unit[0].Prop[key] = resultval + + def simulateEQN(self): + self.data = [] + print("##################################################") + print("##################################################") + self.sim_method = 'Eqn' + self.data.append("model Flowsheet\n") - for unitop in self.UnitOpn: - if unitop[1]==0: - - if unitop[0].type == 'MatStm': - self.data.append(unitop[0].OM_Flowsheet_Eqn(self.compounds,'Eqn')) - else: - self.data.append(unitop[0].OM_Flowsheet_Eqn(self.compounds)) - else: - pass - with open(self.Flomo_path, 'w') as txtfile: - for d in self.data: - txtfile.write(d) - txtfile.write('end Flowsheet;\n') - - 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") - - print('Initiating Simulation in Equation Oriented Mode') - - self.send_for_simulationEqn() - - - def simulateSM(self,ip,op): - self.sim_method = 'SM' - self.data = [] - self.resdata = [] - self.unit = [] - self.csvlist = [] - print("op list",op) - print("ip list",ip) - for i in ip: - common = ip[i] - print("common #############3",common) - print("*********** i *********",i) - for k,v in op.items(): - print("Print K",k) - if(set(v) & set(common)): - print("*****************common matstm***************") - if((i in self.unit) and (k in self.unit)): - print("both exist") - pass - elif(i in self.unit): - print("output exist") - self.unit.insert(self.unit.index(i),k) - elif(k in self.unit): - print("input exists") - self.unit.append(i) - else: - print("nothing exists") - self.unit.append(k) - self.unit.append(i) - print("##############################33") - print(self.unit) - print("################################11") - - for unitop in self.unit: - os.chdir(self.curr_path) - self.data = [] - if unitop.type not in ['MatStm','EngStm']: - inpstms = unitop.InputStms - outstms = unitop.OutputStms - - try: - engstms = unitop.EngStms - except: - engstms = None - - self.data.append("model "+unitop.name.lower()+'\n') - - for c in self.compounds: - ucase = c.title() - lcase = c.lower() - self.data.append("parameter Simulator.Files.Chemsep_Database." + ucase +' '+ ucase + "; \n") - - print("##############compounds added") - self.data.append(unitop.OM_Flowsheet_Init(self.compounds)) - - if type(outstms) is list: - for stm in outstms: - self.data.append(stm.OM_Flowsheet_Init(self.compounds)) - else: - self.data.append(outstms.OM_Flowsheet_Init(self.compounds)) - - - if engstms: - self.data.append(engstms.OM_Flowsheet_Init(self.compounds)) - - if type(inpstms) is list: - for stm in inpstms: - self.data.append(stm.OM_Flowsheet_Init(self.compounds)) - else: - self.data.append(inpstms.OM_Flowsheet_Init(self.compounds)) - - self.data.append('equation\n') - print("##################equation") - self.data.append(unitop.OM_Flowsheet_Eqn(self.compounds)) - ''' - if type(outstms) is list: - for stm in outstms: - #stm.GetEquationValues() - self.data.append(stm.OM_Flowsheet_Eqn(self.compounds,'SM')) - else: - #outstms.GetEquationValues() - self.data.append(outstms.OM_Flowsheet_Eqn(self.compounds,'SM')) -''' - if type(inpstms) is list: - for stm in inpstms: - #stm.GetEquationValues() - self.data.append(stm.OM_Flowsheet_Eqn(self.compounds,'SM')) - else: - #inpstms.GetEquationValues() - self.data.append(inpstms.OM_Flowsheet_Eqn(self.compounds,'SM')) - - # os.chdir(self.sim_dir_path) - unitmofile = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mo') - - with open(unitmofile,'w') as unitFile: - for d in self.data: - unitFile.write(d) - unitFile.write('end '+unitop.name.lower()+';\n') - - unitmosfile = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mos') - with open(unitmosfile, 'w') as mosFile: - mosFile.write('loadModel(Modelica);\n') - mosFile.write("loadFile(\"Simulator\package.mo\");\n") - - mosFile.write("loadFile(\""+unitop.name.lower()+".mo\");\n") - mosFile.write("simulate("+unitop.name.lower()+", outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1);\n") - - print("Initiating simulation in Sequential Modular Mode") - #self.resdata = [] - self.omc_path = self.get_omc_path() - os.chdir(self.sim_dir_path) - #os.system(self.omc_path + ' -s ' + unitop[0].name.lower()+"SEQ"+'.mos') - print("SIM directory Path 1 ###",self.sim_dir_path) - sim = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mos') - process = Popen([self.omc_path, '-s',sim], stdout=PIPE, stderr=PIPE) - self.stdout, self.stderr = process.communicate() - os.chdir(self.curr_path) - #s = subprocess.check_output([self.omc_path, '-s',simpath]) - #print(s) - print("############### StdOut ################") - print(self.stdout) - print("############### StdErr ################") - print(self.stderr) - print('Simulating '+unitop.name.lower()+'...') - csvpath = os.path.join(self.sim_dir_path,unitop.name.lower()+'_res.csv') - - self.csvlist.append(csvpath) - - with open(csvpath,'r') as resultFile: - csvreader = csv.reader(resultFile,delimiter=',') - for row in csvreader: - self.resdata.append(row) - - os.chdir(self.curr_path) - if type(inpstms) is list: - for stm in inpstms: - for key, value in stm.Prop.items(): - propertyname = stm.name + '.' + key - if propertyname in self.resdata[0]: - ind = self.resdata[0].index(propertyname) - resultval = str(self.resdata[-1][ind]) - stm.Prop[key] = resultval - - #print("input",stm.Prop[key]) - - - else: - for key, value in inpstms.Prop.items(): - propertyname = inpstms.name + '.' + key - if propertyname in self.resdata[0]: - ind = self.resdata[0].index(propertyname) - resultval = str(self.resdata[-1][ind]) - inpstms.Prop[key] = resultval - #print("input",inpstms.Prop[key]) - - if type(outstms) is list: - for stm in outstms: - for key, value in stm.Prop.items(): - propertyname = stm.name + '.' + key - if propertyname in self.resdata[0]: - ind = self.resdata[0].index(propertyname) - resultval = str(self.resdata[-1][ind]) - stm.Prop[key] = resultval - print("output key:",key,"value:",stm.Prop[key]) - else: - for key, value in outstms.Prop.items(): - propertyname = outstms.name + '.' + key - if propertyname in self.resdata[0]: - ind = self.resdata[0].index(propertyname) - resultval = str(self.resdata[-1][ind]) - outstms.Prop[key] = resultval - print("output key:",key,"value:",outstms.Prop[key]) - - - self.dataframes = [pd.read_csv(i) for i in self.csvlist] - os.chdir(self.sim_dir_path) - dffinal = pd.concat(self.dataframes,axis=1) - dffinal.to_csv('FlowsheetSEQ.csv',index=False) - self.resdata.clear() - with open(os.path.join(self.sim_dir_path+'/FlowsheetSEQ.csv'),'r') as resultFile: - csvreader = csv.reader(resultFile,delimiter=',') - for row in csvreader: - self.resdata.append(row) - - - - - - - - - - - - - - - - - + for c in self.compounds: + ucase = c.title() + lcase = c.lower() + self.data.append("parameter database." + ucase +' '+ ucase + "; \n") + + for unitop in self.UnitOpn: + if unitop.type != 'MaterialStream': + self.data.append(unitop.OM_Flowsheet_Initialize()) + else: + self.data.append(unitop.OM_Flowsheet_Initialize(self.compounds)) + + + self.data.append("equation\n") + + self.outlist = [] + self.stm = ['MaterialStream','EngStm'] + for unitop in self.UnitOpn: + if unitop.type not in self.stm: + for j in unitop.OutputStms: + self.outlist.append(j) + print(j.name) + + for unitop in self.UnitOpn: + if unitop not in self.outlist: + + if unitop.type == 'MaterialStream': + self.data.append(unitop.OM_Flowsheet_Equation(self.compounds,'Eqn')) + else: + self.data.append(unitop.OM_Flowsheet_Equation()) + else: + pass + with open(self.Flomo_path, 'w') as txtfile: + for d in self.data: + txtfile.write(str(d)) + txtfile.write('end Flowsheet;\n') + + 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_simulationEqn() + + + def simulateSM(self,ip,op): + print("ip op = ", ip, op) + self.sim_method = 'SM' + self.data = [] + self.resdata = [] + self.unit = [] + self.csvlist = [] + print("op list",op) + print("ip list",ip) + for i in ip: + common = ip[i] + print("common #############3",common) + print("*********** i *********",i) + for k,v in op.items(): + print("Print K",k) + if(set(v) & set(common)): + print("*****************common MaterialStream***************") + if((i in self.unit) and (k in self.unit)): + print("both exist") + pass + elif(i in self.unit): + print("output exist") + self.unit.insert(self.unit.index(i),k) + elif(k in self.unit): + print("input exists") + self.unit.append(i) + else: + print("nothing exists") + self.unit.append(k) + self.unit.append(i) + print("##############################33") + print(self.unit) + print("################################11") + + for unitop in self.unit: + os.chdir(self.root_dir) + self.data = [] + if unitop.type not in ['MaterialStream','EngStm']: + inpstms = unitop.InputStms + outstms = unitop.OutputStms + + try: + engstms = unitop.EngStms + except: + engstms = None + + self.data.append("model "+unitop.name.lower()+'\n') + + for c in self.compounds: + ucase = c.title() + lcase = c.lower() + self.data.append("parameter Simulator.Files.Chemsep_Database." + ucase +' '+ ucase + "; \n") + + print("##############compounds added") + self.data.append(unitop.OM_Flowsheet_Initialize()) + + if type(outstms) is list: + for stm in outstms: + self.data.append(stm.OM_Flowsheet_Initialize()) + else: + self.data.append(outstms.OM_Flowsheet_Initialize()) + + + if engstms: + self.data.append(engstms.OM_Flowsheet_Initialize()) + + if type(inpstms) is list: + for stm in inpstms: + self.data.append(stm.OM_Flowsheet_Initialize()) + else: + self.data.append(inpstms.OM_Flowsheet_Initialize()) + + self.data.append('equation\n') + print("##################equation") + self.data.append(unitop.OM_Flowsheet_Equation()) + + if type(inpstms) is list: + for stm in inpstms: + #stm.GetEquationValues() + self.data.append(stm.OM_Flowsheet_Equation()) + else: + #inpstms.GetEquationValues() + 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') + + with open(unitmofile,'w') as unitFile: + for d in self.data: + unitFile.write(d) + unitFile.write('end '+unitop.name.lower()+';\n') + + unitmosfile = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mos') + with open(unitmosfile, 'w') as mosFile: + mosFile.write('loadModel(Modelica);\n') + mosFile.write("loadFile(\"Simulator\package.mo\");\n") + + mosFile.write("loadFile(\""+unitop.name.lower()+".mo\");\n") + mosFile.write("simulate("+unitop.name.lower()+", outputFormat=\"csv\", stopTime=1.0, numberOfIntervals=1);\n") + + print("Initiating simulation in Sequential Modular Mode") + #self.resdata = [] + self.omc_path = self.get_omc_path() + os.chdir(self.sim_dir_path) + #os.system(self.omc_path + ' -s ' + unitop[0].name.lower()+"SEQ"+'.mos') + print("SIM directory Path 1 ###",self.sim_dir_path) + sim = os.path.join(self.sim_dir_path,unitop.name.lower()+'.mos') + self.process = Popen([self.omc_path, '-s',sim], stdout=PIPE, stderr=PIPE) + self.stdout, self.stderr = self.process.communicate() + os.chdir(self.root_dir) + #s = subprocess.check_output([self.omc_path, '-s',simpath]) + #print(s) + print("############### StdOut ################") + print(self.stdout) + print("############### StdErr ################") + print(self.stderr) + print('Simulating '+unitop.name.lower()+'...') + csvpath = os.path.join(self.sim_dir_path,unitop.name.lower()+'_res.csv') + + self.csvlist.append(csvpath) + + with open(csvpath,'r') as resultFile: + csvreader = csv.reader(resultFile,delimiter=',') + for row in csvreader: + self.resdata.append(row) + + os.chdir(self.root_dir) + if type(inpstms) is list: + for stm in inpstms: + for key,value in stm.Prop.items(): + propertyname = stm.name + '.' + key + if propertyname in self.resdata[0]: + ind = self.resdata[0].index(propertyname) + resultval = str(self.resdata[-1][ind]) + stm.Prop[key] = resultval + #print("input",stm.Prop[key]) + + else: + for key, value in inpstms.Prop.items(): + propertyname = inpstms.name + '.' + key + if propertyname in self.resdata[0]: + ind = self.resdata[0].index(propertyname) + resultval = str(self.resdata[-1][ind]) + inpstms.Prop[key] = resultval + #print("input",inpstms.Prop[key]) + + if type(outstms) is list: + for stm in outstms: + for key, value in stm.Prop.items(): + propertyname = stm.name + '.' + key + if propertyname in self.resdata[0]: + ind = self.resdata[0].index(propertyname) + resultval = str(self.resdata[-1][ind]) + stm.Prop[key] = resultval + print("output key:",key,"value:",stm.Prop[key]) + else: + for key, value in outstms.Prop.items(): + propertyname = outstms.name + '.' + key + if propertyname in self.resdata[0]: + ind = self.resdata[0].index(propertyname) + resultval = str(self.resdata[-1][ind]) + outstms.Prop[key] = resultval + print("output key:",key,"value:",outstms.Prop[key]) + + self.dataframes = [pd.read_csv(i) for i in self.csvlist] + os.chdir(self.sim_dir_path) + dffinal = pd.concat(self.dataframes,axis=1) + dffinal.to_csv('FlowsheetSEQ.csv',index=False) + self.resdata.clear() + with open(os.path.join(self.sim_dir_path+'/FlowsheetSEQ.csv'),'r') as resultFile: + csvreader = csv.reader(resultFile,delimiter=',') + for row in csvreader: + self.resdata.append(row) diff --git a/OMChem/Heater.py b/OMChem/Heater.py index c0d8d95..cf9b8f1 100644 --- a/OMChem/Heater.py +++ b/OMChem/Heater.py @@ -1,9 +1,10 @@ from OMChem.EngStm import EngStm class Heater(): + counter = 1 def __init__(self,name='Heater',PressureDrop = None, eff = None): self.PressureDrop = PressureDrop self.eff = eff - self.name = name + #self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None @@ -23,6 +24,15 @@ class Heater(): 'heatAdd':None, } + # new + self.name = name + str(Heater.counter) + self.no_of_input = 1 + self.no_of_output = 1 + Heater.counter += 1 + + def getname(self): + return self.name + def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms self.OutputStms = OutputStms @@ -46,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 f27b3da..0000000 --- a/OMChem/MatStm.py +++ /dev/null @@ -1,501 +0,0 @@ -from OMPython import OMCSession -import json -import sys -from collections import defaultdict - -class MatStm(): - def __init__(self,name =None,CompNames = [],Temperature=300,Pressure=101325,VapPhasMolFrac=None,VapPhasMasFrac=None,LiqPhasMolFrac=None,LiqPhasMasFrac=None,CompMolFrac = [1.0], CompMasFrac = [], MolFlow=100, MasFlow=None,**kwargs): - self.name = name[0] - 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 = name[1] - self.thermoPackage ="Raoults_Law" - self.mode1 = "P" - self.mode1val = "" - self.mode2 = "T" - self.mode2val = "" - - # self.ValEntList = {"T":T," P":P," VapPhasMolFrac":vapPhasMolFrac," CompNames":CompNames," CompMolFrac[1]":CompMolFrac," CompMasFrac":CompMasFrac," MolFlow[1]":MolFlow," MasFlow[1]":MasFlow} - - - # self.OMProp = { - # 'Pressure': self.mode1, - # 'Temperature': self.mode2, - # 'Liquid Phase Mole Fraction': 'liqPhasMolFrac', - # 'Liquid Phase Mas Fraction': 'liqPhasMasFrac', - # 'Vapour Phase Mole Fraction': 'vapPhasMolFrac', - # 'Vapour Phase Mas Fraction': 'vapPhasMasFrac', - # 'Total Molar Flow': 'totMolFlo[1]', - # 'Total Mas Flow': 'totMasFlo[1]', - # 'Av. Molecular Weight': 'MW[1]', - # 'Comp Mole Fraction': ['compMolFrac[1,1]','compMolFrac[1,2]','compMolFrac[1,3]'], - # 'Comp Mas Fraction': ['compMasFrac[1,1]','compMasFrac[1,2]','compMasFrac[1,3]'], - # 'Comp Molar Flow': ['compMolFlo[1,1]','compMolFlo[1,2]','compMolFlo[1,3]'], - # 'Comp Mas Flow': ['compMasFlo[1,1]','compMasFlo[1,2]','compMasFlo[1,3]'], - # 'Molar Specific Heat': 'phasMolSpHeat[1]', - # 'Molar Enthalpy': 'phasMolEnth[1]', - # 'Molar Entropy': 'phasMolEntr[1]' - # } - self.startDict = {} - self.eqnDict = {} - - - 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 modesList(self): - return ["PT","PH","PVF","TVF","PS"] - - 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') - - # self.OMVapProp = { - # 'Pressure': self.mode1, - # 'Temperature': self.mode2, - # 'Total Molar Flow': 'totMolFlo[3]', - # 'Total Mas Flow': 'totMasFlo[3]', - # 'Comp Mole Fraction': ['compMolFrac[3,1]','compMolFrac[3,2]','compMolFrac[3,3]'], - # 'Comp Mas Fraction': ['compMasFrac[3,1]','compMasFrac[3,2]','compMasFrac[3,3]'], - # 'Comp Molar Flow': ['compMolFlo[3,1]','compMolFlo[3,2]','compMolFlo[3,3]'], - # 'Comp Mas Flow': ['compMasFlo[3,1]','compMasFlo[3,2]','compMasFlo[3,3]'], - # 'Av. Molecular Weight': 'phasMolEnth[3]', - # 'Molar Specific Heat': 'phasMolSpHeat[3]', - # 'Molar Enthalpy': 'phasMolEnth[3]', - # 'Molar Entropy': 'phasMolEntr[3]'} - - - - # self.VapProp = { - # self.mode1:None, - # self.mode2:None, - # 'liqPhasMolFrac':None, - # 'liqPhasMasFrac':None, - # 'vapPhasMolFrac':None, - # 'vapPhasMasFrac':None, - # 'totMolFlo[3]':None, - # 'totMasFlo[3]':None, - # 'MW[1]':None, - # 'compMolFrac[3,1]':None, - # 'compMolFrac[3,2]':None, - # 'compMolFrac[3,3]':None, - # 'compMasFrac[3,1]':None, - # 'compMasFrac[3,2]':None, - # 'compMasFrac[3,3]'None, - # 'compMolFlo[3,1]':None, - # 'compMolFlo[3,2]':None, - # 'compMolFlo[3,3]':None, - # 'compMasFlo[3,1]':None, - # 'compMasFlo[3,2]':None, - # 'compMasFlo[3,3]':None, - # 'phasMolSpHeat[3]':None, - # 'phasMolEnth[3]':None, - # 'phasMolEntr[3]':None - # } - - - # self.OMLiqProp = { - # 'Pressure': self.mode1, - # 'Temperature': self.mode2, - # 'Total Molar Flow': 'totMolFlo[2]', - # 'Total Mas Flow': 'totMasFlo[2]', - # 'Comp Mole Fraction': ['compMolFrac[2,1]','compMolFrac[2,2]','compMolFrac[2,3]'], - # 'Comp Mas Fraction': ['compMasFrac[2,1]','compMasFrac[2,2]','compMasFrac[2,3]'], - # 'Comp Molar Flow': ['compMolFlo[2,1]','compMolFlo[2,2]','compMolFlo[2,3]'], - # 'Comp Mas Flow': ['compMasFlo[2,1]','compMasFlo[2,2]','compMasFlo[2,3]'], - # 'Av. Molecular Weight': 'MW[2]', - # 'Molar Specific Heat': 'phasMolSpHeat[2]', - # 'Molar Enthalpy': 'phasMolEnth[2]', - # 'Molar Entropy': 'phasMolEntr[2]'} - - - # self.LiqProp = { - # self.mode1:P, - # self.mode2:None, - # 'liqPhasMolFrac':None, - # 'liqPhasMasFrac':None, - # 'vapPhasMolFrac':None, - # 'vapPhasMasFrac':None, - # 'totMolFlo[2]':None, - # 'totMasFlo[2]':None, - # 'MW[1]':None, - # 'compMolFrac[2,1]':None, - # 'compMolFrac[2,2]':None, - # 'compMolFrac[2,3]':None, - # 'compMasFrac[2,1]':None, - # 'compMasFrac[2,2]':None, - # 'compMasFrac[2,3]'None, - # 'compMolFlo[2,1]':None, - # 'compMolFlo[2,2]':None, - # 'compMolFlo[2,3]':None, - # 'compMasFlo[2,1]':None, - # 'compMasFlo[2,2]':None, - # 'compMasFlo[2,3]':None, - # 'phasMolSpHeat[2]':None, - # 'phasMolEnth[2]':None, - # 'phasMolEntr[2]':None - # } - - 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 - - - # if self.P: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + '.P=' + str(self.P) + ';\n') - # if self.T: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + '.T=' + str(self.T) + ';\n') - # if self.VapPhasMolFrac: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + '.vapPhasMolFrac=' + str(self.VapPhasMolFrac) + ';\n') - - - # if self.CompMolFrac != []: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + ".compMolFrac[1,:] = {") - # mf = str(self.CompMolFrac).strip('[').strip(']') - # self.OM_data_eqn = self.OM_data_eqn + mf + ('};\n') - # if self.CompMasFrac != []: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + ".compMasFrac[1,:] = {") - # Mf = str(self.CompMasFrac).strip('[').strip(']') - # self.OM_data_eqn = self.OM_data_eqn + Mf + ('};\n') - - # if self.MolFlow: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + ".totMolFlo[1] = " + str(self.MolFlow) + ";\n") - # if self.MasFlow: - # self.OM_data_eqn = self.OM_data_eqn + (self.name + ".totMasFlo[1] = " + str(self.MasFlow) + ";\n") - - # return self.OM_data_eqn
\ No newline at end of file diff --git a/OMChem/Mixer.py b/OMChem/Mixer.py index 9419de1..c726cdc 100644 --- a/OMChem/Mixer.py +++ b/OMChem/Mixer.py @@ -1,28 +1,39 @@ class Mixer(): - def __init__(self,name='mixer',NOI=5,Pcal = 'Inlet_Average'): + counter = 1 # + def __init__(self,name='Mixer',NOI=5,Pcal = 'Inlet_Average'): self.NOI = NOI self.Pcal = Pcal - self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = [] self.OutputStms = None self.type = 'Mixer' + # new + self.name = name + str(Mixer.counter) + self.no_of_input = 4 + self.no_of_output = 1 + Mixer.counter += 1 + + def getname(self): + return self.name + def modesList(self): return [] def paramgetter(self,mode=None): dict = {} return dict + def paramsetter(self,dict): self.NOI = dict["NOI"] + def OM_Flowsheet_Init(self, addedcomp): self.OM_data_init = '' 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("'", "") @@ -35,7 +46,6 @@ class Mixer(): self.InputStms = InputStms self.OutputStms = OutputStms - def OM_Flowsheet_Eqn(self, addedcomp): self.OM_data_eqn = '' comp_count = len(addedcomp) @@ -46,4 +56,3 @@ class Mixer(): strcount += 1 self.OM_data_eqn = self.OM_data_eqn + ('connect(' + self.name + '.outlet,' + self.OutputStms[0].name + '.inlet);\n') return self.OM_data_eqn - diff --git a/OMChem/Pump.py b/OMChem/Pump.py index 04c8425..3b6ed2c 100644 --- a/OMChem/Pump.py +++ b/OMChem/Pump.py @@ -1,8 +1,9 @@ from OMChem.EngStm import EngStm class Pump(): + counter = 1 def __init__(self,name='Pump',eff = None): self.eff = eff - self.name = name + #self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None @@ -13,6 +14,14 @@ class Pump(): self.type = 'Pump' self.mode = None self.modeVal = None + # new + self.name = name + str(Pump.counter) + self.no_of_input = 1 + self.no_of_output = 1 + Pump.counter += 1 + + def getname(self): + return self.name def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms @@ -27,7 +36,6 @@ class Pump(): return dict def paramsetter(self,dict): - self.eff = dict['eff'] self.modeVal = dict[self.mode] @@ -36,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 13cffea..a018873 100644 --- a/OMChem/ShortcutColumn.py +++ b/OMChem/ShortcutColumn.py @@ -1,25 +1,37 @@ from OMChem.EngStm import EngStm class ShortcutColumn(): - def __init__(self,name=("ShortcutCol",1),condP = None, rebP = None, LKey = None, HKey = None): + counter = 1 + def __init__(self,name='ShortCol',condP = None, rebP = None, LKey = None, HKey = None): self.condP = condP self.rebP = rebP self.LKey = LKey self.HKey = HKey self.LKeyMolFrac = None self.HKeyMolFrac = None - self.name = name[0] + #self.name = name[0] + self.name = name + str(ShortcutColumn.counter) self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None self.OutputStms = None + self.EngStm1 = EngStm(name='EngStm1'+self.name) self.EngStm2 = EngStm(name='EngStm2'+self.name) - self.count = name[1] + #self.count = name[1] + self.count = ShortcutColumn.counter self.condType='' self.actR = None self.thermoPackage='Raoults_Law' self.type = 'ShortCol' + # new + self.no_of_input = 1 + self.no_of_output = 2 + ShortcutColumn.counter += 1 + + def getname(self): + return self.name + def modesList(self): return [] @@ -47,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 a055851..f873146 100644 --- a/OMChem/Splitter.py +++ b/OMChem/Splitter.py @@ -1,7 +1,8 @@ import json class Splitter(): - def __init__(self,name='splitter',NOO=5,calcType = 'Molar_Flow',specval = [50,50]): + counter = 1 + def __init__(self,name='Splitter',NOO=5,calcType = 'Molar_Flow',specval = [50,50]): self.NOO = NOO self.calcType = calcType self.name = name @@ -11,7 +12,15 @@ class Splitter(): self.OutputStms = [] self.type = 'Splitter' self.specval = json.dumps(specval).replace('[','{').replace(']','}') - + # new + self.name = name + str(Splitter.counter) + self.no_of_input = 1 + self.no_of_output = 4 + Splitter.counter += 1 + + def getname(self): + return self.name + def modesList(self): return [] def paramgetter(self,mode=None): @@ -24,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 f8f61b6..9e8494b 100644 --- a/OMChem/Valve.py +++ b/OMChem/Valve.py @@ -1,9 +1,10 @@ class Valve(): - def __init__(self,name='valve'): + counter = 1 + def __init__(self,name='Valve'): #self.PressDrop = PressureDrop self.mode = None self.modeVal = None - self.name = name + #self.name = name self.OM_data_eqn = '' self.OM_data_init = '' self.InputStms = None @@ -14,6 +15,14 @@ class Valve(): 'pressDrop':None, 'outP':None } + # new + self.name = name + str(Valve.counter) + self.no_of_input = 1 + self.no_of_output = 1 + Valve.counter += 1 + + def getname(self): + return self.name def modesList(self): return ["pressDrop","outP"] @@ -35,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/__pycache__/CompSep.cpython-36.pyc b/OMChem/__pycache__/CompSep.cpython-36.pyc Binary files differdeleted file mode 100644 index dc4410b..0000000 --- a/OMChem/__pycache__/CompSep.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Cooler.cpython-36.pyc b/OMChem/__pycache__/Cooler.cpython-36.pyc Binary files differdeleted file mode 100644 index be8d9fe..0000000 --- a/OMChem/__pycache__/Cooler.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/DistCol.cpython-36.pyc b/OMChem/__pycache__/DistCol.cpython-36.pyc Binary files differdeleted file mode 100644 index 518410e..0000000 --- a/OMChem/__pycache__/DistCol.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/EngStm.cpython-36.pyc b/OMChem/__pycache__/EngStm.cpython-36.pyc Binary files differdeleted file mode 100644 index 8799e46..0000000 --- a/OMChem/__pycache__/EngStm.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Flash.cpython-36.pyc b/OMChem/__pycache__/Flash.cpython-36.pyc Binary files differdeleted file mode 100644 index 3c55d7e..0000000 --- a/OMChem/__pycache__/Flash.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Flowsheet.cpython-36.pyc b/OMChem/__pycache__/Flowsheet.cpython-36.pyc Binary files differdeleted file mode 100644 index dd8f589..0000000 --- a/OMChem/__pycache__/Flowsheet.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Heater.cpython-36.pyc b/OMChem/__pycache__/Heater.cpython-36.pyc Binary files differdeleted file mode 100644 index 1139a24..0000000 --- a/OMChem/__pycache__/Heater.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/MatStm.cpython-36.pyc b/OMChem/__pycache__/MatStm.cpython-36.pyc Binary files differdeleted file mode 100644 index 9b5b187..0000000 --- a/OMChem/__pycache__/MatStm.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Mixer.cpython-36.pyc b/OMChem/__pycache__/Mixer.cpython-36.pyc Binary files differdeleted file mode 100644 index c75307b..0000000 --- a/OMChem/__pycache__/Mixer.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Pump.cpython-36.pyc b/OMChem/__pycache__/Pump.cpython-36.pyc Binary files differdeleted file mode 100644 index c351aba..0000000 --- a/OMChem/__pycache__/Pump.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/ShortcutColumn.cpython-36.pyc b/OMChem/__pycache__/ShortcutColumn.cpython-36.pyc Binary files differdeleted file mode 100644 index 1ea4727..0000000 --- a/OMChem/__pycache__/ShortcutColumn.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Splitter.cpython-36.pyc b/OMChem/__pycache__/Splitter.cpython-36.pyc Binary files differdeleted file mode 100644 index 2830093..0000000 --- a/OMChem/__pycache__/Splitter.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/Valve.cpython-36.pyc b/OMChem/__pycache__/Valve.cpython-36.pyc Binary files differdeleted file mode 100644 index aba6ad1..0000000 --- a/OMChem/__pycache__/Valve.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/adiabatic_comp.cpython-36.pyc b/OMChem/__pycache__/adiabatic_comp.cpython-36.pyc Binary files differdeleted file mode 100644 index c5e8b65..0000000 --- a/OMChem/__pycache__/adiabatic_comp.cpython-36.pyc +++ /dev/null diff --git a/OMChem/__pycache__/adiabatic_exp.cpython-36.pyc b/OMChem/__pycache__/adiabatic_exp.cpython-36.pyc Binary files differdeleted file mode 100644 index 1138bdc..0000000 --- a/OMChem/__pycache__/adiabatic_exp.cpython-36.pyc +++ /dev/null diff --git a/OMChem/adiabatic_comp.py b/OMChem/adiabatic_comp.py index b8849fd..d0a6b72 100644 --- a/OMChem/adiabatic_comp.py +++ b/OMChem/adiabatic_comp.py @@ -1,18 +1,29 @@ from OMChem.EngStm import EngStm -class AdiaComp(): - def __init__(self,name=('AdiaComp',1), eff = None): +class AdiabaticCompressor(): + counter = 1 + def __init__(self,name='AdiabaticCompressor', eff = None): self.eff = eff - self.name = name[0] + #self.name = name[0] + self.name = name + str(AdiabaticCompressor.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.type = 'AdiaComp' - self.thermoPackage ="Raoults_Law" + #self.count = name[1] + 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 + AdiabaticCompressor.counter += 1 + + def getname(self): + return self.name def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms @@ -39,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 102596d..2754f0a 100644 --- a/OMChem/adiabatic_exp.py +++ b/OMChem/adiabatic_exp.py @@ -1,19 +1,30 @@ from OMChem.EngStm import EngStm -class AdiaExp(): - def __init__(self,name=('AdiaExp',1), eff = None): +class AdiabaticExpander(): + counter = 1 + def __init__(self,name='AdiabaticExpander', eff = None): self.eff = eff - self.name = name[0] + #self.name = name[0] + 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.type = 'AdiaExp' - self.thermoPackage ="Raoults_Law" + #self.count = name[1] + 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 + AdiabaticExpander.counter += 1 + + def getname(self): + return self.name + def connect(self,InputStms = None,OutputStms = None): self.InputStms = InputStms self.OutputStms = OutputStms @@ -39,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("'", "") |