Skip to content

Commit a4903a2

Browse files
authored
Merge branch 'main' into improve_auto_cut
2 parents 181742c + 36bceb3 commit a4903a2

7 files changed

Lines changed: 41 additions & 14 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#
55
################################################################################
66

7+
CC=gcc
8+
CXX=g++
9+
710
.PHONY : all minimal main solver check pycheck arkane clean install decython documentation test q2dtor
811

912
all: pycheck main solver check

documentation/source/users/rmg/input.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ by Benson's method.
4949

5050
For example, if you wish to use the GRI-Mech 3.0 mechanism [GRIMech3.0]_ as a ThermoLibrary in your model, the syntax will be::
5151

52-
thermoLibraries = ['primaryThermoLibrary','GRI-Mech3.0']
52+
thermoLibraries = ['primaryThermoLibrary', 'GRI-Mech3.0']
5353

5454
.. [GRIMech3.0] Gregory P. Smith, David M. Golden, Michael Frenklach, Nigel W. Moriarty, Boris Eiteneer, Mikhail Goldenberg, C. Thomas Bowman, Ronald K. Hanson, Soonho Song, William C. Gardiner, Jr., Vitali V. Lissianski, and Zhiwei Qin http://combustion.berkeley.edu/gri-mech/
5555
@@ -78,7 +78,7 @@ In the following example, the user has created
7878
a reaction library with a few additional reactions specific to n-butane, and these reactions
7979
are to be used in addition to the Glarborg C3 library::
8080

81-
reactionLibraries = [('Glarborg/C3',False)],
81+
reactionLibraries = [('Glarborg/C3', False)],
8282

8383
The keyword False/True permits user to append all unused reactions (= kept in the edge) from this library to the chemkin file.
8484
True means those reactions will be appended. Using just the string inputs would lead to
@@ -104,6 +104,23 @@ given in each mechanism, the different mechanisms can have different units.
104104
Library.
105105

106106

