Ejemplo n.º 1
0
    def test_tolerances(self):
        gas = ct.Solution('h2o2.xml')
        left = ct.Inlet1D(gas)
        flame = ct.IdealGasFlow(gas)
        right = ct.Inlet1D(gas)
        # Some things don't work until the domains have been added to a Sim1D
        sim = ct.Sim1D((left, flame, right))

        with self.assertRaisesRegex(ct.CanteraError, 'no component'):
            flame.set_steady_tolerances(foobar=(3e-4, 3e-6))

        flame.set_steady_tolerances(default=(5e-3, 5e-5),
                                    T=(3e-4, 3e-6),
                                    Y=(7e-7, 7e-9))
        flame.set_transient_tolerances(default=(6e-3, 6e-5),
                                       T=(4e-4, 4e-6),
                                       Y=(2e-7, 2e-9))

        # Flow domain
        atol_ss = set(flame.steady_abstol())
        atol_ts = set(flame.transient_abstol())
        rtol_ss = set(flame.steady_reltol())
        rtol_ts = set(flame.transient_reltol())

        self.assertEqual(atol_ss, set((5e-5, 3e-6, 7e-9)))
        self.assertEqual(atol_ts, set((6e-5, 4e-6, 2e-9)))
        self.assertEqual(rtol_ss, set((5e-3, 3e-4, 7e-7)))
        self.assertEqual(rtol_ts, set((6e-3, 4e-4, 2e-7)))
Ejemplo n.º 2
0
    def test_boundaryProperties(self):
        gas1 = ct.Solution('h2o2.xml')
        gas2 = ct.Solution('h2o2.xml')
        inlet = ct.Inlet1D(name='something', phase=gas1)
        flame = ct.IdealGasFlow(gas1)
        sim = ct.Sim1D((inlet, flame))

        self.assertEqual(inlet.name, 'something')

        gas2.TPX = 400, 101325, 'H2:0.3, O2:0.5, AR:0.2'
        Xref = gas2.X
        Yref = gas2.Y
        inlet.Y = Yref

        self.assertArrayNear(inlet.Y, Yref)
        self.assertArrayNear(inlet.X, Xref)

        gas2.TPX = 400, 101325, 'H2:0.5, O2:0.2, AR:0.3'
        Xref = gas2.X
        Yref = gas2.Y
        inlet.X = Xref
        self.assertArrayNear(inlet.X, Xref)
        self.assertArrayNear(inlet.Y, Yref)

        inlet.X = {'H2': 0.3, 'O2': 0.5, 'AR': 0.2}
        self.assertNear(inlet.X[gas2.species_index('H2')], 0.3)
Ejemplo n.º 3
0
    def test_grid_check(self):
        gas = ct.Solution('h2o2.xml')
        flame = ct.IdealGasFlow(gas)

        with self.assertRaisesRegex(ct.CanteraError, 'monotonically'):
            flame.grid = [0, 0.1, 0.1, 0.2]

        with self.assertRaisesRegex(ct.CanteraError, 'monotonically'):
            flame.grid = [0, 0.1, 0.2, 0.05]
Ejemplo n.º 4
0
    def test_invalid_property(self):
        gas1 = ct.Solution('h2o2.xml')
        inlet = ct.Inlet1D(name='something', phase=gas1)
        flame = ct.IdealGasFlow(gas1)
        sim = ct.Sim1D((inlet, flame))

        for x in (inlet, flame, sim):
            with self.assertRaises(AttributeError):
                x.foobar = 300
            with self.assertRaises(AttributeError):
                x.foobar
Ejemplo n.º 5
0
    def test_instantiate(self):
        gas = ct.Solution('h2o2.xml')

        flame = ct.IdealGasFlow(gas)
Ejemplo n.º 6
0
 def test_uncopyable(self):
     import copy
     gas = ct.Solution('h2o2.xml')
     flame = ct.IdealGasFlow(gas)
     with self.assertRaises(NotImplementedError):
         copy.copy(flame)
Ejemplo n.º 7
0
 def test_unpicklable(self):
     import pickle
     gas = ct.Solution('h2o2.xml')
     flame = ct.IdealGasFlow(gas)
     with self.assertRaises(NotImplementedError):
         pickle.dumps(flame)
Ejemplo n.º 8
0
 def test_badInstantiate(self):
     solid = ct.Solution('diamond.xml', 'diamond')
     with self.assertRaises(TypeError):
         flame = ct.IdealGasFlow(solid)
Ejemplo n.º 9
0
 def test_badInstantiate(self):
     solid = ct.Solution("diamond.yaml", "diamond")
     with self.assertRaises(TypeError):
         flame = ct.IdealGasFlow(solid)
Ejemplo n.º 10
0
    def test_instantiate(self):
        gas = ct.Solution("h2o2.yaml")

        flame = ct.IdealGasFlow(gas)