From 21505655d0e73c4f749b30f14cf7eba1456512b6 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Sun, 17 Oct 2021 13:31:00 -0400 Subject: [PATCH] [1D] Include Soret-enabled flag in YAML input/output --- interfaces/cython/cantera/test/test_onedim.py | 6 +++++- src/oneD/StFlow.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/interfaces/cython/cantera/test/test_onedim.py b/interfaces/cython/cantera/test/test_onedim.py index 4c5fcee1c81..3c2705905fc 100644 --- a/interfaces/cython/cantera/test/test_onedim.py +++ b/interfaces/cython/cantera/test/test_onedim.py @@ -627,6 +627,7 @@ def test_save_restore_yaml(self): self.assertArrayNear(V1, V3, 1e-3) self.assertFalse(self.sim.radiation_enabled) + self.assertFalse(self.sim.soret_enabled) self.sim.restore(filename, "test2", loglevel=0) self.assertTrue(self.sim.radiation_enabled) @@ -690,16 +691,19 @@ def test_save_restore_add_species_yaml(self): self.sim.max_grid_points = 234 self.solve_fixed_T() self.solve_mix(ratio=5, slope=0.5, curve=0.3) + self.sim.transport_model = "multicomponent" + self.sim.soret_enabled = True self.sim.save(filename, "test", loglevel=0) T1 = self.sim.T Y1 = self.sim.Y - gas2 = ct.Solution("h2o2-plus.xml") + gas2 = ct.Solution("h2o2-plus.xml", transport_model="multicomponent") self.sim = ct.FreeFlame(gas2) self.sim.restore(filename, "test", loglevel=0) T2 = self.sim.T Y2 = self.sim.Y + self.assertTrue(self.sim.soret_enabled) self.assertEqual(self.sim.max_grid_points, 234) self.assertArrayNear(T1, T2) for k1, species in enumerate(gas1.species_names): diff --git a/src/oneD/StFlow.cpp b/src/oneD/StFlow.cpp index 708e05b2a07..7387c0a3e4b 100644 --- a/src/oneD/StFlow.cpp +++ b/src/oneD/StFlow.cpp @@ -878,6 +878,8 @@ AnyMap StFlow::serialize(const double* soln) const state["energy-enabled"] = m_do_energy; } + state["Soret-enabled"] = m_do_soret; + std::set species_flags(m_do_species.begin(), m_do_species.end()); if (species_flags.size() == 1) { state["species-enabled"] = m_do_species[0]; @@ -931,6 +933,10 @@ void StFlow::restore(const AnyMap& state, double* soln, int loglevel) } } + if (state.hasKey("Soret-enabled")) { + m_do_soret = state["Soret-enabled"].asBool(); + } + if (state.hasKey("species-enabled")) { const AnyValue& se = state["species-enabled"]; if (se.isScalar()) {