107+
.. _externallib:
108+
109+
External Libraries
110+
------------------
111+
Users may direct RMG to use thermo and/or kinetic libraries which are not included in the RMG database,
112+
e.g., a library a user created that was intentionally saved to a path different than the conventional
113+
RMG-database location. In such cases, the user can specify the full path to the library in the input file::
114+
115+
thermoLibraries = ['path/to/your/thermo/library/file.py']
116+
117+
or::
118+
119+
reactionLibraries = [(path/to/your/kinetic/library/folder/']
120+
121+
Combinations in any order of RMG's legacy libraries and users' external libraries are allowed,
122+
and the order in which the libraries are specified is the order in which they are loaded and given priority.
123+
107124
.. _seedmechanism:
108125

109126
Seed Mechanisms

environment.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ dependencies:
8181
- conda-forge::gprof2dot
8282
- conda-forge::numdifftools
8383
- conda-forge::quantities
84+
- conda-forge::muq
85+
- conda-forge::lpsolve55
86+
- conda-forge::ringdecomposerlib-python
8487

8588
# packages we maintain
86-
- rmg::lpsolve55
87-
- rmg::muq2
8889
- rmg::pydas >=1.0.3
8990
- rmg::pydqed >=1.0.3
90-
- rmg::pyrdl
9191
- rmg::pyrms
9292
- rmg::symmetry
9393

rmgpy/data/kinetics/database.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(self):
6262
self.recommended_families = {}
6363
self.families = {}
6464
self.libraries = {}
65+
self.external_library_labels = {}
6566
self.library_order = [] # a list of tuples in the format ('library_label', LibraryType),
6667
# where LibraryType is set to either 'Reaction Library' or 'Seed'.
6768
self.local_context = {
@@ -227,17 +228,18 @@ def load_libraries(self, path, libraries=None):
227228
The `path` points to the folder of kinetics libraries in the database,
228229
and the libraries should be in files like :file:`<path>/<library>.py`.
229230
"""
230-
231+
self.external_library_labels = dict()
231232
if libraries is not None:
232233
for library_name in libraries:
233234
library_file = os.path.join(path, library_name, 'reactions.py')
234235
if os.path.exists(library_name):
235236
library_file = os.path.join(library_name, 'reactions.py')
236-
short_library_name = os.path.split(library_name)[-1]
237+
short_library_name = os.path.basename(library_name.rstrip(os.path.sep))
237238
logging.info(f'Loading kinetics library {short_library_name} from {library_name}...')
238239
library = KineticsLibrary(label=short_library_name)
239240
library.load(library_file, self.local_context, self.global_context)
240241
self.libraries[library.label] = library
242+
self.external_library_labels[library_name] = library.label
241243
elif os.path.exists(library_file):
242244
logging.info(f'Loading kinetics library {library_name} from {library_file}...')
243245
library = KineticsLibrary(label=library_name)

rmgpy/reaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,15 +1030,15 @@ def generate_reverse_rate_coefficient(self, network_kinetics=False, Tmin=None, T
10301030
return self.reverse_arrhenius_rate(kf, kunits)
10311031

10321032
elif isinstance(kf, Chebyshev):
1033-
Tlist = 1.0 / np.linspace(1.0 / kf.Tmax.value, 1.0 / kf.Tmin.value, 50)
1034-
Plist = np.linspace(kf.Pmin.value, kf.Pmax.value, 20)
1033+
Tlist = 1.0 / np.linspace(1.0 / kf.Tmax.value_si, 1.0 / kf.Tmin.value_si, 50)
1034+
Plist = np.linspace(kf.Pmin.value_si, kf.Pmax.value_si, 20)
10351035
K = np.zeros((len(Tlist), len(Plist)), float)
10361036
for Tindex, T in enumerate(Tlist):
10371037
for Pindex, P in enumerate(Plist):
10381038
K[Tindex, Pindex] = kf.get_rate_coefficient(T, P) / self.get_equilibrium_constant(T)
10391039
kr = Chebyshev()
1040-
kr.fit_to_data(Tlist, Plist, K, kunits, kf.degreeT, kf.degreeP, kf.Tmin.value, kf.Tmax.value, kf.Pmin.value,
1041-
kf.Pmax.value)
1040+
kr.fit_to_data(Tlist, Plist, K, kunits, kf.degreeT, kf.degreeP, kf.Tmin.value, kf.Tmax.value,
1041+
kf.Pmin.value_si, kf.Pmax.value_si)
10421042
return kr
10431043

10441044
elif isinstance(kf, PDepArrhenius):

rmgpy/rmg/model.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,12 @@ def add_reaction_library_to_edge(self, reaction_library):
17221722
num_old_edge_reactions = len(self.edge.reactions)
17231723

17241724
logging.info("Adding reaction library {0} to model edge...".format(reaction_library))
1725-
reaction_library = database.kinetics.libraries[reaction_library]
1725+
if reaction_library in database.kinetics.libraries:
1726+
reaction_library = database.kinetics.libraries[reaction_library]
1727+
elif reaction_library in database.kinetics.external_library_labels:
1728+
reaction_library = database.kinetics.libraries[database.kinetics.external_library_labels[reaction_library]]
1729+
else:
1730+
raise ValueError(f'Library {reaction_library} not found.')
17261731

17271732
rxns = reaction_library.get_library_reactions()
17281733
for rxn in rxns:

test/rmgpy/data/transportTest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ def test_joback(self):
151151
[
152152
"acetone",
153153
"CC(=O)C",
154-
Length(5.36421, "angstroms"),
154+
Length(5.32979, "angstroms"),
155155
Energy(3.20446, "kJ/mol"),
156-
"Epsilon & sigma estimated with Tc=500.53 K, Pc=47.11 bar (from Joback method)",
156+
"Epsilon & sigma estimated with Tc=500.53 K, Pc=48.02 bar (from Joback method)",
157157
],
158158
[
159159
"cyclopenta-1,2-diene",

0 commit comments

Comments
 (0)