Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print warning if no natural isotopes when using add_element #2926

Closed
aprilnovak opened this issue Mar 28, 2024 · 4 comments · Fixed by #2938
Closed

Print warning if no natural isotopes when using add_element #2926

aprilnovak opened this issue Mar 28, 2024 · 4 comments · Fixed by #2938
Assignees

Comments

@aprilnovak
Copy link
Contributor

Description

When adding nuclides to a material with add_element, OpenMC will silently do nothing if there are no natural nuclides of that element (e.g., plutonium). It would be nice if the user encountered a warning about this, because if the user was trying to do this in the first place they did not realize/recognize that there weren't actually any natural isotopes for that element.

Alternatives

Print a warning if add_element does not add any nuclides.

Compatibility

New feature, better user experience.

@shimwell
Copy link
Member

shimwell commented Mar 30, 2024

Perhaps we could add to the element.expand method that is called by material.add_element. We could add a check here in the expand method to check the length of isotopes found and print a warning if len(isotopes) == 0

perhaps something like

warnings.warn(f'No naturally occurring nuclides were found for element {self.name}')

@cxtherineyu
Copy link
Contributor

Is this issue still open? I'd love to attempt to tackle it.

@shimwell
Copy link
Member

shimwell commented Apr 1, 2024

I think the issue is all yours @cxtherineyu thanks for volunteering

@MicahGale
Copy link
Contributor

MicahGale commented Apr 1, 2024

My quick two cents. A custom Warning class should be defined so warnings can be correctly filtered by the end user instead of just calling Warnings.warn(""). I think maybe something like: NoNaturalIsotopesWarning

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 a pull request may close this issue.

4 participants