# Interfaces, layers, and material models

Layered media offer exact or semi-analytical answers while exercising almost every material path.

## One dielectric interface

At normal incidence from index $n_1$ to $n_2$, power reflectance is

$$
R=\left|\frac{n_1-n_2}{n_1+n_2}\right|^2,
\qquad T=1-R
$$

for lossless nonmagnetic media with the appropriate power convention.

```bash
uv run fdtdx-bench run --case analytical_dielectric_slab
uv run fdtdx-bench run --case analytical_fresnel_n2
uv run fdtdx-bench run --case parity_fresnel_interface
```

The upstream-method slab measures $R=0.04076$ and $T=0.95924$ against 0.04 and 0.96. The parity case repeats the comparison against a pinned Tidy3D result.

## Build a stack

```{figure} ../_static/generated/plane_wave_field.png
:alt: Field across a dielectric layer
```

A transfer matrix supplies the independent reference for multiple layers. The Tidy3D parity case then checks the same spectral path against an external solver.

```bash
uv run fdtdx-bench run --case analytical_multilayer_tmm
uv run fdtdx-bench run --case parity_multilayer_T
uv run fdtdx-bench run --case parity_bragg_stack
```

The three-layer Tidy3D comparison records 0.0196 relative-$L_2$ error and 0.0185 maximum absolute error.

## Add conductivity and dispersion

```{figure} ../_static/generated/material_models.svg
:alt: Lorentz and Drude material curves
```

```bash
uv run fdtdx-bench run --case analytical_skin_depth
uv run fdtdx-bench run --case parity_skin_depth
uv run fdtdx-bench run --case parity_metal_reflect
uv run fdtdx-bench run --case analytical_dispersion
uv run fdtdx-bench run --case analytical_dispersive_source
```

These separate bulk attenuation, interface reflection, auxiliary-pole stepping, impedance, and source correction. A single “metal looks reflective” picture would not distinguish them.

## Rotate the tensor

```bash
uv run fdtdx-bench run --case analytical_anisotropic
uv run fdtdx-bench run --case analytical_birefringence
uv run fdtdx-bench run --case analytical_oriented_dispersion
uv run fdtdx-bench run --case analytical_complex_tensor
```

The final case checks a rotated, lossy uniaxial tensor. It is the strongest guard against accidentally dropping off-diagonal complex terms during material mapping.

