Skip to content

Commit

Permalink
T3 Main Test Fix
Browse files Browse the repository at this point in the history
T3 Main tests were failing due to changes in RMG-Py. This has been rectified. The first change is now we look for the numeric identifier of the species instead of the species name as the numeric identifier should never change and is unique. The second function change is that the chemical reaction string uses '<=>' instead of '='.
  • Loading branch information
calvinp0 committed Oct 27, 2023
1 parent 84283fe commit 9429b60
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import datetime
import os
import shutil
import re

from rmgpy.data.thermo import ThermoLibrary
from rmgpy.reaction import Reaction
Expand Down Expand Up @@ -734,7 +735,12 @@ def test_determine_species_based_on_collision_violators():
'S(26357)',
'S(25149)'
]
assert [t3.species[index]['Chemkin label'] for index in species_to_calc] == expected_species_to_calc
expected_numeric_identifiers = [int(re.findall(r'\((\d+)\)', species)[0]) for species in expected_species_to_calc]
numeric_identifiers = [int(re.findall(r'\((\d+)\)', t3.species[index]['Chemkin label'])[0]) for index in species_to_calc]

# Assert that the numeric identifiers are the same
# We do this because 'S' is a generic label for a species, and the numeric identifier is what distinguishes them
assert expected_numeric_identifiers == numeric_identifiers


def test_trsh_rmg_tol():
Expand Down Expand Up @@ -865,7 +871,7 @@ def test_add_reaction():

assert t3.get_reaction_key(reaction=rmg_reactions[342]) == 0
assert t3.reactions[0]['RMG label'] == 's0_H + s1_CC=CCCC <=> s2_S2XC6H13'
assert 'H(2)+S(1229)=C6H13(794)' in t3.reactions[0]['Chemkin label']
assert 'H(2)+C6H12(1229)<=>S2XC6H13(794)' in t3.reactions[0]['Chemkin label']
assert t3.reactions[0]['QM label'] == 's0_H + s1_CC=CCCC <=> s2_S2XC6H13'
assert t3.reactions[0]['SMILES label'] == '[H] + CC=CCCC <=> CC[CH]CCC'
assert isinstance(t3.reactions[0]['object'], Reaction)
Expand All @@ -875,7 +881,7 @@ def test_add_reaction():

assert t3.get_reaction_key(reaction=rmg_reactions[100]) == 1
assert t3.reactions[1]['RMG label'] == 's3_S2XC12H25 + s4_fuel <=> s5_S3XC12H25 + s4_fuel'
assert 'S(839)+fuel(1)=S(840)+fuel(1)' in t3.reactions[1]['Chemkin label']
assert 'S2XC12H25(839)+fuel(1)<=>S3XC12H25(840)+fuel(1)' in t3.reactions[1]['Chemkin label']
assert t3.reactions[1]['QM label'] == 's3_S2XC12H25 + s4_fuel <=> s5_S3XC12H25 + s4_fuel'
assert t3.reactions[1]['SMILES label'] == 'CC[CH]CCCCCCCCC + CCCCCCCCCCCC <=> CCC[CH]CCCCCCCC + CCCCCCCCCCCC'
assert isinstance(t3.reactions[1]['object'], Reaction)
Expand All @@ -885,7 +891,7 @@ def test_add_reaction():

assert t3.get_reaction_key(reaction=rmg_reactions[14]) == 2
assert t3.reactions[2]['RMG label'] == 's6_PC4H9 <=> s7_C2H4 + s8_C2H5'
assert 'PC4H9(191)=C2H4(22)+C2H5(52)' in t3.reactions[2]['Chemkin label']
assert 'PC4H9(191)<=>C2H4(22)+C2H5(52)' in t3.reactions[2]['Chemkin label']
assert t3.reactions[2]['QM label'] == 's6_PC4H9 <=> s7_C2H4 + s8_C2H5'
assert t3.reactions[2]['SMILES label'] == '[CH2]CCC <=> C=C + C[CH2]'
assert isinstance(t3.reactions[2]['object'], Reaction)
Expand Down

0 comments on commit 9429b60

Please sign in to comment.