def test_boundaryProperties(self): gas1 = ct.Solution('h2o2.xml') gas2 = ct.Solution('h2o2.xml') inlet = ct.Inlet1D(name='something', phase=gas1) flame = ct.FreeFlow(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)
def test_tolerances(self): gas = ct.Solution('h2o2.xml') left = ct.Inlet1D(gas) flame = ct.FreeFlow(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.assertRaises(ct.CanteraError): 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)))
def test_grid_check(self): gas = ct.Solution('h2o2.xml') flame = ct.FreeFlow(gas) with self.assertRaises(RuntimeError): flame.grid = [0, 0.1, 0.1, 0.2] with self.assertRaises(RuntimeError): flame.grid = [0, 0.1, 0.2, 0.05]
def test_invalid_property(self): gas1 = ct.Solution('h2o2.xml') inlet = ct.Inlet1D(name='something', phase=gas1) flame = ct.FreeFlow(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
def test_instantiate(self): gas = ct.Solution('h2o2.xml') flame = ct.FreeFlow(gas)
def test_uncopyable(self): import copy gas = ct.Solution('h2o2.xml') flame = ct.FreeFlow(gas) with self.assertRaises(NotImplementedError): copy.copy(flame)
def test_unpicklable(self): import pickle gas = ct.Solution('h2o2.xml') flame = ct.FreeFlow(gas) with self.assertRaises(NotImplementedError): pickle.dumps(flame)
def test_badInstantiate(self): solid = ct.Solution('diamond.xml', 'diamond') with self.assertRaises(TypeError): flame = ct.FreeFlow(solid)