From d9630308393345ef7fb5a9ca0d70499ae40d0a69 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 24 Sep 2019 14:16:52 -0500 Subject: [PATCH] [Thermo] add unit tests for add_species_alias and find_isomers --- interfaces/cython/cantera/test/test_thermo.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 17ba484d18..66ca27472b 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -1140,6 +1140,23 @@ def test_modify_thermo_invalid(self): with self.assertRaisesRegex(ct.CanteraError, 'modifySpecies'): self.gas.modify_species(self.gas.species_index('H2'), copy) + def test_alias(self): + self.gas.add_species_alias('H2', 'hydrogen') + self.assertTrue(self.gas.species_index('hydrogen') == 0) + self.gas.X = 'hydrogen:.5, O2:.5' + self.assertNear(self.gas.X[0], 0.5) + with self.assertRaisesRegex(ct.CanteraError, 'Unable to add alias'): + self.gas.add_species_alias('spam', 'eggs') + + def test_isomers(self): + gas = ct.Solution('nDodecane_Reitz.yaml') + iso = gas.find_isomers({'C':4, 'H':9, 'O':2}) + self.assertTrue(len(iso) == 2) + iso = gas.find_isomers({'C':7, 'H':15}) + self.assertTrue(len(iso) == 1) + iso = gas.find_isomers({'C':7, 'H':16}) + self.assertTrue(len(iso) == 0) + class TestSpeciesThermo(utilities.CanteraTest): h2o_coeffs = [