Source code#

SuPySolver#

class SuPySolver(geometry: Geometry | ndarray, tolerance: float = 1e-08, max_iteration: int = 10000, accuracy: int = 2, extrapolation_order: int = 2, debug_mode: int = 1)[source]#

Bases: EIGENSOLVER

A solver for computing eigenvalues and supermodes of optical fiber geometries using a C++ eigensolver.

This class manages the eigenvalue problem for optical structures and returns computed supermodes. The solver utilizes a C++ backend for efficient eigenvalue computation and integrates with finite difference methods to solve for various boundary conditions.

Parameters:
  • geometry (Geometry or numpy.ndarray) – The refractive index geometry of the optical structure.

  • tolerance (float, optional) – Absolute tolerance for the propagation constant computation (default is 1e-8).

  • max_iteration (int, optional) – Maximum iterations for the C++ eigensolver (default is 10,000).

  • accuracy (int, optional) – Accuracy level of the finite difference method (default is 2).

  • extrapolation_order (int, optional) – Order of Taylor series used to extrapolate eigenvalues (default is 2).

  • debug_mode (int, optional) – Debug output level from the C++ binding, where 0 is no output and higher values provide more detail (default is 1).

initialize_binding(n_sorted_mode: int, boundaries: Boundaries, n_added_mode: int) None[source]#

Initialize and configure the C++ solver binding for eigenvalue computations.

Parameters:
  • n_sorted_mode (int) – Number of modes to sort and retrieve from the solver.

  • boundaries (Boundaries) – Boundary conditions for the finite difference system.

  • n_added_mode (int) – Number of extra modes calculated for accuracy and reliability.

Returns:

Configured C++ solver instance.

Return type:

EigenSolver

init_superset(wavelength: float, n_step: int = 300, itr_initial: float = 1.0, itr_final: float = 0.1) None[source]#

Initialize a SuperSet instance containing computed supermodes over a range of inverse taper ratios (ITR).

Parameters:
  • wavelength (float) – Wavelength for the mode computation.

  • n_step (int, optional) – Number of steps for the ITR interpolation (default is 300).

  • itr_initial (float, optional) – Initial ITR value (default is 1.0).

  • itr_final (float, optional) – Final ITR value (default is 0.1).

index_to_eigen_value(index: float) float[source]#

Convert a refractive index to the corresponding eigenvalue for the solver.

Parameters:

index (float) – Refractive index to convert.

Returns:

Calculated eigenvalue based on the given index and the wavenumber.

Return type:

float

eigen_value_to_index(eigen_value: float) float[source]#

Convert an eigenvalue from the solver to the corresponding refractive index.

Parameters:

eigen_value (float) – Eigenvalue to convert.

Returns:

Equivalent refractive index calculated from the eigenvalue and the wavenumber.

Return type:

float

get_supermode_labels(n_modes: int, boundaries: Boundaries, auto_label: bool) list[source]#

Generate labels for supermodes based on boundary conditions and whether auto-labeling is enabled.

Parameters:
  • n_modes (int) – Number of modes for which labels are needed.

  • boundaries (Boundaries) – Boundary conditions that affect mode symmetries.

  • auto_label (bool) – If True, automatically generates labels based on mode symmetries; otherwise, generates generic labels.

Returns:

List of labels for the supermodes.

Return type:

list

add_modes(n_sorted_mode: int, boundaries: Boundaries, n_added_mode: int = 4, index_guess: float = 0.0, auto_label: bool = True) None[source]#

Compute and add a specified number of supermodes to the solver’s collection.

Parameters:
  • n_sorted_mode (int) – Number of modes to output and sort from the solver.

  • boundaries (Boundaries) – Boundary conditions for the finite difference calculations.

  • n_added_mode (int, optional) – Additional modes computed to ensure mode matching accuracy (default is 4).

  • index_guess (float, optional) – Starting guess for the refractive index used in calculations (default is 0., auto-evaluated if set to 0).

  • auto_label (bool, optional) – If True, enables automatic labeling of modes based on symmetry (default is True).

Returns:

This method updates the solver’s internal state but does not return any value.

Return type:

None

property alpha_vector#

Vector of alpha parameters used in iterative extrapolation.

