Skip to content

Commit 558e48e

Browse files
committed
cantera 3 updates
1 parent 6d03db1 commit 558e48e

File tree

6 files changed

+53
-55
lines changed

6 files changed

+53
-55
lines changed

environment.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
name: rmg_env
2626
channels:
2727
- conda-forge
28-
- cantera
2928
- rmg
3029
dependencies:
3130
# System-level dependencies - we could install these at the OS level
@@ -46,7 +45,7 @@ dependencies:
4645

4746
# external software tools for chemistry
4847
- conda-forge::coolprop
49-
- cantera::cantera =2.6
48+
- conda-forge::cantera >= 3
5049
- conda-forge::mopac
5150
# see https://github.com/ReactionMechanismGenerator/RMG-Py/pull/2639#issuecomment-2050292972
5251
- conda-forge::cclib >=1.6.3,<1.9
@@ -59,7 +58,7 @@ dependencies:
5958
- conda-forge::cython >=0.25.2
6059
- conda-forge::scikit-learn
6160
- conda-forge::scipy >=1.9
62-
- conda-forge::numpy >=1.10.0
61+
- conda-forge::numpy >=1.10.0,<2
6362
- conda-forge::pydot
6463
- conda-forge::jinja2
6564
- conda-forge::jupyter

rmgpy/reaction.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -348,35 +348,35 @@ def to_cantera(self, species_list=None, use_chemkin_identifier=False):
348348

349349
elif isinstance(self.kinetics, ThirdBody):
350350
if ct_collider is not None:
351-
ct_reaction = ct.ThreeBodyReaction(reactants=ct_reactants, products=ct_products, third_body=ct_collider)
351+
ct_reaction = ct.Reaction(reactants=ct_reactants, products=ct_products, third_body=ct_collider)
352352
else:
353-
ct_reaction = ct.ThreeBodyReaction(reactants=ct_reactants, products=ct_products)
353+
ct_reaction = ct.Reaction(reactants=ct_reactants, products=ct_products)
354354

355355
elif isinstance(self.kinetics, Troe):
356356
if ct_collider is not None:
357-
ct_reaction = ct.FalloffReaction(
357+
ct_reaction = ct.Reaction(
358358
reactants=ct_reactants,
359359
products=ct_products,
360-
tbody=ct_collider,
360+
third_body=ct_collider,
361361
rate=ct.TroeRate()
362362
)
363363
else:
364-
ct_reaction = ct.FalloffReaction(
364+
ct_reaction = ct.Reaction(
365365
reactants=ct_reactants,
366366
products=ct_products,
367367
rate=ct.TroeRate()
368368
)
369369

370370
elif isinstance(self.kinetics, Lindemann):
371371
if ct_collider is not None:
372-
ct_reaction = ct.FalloffReaction(
372+
ct_reaction = ct.Reaction(
373373
reactants=ct_reactants,
374374
products=ct_products,
375-
tbody=ct_collider,
375+
third_body=ct_collider,
376376
rate=ct.LindemannRate()
377377
)
378378
else:
379-
ct_reaction = ct.FalloffReaction(
379+
ct_reaction = ct.Reaction(
380380
reactants=ct_reactants,
381381
products=ct_products,
382382
rate=ct.LindemannRate()

rmgpy/tools/canteramodel.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -840,20 +840,15 @@ def check_equivalent_falloff(fall1, fall2):
840840
for j in range(ct_rxn1.rate.data.shape[1]):
841841
assert check_nearly_equal(ct_rxn1.rate.data[i, j], ct_rxn2.rate.data[i, j], dE), \
842842
"Similar Chebyshev coefficients"
843-
844-
elif isinstance(ct_rxn1, ct.ThreeBodyReaction):
845-
assert ct_rxn1.default_efficiency == ct_rxn2.default_efficiency, "Same default efficiency"
846-
assert ct_rxn1.efficiencies == ct_rxn2.efficiencies, "Same efficiencies"
847-
848-
elif isinstance(ct_rxn1, ct.FalloffReaction):
849-
assert ct_rxn1.default_efficiency == ct_rxn2.default_efficiency, "Same default efficiency"
850-
assert ct_rxn1.efficiencies == ct_rxn2.efficiencies, "Same efficiencies"
851-
if ct_rxn1.falloff or ct_rxn2.falloff:
852-
check_equivalent_falloff(ct_rxn1.falloff, ct_rxn2.falloff)
853-
if ct_rxn1.high_rate or ct_rxn2.high_rate:
854-
check_equivalent_arrhenius(ct_rxn1.high_rate, ct_rxn2.high_rate)
855-
if ct_rxn1.low_rate or ct_rxn2.low_rate:
856-
check_equivalent_arrhenius(ct_rxn1.low_rate, ct_rxn2.low_rate)
843+
else:
844+
assert ct_rxn1.default_efficiency == ct_rxn2.default_efficiency, "Same default efficiency"
845+
assert ct_rxn1.efficiencies == ct_rxn2.efficiencies, "Same efficiencies"
846+
if ct_rxn1.falloff or ct_rxn2.falloff:
847+
check_equivalent_falloff(ct_rxn1.falloff, ct_rxn2.falloff)
848+
if ct_rxn1.high_rate or ct_rxn2.high_rate:
849+
check_equivalent_arrhenius(ct_rxn1.high_rate, ct_rxn2.high_rate)
850+
if ct_rxn1.low_rate or ct_rxn2.low_rate:
851+
check_equivalent_arrhenius(ct_rxn1.low_rate, ct_rxn2.low_rate)
857852

858853
except Exception as e:
859854
print("Cantera reaction {0} failed equivalency check on: {1}".format(ct_rxn1, e))

test/rmgpy/reactionTest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2954,7 +2954,7 @@ def test_pdep_arrhenius(self):
29542954
# Check that the reaction string is the same
29552955
assert repr(converted_obj) == repr(ct_obj)
29562956
# Check that the Arrhenius rates are identical
2957-
assert str(converted_obj.rates) == str(ct_obj.rates)
2957+
assert converted_obj.rate.rates == ct_obj.rate.rates
29582958

29592959
def test_multi_pdep_arrhenius(self):
29602960
"""
@@ -2975,7 +2975,7 @@ def test_multi_pdep_arrhenius(self):
29752975
# Check that the reaction string is the same
29762976
assert repr(converted_rxn) == repr(ct_rxn)
29772977
# Check that the Arrhenius rates are identical
2978-
assert str(converted_rxn.rates) == str(ct_rxn.rates)
2978+
assert converted_rxn.rate.rates == ct_rxn.rate.rates
29792979

29802980
def test_chebyshev(self):
29812981
"""

test/rmgpy/speciesTest.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -458,24 +458,24 @@ def test_cantera(self):
458458

459459
rmg_ct_species = rmg_species.to_cantera(use_chemkin_identifier=True)
460460

461-
ct_species = ct.Species.fromCti(
462-
"""species(name=u'Ar',
463-
atoms='Ar:1',
464-
thermo=(NASA([200.00, 1000.00],
465-
[ 2.50000000E+00, 0.00000000E+00, 0.00000000E+00,
466-
0.00000000E+00, 0.00000000E+00, -7.45375000E+02,
467-
4.37967000E+00]),
468-
NASA([1000.00, 6000.00],
469-
[ 2.50000000E+00, 0.00000000E+00, 0.00000000E+00,
470-
0.00000000E+00, 0.00000000E+00, -7.45375000E+02,
471-
4.37967000E+00])),
472-
transport=gas_transport(geom='atom',
473-
diam=3.33,
474-
well_depth=136.501,
475-
dipole=2.0,
476-
polar=1.0,
477-
rot_relax=15.0))"""
478-
)
461+
ct_species = ct.Species.from_yaml("""
462+
name: Ar
463+
composition: {Ar: 1}
464+
thermo:
465+
model: NASA7
466+
temperature-ranges: [200.0, 1000.0, 6000.0]
467+
data:
468+
- [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.37967]
469+
- [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.37967]
470+
transport:
471+
model: gas
472+
geometry: atom
473+
diameter: 3.33
474+
well-depth: 136.501
475+
dipole: 2.0
476+
polarizability: 1.0
477+
rotational-relaxation: 15.0
478+
""")
479479
assert type(rmg_ct_species) == type(ct_species)
480480
assert rmg_ct_species.name == ct_species.name
481481
assert rmg_ct_species.composition == ct_species.composition

test/rmgpy/transportDataTest.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,20 @@ def test_to_cantera(self):
161161
rmg_ct_transport = transport.to_cantera()
162162
import cantera as ct
163163

164-
ct_species = ct.Species.fromCti(
165-
"""species(name=u'Ar',
166-
atoms='Ar:1',
167-
transport=gas_transport(geom='atom',
168-
diam=3.33,
169-
well_depth=136.501,
170-
dipole=2.0,
171-
polar=1.0,
172-
rot_relax=15.0))"""
173-
)
164+
ct_species = ct.Species.from_yaml("""
165+
name: Ar
166+
composition: {Ar: 1}
167+
thermo:
168+
model: constant-cp
169+
transport:
170+
model: gas
171+
geometry: atom
172+
diameter: 3.33
173+
well-depth: 136.501
174+
dipole: 2.0
175+
polarizability: 1.0
176+
rotational-relaxation: 15.0
177+
""")
174178

175179
ct_transport = ct_species.transport
176180

0 commit comments

Comments
 (0)