Skip to content

Commit 5d66e8d

Browse files
committed
Merge branch 'main' of https://github.com/ReactionMechanismGenerator/RMG-Py into wsl_docs_addition
2 parents 4a746b7 + 0419c44 commit 5d66e8d

6 files changed

Lines changed: 21 additions & 47 deletions

File tree

documentation/source/reference/data/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Class Description
5050
=========================== ====================================================
5151
:class:`DepositoryReaction` A reaction with kinetics determined from querying a kinetics depository
5252
:class:`LibraryReaction` A reaction with kinetics determined from querying a kinetics library
53-
:class:`TemplateReaction` A reaction with kinetics determined from querying a kinetics group additivity or rate rules method
53+
:class:`TemplateReaction` A reaction with kinetics determined from querying a rate rules method
5454
:class:`ReactionRecipe` A sequence of actions that represent the process of a chemical reaction
5555
--------------------------- ----------------------------------------------------
5656
:class:`KineticsDepository` A depository of all kinetics parameters for one or more reactions

documentation/source/users/rmg/kinetics.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ parameters
4040
+-------+--------------------------------------------------------------------------------------+
4141
|Rank 8 |B3LYP & lower DFT (rotors if necessary) |
4242
+-------+--------------------------------------------------------------------------------------+
43-
|Rank 9 |Group Additivity |
43+
|Rank 9 |Direct Estimate/Guess |
4444
+-------+--------------------------------------------------------------------------------------+
45-
|Rank 10|Direct Estimate/Guess |
46-
+-------+--------------------------------------------------------------------------------------+
47-
|Rank 11|Average of Rates |
45+
|Rank 10|Average of Rates |
4846
+-------+--------------------------------------------------------------------------------------+
4947
|Rank 0 |General Estimate (Never used in generation) |
5048
+-------+--------------------------------------------------------------------------------------+

rmgpy/data/kinetics/family.py

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TemplateReaction(Reaction):
7777
Attribute Type Description
7878
=============== ========================= =====================================
7979
`family` ``str`` The kinetics family that the reaction was created from.
80-
`estimator` ``str`` Whether the kinetics came from rate rules or group additivity.
80+
`estimator` ``str`` The name of the kinetic estimator; currently only rate rules is supported.
8181
`reverse` :class:`TemplateReaction` The reverse reaction, for families that are their own reverse.
8282
`is_forward` ``bool`` Whether the reaction was generated in the forward direction of the family.
8383
`labeled_atoms` ``dict`` Keys are 'reactants' or 'products', values are dictionaries.
@@ -2396,23 +2396,20 @@ def get_reaction_template(self, reaction):
23962396
def get_kinetics_for_template(self, template, degeneracy=1, method='rate rules'):
23972397
"""
23982398
Return an estimate of the kinetics for a reaction with the given
2399-
`template` and reaction-path `degeneracy`. There are two possible methods
2400-
to use: 'group additivity' (new possible RMG-Py behavior) and 'rate rules' (old
2401-
RMG-Java behavior, and default RMG-Py behavior).
2399+
`template` and reaction-path `degeneracy`. There is currently only one method to use:
2400+
'rate rules' (old RMG-Java behavior, and default RMG-Py behavior). Group additivity was removed in August 2023.
24022401
24032402
Returns a tuple (kinetics, entry):
24042403
If it's estimated via 'rate rules' and an exact match is found in the tree,
24052404
then the entry is returned as the second element of the tuple.
2406-
But if an average is used, or the 'group additivity' method, then the tuple
2407-
returned is (kinetics, None).
2405+
But if an average is used, then the tuple returned is (kinetics, None).
2406+
24082407
"""
2409-
if method.lower() == 'group additivity':
2410-
return self.estimate_kinetics_using_group_additivity(template, degeneracy), None
2411-
elif method.lower() == 'rate rules':
2408+
if method.lower() == 'rate rules':
24122409
return self.estimate_kinetics_using_rate_rules(template, degeneracy) # This returns kinetics and entry data
24132410
else:
24142411
raise ValueError('Invalid value "{0}" for method parameter; '
2415-
'should be "group additivity" or "rate rules".'.format(method))
2412+
'currently only "rate rules" is supported.'.format(method))
24162413

