corset.core#

Core classes for representing and simulating Gaussian beams and optical setups.

Setups are represented as OpticalSetup instances which propagate an initial Beam through a sequence of Lens elements. This yields a piecewise defined beam radius made from Gaussian beam segments between the elements. The individual beams are represented using a complex beam parameter combined with an axial offset and wavelength. The beams are propagated using the ray transfer matrix method for Gaussian beams, see here.

class corset.core.Beam(beam_parameter, z_offset, wavelength, gauss_cov=None) None#

Paraxial Gaussian beam representation.

Implements _repr_png_() to show a plot of the beam radius in IPython environments.

Parameters:
  • beam_parameter (complex)

  • z_offset (float)

  • wavelength (float)

  • gauss_cov (ndarray | None)

classmethod fit(zs, rs, wavelength, p0=None) Beam#

Fit a Gaussian beam radius to measured data.

This uses scipy.optimize.curve_fit to estimate the focus position and waist given arrays of axial positions zs and measured radii rs.

Parameters:
  • zs (ndarray) – Axial positions where radii were measured.

  • rs (ndarray) – Measured beam radii corresponding to zs.

  • wavelength (float) – Wavelength used to relate waist and Rayleigh range.

  • p0 (tuple[float, float] | None, default: None) – Initial guess for (focus, waist). If omitted a simple heuristic is used.

Return type:

Beam

Returns:

Beam instance fitted to the data..

classmethod from_gauss(focus, waist, wavelength, cov=None) Beam#

Create a Beam instance from focus position and waist.

Parameters:
  • focus (float) – The axial position of the beam focus.

  • waist (float) – The beam waist radius.

  • wavelength (float) – The wavelength of the beam.

  • cov (ndarray | None, default: None) – Optional covariance matrix for the beam parameters.

Return type:

Beam

Returns:

Beam instance.

plot(**kwargs) OpticalSetupPlot#

Plot the beam as part of an optical setup with no other elements.

Parameters:

**kwargs – Keyword arguments forwarded to OpticalSetup.plot().

Return type:

OpticalSetupPlot

Returns:

OpticalSetupPlot instance for further customization.

radius(z) float | ndarray#

Compute the beam radius at axial position(s).

Parameters:

z (float | ndarray) – Axial position(s) where the beam radius is evaluated.

Return type:

float | ndarray

Returns:

Beam radius at the specified axial position(s).

beam_parameter: complex#

Complex beam parameter \(q = z - z_0 + i z_R\) defined at position \(z\) with focus at \(z_0\) and Rayleigh range \(z_R\).

property focus: float#

Axial position of the beam focus i.e. waist position

gauss_cov: ndarray | None = None#

Covariance matrix for focus position and waist

property rayleigh_range: float#

Rayleigh range

property waist: float#

Waist radius

wavelength: float#

Wavelength of the beam

z_offset: float#

Axial position at which the ray is defined

class corset.core.OpticalSetup(initial_beam, elements, validate=True) None#

Optical setup described by an initial beam and a sequence of elements.

Implements _repr_png_() to show a plot of the optical setup in IPython environments.

Parameters:
  • initial_beam (Beam)

  • elements (list[tuple[float, ThinLens | ThickLens]])

  • validate (dataclasses.InitVar[bool])

plot(*, ax=None, points=None, limits=None, beam_kwargs={'alpha': 0.5, 'color': 'C0'}, free_lenses=[]) OpticalSetupPlot#

Plot the optical setup, see corset.plot.plot_optical_setup()

Return type:

OpticalSetupPlot

Parameters:
  • self (OpticalSetup)

  • ax (Axes | None)

  • points (int | ndarray | None)

  • limits (tuple[float, float] | None)

  • beam_kwargs (dict)

  • free_lenses (list[int])

radius(z) float | ndarray#

Compute the beam radius at axial position(s).

Return type:

float | ndarray

Parameters:

z (float | ndarray)

property beam_parameters: list[complex]#

Compute the ray vectors between elements including before the first element and after the last.

property beams: list[Beam]#

Compute the Beam instances between elements including before the first element and after the last.

elements: list[tuple[float, ThinLens | ThickLens]]#

Optical elements as (position, element) tuples sorted by position

initial_beam: Beam#

Initial beam before left most element

validate: dataclasses.InitVar[bool] = True#

Validate that elements are sorted by position

class corset.core.ThickLens(in_roc, out_roc, thickness, refractive_index, left_margin=0, right_margin=0, name=None) None#

Thick lens element including additional information.

Parameters:
  • in_roc (float)

  • out_roc (float)

  • thickness (float)

  • refractive_index (float)

  • left_margin (float)

  • right_margin (float)

  • name (str | None)

property focal_length: float#

Approximate focal length of the thick lens.

in_roc: float#

Input surface radius of curvature

left_margin: float = 0#

Physical size to the left of the lens center

property matrix: ndarray#

ABCD matrix of the lens element.

name: str | None = None#

Name for reference and plotting

out_roc: float#

Output surface radius of curvature

refractive_index: float#

Refractive index of the lens material

right_margin: float = 0#

Physical size to the right of the lens center

thickness: float#

Thickness of the lens

class corset.core.ThinLens(focal_length, left_margin=0, right_margin=0, name=None) None#

Thin lens element including additional information.

Parameters:
  • focal_length (float)

  • left_margin (float)

  • right_margin (float)

  • name (str | None)

focal_length: float#

Focal length of the lens

left_margin: float = 0#

Physical size to the left of the focal plane

property matrix: ndarray#

ABCD matrix of the lens element.

name: str | None = None#

Name for reference and plotting

right_margin: float = 0#

Physical size to the right of the focal plane

corset.core.Lens = corset.core.ThinLens | corset.core.ThickLens#

Lens type union