Cantera / cantera

Chemical kinetics, thermodynamics, and transport tool suite
https://cantera.org
Other
580 stars 341 forks source link

[python] Fix dimension of sliced SolutionArray methods #1726

Open ischoegl opened 2 days ago

ischoegl commented 2 days ago

Changes proposed in this pull request

If applicable, fill in the issue number this pull request is fixing

Closes #1717

If applicable, provide an example illustrating new features this pull request is introducing

In [1]: import cantera as ct
   ...: gas = ct.Solution("h2o2.yaml")
   ...: gas.TPY = 900, 1.e05, {"H2": 1.0, "O2": 1.0}

In [2]: arr = ct.SolutionArray(gas, states=[list(gas.state)] * 10)

In [3]: arr("H2").Y.shape
Out[3]: (10, 1)

In [4]: arr("H2").net_production_rates.shape
Out[4]: (10, 1)

Comments

This is to make the interface somewhat consistent with Solution; there are some differences, e.g. round vs square brackets, or passing of lists vs argument lists, where fixes go beyond the scope of this PR. Also, Solution currently does not slice gas["O2"].binary_diff_coeffs correctly, so this PR merely ensures that implementations are mostly consistent.

Checklist

codecov[bot] commented 2 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 72.80%. Comparing base (bc24169) to head (b9a8936). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1726 +/- ## ======================================= Coverage 72.79% 72.80% ======================================= Files 381 381 Lines 54011 54020 +9 Branches 9207 9210 +3 ======================================= + Hits 39319 39328 +9 Misses 11707 11707 Partials 2985 2985 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.