Repository navigation
Conversation
Contributor
Author
|
Some tests from the paper using this PR: U235 test:
He4 test:
|
Contributor
|
Hi @GuySten, @paulromano, just wondering if there’s an estimate for when this might be merged? |
GuySten
force-pushed
the
point-detector
branch
from
September 4, 2026 12:59
91b38ab to
2d5fbb3
Compare
GuySten
marked this pull request as draft
September 10, 2026 18:49
ParticleRay was spelled `public Ray, public Particle`, which required both
Ray and ParticleData to inherit GeometryState virtually so that the two
halves would share one copy. That is paid for by the whole code: a virtual
base means every geometry access through a Particle -- r(), u(), coord(),
material() -- reaches its data through the vtable. Reading coord_[0]
compiled to
movq (%rdi), %rax load vptr
movq -24(%rax), %rax load vbase offset from the vtable
movq 24(%rdi,%rax), %rax only now index coord_
where a plain base needs just `movq 24(%rdi), %rax`. Particle is the hottest
class in the code and this reached every user of it, for the sake of one kind
of ray.
Split the per-flight bookkeeping into RayState, which carries no geometry,
and move the tracing loop into a trace_ray() template explicitly instantiated
for Ray and ParticleRay. Ray becomes a plain `GeometryState, RayState` and
ParticleRay a plain `Particle, RayState`, each reaching GeometryState once,
non-virtually. Sharing the loop through a template rather than a base class
is what removes the need for the two to meet at a common base at all, and it
devirtualizes the on_intersection() and update_distance() hooks for
ParticleRay as a side effect. This also clears the -Wvirtual-move-assign
warning the virtual base produced.
Also here, both consequences of building a ParticleData outside the transport
machinery:
- Default-initialize seeds_ and stream_. init_particle_seeds() is what
normally sets them, and a ParticleRay is built without it, leaving
current_seed() indexing seeds_ with an indeterminate stream_.
- Add ParticleRay::reset(), which re-initializes a ray in place. The buffers
ParticleData's constructor sizes from the loaded model -- the microscopic
cross section caches, the filter matches, the flux derivatives -- come to
tens of kilobytes, so a caller launching many rays wants to reuse one
rather than construct each. Note that init_from_r_u() clears material(),
which is what stops a reused ray from carrying stale cross sections into
its next flight.
Verified by rendering both ray-traced plot types, which drive the same loop
through ProjectionRay and PhongRay: output is byte-identical to before.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WtCexLeoCYmBVQocfBaEG5
GuySten
force-pushed
the
point-detector
branch
from
September 12, 2026 19:20
2162bf6 to
83066b5
Compare
Implement a next-event estimator that scores the flux at fixed points in
space. At every collision -- and at every source emission -- a
deterministic contribution is made to each active detector:
phi = (1/W) * sum_i w_i * p_i(Omega_i) * exp(-tau_i) / R_i^2
where p_i is the scattering PDF evaluated in the direction of the
detector, tau_i is the optical depth along the line of sight, and R_i is
the distance to it. The optical depth is found by launching a ParticleRay
toward the detector and accumulating mean free paths along the flight.
The 1/R^2 kernel is singular at the detector, so each detector carries an
exclusion sphere of radius r0 inside which the estimator is replaced by
its analytic average over the sphere,
<K> = 3 * (1 - exp(-Sigma_t * r0)) / (Sigma_t * r0^3)
evaluated as 3 * exprel(-Sigma_t * r0) / r0^2 to stay accurate as
Sigma_t * r0 -> 0.
The pieces:
- PointFilter (filter_point.{h,cpp}) holds the detector positions and
exclusion radii, and maps a traced ray back to the bins that share
its endpoint. It scores only under the point-detector estimator.
- next_event_scoring.{h,cpp} provides the per-reaction entry points
(elastic, inelastic, fission, S(a,b) and source) and a pool of rays
reused across contributions, guarded by a PointDetectorStream RAII
object that switches the RNG to a dedicated substream so that
scoring cannot perturb the parent random walk.
- tally.{h,cpp} validates the estimator (scores, filters and a
non-vacuum outer boundary), collects the active detectors and sizes
the ray pool.
- physics.cpp and source.cpp call the scoring hooks at each collision
and at emission.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WtCexLeoCYmBVQocfBaEG5
Expose PointFilter in openmc.filter and openmc.lib.filter, and let Tally accept the 'point-detector' estimator. PointFilter takes a sequence of (x, y, z, exclusion_radius) detectors, validates them on construction and round-trips through XML and HDF5 like every other filter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtCexLeoCYmBVQocfBaEG5
Cover PointFilter construction and validation, XML/HDF5 round-tripping, the estimator guards in Tally.scores, and the physics of the estimator itself: a bare point source in a void against the analytic 1/(4 pi R^2), attenuation through a slab, and agreement with a collision-estimator flux tally in a scattering medium. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtCexLeoCYmBVQocfBaEG5
Add the next-event estimator to the methods manual (the estimator itself, the exclusion sphere, and the variance and bias caveats that come with a singular kernel), describe the point filter and the 'point-detector' estimator in the user's guide, and add the filter to the tallies.xml, statepoint and Python API references. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WtCexLeoCYmBVQocfBaEG5
GuySten
force-pushed
the
point-detector
branch
from
September 12, 2026 19:46
83066b5 to
ab7e4cf
Compare
5 tasks done
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
This branch has not been deployed
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 implements point detectors in openmc.
It is based on the work done in #3109 but with classical kinematics.
Currently only continuous energy neutrons are supported.
This PR depends on #3881, #3935.
Checklist