Repository navigation
Add BlazedRulings, a triangular groove whose blaze and antiblaze facets have any angles - #301
Merged
Merged
Conversation
…cets have any angles The efficiency is the closed form of the scalar (Kirchhoff) integral over one period, a sinc function from each facet. A vertical antiblaze facet gives `SawtoothRulings`, and facets of the same angle give `TriangularRulings`. The angles are measured from the surface at each point, and the depth of the grooves follows the local spacing of the rulings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #301 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 142 142
Lines 13864 14007 +143
==========================================
+ Hits 13864 14007 +143
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…e surface - Raise a `ValueError` unless both facet angles are greater than 0 and at most 90 degrees, or both negative, and not both vertical. Angles outside that range gave efficiencies far above one, and two flat facets divided zero by zero. - Accept angles as plain numbers in radians, which raised an `AttributeError`. - Compute the depth of the grooves from their period along the surface, which is longer than the distance between the ruling planes where those planes are not perpendicular to the surface. - Document which way the blaze facets face (toward the ruling vector, into the negative orders), and that negative angles mirror the groove to blaze the positive orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB
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.
Adds
optika.rulings.BlazedRulings(spacing, angle_blaze, angle_antiblaze, diffraction_order), a triangular groove whose blaze facet and antiblaze facet can each have any angle. Ruled gratings are specified this way, by a blaze angle and an antiblaze angle, and the existing profiles only cover the two ends:SawtoothRulings(a vertical antiblaze facet) andTriangularRulings(two equal facets).Model
Parameters. The angles are measured from the surface at each point, so the facets follow its curvature. The depth and the width of each facet come from the local period of the rulings along the surface, so the facets keep their angles where the spacing varies. Where the ruling planes are not perpendicular to the surface, that period is longer than the distance between the planes. With d that period:
Efficiency. The scalar (Kirchhoff) integral over one period has a closed form, a sinc function from each facet:
η_i = [f sinc(γ + i f) + (−1)^i (1 − f) sinc(γ − i (1 − f))]²
Here γ = H |n₁ cos α − n₂ cos β| / λ is the same γ as in
SawtoothRulings.Limits. f = 1 gives
SawtoothRulingsexactly, and f = 1/2 givesTriangularRulingsexactly.Orientation. The blaze facets face the ruling vector, so positive angles blaze the negative orders, like
SawtoothRulingswith a positive depth. Negative angles mirror the groove and blaze the positive orders.Checks.
efficiencyraises aValueErrorunless both angles are in (0°, 90°], or both in [−90°, 0), and not both vertical. Plain numbers are taken as radians.The docstring example plots the first-order efficiency of a 3° blaze for antiblaze angles from 90° down to 3°. Over that range the peak falls from 1.0 to 0.30 and moves to shorter wavelengths.
Tests
TestBlazedRulingsruns the sharedAbstractTestAbstractRulingssuite, with one constant-spacing case and one variable-spacing case.test_blazed_rulings_sawtooth: a 90° antiblaze matchesSawtoothRulingswith depth d tan θb, over orders −100 to 100, four wavelengths and three angles of incidence.test_blazed_rulings_triangular: equal angles matchTriangularRulingswith depth (d/2) tan θ.test_blazed_rulings_quadrature: the closed form matches a direct midpoint-rule integral of the phase screen, for a 1°/4° profile in orders −4 to 4, to 1e-7.test_blazed_rulings_spacing_local: with aPolynomial1dRulingSpacing, the efficiency at each position matches rulings with that constant spacing.test_blazed_rulings_period_tangential: with ruling planes tilted 30° from the surface normal, the efficiency matches rulings whose planes are perpendicular to the surface with the same period along it.test_blazed_rulings_mirrored: negative angles, with the incident light and the order mirrored too, give the same efficiency.test_blazed_rulings_radians: plain numbers match the same angles in degrees.test_blazed_rulings_invalid: ten sets of angles that don't describe a groove raise aValueError.BlazedRulingsis added totest_efficiency_reciprocalandtest_efficiency_conserved(the sum over orders is 1).All 227 rulings tests pass locally, and black and ruff are clean.
Overlap with #302
#302 fixes two bugs in the shared
_gamma: it dropped the sign that decides which orders an asymmetric profile blazes in transmission, and it sent everything to order 0 when light arrived from the back of the surface.BlazedRulingsinherits both until #302 merges. Whichever of the two merges second needs a rebase to:|…|from the γ in theBlazedRulingsnotes;BlazedRulingsto Keep the sign of the phase of relief rulings, and measure it from the side the light arrives on #302's transmission and back-side tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01StcJvUf6xFg2ese9XDDhaB