Skip to content

Add a Glass refractive material with Sellmeier dispersion#176

Open
jacobdparker wants to merge 1 commit into
mainfrom
feature/refractive-glass
Open

Add a Glass refractive material with Sellmeier dispersion#176
jacobdparker wants to merge 1 commit into
mainfrom
feature/refractive-glass

Conversation

@jacobdparker

Copy link
Copy Markdown
Contributor

What

Adds optika.materials.Glass, the first surface material whose index of
refraction changes the index carried by a transmitted ray. Every existing
surface material leaves the transmitted index unchanged — Vacuum returns 1,
and the mirrors/multilayers/filters all return rays.index_refraction — so
refractive (lens) systems weren't representable in optika.

How

Glass.index_refraction(rays) evaluates the three-term Sellmeier dispersion
equation,

n²(λ) = 1 + B₁λ²/(λ²−C₁) + B₂λ²/(λ²−C₂) + B₃λ²/(λ²−C₃),

at the ray's vacuum wavelength. Classmethods Glass.n_bk7() and Glass.f2()
return SCHOTT N-BK7 crown and F2 flint glass using published coefficients.

Tests

TestGlass runs the standard AbstractTestAbstractMaterial battery, plus
test_glass_dispersion which checks the index at the helium d Fraunhofer line
against the published value (N-BK7 → 1.5168, F2 → 1.6200), confirms normal
dispersion (higher index toward the blue), and that the glass transmits rather
than reflects.

Why

This is the prerequisite for representing refractive optics in optika, and it
gives the stop root-finding problem a real surface where n2 ≠ n1 for a
transmitted ray (relevant to the _anchor_surface discussion on #169). A
follow-up will use it for a lens tutorial once the stop-solver supports
refractive systems — see the companion issue.

🤖 Generated with Claude Code

Adds `optika.materials.Glass`, the first surface material that changes the
index of refraction of a transmitted ray (`Vacuum`, the mirrors, and the
multilayers all leave the transmitted index unchanged). The index of
refraction follows the three-term Sellmeier dispersion equation, with
`n_bk7()` and `f2()` constructors for SCHOTT N-BK7 crown and F2 flint glass.

This makes refractive (lens) systems representable in optika, and gives the
stop root-finding problem a real surface where `n2 != n1` for a transmitted
ray.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.35%. Comparing base (e9a4eb5) to head (240b003).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #176   +/-   ##
=======================================
  Coverage   99.34%   99.35%           
=======================================
  Files         116      116           
  Lines        5974     6024   +50     
=======================================
+ Hits         5935     5985   +50     
  Misses         39       39           
Flag Coverage Δ
unittests 99.35% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

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.

1 participant