finesse.simulations.basesolver module

class finesse.simulations.basesolver.BaseSolver(str name, list nodes, FrequencyContainer optical_frequencies, dict signal_frequencies, bool is_signal_matrix, bool forced_refill, dict node_aliases, bool debug_mode=False)[source]

Bases: object

A linear set of systems can be represented as a matrix, each equation in this system is a particular state which we want to compute. The system is solved by applying some inputs into various states, or the right hand side (RHS) vector, and solving the system.

The underlying matrix can be either a sparse or dense matrix. This class should not assume either, but merely call upon a standard matrix interface. Therefore the algorithm used for solving can vary significantly. The overall matrix is sectioned into submatricies which connect various states together.

Nodes represent a physical location in the model in which some state of the system must be computed. Some nodes can have multiple states, such as multiple optical modes.

add_rhs(self, str key)[source]
any_frequencies_changing
assign_noise_operators(self, connector_workspaces)[source]
assign_operators(self, connector_workspaces)[source]

An important function. This takes all the connector workspaces - i.e. model elements that have requested some type of connection in the model - and ensures they have the correct submatrix allocated to them in for this solver.

changing_mismatch_node_ids
clear_rhs(self)[source]
connections
construct(self)[source]

This is called when workspaces and submatrices have been setup. Calling construct should now go and allocate the memory for the matrix and RHS.

This method should be overwritten by an inheriting solver class with specfics of the solving technique.

destruct(self)[source]

This is called when finishing and unbuilding the simulation.

Classes that override this call should mindful of what this method is doing to and call it.

factor(self)[source]
fill_noise_inputs(self)[source]
fill_rhs(self)[source]
findex(self, node, Py_ssize_t freq) Py_ssize_t

Returns simulation unique index for a given frequency at this node. Used to refer to submatrices of HOMs in the interferometer matrix.

Parameters

nodeNode

Node object to get the index of.

freqint

Frequency index.

Returns

indexint

Index of the node for a given frequency.

forced_refill
get_frequency_object(self, frequency, node)[source]

Get a Frequency object corresponding to a numerical or symbolic value. Returns none if nothing has been found.

Parameters

fnumber or Symbol

Frequency to search for in this simulation.

Returns

Frequency

The frequency object.

get_node_frequencies(self, node) tuple
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]

index_2_node
initial_fill(self)[source]
initial_run(self)[source]

Once a solver has been constructed it will most likely need to be initially filled and ran. Some sparse solvers for example must do a full factor first, then can perform faster refactors.

This method should be overwritten by an inheriting solver class with specfics of the solving technique.

initialise(self, sim)[source]
input_components(self)[source]

Components that are injecting something into the simulation

manual_rhs

manual_rhs: ‘bool’

node_2_index
node_aliases
node_id(self, node) Py_ssize_t
nodes
noise_sources
num_solves
optical_frequencies
print_matrix(self)[source]
refactor(self)[source]
refill(self)[source]
refill_rhs(self)[source]
run(self)[source]

Executes the simulation for model in its current state.

Takes the following steps to compute an output:
  • If self.manual_rhs:
    • Clears the RHS vector

    • Fills the RHS vector

  • Fills the matrix

  • Solves

setup_nodes(self, list all_nodes, dict node_aliases)[source]
signal_frequencies
solve(self)[source]
solve_noises(self)[source]
unique_elec_mech_fcnts
update_frequency_info(self)[source]
workspaces
class finesse.simulations.basesolver.MatrixSystemWorkspaces[source]

Bases: object

clear_workspaces(self)[source]
detector_list_to_C(self)[source]
list_to_C(self)[source]

Converts the python lists of workspaces into C Pyobject arrays for fast loop access.

noise_detectors
num_noise_detectors
num_to_noise_input_refill
num_to_noise_refill
num_to_refill
num_to_rhs_refill
to_initial_fill
to_noise_input_refill
to_noise_refill
to_refill
to_rhs_refill