Repository navigation
Ring sampling of sources: every ray represents the same area - #153
Merged
Merged
Conversation
The ring samplings put the outermost ring on the edge of the disc (`DiscRings`, CollimatedSource) or cone (`ConeRings`, PointSource) and gave every ring rays in proportion to its circumference. The edge ring represents only the inner half of its annulus, hence the edge got twice its share: with 10 rings, 20 % of the rays lay in the outer 10 % of the area. Spot sizes, point spread functions and power fractions, which weight every ray equally, were biased towards the rim, e.g. the RMS spot behind a plano-convex lens was 4.1 % too large with 10 rings (1.3 % with 30), compared to the equal-area sunflower sampling. The rays per ring are now in proportion to the area (solid angle) each ring represents, half of its circumference for the edge ring (trapezoidal rule). The positions of the rings are unchanged, the marginal rays still lie on the edge. The RMS spot is 0.34 % off with 10 rings and the error falls as 1/N² instead of 1/N. The same applies to SphericalGaussianBeamletSource and EllipticalGaussianBeamletSource, whose beamlets carry equal power. The sub-waist of SphericalGaussianBeamletSource is computed from the actual spacing of its rings, θ / (num_rings - 1), as its docstring states, not from θ / num_rings. Tests: the rays per ring follow the weights; the RMS spot of the rings agrees with the sunflower sampling to 1 %; the fraction of the rays of a point source within half its spread angle equals the fraction of the solid angle.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #153 +/- ##
=======================================
Coverage 89.57% 89.58%
=======================================
Files 81 81
Lines 4498 4502 +4
=======================================
+ Hits 4029 4033 +4
Misses 469 469 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
StackEnjoyer
approved these changes
Oct 15, 2026
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.
Bugfixes
CollimatedSourceandPointSourcewith ring sampling gave the ring on the edge twice its share of rays; spot sizes and PSFs, which weight every ray equally, were biased towards the rim (RMS spot behind a plano-convex lens +4.1 % with 10 rings, now +0.34 %; the error falls as 1/N² instead of 1/N)SphericalGaussianBeamletSourceandEllipticalGaussianBeamletSourceSphericalGaussianBeamletSourcecomputes the beamlet sub-waist from the actual ring spacing θ / (num_rings − 1), as its docstring states, instead of θ / num_ringsThe positions of the rings are unchanged, the marginal rays still lie on the edge; only the number of rays per ring changes (trapezoidal rule).
Doc changes
DiscRings,ConeRings: how the rays are distributed over the ringsAgent skill
Closes #151