-
-
Notifications
You must be signed in to change notification settings - Fork 349
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
Flame restart and initial guess examples and fix issue #1288 #1293
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwest ... thanks for looking into this! Restarts and improved file IO from SolutionArray
(and FlameBase
) were among the first things I implemented when I started contributing for 2.5.1 (I had used restarts from HDF extensively in the past). The pandas
issue slipped through, which should have been secured by unit tests (which were never added). Fwiw, pandas
itself was just a vehicle to write an earlier HDF version that never made it into a release, but it was kept around ...
While this PR may not be fully developed (some catch blocks look like this is still work in progress), I added a couple of comments. Also, several of your tests read like unit tests ... let me know if you have questions ...
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## main #1293 +/- ##
=======================================
Coverage 67.18% 67.19%
=======================================
Files 314 314
Lines 41904 41905 +1
Branches 16863 16862 -1
=======================================
+ Hits 28155 28156 +1
Misses 11518 11518
Partials 2231 2231
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Thanks for the comments @ischoegl. I think I've addressed them (and tidied some other things up on the rebase). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwest ... thank you for updating. To follow up on my initial comments, I have a couple of more substantive suggestions.
I don't think that the example needs to check / demonstrate equivalence of restored solutions, as there are already unit tests for that purpose (I linked those that do exist - pandas is the main one that is missing). On the other hand, the pruning checks are very informative - I think it would be nice to just play around with tolerances, pruning, and refine criteria as these are not necessarily well understood by users, while giving ample opportunity to demonstrate file I/O.
Fwiw, there's another relevant example that is a little more advanced - see diffusion_flame_batch.py. I think a simpler example like the one you are proposing here is a great addition.
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
interfaces/cython/cantera/examples/onedim/flame_initial_guess.py
Outdated
Show resolved
Hide resolved
Allows you to pass a pandas DataFrame as the data argument to a flame's set_initial_guess method. Closes Cantera#1288
Examples of different ways to do this, saving via yaml, HDF5 and CSV, then loading either as a restart or as an initial guess, including with some modifications to the data (eg. fewer grid points, or species). There are some subtleties, like you have to create the correct boundary conditions before you load the initial guess. There is one method (loading an initial guess from an HDF file) that is currently not working, so this is anticipated. Because of issue Cantera#1288 in 2.6.0 the required version is set to 3.0
The ability to get an initial guess from an h5 file does not work. Removing the broken attempt, documentation, and example that suggests it should. As per ishoegl's suggestion Cantera#1293 (comment) For a work-around, restore a flame from the hdf5 file with flame.read_hdf then make a SolutionArray (or pandas.DataFrame) from that and use one of those to create an initial guess (both of which work)
- don't make it look like unit tests - print some output - keep under 88 characters - always create one solution, then save it in several formats
I think I have addressed all @ischoegl's comments and suggestions in the last 2 commits. |
@rwest ... thanks for the updates (:+1: on the |
Co-authored-by: Richard West <[email protected]>
Thanks. done. |
Thanks! ... but - ugh - |
The pandas fix looks ok to me. Good catch. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwest - thanks for the fix and the example! It all looks good to me.
The ability to get an initial guess from an h5 file does not work. Removing the broken attempt, documentation, and example that suggests it should. As per ishoegl's suggestion #1293 (comment) For a work-around, restore a flame from the hdf5 file with flame.read_hdf then make a SolutionArray (or pandas.DataFrame) from that and use one of those to create an initial guess (both of which work)
Changes proposed in this pull request
set_initial_guess
to receive a Pandas DataFrame object, as documented.If applicable, fill in the issue number this pull request is fixing
Closes #1288
If applicable, provide an example illustrating new features this pull request is introducing
Most of the pull request is providing examples (including one of the fixed bug).
Checklist
scons build
&scons test
) and unit tests address code coverage