Skip to content

D1S decay photon dose to a virtual material: the PRs needed and why #137

Open

Description

@shimwell

Goal

Run a D1S shutdown dose calculation in OpenMC and tally the decay photon dose to a virtual material, for example silicon electronics behind shielding, without putting silicon in the model. The tally should look like the neutron virtual material workflow:

silicon = openmc.Material()
silicon.add_element('Si', 1.0)
silicon.set_density('g/cm3', 2.329)

model.settings.photon_transport = True
model.settings.use_decay_photons = True

dose = openmc.Tally()
dose.filters = [openmc.CellFilter(detector), openmc.ParticleFilter('photon')]
dose.nuclides = silicon.get_nuclides()
dose.scores = ['heating']
dose.multiply_density = False
model.tallies = [dose]

nuclides = d1s.prepare_tallies(model)        # adds a ParentNuclideFilter
model.run()                                   # with photon weight windows

tcf = d1s.time_correction_factors(nuclides, timesteps, source_rates)
result = d1s.apply_time_correction(tally, tcf)
result.apply_virtual_material(silicon)        # eV/s deposited in silicon

On develop every step of this either fails or gives a wrong answer. Four PRs fix it, each one a different step in the chain.

Status (2 Dec 2026)

Nothing has merged yet. Two of the four PRs are now upstream. Develop still has each bug they fix.

PR Fixes State Next step
openmc-dev#4131 photon micro cross section caches Open upstream. Changes requested, waiting for maintainer review Ask for the review
#133 photon heating cross section for virtual materials Open on fork. Rebased onto the current head of openmc-dev#4131 on 30 Nov and checked again against current develop Point at develop once openmc-dev#4131 merges
openmc-dev#4262 (was fork #135) parent nuclide kept on split and secondary particles Open upstream. CI passes, waiting for review Get it reviewed
#136 apply_virtual_material on derived tallies Open on fork. Merges cleanly Open upstream now
openmc-dev/openmc#4131  ──►  #133  ──┐
#4262 ───────────────────────────────┼──►  D1S decay photon dose in virtual silicon
#136  ───────────────────────────────┘

The PRs

openmc-dev#4131 (upstream, by GuySten): photon micro cross section caches

Problem. Photon micro cross sections are cached per element, but tally scoring looked them up by nuclide index. For a nuclide absent from the cell, only the neutron cache was refreshed. As a result:

  • any photon tally with nuclide bins read another element's data, or memory past the end of the cache (negative values and numbers like 1e174 on develop);
  • an absent element was scored at a stale energy (48 times too high in one test).

Why the workflow needs it. The virtual material tally scores silicon nuclide bins in cells that contain no silicon, which is exactly the case these bugs break.

Changes since the issue was opened.

  • GuySten fixed the NaN (log of zero) that the extended test found with the collision estimator.
  • The code review suggestions were applied.
  • A test now checks that an absent element is refreshed, with both the tracklength and collision estimators.
  • The PR was brought up to date with develop and still merges cleanly.

Still outstanding.

  • Paul Romano marked it "changes requested" on 6 Oct, with the note "I'd like to review this one when I have a chance". He hasn't reviewed it since.
  • On 17 Nov idingkai reported a segfault in Nuclide::calculate_xs. GuySten asked for a separate issue with a reproducer, and it isn't clear the segfault comes from this PR.

This also covers the photon half of #96 (photon micro cross section tallies in void materials). #96 can be closed when openmc-dev#4131 merges.

#133: score photon heating from a heating cross section

Problem. Photon heating is scored from the energy balance of each collision and credited to the element that was struck. With multiply_density=False:

  • a silicon bin scores zero wherever there is no silicon;
  • where silicon is present, the density is already included.

So apply_virtual_material gives the wrong answer either way.

Fix. At startup the PR computes a photon heating cross section for each element: the expected value of that same energy balance. These tallies then score flux times that cross section, as neutron heating does with KERMA coefficients. In October it agreed with energy balance heating to within 0.5% for C, Si, Fe, W and Pb from 20 keV to 10 MeV.

Why the workflow needs it. Without it there is no way to get the photon dose in a material that is not in the model.

Rebased and checked again (30 Nov). Details are in the PR comment.

openmc-dev#4262 (was fork #135): keep the parent nuclide on split and secondary particles

Problem. D1S tags each decay photon with the radionuclide that emitted it, and ParentNuclideFilter bins tallies by that tag so time correction factors can be applied per radionuclide. On develop, Particle::split and Particle::create_secondary still don't copy the tag. So these photons drop out of every tally filtered by parent nuclide:

  • photons split by weight windows;
  • photons created by decay photons (fluorescence, bremsstrahlung, annihilation).

In a steel shell model (14 MeV source, photon flux tally, script in openmc-dev#4262), the tally filtered on all parent nuclides came out about 11% low with photon weight windows, and about 1.6% low without them. How much is lost depends on how much the windows split, so real weight windows could lose much more.

Why the workflow needs it. Real shutdown dose problems need weight windows, and prepare_tallies puts a ParentNuclideFilter on the dose tally.

It is independent of the other PRs: two lines in src/particle.cpp plus a test. It also fixes the per parent nuclide breakdown in R2S. It affects every D1S and R2S user who runs with weight windows, which is why it went upstream on its own.

#136: allow apply_virtual_material on derived tallies

Problem. With the default sum_nuclides=True, apply_time_correction returns a derived tally that has only a mean and standard deviation. apply_virtual_material then raised "the tally does not contain any results" (it still does on develop). Applying the material before the time correction did work, so the result depended on call order.

Fix. For these tallies the PR scales the mean and standard deviation directly. Both orders now give identical results.

Why the workflow needs it. The workflow above calls the two in that order. It is independent of the other PRs and can go upstream now.

Merge plan

  1. Get Keep the parent nuclide on split and secondary particles openmc-dev/openmc#4262 reviewed and merged, and open Allow apply_virtual_material on derived tallies #136 upstream. Neither depends on anything else.
  2. Get Keep the micro cross section caches addressed correctly openmc-dev/openmc#4131 reviewed and merged.
  3. Point Score photon heating from a heating cross section for virtual materials #133 at develop, rebasing again if needed, then delete upstream-pr-4131.
  4. Run the end to end check again on the steel shell model with the 14 MeV source. In October, with all four PRs applied, the silicon dose came out the same:
    • with and without the parent nuclide filter;
    • with and without weight windows;
    • in either post processing order.

Related, not needed for this goal

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions