Repository navigation
Feature: detector hits as values, moving a detector empties it - #164
Merged
Merged
Conversation
A hit kept a reference to the ray or beamlet that made it, so solving the same beam again changed the hits of earlier solves (#42). All four hit types now store only the values their evaluation needs and are isbits: - RayHit, PolarizedRayHit: hit point, direction, opl, λ, n, projection factor (and E) - AstigmaticGaussianBeamletHit: its cache plus polarization, segment length and λ - GaussianBeamletHit: the complex beam parameter q0 = s0 + i z_R at the segment start; the field within the segment follows in closed form from q(l) = q0 + l, instead of evaluating the waist and divergence rays at every field point. s0, w0 and the divergence come from the rays (_local_beam, split off gauss_parameters), so the result equals the ray construction for rays in one plane with the chief ray. The kinematic primitives of AbstractDetector call empty! first: the stored hits belong to the pose of the detector during the solve. Docs and agent skill state that a detector keeps the hits of consecutive solves side by side, and that the field functions superpose all of them coherently. Closes #42 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #164 +/- ##
==========================================
+ Coverage 90.13% 90.18% +0.04%
==========================================
Files 82 82
Lines 4581 4593 +12
==========================================
+ Hits 4129 4142 +13
+ Misses 452 451 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The beam parameter q0 = s0 + i z_R at the segment start follows from the curvature c and the local Gouy phase ψ that gauss_parameters already returns: q0 = −i sin(ψ) exp(iψ) / c. This keeps the invariant of the waist and divergence rays, as _local_beam did, so gauss_parameters is unchanged against master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
@TacHawkes some benchmark results: Benchmark: master (
|
| Hits on the detector | electric_field master |
electric_field branch |
Speedup | Memory of hits, master | Memory of hits, branch |
|---|---|---|---|---|---|
100 GaussianBeamletHit |
187–245 ms | 43–65 ms | 3–5× | 222 kB | 40 kB |
1000 GaussianBeamletHit |
1.79–2.84 s | 0.63–0.69 s | 3–4× | 2.1 MB | 0.23 MB |
1000 AstigmaticGaussianBeamletHit |
1.00–1.45 s | 1.44–1.92 s | not really | 6.4 MB | 0.62 MB |
10 000 RayHit |
1.21–1.89 s | 1.90–2.03 s | not really | 1.39 MB | 1.07 MB |
10 000 PolarizedRayHit |
2.07–2.57 s | 2.24–2.50 s | not really | 1.86 MB | 1.72 MB |
- Stigmatic hits: the field follows in closed form from the beam parameter at the segment start, instead of evaluating the waist and divergence rays at every grid point.
- Memory: beamlet hits no longer keep the traced beam tree alive (9–10× less); ray hits store values instead of a reference to the ray.
- Solve time (including building the hits) and
spot_diagram: no difference beyond the noise. - Memory measured with
Base.summarysize(hits(detector)).
Collaborator
ReviewSeems like a better option to solve #42. There are some points you should look into. Points
|
… hits - Docstring of GaussianBeamletHit and the stigmatic beam page: the detector field agrees with the waist and divergence rays to about 1e-6 where the stigmatic model applies; near the focus of a beam made astigmatic by a tilted or decentered lens the radius can differ by tens of percent - position(::AbstractBeamletHit) removed, as for ray hits: it returned the segment start, not the hit point; hit_point reads the fields - _projection_factor renamed _sqrt_projection, it returns √|d·n| Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Against an AstigmaticGaussianBeamlet, the closed form from q0 at the segment start focused a beam behind a tilted, decentered lens to the diffraction limit (9.4 µm at 2° tilt, AGB 33 µm, master 28 µm): it drops that the waist and divergence rays no longer cross. The hit stores the two rays instead, as offsets y0 + l v from the chief ray on the planes normal to it (GaussianSegment, isbits), and gauss_parameters(segment, l) evaluates them with the formula of Arnaud and DeJager. gauss_parameters(gauss, z, ψ0; hint) uses the same method, so a hit and its beamlet give the same field; w, R and ψ equal master to 1e-9. The slopes are cot θ = (ŷ·a)/|ŷ × a| instead of tan(π/2 − acos(ŷ·a)), and the plane crossings are linear in l, so no line-plane intersection per evaluation. The validity notes of the previous commit are removed, the hit and gauss_parameters no longer differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Thanks, all good points.
Fixed in bc9a701. |
TacHawkes
approved these changes
Oct 17, 2026
_ray_end and _projection computed what hit_point and projection_factor already name for hits; they are now methods of these verbs for an AbstractRay. _sqrt_projection is gone, the two beamlet hits take sqrt(projection_factor(ray)). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The end point position(ray) + length(ray) * direction(ray) was written out in 15 places (beamsplitters, lenses, mirrors, polarizers, the Gaussian beamlet, Base.show of a beam). hit_point and projection_factor of an AbstractRay move to the ray interface in AbstractRay.jl, and these places call hit_point(ray). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StackEnjoyer
marked this pull request as ready for review
October 18, 2026 21:04
This was referenced Oct 19, 2026
Merged
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.
Features
positionof detector hits removed, usehit_pointBugfixes
Doc changes
SKILL.md,WORKFLOW.md,CHECKLIST.md,components/detectors.mdupdatedInternal changes
hit_point(ray)replaces the end point of a ray written out in 15 placesCloses #42