Skip to content

Commit

Permalink
[unittests] Cover transport model updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jan 23, 2025
1 parent 89e4e31 commit 9c3a57c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/general/test_composite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ TEST(SolutionArray, simple)
auto gas = newSolution("h2o2.yaml", "", "none");
auto arr = SolutionArray::create(gas, 5);

ASSERT_EQ(gas->transportModel(), "none");
ASSERT_EQ(arr->transportModel(), "none");

ASSERT_EQ(arr->size(), 5);
ASSERT_EQ(arr->meta(), AnyMap());

Expand Down
22 changes: 21 additions & 1 deletion test/python/test_composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,30 @@ def test_append_scrambled_input(self):

@pytest.mark.skipif("native" not in ct.hdf_support(),
reason="Cantera compiled without HDF support")
def test_import_no_norm_data(self):
def test_import_no_norm_data_h5(self):
outfile = self.test_work_path / "solutionarray_no_norm.h5"
outfile.unlink(missing_ok=True)

gas = ct.Solution("h2o2.yaml")
gas.transport_model = "multicomponent"
gas.set_unnormalized_mole_fractions(np.full(gas.n_species, 0.3))
states = ct.SolutionArray(gas, 5)
states.save(outfile, "group0")

gas_new = ct.Solution("h2o2.yaml")
b = ct.SolutionArray(gas_new)
b.restore(outfile, "group0") #, normalize=False)
assert states.T == approx(b.T)
assert states.P == approx(b.P)
assert states.X == approx(b.X)
assert gas_new.transport_model == "multicomponent"

def test_import_no_norm_data_yaml(self):
outfile = self.test_work_path / "solutionarray_no_norm.yaml"
outfile.unlink(missing_ok=True)

gas = ct.Solution("h2o2.yaml")
gas.transport_model = "multicomponent"
gas.set_unnormalized_mole_fractions(np.full(gas.n_species, 0.3))
states = ct.SolutionArray(gas, 5)
states.save(outfile, "group0")
Expand All @@ -502,6 +521,7 @@ def test_import_no_norm_data(self):
assert states.T == approx(b.T)
assert states.P == approx(b.P)
assert states.X == approx(b.X)
assert gas_new.transport_model == "multicomponent"

def check_arrays(self, a, b, rtol=1e-8):
assert a.T == approx(b.T, rel=rtol)
Expand Down
9 changes: 9 additions & 0 deletions test/python/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ def solve_multi(self):

assert self.sim.transport_model == 'multicomponent'

data = self.test_work_path / f"multicomponent.yaml"
data.unlink(missing_ok=True)
group = "multicomponent"
self.sim.save(data, group)

arr = ct.SolutionArray(self.sim.gas)
arr.restore(data, "multicomponent/flame")
assert arr.transport_model == "multicomponent"

def test_flow_type(self):
Tin = 300
p = ct.one_atm
Expand Down

0 comments on commit 9c3a57c

Please sign in to comment.