Waveguides

Cross-sections with eigenmodes. Calling a waveguide with a length, wg(d), gives a section of a Stack.

class camfr.Slab

A 1D layered waveguide.

Slab(clad(1) + core(0.5) + clad(1)): layers along x, from x = 0. The lateral walls are electric by default; change them globally with set_lower_wall/set_upper_wall, or per slab with the methods below.

__init__(term: Term) -> None

__init__(expression: Expression) -> None

add_kz2_estimate(kz2: complex) → None

Add an estimate of kz**2 for the mode search.

expand_field(f: object, eps: float) → ndarray

Expand a field profile f(x) in the slab modes; eps is the precision of the overlap integrals. Returns the mode amplitudes.

expand_gaussian(amplitude: complex, sigma: complex, x0: complex, eps: float) → ndarray

Expand amplitude*exp(-((x-x0)/sigma)**2/2) in the slab modes.

expand_plane_wave(amplitude: complex, theta: complex, eps: float) → ndarray

Expand a plane wave at angle theta (radians) in the slab modes.

plot()

Open an interactive (Tk) window with the modes of this slab.

plot_n(r1, r2=0, r3=0, filename=0, colormap=1)

Plot the refractive index profile.

wg.plot_n(r_x) plots a waveguide along x; stack.plot_n(r_x, r_z) a Stack, BlochStack or Cavity in the x-z plane (r_x, r_y, r_z for a 3D stack); plot_n(section, r_x, r_y) a Section. The ranges are arrays such as arange(x0, x1, dx). For stacks and sections, filename saves the picture instead of showing it (format from the suffix: png, gif, jpg, pdf, …).

set_dummy(b: bool) → None

Internal: mark the slab as a dummy.

set_lower_wall(wall: SlabWall) → None

Set the wall at x = 0 of this slab.

set_upper_wall(wall: SlabWall) → None

Set the wall at x = width() of this slab.

width() → float

Width along x.

class camfr.Section

A 2D cross-section (a 3D waveguide).

Built from Slabs along x, e.g. Section(side(w1) + center(w2) + side(w1)), where each slab is layered along y. M1 is the number of plane waves used to estimate the modes (default N()*mode_surplus), M2 the number of slab modes in the dispersion relation (default N()). The estimation takes most of the solve time; set_estimate skips it. Two expressions give the left and right halves of a symmetric section.

__init__(expression: Expression) -> None

__init__(expression: Expression, M1: int) -> None

__init__(expression: Expression, M1: int, M2: int) -> None

__init__(left: Expression, right: Expression) -> None

__init__(left: Expression, right: Expression, M1: int) -> None

__init__(left: Expression, right: Expression, M1: int, M2: int) -> None

__init__(term: Term) -> None

disp(kz: complex) → complex

Evaluate the dispersion relation at kz (zero for a mode).

eps(coord: Coord) → complex

Permittivity at a Coord.

height() → float

Height along y.

mode(i: int) → SectionMode

Return SectionMode i.

mu(coord: Coord) → complex

Permeability at a Coord.

n(coord: Coord) → complex

Refractive index at a Coord.

plot(field='Ex', mode=0, dx=0.1, dy=0.1, annotations=True)

Plot mode profiles of the Section with Matplotlib.

Parameters:
  • field (str or list of str) – Field component: 'Ex', 'Ey', 'Ez', 'Hx', 'Hy', 'Hz' or 'P' (magnitude of the Poynting vector), case insensitive. Default 'Ex' (E1 in CAMFR terms). A list plots several fields, one per row.

  • mode (int or list of int) – Mode index, from 0 (default). A list plots several modes, one per column.

  • dx (float) – Resolution of the plot in x and y (default 0.1).

  • dy (float) – Resolution of the plot in x and y (default 0.1).

  • annotations (bool) – Write the effective index, mode number and field component on each plot (default True).

Returns:

The figure, e.g. to save or close it:

fig = section.plot(mode=[0, 1], field=['Ex', 'Ey'])
fig.savefig('modes.png')
matplotlib.pyplot.close(fig)

Return type:

matplotlib.figure.Figure

set_estimate(n_eff: complex) → None

Add an estimate of a mode’s effective index.

With estimates, the plane-wave estimation stage is skipped and only these modes are refined: much faster (often 40x). Give one estimate per wanted mode.

set_sorting(sort: Sort_type) → None

