wavesolve.waveguide#

This page contains the documentation for the waveguide submodule, which defines different kinds of waveguides, enables the creation of custom waveguides, and handles mesh generation for finite element analysis.

Waveguide class#

class wavesolve.waveguide.Waveguide#

a Waveguide is a collection of prim2Ds, organized into layers. the refractive index of earlier layers is overwritten by later layers.

__init__(prim2Ds)#
Parameters:

prim2Ds – a (potentially) nested list of Prim2D objects. Later elements overwrite earlier ones, in terms of refractive index.

assign_IOR()#

returns a dictionary which maps all material labels in the Waveguide mesh to the corresponding refractive index value.

compute_mesh_size(x, y, _scale=1.0, _power=1.0, min_size=None, max_size=None)#

compute a target mesh size (triangle side length) at the point (x,y)

Parameters:
  • x (float) – x point to compute mesh size at

  • y (float) – y point to compute mesh size at

  • _scale (float) – a factor that determines how quickly mesh size should increase away from primitive boundaries. higher = more quickly.

  • _power (float) – another factor that determines how mesh size increases away from boundaries. default = 1 (linear increase). higher = more quickly.

  • min_size (float) – the minimum mesh size that the algorithm can choose

  • max_size (float) – the maximum mesh size that the algorithm can chooose

make_mesh(algo=6, order=2, adaptive=True)#

Construct a mesh with boundary refinement at material interfaces

Parameters:
  • algo (int) – Gmsh algorithm, values 1-7

  • order (int) – finite element mesh order. 1 -> linear triangle elements, 2 (default) -> quadratic triangle elements

  • adaptive (bool) – whether to adaptively vary mesh triangle size, default True.

plot_boundaries(ax=None, color='red', lw=1, alpha=1)#

plot the boundaries of all prim2Dgroups

Parameters:
  • ax (matplotlib.axes or None) – matplotlib axis to plot on; if None, one will be made

  • color (str) – plotline color, default “red”

  • lw (float) – linewidth, default 1

  • alpha (float) – opacity, default 1

plot_mesh(mesh=None, IOR_dict=None, alpha=0.3, ax=None, plot_points=True)#

plot a mesh and associated refractive index distribution

Parameters:
  • mesh – the finite element mesh to be plotted. if None, one is made with make_mesh()

  • IOR_dict (dict or None) – dictionary that assigns each named region in the mesh to a refractive index value. if None, one is made automatically.

  • alpha (float) – opacity of mesh lines

  • ax (matplotlib.axes or None) – matplotlib axis to plot on; if None, one will be made

  • plot_points (bool) – plot the mesh triangle points (vertices, and midpoints if order 2)

max_mesh_size = 10.0#

maximum allowed mesh size

Type:

float

mesh_dist_power = 1.0#

mesh boundary refinement power scaling

Type:

float

mesh_dist_scale = 0.25#

mesh boundary refinement linear distance scaling

Type:

float

min_mesh_size = 0.1#

minimum allowed mesh size

Type:

float

classes that inherit from Waveguide#

class wavesolve.waveguide.CircularFiber#

a circular step-index optical fiber

__init__(rcore, rclad, ncore, nclad, core_res, clad_res=None, core_mesh_size=None, clad_mesh_size=None)#
Parameters:
  • rcore (float) – radius of core

  • rclad (float) – radius of cladding

  • ncore (float) – core index

  • nclad (float) – cladding index

  • core_res (int) – number of line segments to divide the core boundary into

  • clad_res (int) – number of line segments to divide the cladding boundary into, default core_res/2

class wavesolve.waveguide.EllipticalFiber#

an axis-aligned elliptical core step-index fiber

__init__(acore, bcore, rclad, ncore, nclad, core_res, clad_res=None, core_mesh_size=None, clad_mesh_size=None)#
Parameters:
  • acore (float) – extent of elliptical core along x (the “x” radius)

  • bcore (float) – extent of elliptical core along y (the “y” radius)

  • rclad (float) – radius of cladding, assumed circular

  • ncore (float) – core index

  • nclad (float) – cladding index

  • core_res (int) – number of line segments to divide the core boundary into

  • clad_res (int) – number of line segments to divide the cladding boundary into, default core_res/2

class wavesolve.waveguide.PhotonicCrystalFiber#

