-
-
Notifications
You must be signed in to change notification settings - Fork 346
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 HDF output to 1D examples #871
Conversation
Codecov Report
@@ Coverage Diff @@
## master #871 +/- ##
==========================================
- Coverage 71.57% 71.56% -0.01%
==========================================
Files 372 372
Lines 44503 44510 +7
==========================================
+ Hits 31851 31853 +2
- Misses 12652 12657 +5
Continue to review full report at Codecov.
|
2febd2c
to
637db69
Compare
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.
Looks good overall. I just had a couple of minor comments.
interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py
Outdated
Show resolved
Hide resolved
data_directory = 'diffusion_flame_batch_data/' | ||
if not os.path.exists(data_directory): | ||
os.makedirs(data_directory) | ||
fig_name = '{}figure_{{0}}.png'.format(data_directory) |
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.
In this case, I find this simpler:
fig_name = '{}figure_{{0}}.png'.format(data_directory) | |
fig_name = data_directory + 'figure_{0}.png' |
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.
This may also be a good place to use pathlib
, there might be a few places you have to cast the Path
instance to a str()
though, in Cantera's methods. I haven't tried it though, depending on how things are done internally, it may "just work", but then again, maybe only on Python 3.6+ which is I believe when they switched over to the built-in open()
allowing pathlib
.
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.
I opted to replace the path concatenations by os.path.join
, i.e. keeping strings albeit in a 'cleaner' approach. Refactoring how paths are handled isn't the main priority here, especially as there's the possibility of dropping XML from Python altogether.
interfaces/cython/cantera/examples/onedim/diffusion_flame_batch.py
Outdated
Show resolved
Hide resolved
data_directory = 'diffusion_flame_extinction_data/' | ||
if not os.path.exists(data_directory): | ||
os.makedirs(data_directory) |
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.
Same comment here about pathlib
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.
Again, not sure. I can replace this using pathlib
but still believe that XML output should be dropped here eventually, which would render this moot. Let me know ...
47bb6ac
to
183023e
Compare
The calculation for the production of gas phase species from surface reactions assumed that the gas phase species were stored at the beginning of the rate-of-production array. This is only the case when the gas ThermoPhase instance is the first phase in the Kinetics thermo vector, which is not guaranteed to be the case. It happens that XML input usually forced the gas phase to be the first phase in the thermo vector, so everything worked out fine. This was because the associated phase(s) for a surface phase had to be listed in an XML file, and the XML initializer reads that list to fill the Kinetics thermo vector. In the YAML format, the associated phase does not need to be explicitly listed. Instead, instances of the appropriate phases are passed to the constructor when the InterfaceKinetics is created. The gas phase can then come before or after the surface phase, meaning there is no guarantee of the order of species. This change checks for the starting index of the gas phase species in the InterfaceKinetics species-length arrays to make sure that the appropriate rates of production are added for the gas phase species. Fixes Cantera#902, Cantera#871, Cantera#873
HDF output for 1D simulations has been added in #840. This PR adds this output option to the Python examples.
Approach: if
h5py
is installed, output is saved to HDF; ifh5py
is not installed, retain old XML output.Checklist
scons build
&scons test
) and unit tests address code coverageIf applicable, fill in the issue number this pull request is fixing
Fixes: N/A
Changes proposed in this pull request:
h5py
is installedburner_ion_flame.py
example (retainion_burner_flame
)diffusion_flame_batch.py
anddiffusion_flame_extinction.py
Note:
diffusion_flame_extinction.py
appears to be broken (loop does not terminate), see #872