-
Notifications
You must be signed in to change notification settings - Fork 230
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
Allow RMG to handle a specific species as a third body collider #1084
Conversation
This specificCollider PR currently fails on the new testSpecificColliderModel test. |
I don't have time to look properly at this this week, but I did have a question about your second example above:
What is this meant to represent? If it's just r˲ = k[HNCN][N₂] then wouldn't Perhaps you could say how it would look in CHEMKIN syntax? Or how would you describe the kinetics? |
I agree, there's no advantage in writing a reaction with a specificCollider in a ThirdBody format, i.e.:
and it's indeed much simpler (and recommended?) to write it as a normal Arrhenius, as pointed out by @rwest. However, if a user happens to use the ThirdBody kinetics format for a library reaction with a specific collider, we would like RMG to handle that correctly. Before this fix, the reaction in the example above would have the following wrong Chemkin representation (with two colliders):
But now RMG will pick that up, add a comment that a specificCollider was identified, and output the kinetics as if a normal Arrhenius kinetics reaction was inputted:
|
a4585f7
to
61e84bb
Compare
Added kinetics documentation. Also addresses RMG-database#191 |
Couldn't figure out how to add relative references to the Classes in modification.rst pointing outside the |
If the sole aim is to protect against user error, I would suggest stopping with a helpful error message, rather than trying to guess what they intended. If they made a mistake, then we may guess incorrectly. (Also, rather unlikely, but if someone actually did want to input "H + O2 + CO2 +M <=> O + OH + CO2 +M" or "A + CO2 + M <=> B + CO2 + M" there would be no way to do so in the new format?) |
@rwest: Will do. Thanks for that. |
I see that Chebyshev also gets a (+M), meaning a specificCollider should be allowed there as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look mostly good! Just a few small details.
rmgpy/reaction.py
Outdated
""" | ||
arrow = ' <=> ' | ||
if not self.reversible: arrow = ' => ' | ||
return arrow.join([' + '.join([str(s) for s in self.reactants]), ' + '.join([str(s) for s in self.products])]) | ||
if self.specificCollider: | ||
return arrow.join([' + '.join([str(s) for s in self.reactants])+' '+str(self.specificCollider), ' + '.join([str(s) for s in self.products])+' '+str(self.specificCollider)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the parentheses around the specificCollider be added here?
rmgpy/data/kinetics/library.py
Outdated
collider = re.search('\(\+[^\)]+\)',reactants) | ||
if collider is not None: | ||
collider = collider.group(0) # save string value rather than the object | ||
assert collider == re.search('\(\+[^\)]+\)',products).group(0), "Third body colliders in reaction {0} in kinetics library {1} are not identical!".format(rxn_string, self.label) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to changes this to "missing from products or are not identical"?
@@ -29,7 +29,7 @@ | |||
################################################################################ | |||
|
|||
""" | |||
This module contains functionality for working with kinetics libraries. | |||
This module contains functionality for working with kinetics families. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you squish this one with the one before?
rmgpy/solver/simple.pyx
Outdated
|
||
""" | ||
specificColliderSpecies: | ||
a list that contains Species classes of species which are specific third body colliders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this makes sense in general, but it reads kind of strangely to me can you change "Species classes of" to "object references to"?
rmgpy/solver/simple.pyx
Outdated
j = self.reactionIndex[rxn] | ||
pdepSpecificColliderReactionIndices.append(j) | ||
self.pdepSpecificColliderKinetics.append(rxn.kinetics) | ||
for spc in itertools.chain(coreSpecies, edgeSpecies): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you just use:
self.specificColliderSpecies.append(rxn.specificCollider)
instead of this loop structure? Is there something missing in the rxn.specificCollider object? Can you add a comment about this?
rmgpy/reaction.py
Outdated
else: | ||
logging.debug('did not modify A factor when modifying degeneracy since ' \ | ||
'the reaction rate was not set') | ||
#else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're not going to let it print the error message I think we might as well delete these lines and clean up the code.
|
||
**MultiArrhenius** | ||
(see `MultiArrhenius Class <http://reactionmechanismgenerator.github.io/RMG-Py/reference/kinetics/multiarrhenius.html>`_ for details):: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you specify that MultiArrhenius is the sum of multiple Arrhenius expressions (as opposed to being one Arrhenius over one Trange and one Arrhenius over another Trange)
kunits='cm^3/(mol*s)', Tmin=(300, 'K'), Tmax=(3000, 'K'), Pmin=(0.0013156, 'atm'), Pmax=(131.56, 'atm'))) | ||
|
||
|
||
The ``Troe``, ``Lindemann``, and ``Chebyshev`` pressure dependent formats could also be defined with a specific collider if needed, for example:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a title so this doesn't get passed over as part of the Chebyshev section?
I don't know how chemkin would interpret Now that we parse things like At the moment the chemkin reactions Perhaps not for this pull request, but might be worth thinking about. |
While Chemkin's pre-processor failed on a PLOG reaction with a specific collider:
it did allow it in a CHEB reaction (also, RMG outputs CHEB with The current state of this branch is to allow a specific collider only for reactions that get a The Chebyshev case is indeed strange. Generally, if a specific collider is present, RMG calculates the rate at the partial pressure of the collider species alone. For Chebyshev this could be a problem if it isn't defined for this specific (low) pressure. I tried running a CHEB format with a specific collider again in Chemkin, this time using a minor species (not Ar). Chemkin failed right away since the intermediate species' concentration was 0 in the beginning of the simulation. I think we shouldn't allow specific colliders in Chebyshev, although using one of the bath gases as a specific collider could make some sense. |
Thanks @mjohnson541! |
BTW, what's up with Travis lately? |
specificCollider is a Species, unlike reactants and products which are lists of Species
A specificCollider species could appear in one of the folowing forms: 'A + B (+S) = C + D (+S)`, or `A + B + S = C + D + S`, depending on the kenetics type of the PDep reaction. RMG first finds a (+S) type specificCollider, then also looks for a species that appears both in the reactants and products (regardless of order). If found, verify that this is the only scpecificCollider (as we currently only support one specificCollider per reaction), and remove it from the reactants and products lists. It is saved as a specificCollider attribute of the Reaction.
Generalizes reading the third body collider whether it is (+M), (+m) or a specific species, i.e., (+N2). Gives RMG the ability to read the collider even if the species name has paranthesis, e.g., N2(5) or CH2(T)(15). This is still not implemented in Chemkin and Cantera, but both have open issues to implement it in the future. Also adds a comment to verbose Chemkin file that a specific third body collider was identified.
Test that a Chemkin reaction with a specific species as a third body collider can be properly read, even if the species name contains parenthesis such as (+CH(T))
- family.py: Added the attribute, though currently not fully tested in families. - pdep.py - LibraryReaction in database.py - depository.py
- Tests that a specific collider is correctly handeled by the solver - Also tests that RMG can reac a specific collider with parenthesis in its name
Other than adding - pdepSpecificColliderKinetics - specificColliderSpecies - pdepSpecificColliderReactionIndices The main change is in the Peff calculation
Due to the numerous calls to __setDegeneracy(), this debug message appears repeatedly while debuging (or running tests with -d). In fact, it could get printed so many times that it fills the CMD stack.
- a detailed list of all available libraries and their description - examples of all libraries kinetic formats - a note regarding the implementation of a specificCollider
Previously RMG could not handle reactions of the sort
A + B (+C) = D (+C)
. Moreover, reactions likeH2 + Ar <=> H + H + Ar
were only handled correctly if the kinetics is of Arrhenius type (like in the BurkeH2O2 libraries), but if the kinetics is in any PDep form, RMG would consider it asH2 + Ar (+M) <=> H + H + Ar (+M)
, wrongly accounting for an additional third body.Usage
Simple add a specific third body collider to your library reaction as you would intuitively (i.e., no need for a SpecificCollider keyword).
For example (and this rxn is the motivation for this PR):
Another example w/o parenthesis, which RMG should also handle correctly now, is:
Currently we only allow one specific collider per reaction (As far as I can see, I don't think more than one would be necessary, and probably also isn't implemented in Chemkin/Cantera, although I haven't checked). E.g.,
A + B (+N2) (+Ar) <=> C (+N2) (+Ar)
isn't valid in RMG, and will throw an appropriate error.The implementation of this feature in the solver (simple.pyx) is through the Peff calculation.
Two tests were added:
Lastly, this PR also allows RMG to consider specificColliders species with parenthesis in their name such as
N2(4)
orCH2(S)
orCH2(S)(15)
, as was recently fixed in Cantera and will be added to the next Chemkin release.Addresses #1070