an optical fiber filled with a hexagonal pattern of air holes, except at the center. must be solved with vector solver.

__init__(rhole, rclad, nclad, spacing, hole_res, clad_res, hole_mesh_size=None, clad_mesh_size=None, nhole=1.0, rcore=0)#
Parameters:
  • rhole (float) – the radius of each air hole perforating the fiber

  • rclad (float) – the outer cladding radius of the fiber

  • nclad (float) – the index of the cladding material

  • spacing (float) – the physical spacing between holes

  • hole_res (int) – the # of line segments used to resolve each hole boundary

  • clad_res (int) – the # of line segments used to resolve the outer cladding boundary

  • hole_mesh_size (float) – target mesh size inside holes

  • clad_mesh_size (float) – target mesh size inside cladding, but outside holes

  • nhole (float) – index of the holes, default 1.

  • rcore (float) – the “core radius” of the fiber. holes whose centers are within this radius from the origin are not generated. default 0 (no central hole).

class wavesolve.waveguide.PhotonicBandgapFiber#

an optical fiber filled with a hexagonal pattern of air holes, except at the center. must be solved with vector solver.

__init__(rvoid, rhole, rclad, nclad, spacing, hole_res, clad_res, hole_mesh_size=None, clad_mesh_size=None, nhole=1.0)#
Parameters:
  • rvoid (float) – the radius of the central air hole

  • rhole (float) – the radius of the cladding air holes perforating the fiber

  • rclad (float) – the outer cladding radius of the fiber

  • nclad (float) – the index of the cladding material

  • spacing (float) – the physical spacing between holes

  • hole_res (int) – the # of line segments used to resolve each hole boundary

  • clad_res (int) – the # of line segments used to resolve the outer cladding boundary

  • hole_mesh_size (float) – target mesh size inside holes

  • clad_mesh_size (float) – target mesh size inside cladding, but outside holes

  • nhole (float) – index of the holes, default 1.

class wavesolve.waveguide.FiberBundleLantern#

Photonic lantern with hexagonal arrangement of individual fibers - WaveSolve compatible

__init__(r_jack, r_fiber_clad, r_core, n_rings, n_core, n_clad, core_res=16, clad_res=32, jack_res=None, spacing_factor=2.0, include_center=True, taper_ratio=1.0, r_target_mmcore_size=None, core_mesh_size=None, clad_mesh_size=None, n_jack=None, center_clad_factor=1.5, ring_clad_factors=None)#

Initialize hexagonal fiber bundle photonic lantern.

Parameters:
  • r_jack – jacket radius

  • r_fiber_clad – individual fiber cladding radius

  • r_core – core radius (final size after taper)

  • n_rings – number of hexagonal rings

  • n_core – core refractive index

  • n_clad – cladding refractive index

  • core_res – resolution for each core circle

  • clad_res – resolution for each fiber cladding circle

  • jack_res – resolution for jacket circle (default clad_res/2)

  • spacing_factor – multiplier for fiber spacing (center-to-center)

  • include_center – whether to include center fiber

  • taper_ratio – scaling factor (initial_size/final_size)

  • r_target_mmcore_size – desired MM core size. Will override taper ratio.

  • core_mesh_size – target mesh size in cores

  • clad_mesh_size – target mesh size in cladding

  • n_jack – jacket refractive index (default same as cladding)

  • center_clad_factor – factor to enlarge center fiber cladding (simulates fusing)

  • ring_clad_factors – list/dict of cladding scaling factors for each ring Can be: - list: [ring0_factor, ring1_factor, ring2_factor, …] - dict: {0: ring0_factor, 1: ring1_factor, …} - None: use center_clad_factor for ring 0, 1.0 for others

class wavesolve.waveguide.MCFPhotonicLantern#

Photonic lantern with hexagonal grid of core, i.e. MCF based lantern.

__init__(r_jack, r_clad, r_core, n_rings, n_core, n_clad, core_res=16, clad_res=32, jack_res=None, spacing_factor=2.2, include_center=True, taper_ratio=1.0, r_target_cladding_size=None, core_mesh_size=None, clad_mesh_size=None, n_jack=None)#

Initialize MCF photonic lantern.

