Skip to content

Preserve depletion-chain source metadata through XML conversion - #4147

Open
JROChub wants to merge 1 commit into
openmc-dev:developfrom
JROChub:depletion-chain-source-metadata
Open

JROChub wants to merge 1 commit into
openmc-dev:developfrom
JROChub:depletion-chain-source-metadata

Conversation

@JROChub

@JROChub JROChub commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

This adds component-specific source metadata to depletion-chain construction and XML persistence, following the chain-file request in #4075.

Chain.source_metadata retains separate neutron, decay, and fission-yield records from the existing ENDF evaluation.info['library'] tuple. Each component can contain multiple distinct library/version/release records; a mixed collection is not collapsed to one library label.

The proposed XML layout is an optional root-level <source_metadata> element containing <source component="..." library="..." version="..." release="..."/> entries. Existing nuclide records are unchanged, and files without metadata still load with an empty dictionary. Reduction retains an independent copy of the original construction records. Invalid metadata is rejected before opening an output file.

These records describe chain-construction inputs, not the transport library used for reaction rates or a complete processing history. This is separate from photon HDF5 PR #4117, the general HDF5 metadata proposal #3257, and the release-tool provenance work discussed in openmc-dev/data#101. The guide documents that distinction and includes a save/reload/inspect example.

Validation

Tested with Python 3.13.12, official NNDC ENDF/B-VII.1 neutron/decay/fission-yield files, and a real strict-FP OpenMC shared library. The targeted suite covers filename, Evaluation, and endf.Material inputs; single-pass parsing; mixed and missing sources; deterministic XML; legacy compatibility; reduction without shared mutable records; invalid-input protection; and adjacent decay/yield/reaction behavior.

With OPENMC_ENDF_DATA pointing to the extracted ENDF/B-VII.1 files:

env -u READTHEDOCS OMP_NUM_THREADS=2 python -m pytest \
  tests/unit_tests/test_deplete_chain.py \
  tests/unit_tests/test_data_decay.py \
  tests/unit_tests/test_deplete_nuclide.py \
  tests/unit_tests/test_deplete_reaction.py \
  tests/unit_tests/test_deplete_decay.py -q

Actual output:

70 passed, 8 warnings in 49.87s

The warnings are Python 3.13 multiprocessing/fork deprecations in the existing depletion tests. OPENMC_CROSS_SECTIONS was unset, producing the usual environment warning; this run did not perform neutron transport. The reused native library was built from 5260b9a0fc51f3f312024c425a5c1c227f8ba555 with strict FP enabled; the openmc.lib bindings are unchanged between that revision and this PR's base.

Full Sphinx HTML builds completed for both upstream and patched documentation. After fixing a heading underline and the new property's API anchor, a warnings-as-errors rebuild of the affected pages passed with no warnings. The full baseline's missing-Doxygen and parallel-extension warnings were unchanged. git diff --check also passes.

The full chain was also constructed independently with the unmodified develop implementation at ef49d52c2afb43f4064d1407c1477529bb2d4eb0 and this patch using identical inputs: 3,821 decay, 31 fission-yield, and 423 neutron evaluations. Both produced 3,820 nuclides. With only the optional metadata omitted, the serialized numerical/structural payloads were byte-identical:

bytes:  27638507
SHA256: 1ec982b32924a40cc6b987392aaecabc1c82945489d0aab8891037cdf0968d21

The downloaded neutron collection itself contains several library labels in its ENDF headers, so preserving multiple records is necessary even for this test bundle. Labels, including Unknown, are retained as reported by the existing parser rather than inferred from the archive name.

For example, after reloading the generated full-chain XML:

chain = openmc.deplete.Chain.from_xml("chain.xml")
chain.source_metadata["fission_yield"]
# [{'library': 'ENDF/B', 'version': 7, 'release': 1}]
[record["library"] for record in chain.source_metadata["decay"]]
# ['ENDF/B', 'JEFF', 'Unknown']

Related to #4075.

This branch has not been deployed

No deployments
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