Repository navigation
Description
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 siliconOn 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.
- It is now based on the current head of Keep the micro cross section caches addressed correctly openmc-dev/openmc#4131, and the fork branch
upstream-pr-4131was fast-forwarded to match. - Merged with current develop, which includes Annihilate positrons below the positron energy cutoff openmc-dev/openmc#4157 and Skip atomic relaxation emissions below the photon energy cutoff openmc-dev/openmc#4158, it builds cleanly and the validation table matches the original to about 0.1%. Everything is within 0.2% except 10 MeV in high Z elements (Fe and Pb 1.003, W 1.005). That gap is the known reference density of the density effect in the bremsstrahlung tables.
- The PR copies the pair production screening radius lookup
r[Z_], which has an indexing bug (see "Related" below). Whatever index the fix settles on, sampling and the heating cross section must use the same one.
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
- 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.
- Get Keep the micro cross section caches addressed correctly openmc-dev/openmc#4131 reviewed and merged.
- Point Score photon heating from a heating cross section for virtual materials #133 at develop, rebasing again if needed, then delete
upstream-pr-4131. - 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
- Pair production screening radius: still looked up as
r[Z_]instead ofr[Z_ - 1]insrc/photon.cppon develop. The table starts at hydrogen, so every element uses the next element's radius. Not filed yet. This is worth a small upstream PR. Score photon heating from a heating cross section for virtual materials #133 copies the same lookup, so both need the same index. - Material.set_densities rebuilds bremsstrahlung tables from the log energy grid #134:
Material.set_densitiesrebuilds the bremsstrahlung tables from the log energy grid. This affects coupled depletion with photon transport, not D1S. Still open. - Photon weight windows from FW-CADIS: outstanding tasks #147: coupled neutron photon FW-CADIS with random ray. D1S dose behind thick shields needs photon weight windows, and the photon multigroup work that merged since (Add photon multigroup cross section generation openmc-dev/openmc#4073 photon MGXS generation, Adding multigroup photon transport capability in MC mode openmc-dev/openmc#4141 multigroup photon transport) is groundwork for that.
- Workshop notebook: once everything is merged, the neutronics workshop silicon dose notebook (task 9, notebook 7) can drop its NIST mu_en workaround. A D1S version of it would make a good example.
Activity