Skip to content

Commit

Permalink
include solvent information in the .rms file
Browse files Browse the repository at this point in the history
  • Loading branch information
mjohnson541 committed Jun 17, 2019
1 parent e77f98b commit c71800e
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions rmgpy/yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ def convertchemkin2yml(chemkinpath,spcdictpath=None,output="chem.rms"):
spcs,rxns = loadChemkinFile(chemkinpath)
writeyml(spcs,rxns,path=output)

def writeyml(spcs,rxns,path="chem.yml"):
D = getmechdict(spcs,rxns)
def writeyml(spcs,rxns,solvent=None,solventData=None,path="chem.yml"):
D = getmechdict(spcs,rxns,solvent=solvent,solventData=solventData)
yaml.dump(D,stream=file(path,'w'))

def getmechdict(spcs,rxns):
def getmechdict(spcs,rxns,solvent='solvent',solventData=None):
D = dict()
D["Units"] = dict()
D["Reactions"] = []
D["Phases"] = [dict()]
D["Phases"][0]["name"] = "phase"
D["Phases"][0]["Species"] = [obj2dict(x,spcs) for x in spcs]
D["Reactions"] = [obj2dict(x,spcs) for x in rxns]
if solventData:
D["Solvents"]= [obj2dict(solventData,spcs,label=solvent)]
return D

def getradicals(spc):
Expand Down Expand Up @@ -119,11 +121,11 @@ def obj2dict(obj,spcs,label="solvent"):
D["name"] = label
dsub = dict()
dsub["type"] = "RiedelViscosity"
dsub["A"] = obj.A.value_si
dsub["B"] = obj.B.value_si
dsub["C"] = obj.C.value_si
dsub["D"] = obj.D.value_si
dsub["E"] = obj.E.value_si
dsub["A"] = float(obj.A)
dsub["B"] = float(obj.B)
dsub["C"] = float(obj.C)
dsub["D"] = float(obj.D)
dsub["E"] = float(obj.E)
D["mu"] = dsub
elif obj is None:
return None
Expand Down Expand Up @@ -159,4 +161,8 @@ def __init__(self, outputDirectory=''):
makeOutputSubdirectory(outputDirectory, 'rms')

def update(self, rmg):
writeyml(rmg.reactionModel.core.species,rmg.reactionModel.core.reactions,os.path.join(self.outputDirectory,'rms','chem{}.rms').format(len(rmg.reactionModel.core.species)))
solventData = None
if rmg.solvent:
solventData = rmg.database.solvation.getSolventData(rmg.solvent)
writeyml(rmg.reactionModel.core.species,rmg.reactionModel.core.reactions,solvent=rmg.solvent,solventData=solventData,
path=os.path.join(self.outputDirectory,'rms','chem{}.rms').format(len(rmg.reactionModel.core.species)))

0 comments on commit c71800e

Please sign in to comment.