Open kkiesling opened 1 year ago
We discussed this issue in the OpenMC Monthly Drop-in and came up with a few solutions to address the inconsistencies or at least notify users of possible inconsistencies.
add_element
is called but no cross section library is present OR if the attribute is set later and it differs from the environment variable. There are probably a few options to trigger the warning but a warning should be added regardless I think.I think implementing option 1 is best for consistency but probably not doable for me personally in the near term, but at least implementing the warning will be helpful for other users.
At this point I would say that using Materials.cross_sections is not recommended. Once we introduced the openmc.config
variable for setting data sources, it provided a better way of indicating data without the need for environment variables. Moving forward, I suggest that we deprecate and then eventually remove the option to set Materials.cross_sections
.
I noticed a discrepancy in how
add_element()
is handled depending on how the cross sections path is set. This became apparent with specifically adding elemental carbon and using the ENDF/B-7.1 data. When using theMaterial.cross_sections
property to set the XS path, carbon is expanded into C12 and C13 first, which causes an error with ENDF/B-7.1 when running (ERROR: Could not find nuclide C12 in the nuclear data library.
). In the case where the XS path is set as an environment variable first (OPENMC_CROSS_SECTIONS
), it is not expanded into the individual nuclides and instead added asC0
(which is how 7.1 handles this nuclide). Adding the nuclide asC0
seems to be fine.I can understand why this treatment differs, but ideally, the treatment of the elemental carbon would be handled identically regardless of how and when the XS library is set.
Here are some example scripts/steps that can be run to generate the
materials.xml
file to view this difference:Using OPENMC_CROSS_SECTIONS environment variable
Script:
bash:
Python script:
XML output:
materials_env_eleC.xml
(adding elemental carbon):materials_env_c0.xml
(adding nuclide C0):setting
Materials.cross_sections
before exportingScript:
bash:
Python script:
XML output:
materials_withpath_eleC.xml
(adding elemental carbon): This behavior to expand the element when it is is added makes sense to me and I think should be the behavior regardless of how the XS path is set, even though it causes an error when running later.materials_withpath_c0.xml
(adding nuclide C0):Like I said, I understand why this is happening- in the case where the XS path is set as an environment variable, the knowledge of how elemental carbon should be handled for this particular data library is known. Whereas in the case where it is set as a materials attribute, that info on how to handle it isn't available. I don't know if this happens with other nuclides/elements too.
Ideally,
add_element('C')
would be how it expands the nuclides, regardless of how and when the cross sections are set. IMO the correct handling to expand all elements into the individual nuclides, like is done for thematerials_withpath_eleC.xml
file (meaningmaterials_env_eleC.xml
shows the "incorrect" handling even though this file is what ultimately works for running).