Creating a new HDF5 nuclear data library for UQ#3911
Draft
Grego01-biot wants to merge 31 commits intoopenmc-dev:developfrom
Draft
Creating a new HDF5 nuclear data library for UQ#3911Grego01-biot wants to merge 31 commits intoopenmc-dev:developfrom
Grego01-biot wants to merge 31 commits intoopenmc-dev:developfrom
Conversation
…hrough HDF5 files
…cross_section_sampling
…cross_section_sampling
added 2 commits
April 15, 2026 18:31
…rrelations and addition of diagnostics before storing the matrices
…d adding tests to check the safeguards for self-covariance matrices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The goal of this PR is to create a new HDF5 nuclear data library with covariance data stored in that would live on the OpenMC nuclear data libraries page. This is only the HDF5 data storage part with no modifications to the C++ source code. The final goal would be to have the capability to perform on-the-fly cross section sampling using the stored data in HDF5 format. Another draft PR will be added shortly to openmc-dev/data repository in order to have the capability to generate the entire nuclear data library with MF=33 evaluations.
Python API addition
In order to do so, two new Python files are created and added to openmc/data:
mf33_njoy.py is a minimal driver that runs ERRORR module from NJOY to produce multigroup relative covariance matrices from an ENDF-6 evaluation. The user provides an explicit energy grid (group boundaries in eV) and optionally a weight spectrum used to produce multi-group cross sections. The output is the raw ERRORR tape33 text.
xs_covariance_njoy.py is where the data model, ENDF text parser, covariance factorization. The key class is
NeutronXSCovariances, which holds parsed MF=33 covariance matrices and their lower-triangular factors. It provides the capability to read/write to HDF5 files and to write/read MF33 sub-tree inside an existing HDF5 group (used byIncidentNeutron).neutron.py is modified to add an
mg_covarianceproperty onIncidentNeutronand write covariance data inexport_to_hdf5()under/<nuclide>/covariance/mf33/. It also can read covariance data back infrom_hdf5().The idea is to start by generating multigroup covariance matrices for MF33 using ERRORR module from NJOY, parsing output tape33, storing the covariance data, the temperature, the type of covariance (relative or absolute), the energy grids and the reactions number.
HDF5 storage strategy
It is important to consider two types of covariance data:
It is important to note that the assembly and joint eigendecomposition of the full joint covariance matrix are deferred to OpenMC's preprocessing step, where the user can decide which reactions to jointly sample. The idea is that before transport, the code will assemble the full joint covariance matrix for all requested reactions and store the eigendecomposition in memory for sampling purposes.
HDF5 layout
Covariance data is stored under
/nuclide/covariance/mf33/.The group carries metadata as attributes: a format string, a flag indicating relative covariances, the MAT number, and the processing temperature. Two datasets sit at the top level:energy_grid_evholding the G+1 group boundaries in eV, and mts listing the MT numbers that have covariance data. Below that, two sub-groups organize the actual matrices. Thereactions/sub-group stores raw covariance matrices as (G, G) datasets indexed by{mt}/{mt1}(includes all cross-correlations). Thefactors/sub-group stores the lower-triangular factors L as (G, r) datasets, also indexed by{mt}/{mt1}, for self-correlations only.This capability enables two UQ workflows within OpenMC: sensitivity analysis via the sandwich rule, and direct cross-section sampling via the Total Monte Carlo approach (similar to SANDY). It would also allow users to generate and store their own multigroup covariance data by providing a precomputed flux spectrum as input to NJOY and selecting the desired output energy grid (the lower energy bound cannot be 0 eV due to ERRORR and resolved resonance region treatment irespr = 1). For now, the strategy is to use the SCALE energy group structure with 252 energy groups. The data structure described here is a starting point — feedback on the schema and storage layout is more than welcome!
Here is an example of the code used to generate the new HDF5 file for Fe56.h5 using 1500 energy groups:
It is important to note that the code needs modularity to account for the tolerance used in NJOY, the dilution cross section used for the multigroup covariance generation and the combination or not of MF32 and MF33. For this PR, MF=31, MF=34 and MF=35 are not considered for storage in the HDF5.
Fixes # (issue)
Checklist
I have run clang-format (version 18) on any C++ source files (if applicable)