Skip to content

Conversation

@TacHawkes
Copy link
Collaborator

This small PR adds a new keyword depth_max to the solve_system! function in order to solve #40 This depth limits the max branching depth of a beam.

This is useful to set when tracing resonant elements like resonators or filter cavities.

@TacHawkes TacHawkes self-assigned this Oct 7, 2025
@TacHawkes TacHawkes requested a review from StackEnjoyer October 7, 2025 17:34
@codecov
Copy link

codecov bot commented Oct 7, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.60%. Comparing base (16cecf8) to head (5be22f7).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #41      +/-   ##
==========================================
+ Coverage   71.57%   71.60%   +0.02%     
==========================================
  Files          57       57              
  Lines        2881     2884       +3     
==========================================
+ Hits         2062     2065       +3     
  Misses        819      819              

☔ View full report in Codecov by Sentry.
📢 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.

@TacHawkes
Copy link
Collaborator Author

Setting the keyword recovers the performance. It is up to the user to set depth_max to achieve the desired precision when simulating a resonant elements.

Example:

using GLMakie, BeamletOptics

GLMakie.activate!(; ssao=true)
const BMO = BeamletOptics

const mm = 1e-3

mirror_diameter = 25mm
cavity_length = 12mm
reflectance = 0.92
detector_offset = 70mm

input_wavelength = 632.8e-9
input_waist = 0.04mm

mirror1 = RoundThinBeamsplitter(mirror_diameter; reflectance)
mirror2 = RoundThinBeamsplitter(mirror_diameter; reflectance)

translate3d!(mirror2, [0, cavity_length, 0])

detector = Detector(40mm)
translate3d!(detector, [0, cavity_length + detector_offset, 0])

system = StaticSystem([mirror1, mirror2, detector])

beam = GaussianBeamlet([0, -detector_offset, 0], [0, 1, 0], input_wavelength, input_waist)

empty!(detector)
solve_system!(system, beam, depth_max=100)

##
x, z, I = intensity(detector; n=400, crop_factor=1.0)

##
fig = Figure(size=(720, 540))
ax = Axis(fig[1, 1]; aspect=DataAspect(), xlabel="x (mm)", ylabel="z (mm)")
hm = heatmap!(ax, x ./ mm, z ./ mm, log10.(I .+ eps()))
colorbar = Colorbar(fig[1, 2], hm, label="Intensity (a.u.)")

fig

@StackEnjoyer StackEnjoyer merged commit 03d6b97 into master Oct 8, 2025
6 checks passed
@StackEnjoyer StackEnjoyer deleted the max_branch_depth branch October 8, 2025 10:06
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.

3 participants