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 set_equivalence_ratio to SolutionArray objects #604

Closed
speth opened this issue Mar 4, 2019 · 5 comments · Fixed by #677
Closed

Add set_equivalence_ratio to SolutionArray objects #604

speth opened this issue Mar 4, 2019 · 5 comments · Fixed by #677

Comments

@speth
Copy link
Member

speth commented Mar 4, 2019

Currently, the Python SolutionArray class has no equivalent of ThermoPhase.set_equivalence_ratio. A version of this function could be added to the SolutionArray class so that one can set the equivalence ratio to a range of values. This would make calculation of an adiabatic flame temperature curve very simple:

states = ct.SolutionArray(gas, 100)
phi = np.arange(0, 2, 100)
states.set_equivalence_ratio(phi, 'CH4:1.0', 'O2:1.0, N2:3.76')
states.equilibrate('HP')
plt.plot(phi, states.T)

This function could also enable specifying a range of fuel and/or oxidizer compositions, in the case where a dict is used for the composition:

states.set_equivalence_ratio(phi, {'CH4': np.linspace(0, 1, 100), 'H2': np.linspace(1, 0, 100)})
@bryanwweber
Copy link
Member

Should the size of the arrays in set_equivalence_ratio match the existing size of the SolutionArray?

@speth
Copy link
Member Author

speth commented Mar 4, 2019

Yes, I would expect this to work the same way as the other setters, e.g. states.TPX = ... work, with the length of an input in each dimension needing to have either the same length as the states object, or be a scalar in which case the values are broadcast in that dimension. An example of how this works now is already in the SolutionArray documentation.

@ischoegl
Copy link
Member

I do have a question regarding the envisioned scope of SolutionArray. At the moment, it only exists as a pure python class. On the other hand, there is ongoing work to phase out ctml (see pull request #584), which may also mean that the XML output for oneD simulations may be revised (@speth posted 1D Flame Development Ideas mentioning "Introduce HDF5 or CSV or JSON or YAML or some other output format for 1D flames to replace XML"). Would the idea be to build on SolutionArray?

@bryanwweber
Copy link
Member

@ischoegl I suspect that any serialization output routine for 1-D classes will be in the C++ layer so that any interface could use it. However, I think it's possible that having a specialized subclass of SolutionArray in Python for 1-D cases would be useful.

@ischoegl
Copy link
Member

Thanks for the insights: I agree that a subclass of SolutionArray handling 1D would be useful, which is what also prompted my inquiry. Has there been any discussion on what the new C++ layer replacing XML could entail?

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

Successfully merging a pull request may close this issue.

3 participants