Uh oh!
There was an error while loading. Please reload this page.
Fix MaterialFromFilter dropping scores after the first collision in a cell - #4090
Open
GuySten wants to merge 2 commits into
Open
Fix MaterialFromFilter dropping scores after the first collision in a cell#4090GuySten wants to merge 2 commits into
GuySten wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix MaterialFromFilter dropping scores after the first collision in a cell
This changes volumetric
MaterialFromFilterresults. Tallies using it werepreviously missing scores; they will now be larger. Cell-to-cell partial
currents (a
fluxscore with this filter) are unaffected. See below for why.Problem
material_lastwas doing two unrelated jobs:MaterialFromFilter, andevent_calculate_xs().Because a particle's energy changes at every collision,
event_collide()forceda cache miss by setting
material_last() = C_NONE. From the second collision ina cell onward the particle therefore carried
material_last == C_NONE, whichmatches no filter bin, so those scores silently vanished from volumetric
MaterialFromFiltertallies. Cell-to-cell partial currents (afluxscore withone of these filters) are scored at the crossing itself, where the previous
material was still correct, and were not affected.
cell_lastis not reset on collision, so the equivalentCellFromFiltertallycounted those scores, and the two decompositions of the same score disagreed.
The effect is largest where it is least visible: a thick, scattering-dominated
cell loses nearly everything after the first collision.
MWE
Changes
material_lastis renamed tomaterial_xs_cache, which is what it actuallyis. It is written in exactly the same places as before, so cross section
caching behaviour is unchanged.
MaterialFromFilternow derives the material fromcell_lastat the lowestcoordinate level instead of tracking it separately. The two "from" filters
read one source of truth and cannot drift apart again.
cell_instance_last, maintained on the same cadence ascell_last. Acell with distributed materials resolves a different material per instance, so
the cell index alone does not determine which material a particle came from.
cell_last,cell_instance_lastandmaterial_xs_cacheon their accessors, including that the first two aredeliberately not updated on collision and that the last must never be used as
a tally attribute.
This deliberately leaves
event_calculate_xs()alone. Rerouting the cache keywas the alternative; deriving the material instead means there is no cross
section behaviour to re-verify.
Testing
tests/unit_tests/test_filter_material_from.py:decompositions are the same partition. Asserts both sum to the undecomposed
total and agree bin for bin. The material sum falls well short of the total
before this change.
asserting all four "from" bins are populated. Resolving the fill without the
instance would put the whole total in the first bin.
fluxscore), asserting the material and celldecompositions still agree.
cell_lastandcell_instance_lastare saved atthe top of
event_cross_surface(), before the crossing, so the derived filtersees the same thing the tracked attribute used to.
Both are per-history identities within a single run, so they hold to round-off
rather than statistically.
tests/regression_tests/surface_tallyusesMaterialFromFilterwith afluxscore, which makes it a partial current rather than a volumetric tally, so its
stored results should be unchanged. A unit test covers that path so the change
is shown not to regress it.
Notes
material_lastwas stale at birth as well: a fresh particle inherited whateverthe reused
Particleobject last held, sincefind_cell()writes thepre-existing material before overwriting it. Deriving from
cell_last, which isinitialised to the particle's own cells at birth, removes that too.
This is the
material_lastportion of #3849, split out as suggested in reviewthere. It does not change
cell_lastsemantics.Checklist