Skip to content

OpenMC-only R2S Transport & Depletion #30

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

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

anu1217
Copy link
Contributor

@anu1217 anu1217 commented May 29, 2025

This PR contains a script that performs all the necessary R2S physics steps using only OpenMC. It works as intended for the model with W and C spherical shells, and works with some modifications for the HCPB model. The latter may also require some variance reduction that could be hard-coded into the script, or perhaps selected using argparse.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Thanks @anu1217 - just one high-level comment on reusing the code in the OpenMC input file that relies on ALARA

Copy link
Member

Choose a reason for hiding this comment

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

This has a lot of overlap with the OpenMC input file that relies on ALARA for activation. Do you think we can combine them somehow or reuse the pieces. A major reason to do so will be to guarantee that we are actually solving the same problem in both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be fairly straightforward to combine them. I imagine some new argparse options and/or methods will take care of the choice of sources used for photon transport...will commit these changes shortly.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

I've left several final (?) comments. We can probably move on from here to start focusing on comparing results.

)
return photon_model

def run_depletion(inputs, neutron_model):
Copy link
Member

Choose a reason for hiding this comment

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

Can we combine this with deplete_wc? The only thing this does differently is unpack the inputs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can unpack inputs in main() instead

args = parser.parse_args()
return args

def read_yaml(args):
Copy link
Member

Choose a reason for hiding this comment

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

This might make more sense if you just pass in the arg with the filename than all the args

inputs = yaml.safe_load(transport_file)
return inputs

def create_materials_obj(inputs):
Copy link
Member

Choose a reason for hiding this comment

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

(apologies if this is contradicting earlier advice, but...)
This can probably be combined with make_materials() since it doesn't do much other than get the densities first.


else:
photon_source = openmc.IndependentSource(
energy = openmc.stats.Discrete(0, 1.0),
Copy link
Member

Choose a reason for hiding this comment

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

For consistency, make this energy = None like above, maybe?

Comment on lines +199 to +201
if str(mat.id) in activated_mats_list :
mat = results[-1].get_material(str(mat.id))
energy = mat.get_decay_photon_energy()
Copy link
Member

Choose a reason for hiding this comment

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

This might be a good place for a little function

energy = get_decay_photon_energies(mat, results[-1])

if args.neutron_transport == True:
neutron_model.tallies = make_neutron_tallies(inputs['filename_dict']['mesh_file'])
neutron_model.export_to_model_xml("neutron_model.xml")
else:
Copy link
Member

Choose a reason for hiding this comment

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

It seems as though args.neutron_transport == False is treated the same as args.photon_transport == True in this case, even though you don't actually check args.photon_transport.

I guess a bunch of this logic is kind of vague here. It might be useful to rethink this so that it's a little more clear...

Copy link
Member

Choose a reason for hiding this comment

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

It might even make sense to have a pyne_r2s function and an openmc_r2s function where each tackles the neutron/photon steps as necessary.

num_cooling_steps = (inputs['dep_params']['source_rates']).count(0)
photon_model = make_openmc_photon_sources(num_cooling_steps, activation_mats, unstructured_mesh, neutron_model, inputs)

photon_tallies = make_photon_tallies(inputs['coeff_geom'], photon_model, num_cooling_steps)
Copy link
Member

Choose a reason for hiding this comment

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

Do you ever write this photon model to an XML file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this happens towards the end of the make_photon_tallies() function

if args.pyne_r2s == True:
if args.neutron_transport == True:
neutron_model.tallies = make_neutron_tallies(inputs['filename_dict']['mesh_file'])
neutron_model.export_to_model_xml("neutron_model.xml")
Copy link
Member

Choose a reason for hiding this comment

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

Can't you also run OpenMC directly from here?

@anu1217 anu1217 marked this pull request as draft July 14, 2025 16:38
anu1217 added 2 commits July 14, 2025 11:56
- Generalize make_settings() to take source as input instead of neutron_source
- Call make_settings() twice to assign neutron settings and photon settings separately
- Rearrange some .export_to_model_xml() calls
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.

2 participants