diff --git a/interfaces/cython/cantera/yaml2ck.py b/interfaces/cython/cantera/yaml2ck.py index 1e8327da44..5b7310dae3 100644 --- a/interfaces/cython/cantera/yaml2ck.py +++ b/interfaces/cython/cantera/yaml2ck.py @@ -472,7 +472,8 @@ def build_reactions_text(reactions: Iterable[ct.Reaction]): else: raise ValueError(f"Unknown reaction type: '{reac.reaction_type}'") - if reac.third_body is not None: + third = reac.third_body + if third is not None and third.name == "M" and len(third.efficiencies): reaction_lines.append( " ".join( f"{spec}/{value:.3E}/" diff --git a/test/data/explicit-third-bodies.inp b/test/data/explicit-third-bodies.inp index eed21f0d8f..7c6bcaf957 100644 --- a/test/data/explicit-third-bodies.inp +++ b/test/data/explicit-third-bodies.inp @@ -21,6 +21,9 @@ REACTIONS R1A+R1B+m = P1+H+M 3.0E19 -2.0 1900 ! An end of line comment DUPLICATE +R1A+R1B+R2 = P1+H+R2 3.0E19 -2.0 1900 ! An end of line comment + DUPLICATE + R1A+R1B(+ M ) = P1+H(+m) 1.0E18 -2.0 1000 LOW/4.0E25 -3.0 0/ R2/0.0/ SP)X/0/ diff --git a/test/data/explicit-third-bodies.xml b/test/data/explicit-third-bodies.xml index ed91bf3664..6a91167c50 100644 --- a/test/data/explicit-third-bodies.xml +++ b/test/data/explicit-third-bodies.xml @@ -6,7 +6,7 @@ H C Ar - H R1A R1B P1 R2 + H R1A R1B P1 R2 SP)X @@ -27,12 +27,12 @@ - 2.500000000E+00, 7.053328190E-13, -1.995919640E-15, 2.300816320E-18, + 2.500000000E+00, 7.053328190E-13, -1.995919640E-15, 2.300816320E-18, -9.277323320E-22, 2.547365990E+04, -4.466828530E-01 - 2.500000010E+00, -2.308429730E-11, 1.615619480E-14, -4.735152350E-18, + 2.500000010E+00, -2.308429730E-11, 1.615619480E-14, -4.735152350E-18, 4.981973570E-22, 2.547365990E+04, -4.466829140E-01 @@ -44,12 +44,12 @@ - 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, + 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, 1.666939560E-11, -1.024664760E+04, -4.641303760E+00 - 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, + 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, -1.018152300E-13, -9.468344590E+03, 1.843731800E+01 @@ -61,12 +61,12 @@ - 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, + 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, 1.666939560E-11, -1.024664760E+04, -4.641303760E+00 - 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, + 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, -1.018152300E-13, -9.468344590E+03, 1.843731800E+01 @@ -78,12 +78,12 @@ - 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, + 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, 1.666939560E-11, -1.024664760E+04, -4.641303760E+00 - 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, + 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, -1.018152300E-13, -9.468344590E+03, 1.843731800E+01 @@ -95,12 +95,12 @@ - 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, + 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, 1.666939560E-11, -1.024664760E+04, -4.641303760E+00 - 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, + 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, -1.018152300E-13, -9.468344590E+03, 1.843731800E+01 @@ -112,12 +112,12 @@ - 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, + 5.149876130E+00, -1.367097880E-02, 4.918005990E-05, -4.847430260E-08, 1.666939560E-11, -1.024664760E+04, -4.641303760E+00 - 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, + 7.485149500E-02, 1.339094670E-02, -5.732858090E-06, 1.222925350E-09, -1.018152300E-13, -9.468344590E+03, 1.843731800E+01 @@ -125,7 +125,7 @@ - + R1A + R1B + M [=] P1 + H + M @@ -139,6 +139,20 @@ H:1 P1:1.0 + + + R1A + R1B + R2 [=] P1 + H + R2 + + + 3.000000E+13 + -2.0 + 1900.000000 + + + R1B:1 R1A:1.0 + H:1 P1:1.0 + + R1A + R1B (+ M) [=] P1 + H (+ M) diff --git a/test/data/explicit-third-bodies.yaml b/test/data/explicit-third-bodies.yaml index 0115a3f8a8..0fe8e3b433 100644 --- a/test/data/explicit-third-bodies.yaml +++ b/test/data/explicit-third-bodies.yaml @@ -79,6 +79,9 @@ reactions: type: three-body rate-constant: {A: 3.0e+13, b: -2.0, Ea: 1900.0 cal/mol} duplicate: true +- equation: R1A + R1B + R2 <=> P1 + H + R2 + rate-constant: {A: 3.0e+13, b: -2.0, Ea: 1900.0 cal/mol} + duplicate: true - equation: R1A + R1B (+ M) <=> P1 + H (+ M) type: falloff high-P-rate-constant: {A: 1.0e+15, b: -2.0, Ea: 1000.0 cal/mol} diff --git a/test/python/test_convert.py b/test/python/test_convert.py index 06cdfb2217..9f871fb85e 100644 --- a/test/python/test_convert.py +++ b/test/python/test_convert.py @@ -559,7 +559,7 @@ def convert( thermo: str | Path | None = None, transport: str | Path | None = None, permissive: bool = False, - ) -> None: + ) -> str: if mech is not None: mech, thermo, transport = self._convert_to_ck( input_file, @@ -578,6 +578,7 @@ def convert( quiet=True, permissive=permissive, ) + return mech def check_conversion(self, basename, cls=ct.Solution, **kwargs): # The round-trip YAML->CK->YAML will always have the single phase name 'gas' @@ -689,7 +690,13 @@ def test_phase_id(self): def test_third_body_reactions(self): input_file = self.test_data_path / "explicit-third-bodies.yaml" - self.convert(input_file) + mech = self.convert(input_file) + with open(mech) as fid: + lines = fid.readlines() + for i, line in enumerate(lines): + if line.startswith("R1A + R1B"): + next = lines[i + 1] + assert next.startswith("LOW") or next.strip() == "DUPLICATE" ck_phase, yaml_phase = self.check_conversion(input_file) self.check_kinetics( ck_phase, yaml_phase, [300, 800, 1450, 2800], [5e3, 1e5, 2e6]