Skip to content

Commit

Permalink
[1D] Include Soret-enabled flag in YAML input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Oct 17, 2021
1 parent fa008db commit 2150565
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion interfaces/cython/cantera/test/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> species_flags(m_do_species.begin(), m_do_species.end());
if (species_flags.size() == 1) {
state["species-enabled"] = m_do_species[0];
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 2150565

Please sign in to comment.