[Python] Fix exception handling when setting soret_enabled

The C++ exception is now correctly translated to a Python exception, instead of
causing the program to abort.
This commit is contained in:
Ray Speth
2016-05-31 16:33:48 -04:00
parent bbb5eed396
commit e100ef9a09
2 changed files with 9 additions and 1 deletions

View File

@@ -671,7 +671,7 @@ cdef extern from "cantera/oneD/StFlow.h":
void solveEnergyEqn()
void fixTemperature()
cbool doEnergy(size_t)
void enableSoret(cbool)
void enableSoret(cbool) except +
cbool withSoret()
cdef cppclass CxxFreeFlame "Cantera::FreeFlame":

View File

@@ -276,6 +276,14 @@ class TestFreeFlame(utilities.CanteraTest):
self.assertNear(Su_multi, Su_soret, 2e-1)
self.assertNotEqual(Su_multi, Su_soret)
def test_soret_flag(self):
self.create_sim(101325, 300, 'H2:1.0, O2:1.0')
self.assertFalse(self.sim.soret_enabled)
with self.assertRaises(RuntimeError):
self.sim.soret_enabled = True
self.sim.transport_model = 'Multi'
self.sim.soret_enabled = True
def test_prune(self):
reactants= 'H2:1.1, O2:1, AR:5'
p = ct.one_atm