@@ -139,17 +139,32 @@ def testSpeciesMatch(self):
139139 assert s1 ['thermo' ]['model' ] == s2 ['thermo' ]['model' ], \
140140 f"Thermo model mismatch for { name } ."
141141
142- # Temperature ranges (ck2yaml rounds, RMG keeps full precision)
143- if 'temperature-ranges' in s1 ['thermo' ] and 'temperature-ranges' in s2 ['thermo' ]:
144- assert s1 ['thermo' ]['temperature-ranges' ] == pytest .approx (
145- s2 ['thermo' ]['temperature-ranges' ], rel = 1e-4
146- ), f"Temperature ranges mismatch for { name } ."
147-
148- # Thermo polynomial data
149- if 'data' in s1 ['thermo' ] and 'data' in s2 ['thermo' ]:
150- assert len (s1 ['thermo' ]['data' ]) == len (s2 ['thermo' ]['data' ]), \
142+ # Temperature ranges and polynomial data
143+ # ck2yaml may collapse single-polynomial NASA7 (e.g. Ar) into one range
144+ # while RMG always writes two polynomials with a midpoint temperature.
145+ t_ranges1 = s1 ['thermo' ].get ('temperature-ranges' , [])
146+ t_ranges2 = s2 ['thermo' ].get ('temperature-ranges' , [])
147+ data1 = s1 ['thermo' ].get ('data' , [])
148+ data2 = s2 ['thermo' ].get ('data' , [])
149+
150+ if len (t_ranges1 ) == 2 and len (t_ranges2 ) == 3 :
151+ # ck2yaml collapsed to single polynomial; RMG has two identical ones
152+ assert t_ranges1 [0 ] == pytest .approx (t_ranges2 [0 ], rel = 1e-4 ), \
153+ f"Temperature range lower bound mismatch for { name } ."
154+ assert t_ranges1 [1 ] == pytest .approx (t_ranges2 [2 ], rel = 1e-4 ), \
155+ f"Temperature range upper bound mismatch for { name } ."
156+ assert len (data1 ) == 1 and len (data2 ) == 2 , \
157+ f"Expected 1 vs 2 polynomials for collapsed species { name } ."
158+ assert data1 [0 ] == pytest .approx (data2 [0 ], rel = 1e-4 ), \
159+ f"Thermo polynomial mismatch for { name } (low range)."
160+ assert data1 [0 ] == pytest .approx (data2 [1 ], rel = 1e-4 ), \
161+ f"Thermo polynomial mismatch for { name } (high range should match low)."
162+ else :
163+ assert t_ranges1 == pytest .approx (t_ranges2 , rel = 1e-4 ), \
164+ f"Temperature ranges mismatch for { name } ."
165+ assert len (data1 ) == len (data2 ), \
151166 f"Number of thermo polynomial ranges differs for { name } ."
152- for i , (poly1 , poly2 ) in enumerate (zip (s1 [ 'thermo' ][ 'data' ], s2 [ 'thermo' ][ 'data' ] )):
167+ for i , (poly1 , poly2 ) in enumerate (zip (data1 , data2 )):
153168 assert poly1 == pytest .approx (poly2 , rel = 1e-4 ), \
154169 f"Thermo polynomial { i } mismatch for { name } ."
155170 # Ideally thermo data would have notes.
0 commit comments