From e100ef9a09d4eb81426d1125bb5e61f48d8edacd Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 31 May 2016 16:33:48 -0400 Subject: [PATCH] [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. --- interfaces/cython/cantera/_cantera.pxd | 2 +- interfaces/cython/cantera/test/test_onedim.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 54f5198bf..bb357e269 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -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": diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index 4f46bc741..a10ace5c2 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -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