finesse.detectors.pdtypes.construct_segment_beat_matrix

finesse.detectors.pdtypes.construct_segment_beat_matrix(mode_index_map, beats_dict, sparse_output=False, assert_hermitian=True)[source]

Takes a pdtype definition dict and converts it into a matrix suitable to use with a KnmMatrix.

Parameters
mode_index_mapdict[(n,m), index]

Dictionary of mode indices and index

beats_dictstr, pdtype style dict

A dictionary in the pdtype style describing a particular segmentation type for a sensor. If a string is given it will try and get a builtin pdtype dict

sparse_outputbool, optional

Return a sparse CSR matrix object rather than a dense one

assert_hermitianbool, optional

If true then the generated matrix from the pdtype definition must be Hermitian

Returns
2D Complex matrix of size (N, N) with N=len(mode_index_map) or a
CSRMatrix if requested.

Examples

>>> pdtypes.construct_segment_beat_matrix(model.mode_index_map, pdtype.YSPLIT)
array([[0.        +0.j, 0.79788456+0.j, 0.        +0.j],
       [0.79788456+0.j, 0.        +0.j, 0.        +0.j],
       [0.        +0.j, 0.        +0.j, 0.        +0.j]])

Another example showing how to manually compute the segmented photodiode beat signal using this matrix output whilst misaligning some optic.

>>> import finesse
>>> import matplotlib.pyplot as plt
>>> finesse.init_plotting()
>>> # Simple laser reflecting from a steering mirror
>>> model = finesse.script.parse('''
... l l1 P=1
... bs bs1 R=1 T=0
... nothing n1
... link(l1, bs1, 10, n1)
... fd E n1.p1.i f=0
... xaxis(bs1.xbeta, lin, 0, 1e-6, 4)
... gauss g1 l1.p1.o w=1m Rc=inf
... modes(maxtem=3)
... ''')
>>> # Run the model and extract the matrix of mode amplitudes
>>> sol = model.run()
>>> E = sol['E']
>>> # Get the beat matrix for a quadrant photodiode
>>> M = finesse.detectors.pdtypes.construct_segment_beat_matrix(
...     model.mode_index_map,
...     finesse.detectors.pdtypes.XSPLIT
... )
>>> # Compute E^* . M . E over the array
>>> S = (E.conj() * (M @ E.T).T).sum(1)
>>> plt.plot(sol.x1, abs(S))
>>> plt.xlabel("Misalignment [rad]")
>>> plt.ylabel("Signal [W]")
>>> plt.title("QPD alignment signal")