Parameters:
  • r_jack – jacket radius

  • r_clad – cladding radius of MCF

  • r_core – core radius (final size after taper)

  • n_rings – number of hexagonal rings

  • n_core – core refractive index

  • n_clad – cladding refractive index

  • core_res – resolution for each core circle

  • clad_res – resolution for cladding circle

  • jack_res – resolution for jacket circle (default clad_res/2)

  • spacing_factor – multiplier for core spacing

  • include_center – whether to include center core

  • taper_ratio – scaling factor (initial_size/final_size)

  • r_target_cladding_size – desired MM core size. Will overide taper ratio.

  • core_mesh_size – target mesh size in cores

  • clad_mesh_size – target mesh size in cladding

  • n_jack – jacket refractive index (default same as cladding)

Prim2D class#

class wavesolve.waveguide.Prim2D#

a Prim2D (2D primitive) is an an array of N (x,y) points, shape (N,2), that denote a closed curve (so, a polygon). inside the closed curve, the primitive has refractive index n.

__init__(n, label, points=[])#
Parameters:
  • n (float) – refractive index

  • label (str) – a bookkeeping label to attach to this object (e.g. “core”)

  • points – a list or array of [x,y] points corresponding to the shape’s boundary

boundary_dist(x, y)#
compute the signed distance of the point (x,y) to the primitive boundary.

this default implementation treats the primitive as a polygon and computes the point-edge distance wrt the every edge, then takes the minimum. it relies on inside() to convert distance to a signed distance.

Parameters:
  • x (float) – x coordinate of a point

  • y (float) – y coordinate of a point

Returns:

signed distance to the boundary (negative inside, positive outside)

Return type:

(float)

dist_map(bounds, res=50)#

plot a signed distance map. useful for checking boundary_dist()

Parameters:
  • bounds (array) – [xmin,xmax,ymin,ymax] extent of the plot

  • res (int) – 1D resolution of the plot

inside(x, y)#
Parameters:
  • x (float) – x coordinate of a point

  • y (float) – y coordinate of a point

Returns:

whether or not [x,y] is inside the primitive boundary

Return type:

(bool)

make_points(args)#

make an Nx2 array of points for marking the primitive boundary, according to some args. CCW ordering! this is a placeholder; subclasses should implement this function.

make_poly(geom)#

convert self.points into a Gmsh polygon

Parameters:

geom – pygmsh geometry kernel

plot_boundary(ax=None, color='red', alpha=1, lw=1)#

plot the boundary of the primitive

Parameters:
  • ax (matplotlib.axes) – matplotlib axis to plot on; if None, one will be made.

  • color (str) – linecolor of the boundary

  • alpha (float) – line opacity

  • lw (float) – line width

classes that inherit from Prim2D#

class wavesolve.waveguide.Circle#

a (discretized) Circle primitive, defined by radius, center, and number of sides

make_points(radius, res, center=(0, 0))#
Parameters:
  • radius (float) – circle radius

  • res (int) – number of line segments with which to discretize the circle

  • center – (x,y) coordinates of the circle center

class wavesolve.waveguide.Ellipse#

axis-aligned ellipse. a is the semi-axis along x, b is the semi-axis along y.

make_points(a, b, res, center=(0, 0))#
Parameters:
  • a (float) – semimajor axis

  • b (float) – semiminor axis

  • res (int) – number of line segments with which to discretize the ellipse

  • center – (x,y) coordinates of the circle center

class wavesolve.waveguide.Rectangle#

rectangle primitive, defined by corner pounts.

make_points(xmin, xmax, ymin, ymax)#
Parameters:
  • xmin (float) – minimum x coordinate of the rectangle

  • xmax (float) – maximum x coordinate

  • ymin (float) – minimum y coordinate

  • ymax (float) – maximum y coordinate

class wavesolve.waveguide.Prim2DUnion#

a union of Prim2Ds

__init__(ps: list[Prim2D], label)#
Parameters:
  • ps (list[Prim2D]) – a list of Prim2D objects to boolean union

  • label (str) – a bookkeeping label to attach to this object (e.g. “core”)

class wavesolve.waveguide.Prim2DArray#

an array of non-intersecting Prim2Ds which share the same material. this is functionally equivalent to a list of Prim2D objects, except that all the Prim2D objects now share a label.

__init__(ps: list[Prim2D], label)#
Parameters:
  • ps (list[Prim2D]) – a list of Prim2D objects

  • label (str) – a bookkeeping label to attach to this object (e.g. “core”)