You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Detector hits change when their beam is solved again #42
A hit keeps a reference to its ray or beamlet, so solving the same beam again without empty!(detector) changes the hits of the earlier solves
Beam that hits with its first ray: all spots coincide. GaussianBeamlet: the summed field of 3 mirror positions is off by 97 %, and electric_field throws BoundsError when the new path has fewer segments
AstigmaticGaussianBeamlet: the field is right, but the automatic window covers only the last spot. Seen on master ff76d460 (0.14.0)
using BeamletOptics
pd =Detector(50e-3)
translate3d!(pd, [0, 100e-3, 0])
system =System([pd])
beam =Beam([0.0, 0, 0], [0.0, 1, 0])
for i in1:5solve_system!(system, beam)
zrotate3d!(beam, deg2rad(1))
endlength(unique(spot_diagram(pd))) # 1, expected 5
Notes
Not affected since retracing was removed (Feature: remove retracing, SDF miss exit #111): a Beam that reaches the detector behind another object, its later rays are new objects in every solve
GaussianBeamletHit reads gauss.chief.rays[id] when the field is evaluated (src/OpticalComponents/Detectors/FieldCalculation.jl:99); AstigmaticGaussianBeamletHit reads the beam only for hit point and polarization (DetectorUtils.jl:174, FieldCalculation.jl:153)
deepcopy of a hit is no fix: it also copies the detector with all earlier hits, via Intersection.object
It appears that deepcopy is not the desired quick fix, since some circular references exist within the general BMO architecture. This means that custom, ref-free hit types are required for a "simple" solution, since deepcopy grinds to a halt for multiple subsequent calls, e.g. on the GaussianBeamlet.
Activity
StackEnjoyer commentedon Oct 15, 2025
It appears that
deepcopyis not the desired quick fix, since some circular references exist within the general BMO architecture. This means that custom, ref-free hit types are required for a "simple" solution, sincedeepcopygrinds to a halt for multiple subsequent calls, e.g. on theGaussianBeamlet.[-]Detector hit ref bug[/-][+]Bug: Detector hits change when their beam is solved again[/+]