Skip to content

Distributed Bragg reflectors / transfer-matrix method

Characteristic-matrix (Macleod) stacks, absorbing and oblique variants. Docstrings are the source of truth, rendered with mkdocstrings (numpydoc style).

photonics_helper.dbr

Distributed Bragg Reflector (DBR) design and transfer-matrix simulation.

Material

Bases: RefractiveIndex

A named material with wavelength-dependent complex refractive index.

name property

name: str

Block

A single layer in a DBR stack.

Attributes:

Name Type Description
length Length — thickness of the layer (m).
material Material with refractive index data.
colour optional colour string for plotting.
position (start, end) coordinates along the stack.

length instance-attribute

length: Length

material instance-attribute

material: Material

colour class-attribute instance-attribute

colour: str | None = None

position deletable property writable

position: tuple[float, float] | None

Pattern

A repeating DBR layer pattern.

Attributes:

Name Type Description
style layer sequence string, e.g. "ABAB" or "ABCABC".
mapping dict mapping style characters to Block instances.
central_wavelength design central wavelength.
length total physical length of the pattern.
out ordered list of Blocks composing the pattern.

style instance-attribute

style: str

mapping instance-attribute

mapping: dict[str, Block]

central_wavelength instance-attribute

central_wavelength: Wavelength

out deletable property

out: list[Block]

length property

length: float

make_pattern

make_pattern() -> None

Build the Block list from style and mapping.

add_block

add_block(block: Block, mapping: str, index: int) -> None

Insert a block at index in the pattern style.

remove_block

remove_block(index: int) -> None

Remove the block at index from the pattern style.

get_index

get_index(wl_micron: float) -> tuple[list[float], list[float]]

Return [n, k] arrays for all blocks at the given wavelength (μm).

plot_index

plot_index(wl: Wavelength | None = None) -> None

plot_2d

plot_2d(height=1e-07, overlay_index: bool = False) -> None

TMM

Transfer-matrix method for a DBR stack.

Computes reflection, transmission, and field profiles using the 2×2 transfer-matrix formalism for stratified media.

Attributes:

Name Type Description
pattern Pattern — the layer stack.
angle_of_incidence angle of incidence in radians.
polarisation "TE" or "TM".
n_incident complex — refractive index of the semi-infinite incident

medium (default air, 1.0 + 0j).

n_substrate complex — refractive index of the semi-infinite exit

(substrate) medium (default air, 1.0 + 0j).

pattern instance-attribute

pattern: Pattern

angle_of_incidence instance-attribute

angle_of_incidence: float

polarisation instance-attribute

polarisation: Literal['TE', 'TM']

n_incident class-attribute instance-attribute

n_incident: complex = 1.0 + 0j

n_substrate class-attribute instance-attribute

n_substrate: complex = 1.0 + 0j

transfer_matrix

transfer_matrix(wavelength: Wavelength) -> NDArray

Compute the full 2×2 characteristic matrix for the stack.

Uses the optical admittance formalism so that absorbing layers (complex n) are handled correctly. The returned matrix M relates the tangential E and H fields at the back and front of the stack::

[E_front]   [M11  M12] [E_back]
[H_front] = [M21  M22] [H_back]

Each layer's characteristic matrix maps the fields at its back interface to its front interface, so the stack matrix is the ordered product M_1 @ M_2 @ ... @ M_n with layer 1 at the incident side (Macleod, Thin-Film Optical Filters, Eq. 2.55).

spectrum

spectrum(wavelengths: WavelengthArray) -> tuple[NDArray, NDArray]

Compute reflection R(λ) and transmission T(λ) across a wavelength range.

field_profile

field_profile(wavelength: Wavelength, return_positions: bool = False) -> NDArray | tuple[list[Length], NDArray]

Compute |E(z)| inside the stack at a single wavelength.

Returns one value per layer: the magnitude of the total electric field at the front of each layer (just after the interface).

Because the characteristic matrix maps fields at the back of a layer to its front, forward propagation through a layer uses the inverse relation solve(M_layer, [E, H]) — multiplying by M_layer would propagate the wrong way.

Parameters:

Name Type Description Default
wavelength Wavelength

Vacuum wavelength (m).

required
return_positions bool

When True, also return the front-interface positions in metres.

False

Returns:

Name Type Description
|E| : NDArray

Field magnitude at the front of each layer.

positions (list[Length], optional)

Interface positions, only when return_positions=True.

field_profile_z

field_profile_z(wavelength: Wavelength, n_points_per_layer: int = 20) -> tuple[NDArray, NDArray]

Continuous |E(z)| profile sampled across the whole stack.

Parameters:

Name Type Description Default
wavelength Wavelength

Vacuum wavelength (m).

required
n_points_per_layer int

Number of samples per layer (including both interfaces). Must be at least 2. Default 20.

20

Returns:

Name Type Description
z NDArray

Positions in metres, strictly increasing from 0 to the total stack length.

E NDArray

|E(z)| at those positions.

Notes

Within layer i the fields are obtained from the back interface via the characteristic matrix of the remaining thickness: at depth x, [E, H] = M(d_i − x) · [E_back, H_back]. At x = 0 this reproduces the front field, so the sampled interface values match :meth:field_profile. The same characteristic-matrix/admittance formalism is used throughout (Macleod, Thin-Film Optical Filters, §2.4).

plot_spectrum

plot_spectrum(wavelengths: WavelengthArray, ax=None)

Plot reflectance R(λ), transmittance T(λ) and absorption A(λ).

Parameters:

Name Type Description Default
wavelengths WavelengthArray — wavelength grid.
required
ax matplotlib Axes, optional — axis to draw on.
None

Returns:

Name Type Description
fig matplotlib Figure

plot_index

plot_index(pattren: Pattern, wl: Wavelength) -> None

Plot refractive index n across the DBR pattern at wavelength wl.

plot_2d

plot_2d(pattren: Pattern, height=1e-07, overlay_index: bool = False) -> None

Plot a 2-D bar chart of the DBR pattern.

Parameters:

Name Type Description Default
pattren Pattern — the DBR pattern.
required
height bar height in metres (default 100 nm).
1e-07
overlay_index if True, overlay refractive index on the bar chart.
False