示例#1
0
    def checkConversion(self, refFile, testFile):
        ref = ct.IdealGasMix(refFile)
        gas = ct.IdealGasMix(testFile)

        self.assertEqual(ref.elementNames(), gas.elementNames())
        self.assertEqual(ref.speciesNames(), gas.speciesNames())
        self.assertTrue(
            (ref.reactantStoichCoeffs() == gas.reactantStoichCoeffs()).all())

        compositionA = [[ref.nAtoms(i, j) for j in range(ref.nElements())]
                        for i in range(ref.nSpecies())]
        compositionB = [[gas.nAtoms(i, j) for j in range(gas.nElements())]
                        for i in range(gas.nSpecies())]
        self.assertEqual(compositionA, compositionB)

        return ref, gas
示例#2
0
    def test_transport_normal(self):
        convertMech('../../data/inputs/h2o2.inp',
                    transportFile='../../data/transport/gri30_tran.dat',
                    outName='h2o2_transport_normal.cti',
                    quiet=True)

        gas = ct.IdealGasMix('h2o2_transport_normal.cti')
        gas.set(X='H2:1.0, O2:1.0', T=300, P=101325)
        self.assertAlmostEqual(gas.thermalConductivity(), 0.07663, 4)
示例#3
0
    def test_transport_embedded(self):
        convertMech('../data/with-transport.inp',
                    outName='with-transport.cti',
                    quiet=True)

        gas = ct.IdealGasMix('with-transport.cti')
        gas.set(X=[0.2, 0.3, 0.5])
        D = gas.mixDiffCoeffs()
        for d in D:
            self.assertTrue(d > 0.0)
示例#4
0
    def test_duplicate_species(self):
        self.assertRaises(
            ck2cti.InputParseError,
            lambda: convertMech('../data/duplicate-species.inp',
                                outName='duplicate-species.cti',
                                quiet=True))

        convertMech('../data/duplicate-species.inp',
                    outName='duplicate-species.cti',
                    quiet=True,
                    permissive=True)

        gas = ct.IdealGasMix('duplicate-species.cti')
        self.assertEqual(gas.speciesNames(), ['foo', 'bar', 'baz'])
示例#5
0
    def test_unterminatedSections(self):
        self.assertRaises(
            ck2cti.InputParseError,
            lambda: convertMech('../data/unterminated-sections.inp',
                                outName='unterminated-sections.cti',
                                quiet=True))

        convertMech('../data/unterminated-sections.inp',
                    outName='unterminated-sections.cti',
                    quiet=True,
                    permissive=True)

        gas = ct.IdealGasMix('unterminated-sections.cti')
        self.assertEqual(gas.nSpecies(), 3)
        self.assertEqual(gas.nReactions(), 2)
示例#6
0
    def test_pathologicalSpeciesNames(self):
        convertMech('../data/species-names.inp',
                    outName='species-names.cti',
                    quiet=True)
        gas = ct.IdealGasMix('species-names.cti')

        self.assertEqual(gas.nSpecies(), 3)
        self.assertEqual(gas.speciesName(0), '(Parens)')
        self.assertEqual(gas.speciesName(1), '@#$%^-2')
        self.assertEqual(gas.speciesName(2), '[xy2]*{.}')

        self.assertEqual(gas.nReactions(), 2)
        nu = gas.productStoichCoeffs() - gas.reactantStoichCoeffs()
        self.assertEqual(list(nu[:, 0]), [-1, -1, 2])
        self.assertEqual(list(nu[:, 1]), [-2, 3, -1])
示例#7
0
    def test_duplicate_thermo(self):
        self.assertRaises(
            ck2cti.InputParseError,
            lambda: convertMech('../data/duplicate-thermo.inp',
                                outName='duplicate-thermo.cti',
                                quiet=True))

        convertMech('../data/duplicate-thermo.inp',
                    outName='duplicate-thermo.cti',
                    quiet=True,
                    permissive=True)

        gas = ct.IdealGasMix('duplicate-thermo.cti')
        self.assertTrue(gas.nSpecies(), 3)
        self.assertTrue(gas.nReactions(), 2)
示例#8
0
 def test_checkReactionBalance(self):
     self.assertRaises(Exception,
                       lambda: ct.IdealGasMix('../data/h2o2_unbalancedReaction.xml'))
示例#9
0
 def setUp(self):
     self.gas = ct.IdealGasMix('../data/explicit-forward-order.xml')
     self.gas.set(T=800, P=101325, X=[0.01, 0.90, 0.02, 0.03, 0.04])