Skip to content

Allow apply_virtual_material on derived tallies - #136

Open
shimwell wants to merge 1 commit into
developfrom
virtual-material-derived-tallies
Open

shimwell wants to merge 1 commit into
developfrom
virtual-material-derived-tallies

Conversation

@shimwell

@shimwell shimwell commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Description

For a D1S decay photon dose in a virtual material the natural sequence is to sum the time corrected tally over parent nuclides and then apply the material:

summed = d1s.apply_time_correction(tally, factors)   # sum_nuclides=True
summed.apply_virtual_material(silicon)

The summed tally is derived and only holds a mean and standard deviation (sum/sum_sq are dropped since they cannot be combined across parent nuclides), so apply_virtual_material raised Unable to apply a virtual material since the tally does not contain any results, which reads as if the run produced nothing. Applying the material first worked, so the result depended on call order.

For a derived tally with no raw moments the mean and standard deviation are now scaled by the atom densities directly. This is the same answer as scaling the raw moments: checked on a D1S statepoint (steel shell, silicon dose, 37 parent nuclides), both orders now give identical means and standard deviations. Tallies with no results at all still raise the same error.

Test

test_apply_virtual_material_to_derived_tally builds a derived copy of the existing virtual material test tally, applies the material and checks it against scaling the raw moments.

Checklist

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

apply_time_correction with sum_nuclides=True returns a derived tally that
only holds a mean and standard deviation, so applying a virtual material
afterwards failed with "the tally does not contain any results". For such
tallies the mean and standard deviation are now scaled directly, which
gives the same result as scaling the raw moments first.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

1 participant