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 and wrote unit test #2938

Merged
merged 2 commits into from
Apr 24, 2024

Conversation

cxtherineyu
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, technetium). 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 aren't actually any natural isotopes for that element.

I created a custom Warning class called 'NoNaturalIsotopesWarning' so warnings can be correctly filtered by the end user instead of just calling Warnings.warn("").

I added a check here in the expand method to check the length of nuclides found and print a warning if len(natural_nuclides) == 0.

Fixes # 2926

Checklist

  • I have performed a self-review of my own code
  • I have followed the style guidelines for Python source files (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@shimwell shimwell linked an issue Apr 5, 2024 that may be closed by this pull request
Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @cxtherineyu for this addition! One request regarding the warning:

openmc/element.py Outdated Show resolved Hide resolved
@paulromano paulromano enabled auto-merge (squash) April 24, 2024 18:26
@paulromano paulromano merged commit 3370ce1 into openmc-dev:develop Apr 24, 2024
17 checks passed
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
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.

Print warning if no natural isotopes when using add_element
2 participants