Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reaction Mechanism Simulator YAML File Generation #1629

Merged
merged 3 commits into from
Jun 24, 2019
Merged

Conversation

mjohnson541
Copy link
Contributor

Adds generation of .rms YAML files for use in ReactionMechanismSimulator.

@codecov
Copy link

codecov bot commented Jun 17, 2019

Codecov Report

Merging #1629 into master will decrease coverage by 0.1%.
The diff coverage is 16.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1629      +/-   ##
==========================================
- Coverage   41.47%   41.37%   -0.11%     
==========================================
  Files         176      177       +1     
  Lines       29314    29455     +141     
  Branches     6035     6059      +24     
==========================================
+ Hits        12158    12186      +28     
- Misses      16303    16417     +114     
+ Partials      853      852       -1
Impacted Files Coverage Δ
rmgpy/yml.py 15.82% <15.82%> (ø)
rmgpy/rmg/main.py 23.11% <50%> (+0.04%) ⬆️
rmgpy/data/kinetics/family.py 52.9% <0%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2adfbb5...256832a. Read the comment docs.

rmgpy/yml.py Outdated
from rmgpy.kinetics.arrhenius import *
from rmgpy.kinetics.falloff import *
from rmgpy.kinetics.chebyshev import *
from rmgpy.data.solvation import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace all of the * imports with explicit ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rmgpy/yml.py Outdated
from rmgpy.data.solvation import *
from rmgpy.util import makeOutputSubdirectory

def convertchemkin2yml(chemkinpath,spcdictpath=None,output="chem.rms"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add spaces to after all commas in this file, in accordance with PEP-8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rmgpy/yml.py Outdated
return D

def getradicals(spc):
if spc.molecule[0].toSMILES() == "[O][O]":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this function? Can you not use Molecule.getRadicalCount?

Also, why does oxygen need to be special cased? Could you add a comment explaining?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is faster since the multiplicities are known.

This is typically used for analyzing radical production in RMS and it's very useful to treat O2 as a stable molecule when you're looking at bulk radical production/loss

rmgpy/yml.py Outdated
elif obj is None:
return None
else:
raise ValueError
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a message to this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rmgpy/yml.py Outdated
D["kinetics"] = obj2dict(obj.kinetics,spcs)
D["type"] = "ElementaryReaction"
D["radicalchange"] = sum([getradicals(x) for x in obj.products]) - sum([getradicals(x) for x in obj.reactants])
elif isinstance(obj,Arrhenius):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is support for the surface kinetics types necessary? I assume not now, since RMG doesn't have surface reactors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added them in, RMS can read the catalysis output files properly yet, but it will be able to in the future.

Copy link
Member

@amarkpayne amarkpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few quick comments that need addressing, but other than that this looks just about ready to go. The rmgpy/yml.py file was missing a header though, so I have pushed a commit with this fix along with some other small style fixes.


def getMechDict(spcs, rxns, solvent='solvent', solventData=None):
D = dict()
D["Units"] = dict()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ["Units"] ever get updated anywhere else in the code? Does the YAML format for RMS/Cantera assume that an empty dictionary for units defaults to something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It defaults to SI units for everything, unless units are specified for individual floats

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works then

rmgpy/yml.py Outdated
def getMechDict(spcs, rxns, solvent='solvent', solventData=None):
D = dict()
D["Units"] = dict()
D["Reactions"] = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not needed right? Further down you have D["Reactions"] = [obj2dict(x, spcs) for x in rxns], which will overwrite this line and also return an empty list if there are no reactions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rmgpy/yml.py Outdated
D["type"] = "Species"
D["smiles"] = obj.molecule[0].toSMILES()
D["thermo"] = obj2dict(obj.thermo, spcs)
if D["smiles"] == "[O][O]":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You defined the getradicals function above, so use this to get rid of the if-else statement here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mjohnson541
Copy link
Contributor Author

Should be ready to merge now

@amarkpayne
Copy link
Member

I agree, feel free to merge this as soon as the tests pass (assuming they do).

@mjohnson541 mjohnson541 merged commit 93fac25 into master Jun 24, 2019
@mjohnson541 mjohnson541 deleted the rmsyaml branch June 24, 2019 14:22
@mliu49 mliu49 mentioned this pull request Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants