Modes and fundamentals#

Mode-family definitions and immutable mode identifiers.

class Family(value)[source]#

Bases: str, Enum

Supported scalar and vector mode families.

LP = 'LP'#
HE = 'HE'#
EH = 'EH'#
TE = 'TE'#
TM = 'TM'#
class Mode(family, nu, m)[source]#

Bases: object

Identify one circular-fiber propagation mode.

Parameters:
  • family ({'LP', 'HE', 'EH', 'TE', 'TM'}) – Electromagnetic mode family.

  • nu (int) – Non-negative azimuthal order.

  • m (int) – Non-negative radial order.

family: str | Family#

Family of the mode

nu: int#

Parameter of the mode. It often corresponds to the parameter of the radial Bessel functions.

m: int#

Radial order of the mode (positive integer). It corresponds to the number of concentric rings in the mode fields.

Fundamental normalized-frequency and propagation relations.

get_delta_from_fiber(fiber)[source]#

Calculate the relative index difference, (Delta), of the fiber.

\[\Delta = \frac{1}{2} \left( 1 - \frac{n_{\text{clad}}^2}{n_{\text{core}}^2} \right)\]
Parameters:

fiber (Fiber) – The fiber object containing core and cladding properties.

Returns:

The relative index difference, (Delta).

Return type:

float

get_wavelength_from_V0(fiber, normalized_frequency)[source]#

Compute the wavelength corresponding to a given V-number, (V_0).

\[\lambda = \frac{2 \pi a \cdot \text{NA}}{V_0}\]

where: - (a) is the core radius. - (text{NA}) is the numerical aperture.

Parameters:
  • fiber (Fiber) – The fiber object.

  • normalized_frequency (float) – The V-number.

Returns:

The wavelength corresponding to V$_0$.

Return type:

float

get_propagation_constant_from_omega(omega, fiber, mode, delta_neff=1e-06)[source]#

Calculate the propagation constant, (beta), for a given angular frequency, fiber, and mode.

\[\beta = k_0 n_{\text{eff}}\]

where: - (k_0 = frac{2 pi}{lambda}) is the free-space wave number. - (n_{text{eff}}) is the effective refractive index.

Parameters:
  • omega (float) – The angular frequency.

  • fiber (Fiber) – The fiber object.

  • mode (Mode) – The mode of interest.

  • delta_neff (float, optional) – Convergence threshold for (n_{text{eff}}) calculation, by default (1 times 10^{-6}).

Returns:

The propagation constant, (beta).

Return type:

float

get_U_parameter(fiber, wavelength, mode, delta_neff=1e-06)[source]#

Calculate the (U) parameter for a given fiber and mode.

\[U = k_0 a \sqrt{n_{\text{core}}^2 - n_{\text{eff}}^2}\]
Parameters:
  • fiber (Fiber) – The fiber object.

  • wavelength (float) – The wavelength of interest.

  • mode (Mode) – The mode of interest.

  • delta_neff (float, optional) – Convergence threshold for (n_{text{eff}}), by default (1 times 10^{-6}).

Returns:

The (U) parameter.

Return type:

float

get_effective_index(fiber, wavelength, mode, delta_neff=1e-06)[source]#

Compute the effective refractive index, (n_{text{eff}}), for a given mode.

Parameters:
  • fiber (Fiber) – The fiber object.

  • wavelength (float) – The wavelength of interest.

  • mode (Mode) – The mode of interest.

  • delta_neff (float, optional) – Convergence threshold for (n_{text{eff}}), by default (1 times 10^{-6}).

Returns:

The effective refractive index, (n_{text{eff}}).

Return type:

float

get_effective_index_result(fiber, wavelength, mode, delta_neff=1e-06)[source]#

Compute an effective index with structured convergence diagnostics.

Parameters:
  • fiber (Fiber) – Fiber to solve.

  • wavelength (float) – Vacuum wavelength in meters.

  • mode (Mode) – Mode to solve.

  • delta_neff (float, optional) – Maximum effective-index search step.

Returns:

Effective index, residual, bracket, iteration count, and explanation.

Return type:

SolverResult[float]

get_mode_cutoff_v0(fiber, wavelength, mode)[source]#

Compute the cutoff V-number, (V_0), for a mode.

Parameters:
  • fiber (Fiber) – The fiber object.

  • wavelength (float) – The wavelength of interest.

  • mode (Mode) – The mode of interest.

Returns:

The cutoff V-number, (V_0).

Return type:

float

get_radial_field(fiber, mode, wavelength, radius)[source]#

Compute the radial field components of a mode in cylindrical coordinates.

The returned pair contains the cylindrical electric components \((E_r, E_\phi, E_z)\) and magnetic components \((H_r, H_\phi, H_z)\).

Parameters:
  • fiber (Fiber) – The fiber object.

  • mode (Mode) – The mode of interest.

  • wavelength (float) – The wavelength of interest.

  • radius (float) – The radial position.

Returns:

Radial field components as CylindricalCoordinates.

Return type:

tuple

Optical-source wavelength and frequency conversions.

class Source(wavelength)[source]#

Bases: object

Represent a monochromatic optical source.

Parameters:

wavelength (TypedUnit.Length) – Vacuum wavelength in meters.

property wavelength: Length#

Validated vacuum wavelength.

property wavenumber#

Wave number (2π/λ).

Returns:

Wave number in radians per meter.

Return type:

pint.Quantity

property omega#

Angular frequency (in rad/s).

Returns:

Angular frequency.

Return type:

pint.Quantity

property frequency#

Frequency (in Hertz).

Returns:

Frequency in Hz.

Return type:

pint.Quantity

Validated immutable configuration models for fibers and solvers.

class LayerSpec(name, radius, refractive_index)[source]#

Bases: object

Describe one immutable concentric step-index layer.

Parameters:
  • name (str) – Human-readable layer name.

  • radius (TypedUnit.Length) – Outer radius in meters. The outermost layer may use infinity.

  • refractive_index (TypedUnit.RefractiveIndex) – Positive finite refractive index.

name: str#
radius: Length#
refractive_index: RefractiveIndex#
class SolverSettings(tolerance=1e-08, max_iterations=100, effective_index_step=1e-06, raise_on_failure=False)[source]#

Bases: object

Configure root searches consistently across solver implementations.

Parameters:
  • tolerance (float, optional) – Absolute root tolerance.

  • max_iterations (int, optional) – Maximum root-finding iterations.

  • effective_index_step (float, optional) – Maximum effective-index bracketing step.

  • raise_on_failure (bool, optional) – Raise ConvergenceError instead of returning a failed result.

tolerance: float#
max_iterations: int#
effective_index_step: float#
raise_on_failure: bool#

Domain-specific exceptions raised by PyFiberModes.

exception PyFiberModesError[source]#

Bases: Exception

Base class for package-specific errors.

exception ValidationError[source]#

Bases: PyFiberModesError, ValueError

Indicate invalid physical geometry or solver configuration.

exception SolverError[source]#

Bases: PyFiberModesError, RuntimeError

Indicate that a modal solver could not complete normally.

exception ConvergenceError[source]#

Bases: SolverError

Indicate that a numerical solver did not converge to a valid root.

exception UnsupportedGeometryError[source]#

Bases: SolverError

Indicate that a requested calculation does not support the fiber geometry.