Skip to content

Enable float32 for depletion_results.h5#3896

Open
yrrepy wants to merge 3 commits intoopenmc-dev:developfrom
yrrepy:depletion_results_float32
Open

Enable float32 for depletion_results.h5#3896
yrrepy wants to merge 3 commits intoopenmc-dev:developfrom
yrrepy:depletion_results_float32

Conversation

@yrrepy
Copy link
Contributor

@yrrepy yrrepy commented Mar 22, 2026

Description

This commit enables the user to choose float32 as the dtype for number and reaction rates datasets saved to the depletion_results.h5 file. It is optional and defaults to float64.
integrator.integrate(path='results.h5', write_rates=True, hdf5_dtype='float32')

The intent is to reduce disk space used by depletion files and/or enable greater fidelity in calculations.
Essentially, at fixed file size it allows greater fidelity in the mesh (or reactions or nuclides, etc), in lieu of precision on the reaction rates and atom density.
e.g. for fixed chain, nuclides, timesteps, etc and fixed h5 file size, by going from float64 to float32 a user can now have 200,000 depleted materials instead of 100,000 (or 200,000 mesh voxels instead of 100,000). A significant boon to geometry fidelity.

per Claude;
XS have approx. 0.1-10% uncertainty, these uncertainties mean the underlying physics supports at most 2-4 significant digits. float32 provides ~7 significant digits.

The CRAM solver itself still operates in float64, and a guard has been added for a route that would have allowed float32 to get in.

Eigenvalues, time, source_rate, and depletion_time datasets remain float64 regardless of this setting.

Checklist

  • I have performed a self-review of my own code
  • I have run clang-format (version 18) on any C++ source files (if applicable)
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

yrrepy added 2 commits March 21, 2026 21:49
  Thread hdf5_dtype ('float32' or 'float64', default 'float64') from
  Integrator/SIIntegrator through StepResult.save() to the HDF5 writer.
  Affects only the saved number and reaction rate datasets.
  np.asarray(n0, dtype=np.float64) replaces n0.copy() so the working
  vector is float64 regardless of input dtype. Guards against silent
  precision loss on restart when initial compositions are read from a
  float32 HDF5 dataset
@yrrepy yrrepy requested a review from paulromano as a code owner March 22, 2026 06:32
@yrrepy yrrepy changed the title Enable float32 for depletion_resultsh5 Enable float32 for depletion_results.h5 Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant