Skip to content

Preserve user material names in convert_to_multigroup - #110

Open
jon-proximafusion wants to merge 2 commits into
developfrom
convert-mgxs-preserve-material-names
Open

Preserve user material names in convert_to_multigroup#110
jon-proximafusion wants to merge 2 commits into
developfrom
convert-mgxs-preserve-material-names

Conversation

@jon-proximafusion

Copy link
Copy Markdown
Collaborator

Summary

convert_to_multigroup overwrote each material's name with a sanitised, HDF5-safe version, because the name was used both as the key for the material's XSdata entry in the MGXS library and as the macroscopic the material reads back. This silently changed user-assigned names, and two distinct materials whose names collided were written as a single cross section (one overwriting the other).

This keeps material.name untouched and instead keys the library by a separate name + id string (sanitised to alphanumeric/underscore; unique because the material ID is unique). The macroscopic reads its data under that library name. As a result:

  • user material names are preserved (a material with no name stays unnamed),
  • distinct materials that share a name no longer collapse — each gets its own cross section.

Verified end-to-end: a model with two distinct same-named materials converts and runs in multigroup mode, the library containing one entry per material.

Tests

Added a unit test asserting names are preserved and same-named materials map to distinct library entries.

convert_to_multigroup overwrote each material's name with a sanitised,
HDF5-safe version, because the name is used as the key for the material's
XSdata entry in the MGXS library and for the macroscopic that reads it back.
This silently changed user-assigned names, and two distinct materials whose
names collided were written as a single cross section (one overwriting the
other).

Use a unique library name (the sanitised name plus the material ID) for the
library entry and macroscopic, then restore each material's original name at
the end, so the user's names are preserved and same-named materials no longer
collapse.
@jon-proximafusion
jon-proximafusion force-pushed the convert-mgxs-preserve-material-names branch 3 times, most recently from 34498bd to 75699d4 Compare June 25, 2026 16:32
convert_to_multigroup now keeps the user's original material name in the
exported materials.xml and keys each macroscopic / MGXS-library entry by
sanitize(name) + "_{id}". Regenerate the inputs_true.dat references for the
random_ray_auto_convert* and random_ray_diagonal_stabilization tests to match.
Only dataset labels change; the MGXS values and results are unaffected.
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.

2 participants