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() -> ndarrayReflection matrix for incidence from the left.
R12(i: int, j: int) -> complexElement (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() -> ndarrayReflection matrix for incidence from the right.
R21(i: int, j: int) -> complexElement (i, j) of R21.
- T12()¶
T12() -> ndarrayTransmission matrix for incidence from the left.
T12(i: int, j: int) -> complexElement (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() -> ndarrayTransmission matrix for incidence from the right.
T21(i: int, j: int) -> complexElement (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, butcomponentreturns a complex number, e.g.lambda f: f.E2().filenamewrites the animation to a GIF file.
- calc() None¶
Calculate the reflection and transmission matrices.
- 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.
- free() None¶
Free the matrices.
- fw_bw()¶
fw_bw(z: float) -> tupleReturn the forward and backward mode amplitudes at z, as a tuple.
fw_bw(z: float, limit: Limit) -> tupleAs fw_bw(z), on the given side (Plus or Min) of an interface at z.
- 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) -> complexPower flux across x = c1, integrated from z = 0 to length().
lateral_S_flux(c1: float, k: int) -> complexContribution of chunk k to lateral_S_flux(c1).
- length() float¶
Length along z.
- 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.
componentmaps 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_zfor a 3D stack); a SectionMode takesr_x, r_y.overlay_noverlays the index profile, drawn as contours ifcontour; except for waveguide modes,filenamesaves 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_zfor a 3D stack);plot_n(section, r_x, r_y)a Section. The ranges are arrays such asarange(x0, x1, dx). For stacks and sections,filenamesaves 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) -> NoneSet the incident field from the left: a vector of N() mode amplitudes.
set_inc_field(fw: ndarray, bw: ndarray) -> NoneSet 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 withe = Expression()ande.add(term).__init__() -> None__init__(term: Term) -> None__init__(expression: Expression) -> None- flatten() Expression¶
Return the expression with nested expressions expanded.
- 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
- 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 withset_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, butcomponentreturns a complex number, e.g.lambda f: f.E2().filenamewrites the animation to a GIF file.
- 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
passestimes. The mode is printed, and the cavity field is set to it.
- length() float¶
Total length along z.
- 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.
componentmaps 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_zfor a 3D stack); a SectionMode takesr_x, r_y.overlay_noverlays the index profile, drawn as contours ifcontour; except for waveguide modes,filenamesaves 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_zfor a 3D stack);plot_n(section, r_x, r_y)a Section. The ranges are arrays such asarange(x0, x1, dx). For stacks and sections,filenamesaves the picture instead of showing it (format from the suffix: png, gif, jpg, pdf, …).
- set_source()¶
set_source(pos: Coord, orientation: Coord) -> NonePlace a dipole current source in the cavity cut at pos, oriented along the Coord orientation.
set_source(fw: ndarray, bw: ndarray) -> NonePlace 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).
- 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.
- 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_zfor a 3D stack);plot_n(section, r_x, r_y)a Section. The ranges are arrays such asarange(x0, x1, dx). For stacks and sections,filenamesaves 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.
- free() None¶
Free the matrices.
- 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).