diff --git a/interfaces/cython/cantera/test/__init__.py b/interfaces/cython/cantera/test/__init__.py index 407f24ec7..16306f1db 100644 --- a/interfaces/cython/cantera/test/__init__.py +++ b/interfaces/cython/cantera/test/__init__.py @@ -2,3 +2,6 @@ from .test_thermo import * from .test_kinetics import * from .test_transport import * from .test_mixture import * +from .test_func1 import * +from .test_reactor import * +from .test_onedim import * diff --git a/interfaces/cython/cantera/test/test_func1.py b/interfaces/cython/cantera/test/test_func1.py new file mode 100644 index 000000000..811944114 --- /dev/null +++ b/interfaces/cython/cantera/test/test_func1.py @@ -0,0 +1,12 @@ +import unittest +import numpy as np + +import cantera as ct +from . import utilities + +class TestFunc1(utilities.CanteraTest): + def test_sin(self): + f = ct.Sin1(3) + self.assertNear(f(0), np.sin(0)) + self.assertNear(f(0.1), np.sin(3*0.1)) + self.assertNear(f(0.7), np.sin(3*0.7)) diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py new file mode 100644 index 000000000..9bf07c784 --- /dev/null +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -0,0 +1,22 @@ +import cantera as ct +from . import utilities + +class TestOnedim(utilities.CanteraTest): + def test_instantiate(self): + gas = ct.Solution('h2o2.xml') + + flame = ct.FreeFlame(gas) + + def test_badInstantiate(self): + solid = ct.Solution('diamond.xml', 'diamond') + with self.assertRaises(TypeError): + flame = ct.FreeFlame(solid) + + def test_instantiateSurface(self): + gas = ct.Solution('diamond.xml', 'gas') + solid = ct.Solution('diamond.xml', 'diamond') + interface = ct.Solution('diamond.xml', 'diamond_100', (gas, solid)) + + surface = ct.ReactingSurface1D() + surface.setKinetics(interface) + diff --git a/interfaces/cython/cantera/test/test_reactor.py b/interfaces/cython/cantera/test/test_reactor.py new file mode 100644 index 000000000..31036360e --- /dev/null +++ b/interfaces/cython/cantera/test/test_reactor.py @@ -0,0 +1,46 @@ +import unittest +import numpy as np + +import cantera as ct +from . import utilities + +class TestReactor(utilities.CanteraTest): + def setUp(self): + self.gas1 = ct.Solution('h2o2.xml') + self.gas2 = ct.Solution('h2o2.xml') + X = np.zeros(self.gas1.nSpecies) + X[3] = 1.0 + self.gas2.setMoleFractions(X) + + self.r1 = ct.Reactor(self.gas1) + self.r2 = ct.Reactor(self.gas2) + + def test_disjoint(self): + T1 = self.gas1.temperature + T2 = self.gas2.temperature + P1 = self.gas1.pressure + P2 = self.gas2.pressure + + net = ct.ReactorNet() + net.addReactor(self.r1) + net.addReactor(self.r2) + net.advance(1.0) + + # Nothing should change from the initial condition + self.assertNear(T1, self.gas1.temperature) + self.assertNear(T2, self.gas2.temperature) + self.assertNear(P1, self.gas1.pressure) + self.assertNear(P2, self.gas2.pressure) + + def test_equalizePressure(self): + w = ct.Wall() + w.install(self.r1, self.r2) + w.expansionRateCoeff = 0.1 + w.area = 1.0 + + net = ct.ReactorNet() + net.addReactor(self.r1) + net.addReactor(self.r2) + + net.advance(1.0) + self.assertNear(self.gas1.pressure, self.gas2.pressure) diff --git a/interfaces/cython/cantera/test/test_thermo.py b/interfaces/cython/cantera/test/test_thermo.py index 7cb778ebf..215a8afc8 100644 --- a/interfaces/cython/cantera/test/test_thermo.py +++ b/interfaces/cython/cantera/test/test_thermo.py @@ -27,3 +27,15 @@ class TestThermoPhase(utilities.CanteraTest): def test_getState(self): self.assertNear(self.phase.pressure, ct.OneAtm) self.assertNear(self.phase.temperature, 300) + + +class TestInterfacePhase(utilities.CanteraTest): + def setUp(self): + self.gas = ct.Solution('diamond.xml', 'gas') + self.solid = ct.Solution('diamond.xml', 'diamond') + self.interface = ct.Solution('diamond.xml', 'diamond_100', + (self.gas, self.solid)) + + def test_properties(self): + self.interface.siteDensity = 100 + self.assertEqual(self.interface.siteDensity, 100) \ No newline at end of file