Order the modes by highest_index or lowest_loss.

width() → float

Width along x.

class camfr.Circ

A cylindrical waveguide inside a perfectly conducting wall, e.g. Circ(core(r) + clad(R - r)). At most one radial index step is supported.

__init__(term: Term) -> None

__init__(expression: Expression) -> None

plot_n(r1, r2=0, r3=0, filename=0, colormap=1)

Plot the refractive index profile.

wg.plot_n(r_x) plots a waveguide along x; stack.plot_n(r_x, r_z) a Stack, BlochStack or Cavity in the x-z plane (r_x, r_y, r_z for a 3D stack); plot_n(section, r_x, r_y) a Section. The ranges are arrays such as arange(x0, x1, dx). For stacks and sections, filename saves the picture instead of showing it (format from the suffix: png, gif, jpg, pdf, …).

class camfr.Planar(material: Material)

An infinite uniform layer.

Its modes (plane waves at different angles) do not couple, so one propagation angle is treated at a time: set it with set_theta or set_kt.

get_kt() → complex

Return the transverse wavenumber, common to all Planars.

set_kt(kt: complex) → None

Set the transverse wavenumber, common to all Planars.

set_theta(theta: complex) → None

Set the propagation angle in this layer (radians); Snell’s law fixes it in all other Planars. Set the wavelength first.

class camfr.BlochSection

A 2D periodic cross-section, solved with plane waves (Fourier orders from set_fourier_orders).

__init__(expression: Expression) -> None

__init__(term: Term) -> None

eps(coord: Coord) → complex

Permittivity at a Coord.

get_kx0() → complex

Bloch wavenumber kx0.

get_ky0() → complex

Bloch wavenumber ky0.

height() → float

Height of the period along y.

mode(i: int) → BlochSectionMode

Return BlochSectionMode i.

mu(coord: Coord) → complex

Permeability at a Coord.

n(coord: Coord) → complex

Refractive index at a Coord.

order(pol: Polarisation, Mx: int, My: int) → int

Index of the mode with polarisation pol and diffraction order (Mx, My).

set_kx0_ky0(kx0: float, ky0: float) → None

Set the transverse Bloch wavenumbers directly.

set_theta_phi(theta: float, phi: float) → None

Set the incidence angles (radians).

width() → float

Width of the period along x.

class camfr.RefSection(material: Material, width: complex, height: complex, M: int)

A uniform rectangular section of one material, with analytic modes.

Slab walls

class camfr.SlabWall

A transverse boundary condition of a Slab. Predefined: slab_E_wall, slab_H_wall, slab_no_wall.

R() → complex

Reflection coefficient of the wall.

class camfr.SlabWallMixed(a: complex, b: complex)

A wall with the condition a*in + b*out = 0 on the field, i.e. reflection -a/b.

class camfr.SlabWall_TBC(kx0: complex, material: Material)

A transparent boundary condition for a given kx and outer material.

class camfr.SlabWall_PC(expression: Expression)

A wall formed by a semi-infinite periodic structure (a photonic crystal) given by one period.

Base classes

class camfr.Waveguide

A waveguide cross-section.

Base class of Slab, Circ, Planar, Section and the other waveguides. Calling a waveguide with a length, wg(d), gives a Term for a Stack.

N() → int

Number of modes in this waveguide (usually N()).

bw_mode(i: int) → Mode

Return backward mode i.

calc() → None

Calculate the modes.

core() → Material

Return the core Material.

eps(coord: Coord) → complex

Permittivity at a Coord.

epsr(coord: Coord) → complex

Relative permittivity at a Coord.

etar(coord: Coord) → complex

The Material etar parameter at a Coord.

fw_mode(i: int) → Mode

Return forward mode i.

mode(i: int) → Mode

Return mode i (0 is the fundamental mode).

mu(coord: Coord) → complex

Permeability at a Coord.

mur(coord: Coord) → complex

Relative permeability at a Coord.

n(coord: Coord) → complex

Refractive index at a Coord.

class camfr.MultiWaveguide

A waveguide with several coupled modes (Slab, Circ, Section, …).

field_from_source(pos: Coord, orientation: Coord) → FieldExpansion

Return the FieldExpansion excited by a dipole current source at pos with the given orientation.

class camfr.MonoWaveguide

A waveguide whose modes do not couple (Planar).