Preserve user material names in convert_to_multigroup#3984
Open
shimwell wants to merge 1 commit into
Open
Conversation
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.
34498bd to
75699d4
Compare
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.
Summary
convert_to_multigroupoverwrote each material'snamewith a sanitised, HDF5-safe version, because the name was used both as the key for the material'sXSdataentry 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.nameuntouched and instead keys the library by a separatename + idstring (sanitised to alphanumeric/underscore; unique because the material ID is unique). The macroscopic reads its data under that library name. As a result: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.
Checklist