Skip to content

Commit

Permalink
[Python] Unnormalized mass/mole fractions do not work with Quantity
Browse files Browse the repository at this point in the history
Needing to go through the "native" state for the phase does not
necessarily preserve unnormalized mass and mole fractions.
  • Loading branch information
speth committed Jun 29, 2023
1 parent d3a545e commit 25fee18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions interfaces/cython/cantera/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ def f(self, *args, **kwargs):
for _attr in dir(Solution):
if _attr.startswith('_') or _attr in Quantity.__dict__ or _attr == 'state':
continue
if _attr.startswith('set_unnormalized'):
continue
else:
_orig = getattr(Solution, _attr)
if hasattr(_orig, "__call__"):
Expand Down
6 changes: 6 additions & 0 deletions test/python/test_thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1756,6 +1756,12 @@ def test_invalid_setter(self):
with self.assertRaises(AttributeError):
q1.HPQ = self.gas.H, self.gas.P, 1

with pytest.raises(AttributeError):
q1.set_unnormalized_mass_fractions(np.ones(q1.n_species))

with pytest.raises(AttributeError):
q1.set_unnormalized_mole_fractions(np.ones(q1.n_species))

def test_incompatible(self):
gas2 = ct.Solution('h2o2.yaml', transport_model=None)
q1 = ct.Quantity(self.gas)
Expand Down

0 comments on commit 25fee18

Please sign in to comment.