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

Determine nuclides correctly for DAGMC models in d1s.get_radionuclides #3335

Merged
merged 10 commits into from
Mar 6, 2025

Conversation

SteSeg
Copy link
Contributor

@SteSeg SteSeg commented Mar 3, 2025

Description

While trying to run a d1s simulation on a DAGMC model @eepeterson and I noticed that the model.geometry.get_all_nuclides() method used in get_radionuclides() of d1s.py does not return any nuclide list in the case of a DAGMCUniverse model. We figured it would be useful to add get_all_materials() and get_all_nuclides() directly in the openmc.Model class that can get such info in both csg an dagmc geometries.

If such methods should not be in the Model class, a quick workaround, directly in d1s.py, that would work would be:

# Determine what nuclides appear in the model
model_nuclides = set(model.geometry.get_all_nuclides())

if not model_nuclides:
    model_nuclides = model.materials.get_nuclides()

Also, it seems that as it is now, the get_radionuclides() method does not take into account the naturally occurring radioactive nuclides, which causes an error in a d1s run if model.materials have such nuclides. So we added the capability of including naturally occurring radionuclides with:

# Add naturally occuring radionuclides
if nuclide.half_life is not None:
    radionuclides.add(nuclide.name)

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@SteSeg SteSeg requested a review from paulromano as a code owner March 3, 2025 21:43
@paulromano paulromano added this to the v0.15.1 milestone Mar 4, 2025
@paulromano
Copy link
Contributor

Also, it seems that as it is now, the get_radionuclides() method does not take into account the naturally occurring radioactive nuclides, which causes an error in a d1s run if model.materials have such nuclides.

@SteSeg Can you describe what the error is that you run into in this situation? Even if a radionuclide were present in the original material composition, the only way for it to make a contribution to the decay photon flux is if it is produced by a neutron reaction in which case it will get added during get_radionuclides anyway.

@SteSeg
Copy link
Contributor Author

SteSeg commented Mar 6, 2025

Also, it seems that as it is now, the get_radionuclides() method does not take into account the naturally occurring radioactive nuclides, which causes an error in a d1s run if model.materials have such nuclides.

@SteSeg Can you describe what the error is that you run into in this situation? Even if a radionuclide were present in the original material composition, the only way for it to make a contribution to the decay photon flux is if it is produced by a neutron reaction in which case it will get added during get_radionuclides anyway.

It was an error that came up when calling either the d1s.time_correction_factors() or d1s.apply_time_correction() method (I don't remember). It was giving back just the name of the nuclide (Ca48 in my case). But I tried to reproduce it commenting out the two lines that included the naturally occurring radionuclides (that I though would solve the issue) but apparently the error is not raised anyways (or anymore). So I just removed those lines right now.

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.

@SteSeg For now, I'd prefer not to add new methods to Model. I think we need an overall better strategy for dealing with DAGMC and CSG models consistently and adding more methods just adds more technical debt. I've made a change on your branch taking advantage of the _materials_by_id property and this should fix the problem with DAMC models for now.

@paulromano paulromano changed the title get_all_materials() & get_all_nuclides() in openmc.Model for d1s in DAGMC universes Determine nuclides correctly for DAGMC models in d1s.get_radionuclides Mar 6, 2025
@paulromano paulromano enabled auto-merge (squash) March 6, 2025 19:42
@pshriwise
Copy link
Contributor

pshriwise commented Mar 6, 2025

@SteSeg if you do need to get DAGMC cells and their materials, I'd have a look at the Model.sync_dagmc_universes capability. Note it requires one to initialize the model with Model.init_lib first. Once this is called, the Geometry.get_all_materials/cells calls should work more naturally I believe.

@paulromano paulromano merged commit 9bfce4e into openmc-dev:develop Mar 6, 2025
14 checks passed
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.

3 participants