This attribute stores the sequence of alpha values used during Richardson extrapolation in the iterative solver. It provides insight into the convergence behavior and can be used for diagnostic purposes.

Type#

numpy.ndarray

Array of float values representing the alpha parameters used in each iteration step.

Notes

This vector is populated during the execution of loop_over_itr() and can be examined to understand the solver’s convergence characteristics. Large variations in alpha values may indicate convergence difficulties.

The optimal alpha value often lies between 0.5 and 2.0, but this can vary significantly depending on the problem characteristics and the condition number of the eigenvalue problem.

property bottom_boundary#

Boundary condition applied to the bottom edge of the computational domain.

This read-only attribute specifies the type of boundary condition used at the bottom boundary of the finite difference grid.

Type#

str

One of “PML”, “PEC”, or “PMC”

Notes

In cylindrical coordinates, the bottom boundary often corresponds to the axis of symmetry (r=0), where special care must be taken to handle the coordinate singularity properly.

See also

left_boundary

Description of boundary condition options

property left_boundary#

Boundary condition applied to the left edge of the computational domain.

This read-only attribute specifies the type of boundary condition used at the left boundary of the finite difference grid. The boundary condition affects how the wave equation is discretized near the domain edges.

Type#

str

One of “PML”, “PEC”, or “PMC”

Options#

  • “PML”: Perfectly Matched Layer - absorbing boundary that minimizes reflections, recommended for most applications

  • “PEC”: Perfect Electric Conductor - electric field tangential component is zero at the boundary

  • “PMC”: Perfect Magnetic Conductor - magnetic field tangential component is zero at the boundary

property n_computed_mode#

Number of eigenmodes to compute during eigenvalue solving.

This attribute determines how many eigenvalues and eigenvectors the solver will compute. A larger number provides more modes but increases computational cost and memory usage.

Type#

int

Typical range: 10-100 depending on the application. For single-mode analysis, 5-10 is often sufficient. For multimode analysis, 20-100 may be needed.

Notes

Changing this value after initialization requires rerunning the eigenvalue computation to take effect. The computational cost scales roughly linearly with this parameter.

It’s recommended to compute more modes than needed (n_computed_mode > n_sorted_mode) to ensure that all physically relevant modes are captured, especially in the presence of numerical noise.

property n_sorted_mode#

Number of modes to keep after sorting by effective index.

This attribute controls how many of the computed eigenmodes are retained and returned by get_mode(). The modes are sorted by their effective refractive index (real part of eigenvalue) in descending order.

Type#

int

Must be <= n_computed_mode. Typical values range from 1 (fundamental mode only) to 10-20 for multimode analysis.

Notes

Changing this value after initialization will affect subsequent calls to get_mode() but does not trigger recomputation of eigenvalues. The sorting and selection is performed on the already computed modes.

property right_boundary#

Boundary condition applied to the right edge of the computational domain.

This read-only attribute specifies the type of boundary condition used at the right boundary of the finite difference grid.

Type#

str

One of “PML”, “PEC”, or “PMC”

See also

left_boundary

Description of boundary condition options

property top_boundary#

Boundary condition applied to the top edge of the computational domain.

This read-only attribute specifies the type of boundary condition used at the top boundary of the finite difference grid.

Type#

str

One of “PML”, “PEC”, or “PMC”

See also

left_boundary

Description of boundary condition options

SuperSet#

class SuperSet(model_parameters: MODELPARAMETERS, wavelength: float, geometry: Geometry)[source]#

Bases: SuperSetPlots

A set of supermodes calculated for a specific optical fiber configuration.

This class manages operations on supermodes, including sorting, plotting, and calculations related to fiber optics simulations.

Parameters:
  • model_parameters (ModelParameters) – Parameters defining the model for simulation.

  • wavelength (float) – The wavelength used in the solver, in meters.

  • geometry (Geometry) – The geometry of the optical structure.

model_parameters: MODELPARAMETERS#
wavelength: float#
geometry: Geometry#
property coordinate_system#

Returns the coordinate system associated with the geometry.

Returns:

The coordinate system of the geometry.

Return type:

CoordinateSystem

property fundamental_supermodes: list[SuperMode]#

Returns the fundamental supermodes based on the highest beta values and minimal spatial overlap.

Returns:

A list of fundamental supermodes.

Return type:

list of SuperMode

property non_fundamental_supermodes: list[SuperMode]#

Returns the non-fundamental supermodes based on the specified spatial overlap tolerance.

Returns:

A list of non-fundamental supermodes.

Return type:

list of SuperMode

property transmission_matrix: ndarray#

Returns the supermode transmission matrix.

Returns:

The transmission matrix for the supermodes.

Return type:

numpy.ndarray

itr_to_slice(itr_list: list[float]) list[int][source]#

Convert ITR values to corresponding slice numbers.

Parameters:

itr_list (list of float) – Inverse taper ratio values.

Returns:

List of slice numbers corresponding to the ITR values.

Return type:

list of int

get_fundamental_supermodes(*, tolerance: float = 0.1) list[SuperMode][source]#

Returns a list of fundamental supermodes with the highest propagation constant values and minimal spatial overlap.

Parameters:

tolerance (float, optional) – Tolerance for spatial overlap (default is 0.1).

Returns:

List of fundamental supermodes.

Return type:

list of SuperMode

get_non_fundamental_supermodes(*, tolerance: float = 0.1) list[SuperMode][source]#

Returns a list of non-fundamental supermodes that do not overlap with the fundamental modes.

Parameters:

tolerance (float, optional) – Tolerance for spatial overlap (default is 0.1).

Returns:

List of non-fundamental supermodes.

Return type:

list of SuperMode

get_mode_solver_classification() list[list[SuperMode]][source]#

Returns a list of modes classified by solver number.

Returns:

List of lists containing modes classified by solver number.

Return type:

list of list of SuperMode

label_supermodes(*label_list) None[source]#

Assign labels to the supermodes.

Parameters:

label_list (tuple) – Labels to assign to the supermodes.

reset_labels() None[source]#

Reset labels for all supermodes to default values.

compute_transmission_matrix() None[source]#

Calculate the transmission matrix including only the propagation constant.

add_coupling_to_t_matrix(*, t_matrix: ndarray, adiabatic_factor: ndarray) ndarray[source]#

Add coupling coefficients to the transmission matrix.

Parameters:
  • t_matrix (numpy.ndarray) – Transmission matrix to which coupling values are added.

  • adiabatic_factor (numpy.ndarray) – Adiabatic factor, set to one if None (normalized coupling).

Returns:

Updated transmission matrix with coupling values.

Return type:

numpy.ndarray

compute_coupling_factor(*, coupler_length: float) ndarray[source]#

Compute the coupling factor defined by the derivative of the inverse taper ratio.

Parameters:

coupler_length (float) – Length of the coupler.

Returns:

Coupling factor as a function of distance in the coupler.

Return type:

numpy.ndarray

get_transmision_matrix_from_profile(*, profile: AlphaProfile, add_coupling: bool = True) tuple[source]#

Get the transmission matrix from the given profile.

Parameters:
  • profile (AlphaProfile) – Z-profile of the coupler.

  • add_coupling (bool, optional) – Whether to add coupling to the transmission matrix (default is True).

Returns:

Tuple containing distance, ITR vector, and transmission matrix.

Return type:

tuple

propagate(*, profile: AlphaProfile, initial_amplitude: list, max_step: float | None = None, n_step: int | None = None, add_coupling: bool = True, method: str = 'RK45', **kwargs: dict) Propagation[source]#

Propagate the amplitudes of the supermodes in a coupler based on the given profile.

Parameters:
  • profile (AlphaProfile) – The z-profile of the coupler.

  • initial_amplitude (list) – The initial amplitude as a list of complex numbers.

  • max_step (float, optional) – The maximum step size used by the solver (default is None).

  • n_step (int, optional) – Number of steps used by the solver (default is None).

  • add_coupling (bool, optional) – Whether to add coupling to the transmission matrix (default is True).

  • method (str, optional) – Integration method to be used by the solver (default is ‘RK45’).

  • **kwargs (dict) – Additional keyword arguments to be passed to the solver.

Returns:

A Propagation object containing the results of the propagation.

Return type:

Propagation

interpret_initial_input(initial_amplitude: list | SuperMode) ndarray[source]#

Interpret the initial amplitude input to ensure compatibility with the expected number of supermodes.

Parameters:

initial_amplitude (list or SuperMode) – The initial amplitude as either a list of complex numbers or a SuperMode object.

Returns:

The initial amplitudes as a NumPy array of complex numbers.

Return type:

numpy.ndarray

Raises:

ValueError – If the length of the initial amplitude list does not match the number of supermodes.

sort_modes_by_beta() None[source]#

Sort supermodes in descending order of their propagation constants (beta).

sort_modes(sorting_method: str = 'beta', keep_only: int | None = None) None[source]#

Sort supermodes according to the specified method, optionally limiting the number of modes retained.

Parameters:
  • sorting_method (str, optional) – Sorting method to use, either “beta” or “symmetry+beta” (default is “beta”).

  • keep_only (int, optional) – Number of supermodes to retain after sorting (default is None).

Raises:

ValueError – If an unrecognized sorting method is provided.

sort_modes_by_solver_and_beta() None[source]#

Sort supermodes primarily by solver number and secondarily by descending propagation constant (beta).

is_compute_compatible(pair_of_mode: tuple) bool[source]#

Determine whether the specified pair of modes is compatible for computation.

Parameters:

pair_of_mode (tuple) – The pair of modes to be checked.

Returns:

True if the pair of modes is compatible for computation, False otherwise.

Return type:

bool

remove_duplicate_combination(supermodes_list: list) list[SuperMode][source]#

Remove duplicate combinations from the mode combination list irrespective of the order.

Parameters:

supermodes_list (list of tuple) – List of mode combinations.

Returns:

Reduced list of unique supermode combinations.

Return type:

list of tuple

interpret_combination(mode_of_interest: list, combination: str) set[source]#

Interpret user input for mode selection and return the combination of modes to consider.

Parameters:
  • mode_of_interest (list) – List of modes of interest.

  • combination (str) – Mode selection method (‘pairs’ or ‘specific’).

Returns:

Set of mode combinations.

Return type:

set of tuple

save_instance(filename: str) Path[source]#

Save the SuperSet instance as a serialized pickle file.

Parameters:

filename (str) – Filename for the serialized instance.

Returns:

The path to the saved instance file.

Return type:

Path

export_data(*args, mode_of_interest='all', **kwargs)#

A wrapped version of the plotting function that interprets the mode_of_interest parameter.

Parameters:
  • self (object) – The instance of the class calling this method.

  • *args (tuple) – Positional arguments passed to the decorated function.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The return value of the decorated plotting function.

Return type:

Any

add_crossings_to_ax(ax: Axes, mode_of_interest: list, data_type: str) None#

Add mode crossings to the given axis.

Parameters:
  • ax (matplotlib.axes.Axes) – The axes object on which to plot.

  • mode_of_interest (list of SuperMode) – List of modes of interest.

  • data_type (str) – The type of data for which to find crossings (e.g., ‘index’, ‘beta’, etc.).

generate_pdf_report(filename: str = 'auto', directory: str = '.', itr_list: list[float] | None = None, slice_list: list[int] | None = None, dpi: int = 200, mode_of_interest: list = 'all', combination: str = 'specific') None#

Generate a full report of the coupler properties as a PDF file.

Parameters:
  • filename (str, optional, default="auto") – Name of the report file to be output. If “auto”, a default name will be generated based on the current timestamp.

  • directory (str, optional, default='.') – Directory to save the report.

  • itr_list (list of float, optional, default=None) – List of ITR values to evaluate the mode field. If None, all available ITR values will be used.

  • slice_list (list of int, optional, default=None) – List of slice values to evaluate the mode field. If None, all available slices will be used.

  • dpi (int, optional, default=200) – Pixel density for the images included in the report.

  • mode_of_interest (list, optional, default='all') – List of modes to consider in the report. If ‘all’, all available modes will be included.

  • combination (str, optional, default='specific') – Method for selecting mode combinations (‘specific’ or ‘pairs’).

Examples

>>> superset_plots.generate_pdf_report(filename="coupler_report", itr_list=[0.1, 0.2, 0.5], mode_of_interest=['LP01', 'LP11'])
This will generate a PDF report named 'coupler_report.pdf' containing plots for the specified modes at given ITR values.
plot(plot_type: str, **kwargs) None#

General plotting function to handle different types of supermode plots.

Parameters:
  • plot_type (str) – The type of plot to generate. Options include ‘index’, ‘beta’, ‘eigen-value’, etc.

  • **kwargs (dict) – Additional keyword arguments for specific plot configurations.

Raises:

ValueError – If an unrecognized plot type is specified.

Examples

>>> superset_plots.plot(plot_type='index', ax=ax)
Generates an effective index plot.
>>> superset_plots.plot(plot_type='invalid')
ValueError: Invalid plot type: invalid. Options are: index, beta, eigen-value, adiabatic, normalized-adiabatic, normalized-coupling, field, beating-length.
plot_adiabatic(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', combination: str = 'pairs', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots with specific combinations of modes.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • combination (str, optional) – Specifies the type of combination to plot. The value is interpreted using self.interpret_combination and can be ‘pairs’, ‘triplets’, etc. Default is ‘pairs’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The mode_of_interest and combination are interpreted based on the instance’s methods.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

plot_beating_length(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', combination: str = 'pairs', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots with specific combinations of modes.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • combination (str, optional) – Specifies the type of combination to plot. The value is interpreted using self.interpret_combination and can be ‘pairs’, ‘triplets’, etc. Default is ‘pairs’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The mode_of_interest and combination are interpreted based on the instance’s methods.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

plot_beta(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

plot_eigen_value(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

plot_field(*args, mode_of_interest='all', **kwargs)#

A wrapped version of the plotting function that interprets the mode_of_interest parameter.

Parameters:
  • self (object) – The instance of the class calling this method.

  • *args (tuple) – Positional arguments passed to the decorated function.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The return value of the decorated plotting function.

Return type:

Any

plot_index(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

plot_normalized_coupling(ax: Axes = None, show: bool = True, mode_of_interest: str = 'all', combination: str = 'pairs', save_filename: str = None, **kwargs) Figure#

A wrapped version of the plotting function that provides additional functionality for creating and managing plots with specific combinations of modes.

Parameters:
  • self (object) – The instance of the class calling this method.

  • ax (plt.Axes, optional) – A matplotlib Axes object to draw the plot on. If None, a new figure and axes are created. Default is None.

  • show (bool, optional) – Whether to display the plot. If False, the plot will not be shown but can still be saved or returned. Default is True.

  • mode_of_interest (str, optional) – Specifies the mode of interest for the plot. If ‘all’, all available modes will be plotted. This parameter is interpreted using the interpret_mode_of_interest function. Default is ‘all’.

  • combination (str, optional) – Specifies the type of combination to plot. The value is interpreted using self.interpret_combination and can be ‘pairs’, ‘triplets’, etc. Default is ‘pairs’.

  • save_filename (str, optional) – A file path to save the figure. If None, the figure will not be saved. Default is None.

  • **kwargs (dict) – Additional keyword arguments passed to the decorated function.

Returns:

The matplotlib Figure object created or used for the plot.

Return type:

plt.Figure

Notes

  • If no ax is provided, a new figure and axes are created using the style context mps.

  • The mode_of_interest and combination are interpreted based on the instance’s methods.

  • The legend is only added if there are labels to display.

  • If save_filename is specified, the figure is saved to the given path.

  • The plot is shown if show is set to True.

SuperMode#

class SuperMode(*, parent_set: object, binding: object, solver_number: int, mode_number: int, boundaries: dict, label: str = None)[source]#

Bases: object

Represents supermodes within fiber optic structures. This class serves as a Python counterpart to a C++ SuperMode class, facilitating integration and computation via the SuPySolver. Instances of this class belong to a SuperSet, and each supermode is uniquely identified within its symmetry set by a mode number.

Parameters:
  • parent_set (object) – The SuperSet instance associated with this supermode.

  • binding (object) – The corresponding C++ bound supermode object.

  • solver_number (int) – Identifier linking this supermode to a specific Python solver.

  • mode_number (int) – Unique identifier for this mode within a symmetry set.

  • boundaries (dict) – Specifications of the boundary conditions for the supermode.

  • label (str, optional) – An arbitrary descriptive label for the supermode.

parent_set: object#
binding: object#
solver_number: int#
mode_number: int#
boundaries: dict#
label: str = None#
ID: list#
property field: Field#

Accesses the field representation associated with the supermode.

Returns:

The field representation of the supermode.

Return type:

Field

property index: Index#

Accesses the index representation associated with the supermode.

Returns:

The index representation of the supermode.

Return type:

Index

property beta: Beta#

Accesses the beta representation associated with the supermode.

Returns:

The beta representation of the supermode.

Return type:

Beta

property normalized_coupling: NormalizedCoupling#

Accesses the normalized coupling representation associated with the supermode.

Returns:

The normalized coupling representation of the supermode.

Return type:

NormalizedCoupling

property adiabatic: Adiabatic#

Accesses the adiabatic representation associated with the supermode.

Returns:

The adiabatic representation of the supermode.

Return type:

Adiabatic

property eigen_value: EigenValue#

Accesses the eigenvalue representation associated with the supermode.

Returns:

The eigenvalue representation of the supermode.

Return type:

EigenValue

property beating_length: BeatingLength#

Accesses the beating length representation associated with the supermode.

Returns:

The beating length representation of the supermode.

Return type:

BeatingLength

property binding_number: int#

Retrieves the binding number specific to the linked C++ solver.

Returns:

The binding number from the associated C++ solver.

Return type:

int

property geometry: object#

Provides access to the geometric configuration associated with the supermode.

Returns:

The geometry of the parent SuperSet.

Return type:

object

property coordinate_system: object#

Accesses the coordinate system used by the supermode.

Returns:

The coordinate system of the parent SuperSet.

Return type:

object

property itr_list: ndarray#

Provides a list of iteration parameters from the model.

Returns:

Array of iteration parameters from the model.

Return type:

numpy.ndarray

property model_parameters: MODELPARAMETERS#

Retrieves parameters defining the model’s computational aspects.

Returns:

Computational parameters from the bound supermode.

Return type:

ModelParameters

property mesh_gradient: ndarray#

Accesses the gradient mesh associated with the supermode.

Returns:

The gradient mesh of the supermode.

Return type:

numpy.ndarray

property amplitudes: ndarray#

Computes the amplitude array for this supermode, setting its own mode number to 1 and all others to 0.

Returns:

Array of complex numbers representing amplitudes.

Return type:

numpy.ndarray

property stylized_label: str#

Provides a stylized label for the supermode. If no custom label is provided, it defaults to a generic label with the mode ID.

Returns:

The stylized or default label.

Return type:

str

is_computation_compatible(other: SuperMode) bool[source]#

Determines if another supermode is compatible for computation, based on unique identifiers and boundary conditions.

Parameters:

other (SuperMode) – The other supermode to compare.

Returns:

True if the supermodes are compatible for computation, False otherwise.

Return type:

bool

is_symmetry_compatible(other: SuperMode) bool[source]#

Determines whether the specified other supermode has the same symmetry.

Parameters:

other (SuperMode) – The other supermode to compare.

Returns:

True if the specified other is symmetry compatible, False otherwise.

Return type:

bool

get_field_interpolation(itr: float = None, slice_number: int = None) RectBivariateSpline[source]#

Computes the field interpolation for a given iteration or slice number. Requires exactly one of the parameters to be specified.

Parameters:
  • itr (float, optional) – The iteration number for which to compute the interpolation.

  • slice_number (int, optional) – The slice number for which to compute the interpolation.

Returns:

Interpolated field values over a grid.

Return type:

RectBivariateSpline

Raises:

ValueError – If neither or both parameters are specified.

get_axis(slice_number: int, add_symmetries: bool = True) tuple[source]#

Computes the scaled axis vectors for a specific slice, optionally including symmetries.

Parameters:
  • slice_number (int) – The slice index for which to compute the axis vectors.

  • add_symmetries (bool, optional, default=True) – Whether to include symmetries in the computed axis vectors.

Returns:

A tuple containing the scaled x-axis and y-axis vectors for the given slice.

Return type:

tuple