Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantity.set_equivalence_ratio and other special setters not working #1446

Closed
speth opened this issue Feb 28, 2023 · 1 comment · Fixed by #1517
Closed

Quantity.set_equivalence_ratio and other special setters not working #1446

speth opened this issue Feb 28, 2023 · 1 comment · Fixed by #1517

Comments

@speth
Copy link
Member

speth commented Feb 28, 2023

Problem description

Several "special" setters for Solution objects do not work on Quantity objects. While they appear to pass through the call to the parent Solution correctly, they don't update the state of the Quantity object afterwards. This affects at least set_equivalence_ratio, set_unnormalized_mass_fractions and set_unnormalized_mole_fractions. While the latter two are not that likely to be needed with Quantity, the first one is fairly important.

Steps to reproduce

>>> import cantera as ct
>>> gas = ct.Solution('gri30.yaml')
>>> q = ct.Quantity(gas)
>>> q.set_equivalence_ratio(0.8, 'CH4:1.0', 'O2:1.0, N2:3.76')
>>> q.equivalence_ratio()
inf
>>> q.mole_fraction_dict()
{'H2': 1.0}
>>> q.set_unnormalized_mass_fractions([1]*53)
>>> q.Y
array([1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0.])
>>> q.set_unnormalized_mole_fractions([1]*53)
>>> q.X
Out[11]: 
array([1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0.])

System information

  • Cantera version: 2.6.0 or main at c54e429
  • Python/MATLAB/other software versions: Python 3.11, though I presume this affects all versions

Additional context

Identified while trying to provide suggestions for this question on the Cantera Users' Group.

@speth speth added the Python label Feb 28, 2023
@ischoegl
Copy link
Member

Confirmed on Python 3.10.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants