Stacks and cavities

Structures along z, built from expressions of waveguide sections.

class camfr.Stack

A stack of waveguides along z.

Stack(wg1(d1) + wg2(d2) + ...). The first and last waveguides are the semi-infinite incidence and exit media (their lengths only matter for field plots). Stack(expression, periods) repeats the expression. The reflection and transmission matrices are computed on demand (calc). Matrix 12 is for light incident from the left (z = 0), 21 from the right (z = length()).

__init__(expression: Expression) -> None

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

__init__(term: Term) -> None

__init__(term: Term, periods: int) -> None

R12()

R12() -> ndarray

Reflection matrix for incidence from the left.

R12(i: int, j: int) -> complex

Element (i, j) of R12: reflection from mode j to mode i.

R12_power() → ndarray

Reflected power, mode to mode, for incidence from the left. BlochSection stacks only.

R21()

R21() -> ndarray

Reflection matrix for incidence from the right.

R21(i: int, j: int) -> complex

Element (i, j) of R21.

T12()

T12() -> ndarray

Transmission matrix for incidence from the left.

T12(i: int, j: int) -> complex

Element (i, j) of T12: transmission from mode j to mode i.

T12_power() → ndarray

Transmitted power, mode to mode, for incidence from the left. BlochSection stacks only.

T21()

T21() -> ndarray

Transmission matrix for incidence from the right.

T21(i: int, j: int) -> complex

Element (i, j) of T21.

animate_field(component, r1, r2, r3=0, filename=0, overlay_n=1, contour=1, ln=0)

Animate the time evolution of a complex field component.

As plot_field, but component returns a complex number, e.g. lambda f: f.E2(). filename writes the animation to a GIF file.

calc() → None

Calculate the reflection and transmission matrices.

eps(coord: Coord) → complex

Permittivity at a Coord.

ext() → Waveguide

Exit waveguide.

ext_S_flux(c1_start: float, c1_stop: float, eps: float) → float

Power flux along z at z = length() between c1_start and c1_stop, relative precision eps.

field(coord: Coord) → Field

Field at a Coord, for the incident field set.

free() → None

Free the matrices.

fw_bw()

fw_bw(z: float) -> tuple

Return the forward and backward mode amplitudes at z, as a tuple.

fw_bw(z: float, limit: Limit) -> tuple

As fw_bw(z), on the given side (Plus or Min) of an interface at z.

inc() → Waveguide

Incidence waveguide.

inc_S_flux(c1_start: float, c1_stop: float, eps: float) → float

Power flux along z at z = 0 between c1_start and c1_stop, relative precision eps.

inc_field() → ndarray

Incident field from the left (mode amplitudes).

lateral_S_flux()

lateral_S_flux(c1: float) -> complex

Power flux across x = c1, integrated from z = 0 to length().

lateral_S_flux(c1: float, k: int) -> complex

Contribution of chunk k to lateral_S_flux(c1).

length() → float

Length along z.

mu(coord: Coord) → complex

Permeability at a Coord.

n(coord: Coord) → complex

Refractive index at a Coord.

plot()

Open an interactive (Tk) window with the fields in this structure.

plot_field(component, r1, r2=0, r3=0, filename=0, colormap=0, overlay_n=1, contour=1, arrow=0)

Plot a field component.

component maps a Field to a real number, e.g. lambda f: f.E2().real. mode.plot_field(component, r_x) plots a waveguide mode along x; stack.plot_field(component, r_x, r_z) the field in a Stack, Cavity or BlochMode, after an incident field or source has been set (r_x, r_y, r_z for a 3D stack); a SectionMode takes r_x, r_y. overlay_n overlays the index profile, drawn as contours if contour; except for waveguide modes, filename saves the picture instead of showing it.

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, …).

refl_field() → ndarray

Reflected field at the left (mode amplitudes).

scatterer() → MultiScatterer

Return the stack as a MultiScatterer.

set_inc_field()

set_inc_field(fw: ndarray) -> None

Set the incident field from the left: a vector of N() mode amplitudes.

set_inc_field(fw: ndarray, bw: ndarray) -> None

Set the incident fields from the left (fw) and right (bw).

set_inc_field_function(f: object, eps: float) → None

Set the incident field from a function f(x) (E2 for TE, H2 for TM); eps is the precision of the overlap integrals. Slabs only.

set_inc_field_gaussian(amplitude: complex, sigma: complex, x0: complex, eps: float) → None

Set a Gaussian incident field amplitude*exp(-((x-x0)/sigma)**2/2); eps is the precision of the overlap integrals. Slabs only.

set_inc_field_plane_wave(amplitude: complex, theta: complex, eps: float) → None

Set a plane wave incident at angle theta (radians); eps is the precision of the overlap integrals. Slabs only.

trans_field() → ndarray

Transmitted field at the right (mode amplitudes).

width() → float

Transverse (c1) size of the incidence waveguide.

class camfr.Expression

A sequence of Terms.

Expressions are usually written with + and *, e.g. air(1) + 3*(GaAs(0.1) + AlAs(0.1)). Build one term by term with e = Expression() and e.add(term).

