Testing point detectors#3757
Draft
GuySten wants to merge 143 commits intoopenmc-dev:developfrom
Draft
Conversation
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Co-authored-by: GuySten <62616591+GuySten@users.noreply.github.com>
Three bugs prevented point detector tallies from producing any results: 1. setup_active_tallies() had no case for TallyType::POINT, so active_point_tallies and active_point_detectors were never populated. All scoring hooks guarded by 'if (!active_point_tallies.empty())' silently skipped every event. 2. score_point_tally_impl() did not set ParticleRay position/energy state before calling score_tracklength_tally_general(). PointFilter requires p.r() == detector position and EnergyFilter reads p.E_last(), both of which were uninitialized/wrong after Ray::trace(). 3. openmc_statepoint_write() had no branch for TallyEstimator::NEXT_EVENT, so the 'estimator' dataset was missing from the HDF5 output, causing Python StatePoint reader to crash with KeyError. Fixes: - Add TallyType::POINT case in setup_active_tallies() that pushes to active_point_tallies and inserts detector positions from PointFilter. - Add corresponding clear() calls in setup_active_tallies() and free_memory_tally(). - Include filter_point.h in tally.cpp. - Set p.r(), p.r_last(), and p.E_last() on the ParticleRay before scoring. - Write 'next-event' estimator string in statepoint for NEXT_EVENT tallies. Verified with smoke tests: water sphere with point detectors produces non-zero flux, 1/r^2 scaling matches analytical expectation within 2%, and symmetric detectors yield statistically consistent results.
…type PointFilter lacked from_hdf5() and get_pandas_dataframe() overrides. The base Filter.from_hdf5() passed a flat numpy array to PointFilter.__init__ which expects Sequence[tuple], causing TypeError. The base get_pandas_dataframe() used np.repeat on the nested tuple structure, causing ValueError. Also add 'next-event' to ESTIMATOR_TYPES so the Tally.estimator setter accepts the value read from statepoint files. Fixes: - Add PointFilter.from_hdf5() that reconstructs (pos, r0) tuples from flat HDF5 bins array. - Add PointFilter.get_pandas_dataframe() that formats detector positions as readable string labels. - Add 'next-event' to ESTIMATOR_TYPES set in tallies.py.
Fix point detector scoring: activate tallies, set ParticleRay state, fix Python reader
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 free
to 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.
Description
This PR is a draft.
It is used to test the functionality in PR #3550 in a classical (non-relativistic) way.
Checklist