Fix convert mgxs to avoid duplicate material names bug#3982
Closed
jon-proximafusion wants to merge 2 commits into
Closed
Fix convert mgxs to avoid duplicate material names bug#3982jon-proximafusion wants to merge 2 commits into
jon-proximafusion wants to merge 2 commits into
Conversation
convert_to_multigroup generates one MGXS per material, keyed by material name. Two distinct materials that share a name (for example the same-named clones from Model.differentiate_mats(), since Material.clone() preserves the name) cannot be written as separate cross sections -- one would silently overwrite the other, dropping a material's data. Names are also sanitised to alphanumeric plus underscore, which can make otherwise distinct names collide. Raise a ValueError instead of silently producing an incorrect library, leaving user-assigned names unchanged.
Member
|
closing as we can make a unique name for all materials |
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
Model.convert_to_multigroup()generates one MGXS per material, keyed by material name. Two distinct materials that share a name would be silently written as a single cross section — one material's data overwrites the other's, dropping a material. This is easy to hit becauseMaterial.clone()(used byModel.differentiate_mats()) preserves the original name, and because names are sanitised to alphanumeric + underscore, which can make otherwise-distinct names collide.Conversion now raises a
ValueErrorinstead of silently producing an incorrect library; material names are left unchanged. The per-material granularity is also noted in theconvert_to_multigroupdocstring.Tests
Added a unit test asserting that two distinct materials sharing a name raise
ValueError.Checklist