__init__() -> None

__init__(term: Term) -> None

__init__(expression: Expression) -> None

add(expression: Term) → None

Append a Term or Expression.

ext() → Waveguide

Last waveguide.

flatten() → Expression

Return the expression with nested expressions expanded.

inc() → Waveguide

First waveguide.

class camfr.Term

A building block of expressions.

Examples: material(d), waveguide(d), a Stack or Scatterer, 2*expr.

__init__(scatterer: Scatterer) -> None

__init__(stack: Stack) -> None

__init__(expression: Expression) -> None

ext() → Waveguide

Exit waveguide.

inc() → Waveguide

Incidence waveguide.

class camfr.Cavity(bottom: Stack, top: Stack)

A cavity, cut in two by a plane.

Cavity(bottom, top): the two Stacks are seen from the cavity cut outwards. Lasing modes are found by varying the wavelength and the gain of the material set with set_gain_material.

animate_field(component, r1, r2, r3=0, filename=0, overlay_n=1, contour=1, ln=0)

Animate the time evolution of a complex field component.

As plot_field, but component returns a complex number, e.g. lambda f: f.E2(). filename writes the animation to a GIF file.

bot_stack() → Stack

The bottom Stack.

field(coord: Coord) → Field

Field at a Coord (after find_mode or set_source).

find_all_modes(lambda_start: float, lambda_stop: float, delta_lambda: float, n_imag_start: float = 0.0, n_imag_stop: float = 0.015, passes: int = 1, number: int = 0) → None

As find_mode, for all lasing modes in the interval (or the ‘number’ highest ones). Modes closer than delta_lambda are not resolved.

find_mode(lambda_start: float, lambda_stop: float, n_imag_start: float = 0.0, n_imag_stop: float = 0.015, passes: int = 1) → None

Find a lasing mode in a wavelength and gain interval.

The wavelength and the imaginary index of the gain material are optimised passes times. The mode is printed, and the cavity field is set to it.

length() → float

Total length along z.

n(coord: Coord) → complex

Refractive index at a Coord.

plot()

Open an interactive (Tk) window with the fields in this structure.

plot_field(component, r1, r2=0, r3=0, filename=0, colormap=0, overlay_n=1, contour=1, arrow=0)

Plot a field component.

component maps a Field to a real number, e.g. lambda f: f.E2().real. mode.plot_field(component, r_x) plots a waveguide mode along x; stack.plot_field(component, r_x, r_z) the field in a Stack, Cavity or BlochMode, after an incident field or source has been set (r_x, r_y, r_z for a 3D stack); a SectionMode takes r_x, r_y. overlay_n overlays the index profile, drawn as contours if contour; except for waveguide modes, filename saves the picture instead of showing it.

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_source()

set_source(pos: Coord, orientation: Coord) -> None

Place a dipole current source in the cavity cut at pos, oriented along the Coord orientation.

set_source(fw: ndarray, bw: ndarray) -> None

Place a source in the cavity cut given by forward and backward mode amplitudes.

sigma() → float

Smallest singular value of the cavity at the current wavelength and gain (minimised to find lasing modes).

top_stack() → Stack

The top Stack.

width() → float

Transverse (c1) size.

class camfr.BlochStack(expression: Expression)

An infinite periodic repetition of an expression; its modes are Bloch modes. N() is 2*N(): forward and backward Bloch waves.

beta_vector() → ndarray

Propagation constants of all Bloch modes.

length() → float

Length of one period along z.

mode(i: int) → BlochMode

Return BlochMode i.

plot()

Open an interactive (Tk) window with the fields in this structure.

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, …).

width() → float

Transverse (c1) size.

class camfr.InfStack(expression: Expression)

A semi-infinite periodic repetition of an expression, used to terminate a Stack.

R12() → ndarray

Reflection matrix.

class camfr.E_Wall(waveguide: Waveguide)

An electric wall terminating a waveguide in z (the default z boundary is open). Not a transverse boundary.

class camfr.H_Wall(waveguide: Waveguide)

A magnetic wall terminating a waveguide in z (the default z boundary is open). Not a transverse boundary.

Scatterers

class camfr.Scatterer

Maps the modes of an incidence waveguide to those of an exit waveguide with reflection and transmission matrices.

calc() → None

Calculate the reflection and transmission matrices.

ext() → Waveguide

Exit waveguide.

free() → None

Free the matrices.

inc() → Waveguide

Incidence waveguide.

class camfr.MultiScatterer

A Scatterer between MultiWaveguides.

class camfr.DenseScatterer

A MultiScatterer with full matrices.

class camfr.DiagScatterer

A MultiScatterer with diagonal matrices.

class camfr.MonoScatterer

A Scatterer between MonoWaveguides.

class camfr.SquashedScatterer(scatterer: DenseScatterer)

A DenseScatterer reduced to a single interface.

class camfr.FlippedScatterer(scatterer: MultiScatterer)

A MultiScatterer seen from the other side (inc and ext swapped).