finesse.simulations.workspace module

class finesse.simulations.workspace.ABCDWorkspace(BaseSimulation sim, owner, values=None)[source]

Bases: ElementWorkspace

This class represents a workspace for ABCD matrix calculations in Finesse simulations. It inherits from the ElementWorkspace class.

Attributes

simBaseSimulation

The BaseSimulation object associated with the workspace.

ownerobject

The owner object of the workspace.

valuesobject, optional

Additional values associated with the workspace.

Methods

set_gouy_function(callback)

Sets the callback function for computing the gouy phase terms.

compile_abcd_cy_exprs()

Compiles the ABCD matrix expressions for the workspace.

flag_changing_beam_parameters(changing_edges)

Called when the workspace should check if changing beam parameters will affect this workspace’s calculations.

update_map_data()

Called when the workspace should update any map data

compile_abcd_cy_exprs(self)[source]

Compiles the ABCD matrix expressions for the workspace. It is called during the simulation setup phase.

flag_changing_beam_parameters(self, OrderedSet changing_edges)[source]

Flags changing beam parameters for the workspace. Workspaces that inherit from this must then check the edges it is dealing with and determine whether it needs to do extra calculations or not.

Parameters

changing_edgesset

A set of edges (tuple of (in, out) node indices) that have a changing beam parameter. The index can be related back to a node object by checking the BaseSimulation.trace_node_index dictionary.

fn_gouy_c
fn_gouy_py
set_gouy_function(self, callback)[source]

Sets the callback function that will be used by the model to compute the gouy phase terms for an element. This can either be a Python function or cdef wrapped with GouyFuncWrapper.

Parameters

callbackfunction or GouyFuncWrapper

The callback function that computes the gouy phase terms for an element. It can be either a Python function or a cdef wrapped function.

update_map_data(self)[source]

Signals that a workspace should update any data held in maps it is using. This is called when the simulation is first run and when the UpdateMaps action is called.

class finesse.simulations.workspace.GouyFuncWrapper[source]

Bases: object

Helper class for wrapping a C fill function that can be referenced from Python by objects. This allows a direct C call to the function from other cdef functions.

Wraps a cdef for setting the gouy phase during a modal simulation.

Examples

Create a C function then wrap it using this class:

>>> cdef int c_set_gouy(ABCDWorkspace ptr_ws) noexcept:
>>>    cdef MirrorWorkspace ws = <MirrorWorkspace>ptr_ws
>>>    ...
>>>
>>> fill = GouyFuncWrapper.make_from_ptr(c_set_gouy)