Open dylanrubini opened 1 week ago
It is also worth noting that the same behaviour occurs in Cantera 3.0.0
Cantera 3.0 reimplements the 2.6 interface, so it is a pre-existing condition. I'm not sure there ever was a rationale - at the back-end, it is a slicing operation that appears to not be implemented.
Thank you, I appreciate the clarification
Fwiw, the implementation should follow the rationale of the underlying Solution
object:
In [1]: import cantera as ct
...: gas = ct.Solution("h2o2.yaml")
...: gas.TPY = 900, 1.e05, {"H2": 1.0, "O2": 1.0}
In [2]: gas["H2"].Y
Out[2]: array([0.5])
In [3]: gas["H2"].net_production_rates
Out[3]: array([-2.58564267e-08])
I think the underlying issue here comes from an incomplete attempt to implement SolutionArray
for surface phases. For surfaces, the number of species that the Interface
object computes kinetics-related properties for (n_total_species
) is more than just the number of surface phase species (n_species
). Besides the slicing issue noted here, there are other problems with using SolutionArray
on Interface
objects that I think are tricky to fix (most importantly, reaction rates depend on composition information from multiple phases, and the state of those Solution
objects is not synchronized when looping over the SolutionArray
's states).
For the time being, we might be best off disabling the use of SolutionArray
with Interface
.
For the time being, we might be best off disabling the use of
SolutionArray
withInterface
Unfortunately, this would break serialization of 1D simulation results (example: catalytic_combustion.py
)
As an alternative, I disabled problematic methods in an update to #1726. Fwiw, I believe the lack of synchronization for Interface
should be tracked/fixed as a completely separate issue.
Problem description
Selecting a subset of species from a
SolutionArray
object does not work as expected when extracting thenet_production_rates
Steps to reproduce
Consider the following Minimum Working Example
Behavior
The first
print
statement prints:as expected because we intended to extract 1 species, in this case
propane(1)
However, the second print statement gives:
This is the shape of the entire
net_production_rates
array including all the species (which totals to 65 in this case).I expected that extracting a subset of species
state('propane(1)')
would apply for all properties that have dimension equal to the number of species, not just for the species mass fractionsY
and mole fractionsX
.Is this the expected behaviour?
System information