finesse.simulations.homsolver module
- class finesse.simulations.homsolver.HOMSolver(str name, list nodes, FrequencyContainer optical_frequencies, dict signal_frequencies, bool is_signal_matrix, bool forced_refill, dict node_aliases, int num_optical_homs, bool debug_mode=False)[source]
Bases:
BaseSolverThis is class provides an interface for generic simulations that are solving for a vector of higher order modes at each node. This allows detectors and other calculation code to be able to perform the same calculations without being specified. This class should be inherited to provide specific implementations. Considerations are:
HOM vector at each node should be contiguous in memory
Not all nodes will have a HOM vector if it isn’t being solved for
Signal nodes will have a single “HOM”
- component_edge_fill(self, comp, edgestr, f1, f2, conjugate=False)[source]
Returns a matrix for the submatrix an element has requested for different connections it needs. The key is:
(element, connection_name, ifreq, ofreq)
This is a context manager, to be used like with sim.component_edge_fill(key) as mat:
mat[:] = computations
Parameters
- elementfinesse.component.Connector
The object reference that created the requests.
- connection_namestr
String name given to the connection.
- ifreqfinesse.Frequency
Incoming frequency.
- ofreqfinesse.Frequency
Outgoing frequency.
Returns
matrix
- field(self, node, Py_ssize_t freq=0, Py_ssize_t hom=0) Py_ssize_t
Returns simulation unique index of a field at a particular frequency index at this node.
Parameters
- node
Node Node object to get the index of.
- freqint
Frequency index.
- homint, optional
Higher Order Mode index, defaults to zero.
- node
- findex(self, node, Py_ssize_t freq) Py_ssize_t
- get_node_info(self, node)[source]
For a given node (object or name) the key parameters for where this node is represented in the matrix of linear equations.
Parameters
- node[str | Node]
The name or the Node object of the node.
Returns
- dict: A dictionary containing the following information about the node:
index: The index of the node.
rhs_index: The index of the right-hand side vector associated with the node.
freq_index: The index of the frequency vector associated with the node.
nfreqs: The number of frequencies.
nhoms: The number of higher order modes. [TODO generalise to pixels/HOMs/whatever]
- get_out(self, node, Py_ssize_t freq=0, Py_ssize_t hom=0) double complex
- nhoms
- node_field_vector
Returns the higher order mode field vector of a given node at a specific frequency index.
Parameters
- node[int|object|str]
The node for which to retrieve the field vector. This can be a string full-name of a node, ‘m1.p1.i’, or a node object. It can also be an integer index of the node for this simulation.
- freq_idxunsigned long
The index of the frequency at which to retrieve the field vector.
Returns
- np.ndarray:
A copy of the field vector of the node at the specified frequency index.
- out_view
out_view: ‘double complex[::1]’
- out_view_size
out_view_size: ‘Py_ssize_t’