finesse.analysis.actions.operator module

Operator based Actions to extract operators and perform operator based analyes, such as calculating eigenmodes.

class finesse.analysis.actions.operator.Eigenmodes(cavity: Cavity, frequency, *, name='eigenmodes', method='schur_qr')[source]

Bases: Action

For a given Cavity defined in a model, this action will compute the roundtrip operator and calculate the eigen-values and -vectors of the cavity. This will not give correct solutions for coupled cavities as these need to include additional effects.

This can be used to determine what modes combination of modes are resonating in a cavity and the required tuning to make that mode resonate.

Parameters

cavitystr or Cavity

cavity name or Cavity instance

frequencyfloat

Optical carrier or signal frequency to use for calculating the operators

methodstr, optional

Method used to compute the eigenvalues and eigenvectors, options are

  • ‘eig’: using numpy’s eig function

  • ‘schur_qr’: using scipy’s ‘schur’ and ‘qr’ decomposition for the eigenvectors

  • ‘schur_svd’: using scipy’s ‘schur’ and ‘svd’ decomposition for the eigenvectors

namestr, optional

Name of the solution generated by this action

class finesse.analysis.actions.operator.EigenmodesSolution[source]

Bases: BaseSolution

Contains the result of an Eigenmodes action. The start node is defined by the Cavity starting point.

Attributes

connectionstuple((Node, Node))

Node connections used in the round trip propagator

roundtrip_matrixarray

Combined round trip matrix operator for the cavity

matriceslist[array]

A list of operators for each connection

eigvalues, eigvectorsarray, array

Eigen values and vectors of the round trip matrix

cavity_planewave_lossfloat

Round trip loss for a planewave

homsarray_like

Array of HOMs used in the model at the time this was computed

methodstr

Method used to compute the eigenvalues and eigenvectors

schur_Zarray

Schur decomposition Z unitary matrix if using schur method

schur_Tarray

Schur decomposition T upper triangular matrix if using schur method

estimate_orders()[source]

A naive estimation of the order of each eigenmodes in this system.

This method calculates the orders by summing the higher-order modes (homs) along axis 1. It then creates a mapping of each order to the indices where they occur, based on the maximum absolute value of the eigenvectors. It is only likely to work in very weakly deformed optical cavities. It is only useful for identifying the order of modes. See track_complex_eigenvalues() for a more robust way to track how initial undistorted modes evolve.

Returns

order_mapdefaultdict

A defaultdict where the keys are the orders and the values are lists of indices corresponding to each order.

order_estimatearray_like

An estimate of the order of each eigenmode based on the maximum absolute value of the eigenvectors.

loss(remove_planewave_loss=False)[source]

Computes the round trip loss of all the eigenmodes of the cavity. Eigenmodes are ordered by loss. Lowest loss may not be the fundamental mode.

Parameters

remove_planewave_lossbool, optional

Whether to remove the roundtrip loss a plane wave would experience to see the loss induced from HOM effects.

Returns

indexarray_like

Indicies of ordering for the eigvalues and eigvectors of this solution

lossarray_like

Roundtrip loss of modes

plot_field(mode_idx, *, x=None, y=None, samples=100, scale=3, ax=None, colorbar=True, **kwargs)[source]

Plots a 2D optical field for one of the eigenmodes.

x and y dimensions can be specified if required, otherwise it will return an area of scale times the spot sizes. When x and y are provided scale and samples will not do anything.

Parameters

mode_idxint

index of the mode to plot

x, yndarray, optional

Specify x and y coordinates to plot beam

samplesint, optional

Number of sample points to use in x and y

scalefloat, optional

Number of sample points to use in x and y

axAxis, optional

A Matplotlib axis to put the image on. If None, a new figure will be made.

colorbarbool

When True the colorbar will be added

**kwargs

Extra keyword arguments will be passed to the pcolormesh plotting function.

plot_phase(scale=None, ax=None, **kwargs)[source]

Plots the eigenmode phases.

Parameters

scalefloat

Scale of scatter point size

axMatplotlib.Axis, optional

The axis to plot on to, if None a new figure is made

**kwargs

Keyword arguments passed to matplotlib.pyplot.scatter for styling trace

plot_roundtrip_loss(remove_planewave_loss=False, ax=None, **kwargs)[source]

Plots the roundtrip loss of the cavity for each eigenmode.

Parameters

remove_planewave_lossbool, optional

If True, remove the loss a planewave would experience to just see the effects from higher order modes.

axMatplotlib.Axis, optional

The axis to plot on to, if None a new figure is made

**kwargs

Keyword arguments passed to matplotlib.pyplot.semilogy for styling trace

class finesse.analysis.actions.operator.Operator(start_node, end_node, via=None, frequency=0, *, name='operator')[source]

Bases: Action

This action can be used to extract operators out from a simulation for external use. The operators are defined by a path in the network between two nodes (via some other if more direction is required).

The model.path method can be used to test which nodes are traversed before using this to extract operators if needed.

Parameters

start_nodestr

Start node name

end_nodestr

End node name

viastr, optional

Via node (or sequence of via nodes) to use to specify a path with multiple options

frequencyfloat, optional

Optical carrier or signal frequency to use for calculating the operators

namestr, optional

Name of the solution generated by this action

class finesse.analysis.actions.operator.OperatorSolution[source]

Bases: BaseSolution

connections: tuple[tuple[str, str], ...]
matrices: list[ndarray, ...]

Contains solution to the Operator action. The main result is the operator attribute which describes the operator taking the field from start to end node.

Attributes

connections[(Node, Node)]

A list of node pairs describing the connections traversed to compute this operator

operatorndarray(ndim=2, dtype=complex)

The operator describing the propagation from start to end node.

matriceslist[array]

A list of operators for each connection

operator: ndarray
finesse.analysis.actions.operator.track_eigenvalues(solutions: Iterator[EigenmodesSolution], position_weight=1, velocity_weight=1)[source]

Track and reorder set of EigenmodesSolution that are varying. This function is not gaurantted to work for all cases.

Parameters

solutionsIterator[EigenmodesSolution]

An iterator of EigenmodesSolution objects containing eigenvalues and eigenvectors.

Returns

eigenvalues_unsortedarray_like

Unsorted eigenvalues

eigenvalues_sortedarray_like

Sorted eigenvalues

indiciesarray_like

Indicies of the sorted eigenvalues

Notes

This function reorders the eigenvalues and eigenvectors at each time step to maintain consistency in tracking the modes over time. The reordering is based on the positions of the eigenvalues in the complex plane.