24172414
def get_kinetics_from_depository(self, depository, reaction, template, degeneracy):
24182415
"""
@@ -2458,8 +2455,8 @@ def _select_best_kinetics(self, kinetics_list):
24582455
def get_kinetics(self, reaction, template_labels, degeneracy=1, estimator='', return_all_kinetics=True):
24592456
"""
24602457
Return the kinetics for the given `reaction` by searching the various
2461-
depositories as well as generating a result using the user-specified `estimator`
2462-
of either 'group additivity' or 'rate rules'. Unlike
2458+
depositories as well as generating a result using the user-specified `estimator`.
2459+
Currently, only 'rate rules' is a supported estimator. Unlike
24632460
the regular :meth:`get_kinetics()` method, this returns a list of
24642461
results, with each result comprising of
24652462
@@ -2468,7 +2465,7 @@ def get_kinetics(self, reaction, template_labels, degeneracy=1, estimator='', re
24682465
3. the entry - this will be `None` if from a template estimate
24692466
4. is_forward a boolean denoting whether the matched entry is in the same
24702467
direction as the inputted reaction. This will always be True if using
2471-
rates rules or group additivity. This can be `True` or `False` if using
2468+
rates rules. This can be `True` or `False` if using
24722469
a depository
24732470
24742471
If return_all_kinetics==False, only the first (best?) matching kinetics is returned.
@@ -2489,7 +2486,9 @@ def get_kinetics(self, reaction, template_labels, degeneracy=1, estimator='', re
24892486
for kinetics, entry, is_forward in kinetics_list0:
24902487
kinetics_list.append([kinetics, depository, entry, is_forward])
24912488

2492-
# If estimator type of rate rules or group additivity is given, retrieve the kinetics.
2489+
# If estimator type of rate rules is given, retrieve the kinetics.
2490+
# TODO: Since group additivity was removed, this logic can be condensed into just 1 branch.
2491+
24932492
if estimator:
24942493
try:
24952494
kinetics, entry = self.get_kinetics_for_template(template, degeneracy, method=estimator)
@@ -2502,7 +2501,6 @@ def get_kinetics(self, reaction, template_labels, degeneracy=1, estimator='', re
25022501
return kinetics, estimator, entry, True
25032502
kinetics_list.append([kinetics, estimator, entry, True])
25042503
# If no estimation method was given, prioritize rate rule estimation.
2505-
# If returning all kinetics, add estimations from both rate rules and group additivity.
25062504
else:
25072505
try:
25082506
kinetics, entry = self.get_kinetics_for_template(template, degeneracy, method='rate rules')
@@ -2513,15 +2511,6 @@ def get_kinetics(self, reaction, template_labels, degeneracy=1, estimator='', re
25132511
# If kinetics were undeterminable for rate rules estimation, do nothing.
25142512
pass
25152513

2516-
try:
2517-
kinetics2, entry2 = self.get_kinetics_for_template(template, degeneracy, method='group additivity')
2518-
if not return_all_kinetics:
2519-
return kinetics2, 'group additivity', entry2, True
2520-
kinetics_list.append([kinetics2, 'group additivity', entry2, True])
2521-
except KineticsError:
2522-
# If kinetics were undeterminable for group additivity estimation, do nothing.
2523-
pass
2524-
25252514
if not return_all_kinetics:
25262515
raise UndeterminableKineticsError(reaction)
25272516

@@ -3599,8 +3588,6 @@ def cross_validate_old(self, folds=5, T=1000.0, random_state=1, estimator='rate
35993588
template = self.retrieve_template(template_labels)
36003589
if estimator == 'rate rules':
36013590
kinetics, entry = self.estimate_kinetics_using_rate_rules(template, degeneracy=1)
3602-
elif estimator == 'group additivity':
3603-
kinetics = self.estimate_kinetics_using_group_additivity(template, degeneracy=1)
36043591
else:
36053592
raise ValueError('{0} is not a valid value for input `estimator`'.format(estimator))
36063593

rmgpy/rmg/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
from rmgpy.kinetics.diffusionLimited import diffusion_limiter
6666
from rmgpy.data.vaporLiquidMassTransfer import vapor_liquid_mass_transfer
6767
from rmgpy.kinetics import ThirdBody
68+
from rmgpy.kinetics import Troe
6869
from rmgpy.molecule import Molecule
6970
from rmgpy.qm.main import QMDatabaseWriter
7071
from rmgpy.reaction import Reaction
@@ -112,7 +113,7 @@ class RMG(util.Subject):
112113
`seed_mechanisms` The seed mechanisms included in the model
113114
`kinetics_families` The kinetics families to use for reaction generation
114115
`kinetics_depositories` The kinetics depositories to use for looking up kinetics in each family
115-
`kinetics_estimator` The method to use to estimate kinetics: 'group additivity' or 'rate rules'
116+
`kinetics_estimator` The method to use to estimate kinetics: currently, only 'rate rules' is supported
116117
`solvent` If solvation estimates are required, the name of the solvent.
117118
`liquid_volumetric_mass_transfer_coefficient_power_law` If kLA estimates are required, the coefficients for kLA power law
118119
---------------------------------------------------------- ------------------------------------------------
@@ -183,7 +184,7 @@ def clear(self):
183184
self.seed_mechanisms = None
184185
self.kinetics_families = None
185186
self.kinetics_depositories = None
186-
self.kinetics_estimator = "group additivity"
187+
self.kinetics_estimator = "rate rules"
187188
self.solvent = None
188189
self.diffusion_limiter = None
189190
self.surface_site_density = None
@@ -1451,7 +1452,7 @@ def check_model(self):
14511452
" rate at the relevant conditions\n\n"
14521453
)
14531454
for violator in violators:
1454-
if isinstance(violator[0].kinetics, ThirdBody):
1455+
if isinstance(violator[0].kinetics, (ThirdBody,Troe)):
14551456
rxn_string = violator[0].to_chemkin(self.reaction_model.core.species)
14561457
else:
14571458
rxn_string = violator[0].to_chemkin()

rmgpy/rmg/model.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -996,18 +996,6 @@ def generate_kinetics(self, reaction):
996996
# Use the one for which the kinetics is the forward kinetics
997997
keep_reverse = gibbs_is_positive and is_forward and rev_is_forward
998998
reason = "Both directions matched the same entry in {0}, but this direction is exergonic.".format(reaction.family)
999-
elif self.kinetics_estimator == "group additivity" and (
1000-
kinetics.comment.find("Fitted to 1 rate") > 0 and not rev_kinetics.comment.find("Fitted to 1 rate") > 0
1001-
):
1002-
# forward kinetics were fitted to only 1 rate, but reverse are hopefully better
1003-
keep_reverse = True
1004-
reason = "Other direction matched a group only fitted to 1 rate."
1005-
elif self.kinetics_estimator == "group additivity" and (
1006-
not kinetics.comment.find("Fitted to 1 rate") > 0 and rev_kinetics.comment.find("Fitted to 1 rate") > 0
1007-
):
1008-
# reverse kinetics were fitted to only 1 rate, but forward are hopefully better
1009-
keep_reverse = False
1010-
reason = "Other direction matched a group only fitted to 1 rate."
1011999
elif entry is not None and rev_entry is not None:
10121000
# Both directions matched explicit rate rules
10131001
# Keep the direction with the lower (but nonzero) rank

rmgpy/solver/base.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ if DASPK == 1:
4848
from pydas.daspk import DASPKError as DASxError
4949
else:
5050
from pydas.dassl cimport DASSL as DASx
51-
from pydas.daspk import DASSLError as DASxError
51+
from pydas.dassl import DASSLError as DASxError
5252

5353
import rmgpy.constants as constants
5454
cimport rmgpy.constants as constants

0 commit comments

Comments
 (0)