qbnd/qsim: carry source-medium matline across CSG sibling-pair faces#346
Open
ggalgoczi wants to merge 3 commits into
Open
qbnd/qsim: carry source-medium matline across CSG sibling-pair faces#346ggalgoczi wants to merge 3 commits into
ggalgoczi wants to merge 3 commits into
Conversation
GBndLib does not enumerate boundary entries for CSG sibling-pair faces (two daughters of one parent sharing a face), so OptiX can pick a boundary whose m1/m2 do not reference the photon's current medium -> absorption/scattering sampled in the wrong material1. Carry the photon's matline (seeded from the genstep at birth in CSGOptiX7.cu, updated each propagate_at_boundary) in sctx::current_matline and use it as m1 in qbnd::fill_state when valid. No-op for correctly-enumerated boundaries (carried == the boundary's own m1_line).
15e0da7 to
6f9d9bd
Compare
…dent faces At a face shared by two sibling primitives (segmented radiator bars + glue, multi-layer CSG lens) OptiX sorts the two coplanar intersections inconsistently; the "exiting" hit (cosI>0) carries the parent medium as m2, wrong for a sibling crossing. Bias the t reported to OptiX's closest-hit sort by +10 um on the exit side so the entering sibling wins. The real unbiased distance is preserved in the PRD, so photon position advancement is unperturbed. Gate the bias per boundary by index contrast |n_m1 - n_m2| > 0.1 (max over wavelength), computed at translation in CSGOptiX::initSimulate from the bnd table and read in __intersection__is. High-contrast faces (e.g. quartz/air ~0.47) need the entering-sibling selection; low-contrast thin gaps (e.g. aerogel/air ~0.025) are harmed by it and gate off. No per-detector hardcode; nullptr => always-on fallback. Stacks on the matline-carry m1 fix (carry source-medium matline across CSG sibling-pair faces): that fixes *which material* m1 is sampled; this fixes *which face* OptiX selects. The two are complementary - on a TIR light-guide either alone collapses the GPU hit count. Verified ePIC hpDIRC mu- 3 GeV: GPU/CPU 0.987, bit-identical to the ungated bias (all glued-sibling faces clear the 0.1 threshold). Low-index-contrast detectors are unaffected (gate stays off at their thin gaps).
Contributor
Cpp-Linter Report
|
a212e4c to
325e81f
Compare
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.
Two CSG sibling primitives sharing a coincident face (daughters of one parent: segmented radiator bars + glue, or the coincident surfaces of a multi-layer lens) are not enumerated as a boundary by GBndLib, so OptiX mishandles them two independent ways — wrong material and wrong face. This PR fixes both.
Wrong material: the boundary OptiX picks has m1/m2 that do not reference the photon's current medium, so absorption/scattering sample the wrong material1. Carry the photon's matline (seeded from the genstep at birth in CSGOptiX7.cu, updated each propagate_at_boundary) in sctx::current_matline and use it as m1 in qbnd::fill_state when valid. No-op for correctly-enumerated boundaries (carried == the boundary's own m1_line). Wrong face: at the coincident face OptiX sorts the two coplanar intersections inconsistently; the exiting hit (cosTheta>0) carries the parent medium as m2 -> the photon refracts through a phantom parent-medium sliver, and on a TIR light-guide (DIRC bars) hits the critical angle and is lost. Bias the t reported to OptiX by +10 um on the exit side (cosI>0) in __intersection__is so the entering sibling wins; the real unbiased isect.w still goes to prd->q0.f so position advancement is unperturbed. Gated per boundary by index contrast |n_m1-n_m2|>0.1 (max over wavelength), computed in CSGOptiX::initSimulate from the bnd table into params.boundary_face_bias: a flat bias over-steps near-index-matched thin gaps (aerogel/air ~0.025 across 10-50 um => -6..-9% on dRICH), so high-contrast faces (quartz/air ~0.47) gate on and low-contrast ones gate off. No per-detector hardcode; nullptr => always-on.
The two fixes are complementary -- the matline picks the right material, the bias picks the right face; on a TIR light-guide either one alone collapses the GPU hit count. Verified ePIC hpDIRC mu- 3 GeV: GPU/CPU 0.987, bit-identical to the unconditional bias (all glued-sibling faces clear the threshold); low-index-contrast detectors unchanged.