Skip to content

Coatings implementation#57

Open
TacHawkes wants to merge 20 commits into
masterfrom
feature/coatings-implementation
Open

Coatings implementation#57
TacHawkes wants to merge 20 commits into
masterfrom
feature/coatings-implementation

Conversation

@TacHawkes

Copy link
Copy Markdown
Collaborator

Abstract

This is a new attempt at coatings and is based on #55 as a prerequisite. It will also render #27 obsolete, as polarizing components can be handled using coatings which results in a much more flexible, modular and extensible API.

This should close #30.


Detailed description: Unified Coatings, Face Partitions, and Polarizing Optics

Overview

This PR implements a unified coatings and dynamic boundary physics pipeline in BeamletOptics.jl. It standardizes boundary interactions (refraction, reflection, splitting) across rays and Gaussian/Astigmatic beamlets, modernizes polarizing components, and optimizes performance to achieve allocation-free tracing.


Key Features

  • Unified Boundary Physics (CoatingBehavior): Introduced traits (Transmissive, Reflective, Splitting) to cleanly dispatch boundary logic.
  • Coating Models: Added support for Uncoated, SimpleARCoating, SimpleHRCoating, SimpleBeamsplitterCoating, JonesCoating, and ThinFilmCoating (multi-layer characteristic matrix calculations).
  • Face-Selective Coatings: Supported named faces (:front, :back, :hypotenuse), direction vectors, and spatial predicates to apply localized coatings.
  • Standardized Splitting: Standardized beamlet splitting (spawning transmitted and reflected children) across components. Added a power_cutoff threshold in solve_system! to prevent infinite loops.
  • Modernized Polarizing Optics: Refactored Waveplate and PolarizingBeamSplitter (plate & cube versions) to sit on top of the coating pipeline. Updated _calculate_global_E0 to use correct 3D polarization projection mapping.

@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.33884% with 300 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.95%. Comparing base (6ebe3bd) to head (8d8a76a).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...rc/OpticalComponents/Coatings/StandaloneCoating.jl 63.43% 98 Missing ⚠️
src/OpticalComponents/Coatings/CoatedComponents.jl 78.23% 64 Missing ⚠️
src/OpticalComponents/Polarizers/Waveplate.jl 64.78% 25 Missing ⚠️
src/SDFs/UnionSDF.jl 61.01% 23 Missing ⚠️
src/System.jl 87.00% 13 Missing ⚠️
src/SDFs/SphericalLensSDF.jl 66.66% 10 Missing ⚠️
src/OpticalComponents/DoubletLenses.jl 10.00% 9 Missing ⚠️
src/OpticalComponents/Coatings/BoundaryPhysics.jl 96.63% 7 Missing ⚠️
src/OpticalComponents/Mirrors.jl 53.33% 7 Missing ⚠️
ext/RenderPresets.jl 0.00% 6 Missing ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
+ Coverage   73.46%   73.95%   +0.49%     
==========================================
  Files          61       70       +9     
  Lines        3885     4891    +1006     
==========================================
+ Hits         2854     3617     +763     
- Misses       1031     1274     +243     

☔ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b50da79f50

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

λ,
from_front
) where {T, R <: Ray{T}}
ndir_t, _ = refraction3d(direction(ray), normal, n_incident, n_transmitted)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle total internal reflection before splitting

When a splitting coating is hit from a higher-index medium above the critical angle, refraction3d returns the reflected direction with the TIR flag set, but this path discards the flag and still creates a transmitted child with n_transmitted and T_coeff. A coated glass-air boundary with behavior = Splitting() will therefore emit a bogus transmitted branch instead of reflecting all power, corrupting traced beam trees in TIR cases.

Useful? React with 👍 / 👎.

zrotate3d!(coating, π)
return RectangularPlateBeamsplitter(substrate, coating)
M = typeof(coating.model)
return RectangularPlateBeamsplitter{typeof(width), M}(substrate, coating)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use promoted dimension type for plate constructors

If callers pass integer dimensions for width while other dimensions or mesh construction promote to floating point, this explicitly instantiates RectangularPlateBeamsplitter{Int64,...} even though substrate and coating are Prism{Float64,...}/Coating{Float64,...}. For inputs like RectangularPlateBeamsplitter(10, 10, 0.2, n) the constructor will fail at runtime; let T be inferred or use promote_type(typeof(width), typeof(height), typeof(thickness)).

Useful? React with 👍 / 👎.

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.

Polarizing components trait

1 participant