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

Add SolutionArray :set_mixture_fraction method. #1242

Merged
merged 7 commits into from
Apr 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions interfaces/cython/cantera/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,25 @@ def set_equivalence_ratio(self, phi, *args, **kwargs):
self._phase.set_equivalence_ratio(phi[index], *args, **kwargs)
self._states[index][:] = self._phase.state

def set_mixture_fraction(self, mixture_fraction, *args, **kwargs):
"""
See `ThermoPhase.set_mixture_fraction`

Note that ``mixture_fraction`` either needs to be a scalar value or
dimensions have to be matched to the `SolutionArray`.
"""

# broadcast argument shape
mixture_fraction, _ = np.broadcast_arrays(mixture_fraction,
self._output_dummy)

# loop over values
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit, but this comment and the one above don't add anything to the explanation. I see they're copied from the other method, but I don't see a reason to copy them over.

Copy link
Member Author

@decaluwe decaluwe Apr 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly for line 1016.

For line 1013, it is not entirely clear to me what line 1012 does. My best guess: if mixture_fraction is a scalar, we convert it to an array of the correct size, where are elements are set to the value mixture_fraction. Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To put a finer point on it: @bryan, would you be supportive of me adding a comment that actually explains what line 1012 does (while deleting the comment on line 1016)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that would be perfect, thank you 😊

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but so: is my understanding above of line 1012 correct? 😂

for index in self._indices:
self._phase.state = self._states[index]
self._phase.set_mixture_fraction(mixture_fraction[index], *args,
**kwargs)
self._states[index][:] = self._phase.state

def collect_data(self, cols=None, tabular=False, threshold=0, species=None):
"""
Returns the data specified by ``cols`` in an ordered dictionary, where
Expand Down