Skip to content

Ring sampling of sources: every ray represents the same area - #153

Merged
StackEnjoyer merged 1 commit into
masterfrom
fix/ring-sampling-weights
Oct 15, 2026
Merged

StackEnjoyer merged 1 commit into
masterfrom
fix/ring-sampling-weights

Conversation

@TacHawkes

@TacHawkes TacHawkes commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Bugfixes

  • Changes results: CollimatedSource and PointSource with 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)
  • Changes results: the same for SphericalGaussianBeamletSource and EllipticalGaussianBeamletSource
  • Changes results: SphericalGaussianBeamletSource computes the beamlet sub-waist from the actual ring spacing θ / (num_rings − 1), as its docstring states, instead of θ / num_rings

The 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 rings

Agent skill

  • No skill files affected

Closes #151

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.
@TacHawkes TacHawkes added this to the v0.14.0 milestone Oct 15, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T04:52:13.324050Z 1192674 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.58%. Comparing base (9630be5) to head (1192674).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@StackEnjoyer
StackEnjoyer merged commit b9c76b0 into master Oct 15, 2026
7 checks passed
@StackEnjoyer
StackEnjoyer deleted the fix/ring-sampling-weights branch October 20, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ring sampling of CollimatedSource and PointSource weights the edge twice

2 participants