# E07 · Gratings, Bloch waves, and band gaps

Use momentum matching to find diffraction directions, then use a period’s transfer matrix to explain why a stack can reject a band of frequencies.

<!-- course-motivation:start -->
## Why learn this?

**How does repetition select where light can travel?**

Repeated grooves can separate wavelengths into different directions, while repeated layers can form a mirror over a band of wavelengths. Designing either device requires connecting one repeating unit to the waves supported by the whole structure.

**What you gain:** Use period and angle to find propagating diffraction orders, connect a layer stack to its reflection band, and distinguish a prediction of allowed directions from a prediction of how much power enters each direction.
<!-- course-motivation:end -->

<!-- course-preparation:start -->
## Before this lesson

Use these focused refreshers if an idea is unfamiliar; you do not need to complete each linked course.

- **Complex amplitudes and phase:** Track phase gained over one period and distinguish a phase factor from attenuation. Used here: Bloch factors describe how a field repeats through a structure. [Review: MIT OCW · Complex Arithmetic and Exponentials](https://ocw.mit.edu/courses/18-03sc-differential-equations-fall-2011/pages/unit-i-first-order-differential-equations/complex-arithmetic-and-exponentials/). Read the notes on Euler's formula, polar form, multiplication, and complex conjugation. The differential-equation applications can wait.
- **Matrices, eigenvectors, and modes:** Multiply 2 × 2 matrices and interpret their eigenvalues. Used here: A period's transfer matrix determines its propagating and decaying solutions. [Review: MIT OCW · Eigenvalues and Eigenvectors](https://ocw.mit.edu/courses/18-06sc-linear-algebra-fall-2011/pages/least-squares-determinants-and-eigenvalues/eigenvalues-and-eigenvectors/). Start with the lecture summary and one 2 × 2 worked problem. Focus on Av = λv and what changes when a matrix is applied repeatedly.

For the RCWA extension, review Fourier harmonics and basis truncation; the notebook introduces boundary matching and efficiencies.
- [TU Delft · Fourier analysis](https://qiweb.tudelft.nl/aoi/fourieranalysis/fourieranalysis/) — Use §4.1 for the transform pair, then §4.2.1–4.2.4 for linearity, scaling, shifts, and convolution. Consult §4.2.7 for two successive transforms.

**Python preparation:** Work with complex matrices and inspect convergence as the number of retained harmonics changes.
- [NumPy · The absolute basics for beginners](https://numpy.org/doc/stable/user/absolute_beginners.html) — Use the sections on array shape, indexing and slicing, basic operations, and broadcasting. Practice changing one parameter and rerunning a cell.

**Developed here:** Connect grating directions, Bloch propagation, and band gaps; calculate diffraction efficiencies in the extension.

[All prerequisites and learning resources](https://vandermode.github.io/optics-in-5-minutes-course/preparation/)
<!-- course-preparation:end -->

## Learning outcomes

- Determine which grating orders propagate in each medium.
- Connect a finite Bragg mirror to an infinite crystal’s Bloch gap.
- Distinguish energy conservation from convergence in a truncated RCWA calculation.

## Use the lesson

Watch the [E07 film](https://www.youtube.com/watch?v=qQ0YwOpt-mA) (5:20), embedded near the top of the lesson.

Serve the complete teaching/ directory over HTTP. The lesson uses shared local assets and native JavaScript modules. Open this episode's folder in the browser. Its standalone notebook also works directly in Colab or Jupyter; it does not import repository code or require a GPU.

The notebook's core takes about 25–30 minutes to work through, with a separate optional extension. The first code cell installs numerical packages only when missing. Saved outputs, figures/, and figures.zip provide static figure access if a notebook frontend blocks rich output.

## Model and normalization

The browser grating panel is kinematic only. The separate Bragg stack is lossless, normally illuminated, with equal layer thicknesses and exterior index 1.9. The optional RCWA model is a 1D lamellar, isotropic, lossless TE layer; it rejects exact cutoffs. TM and nonperiodic structures require additional treatment.

Computed quantities are generated by model.js in the browser and the explicitly written NumPy/SciPy models in lab.py. Model-specific assertions and independent references are in the lab and the course checks. The browser and notebook use documented but not necessarily identical grid sizes. Synthetic randomness is seeded.

## Rebuild

From the repository root, run: python teaching/tools/build_course.py, then python teaching/tools/validate_notebooks.py. The authored page content and controls are in teaching/tools/curriculum.py; opening motivations are in teaching/tools/motivation.py; preparation is in teaching/tools/preparation.py; notebook source is this folder's percent-format lab.py. Building preserves saved outputs when code cells are unchanged. Run npm test --prefix teaching for numerical browser-model tests.

## References

- [Moharam et al. · Stable rigorous coupled-wave analysis](https://opg.optica.org/josaa/abstract.cfm?uri=josaa-12-5-1068)
- [Li · Fourier factorization for discontinuous periodic structures](https://opg.optica.org/josaa/abstract.cfm?uri=josaa-13-9-1870)
