finesse.simulations.simulation module
- class finesse.simulations.simulation.BaseSimulation(model, str name, dict simulation_options)[source]
Bases:
objectThis base level class should be inherited by others to perform the exact needs of a particular type of simulation. This BaseSimulation class contains the methods to store common settings as well as functionality for beam tracing through a model, and detecting which beam parameters will be changing. Developers should ensure that methods raising NotImplementedError are defined in any deriving classes.
- carrier
- carrier_frequencies_to_use
- cavity_workspaces
cavity_workspaces: dict
- changing_maps
- changing_mismatch_couplings
- changing_mismatch_edges
- changing_parameters
- compute_signals
- connector_workspaces
connector_workspaces: list
- detector_workspaces
- generate_carrier_frequencies(self)[source]
Returns a list of Frequency objects that the model has requested
- generate_signal_frequencies(self, nodes, FrequencyContainer carrier_optical_frequencies)[source]
Generates the optical, mechanical, and electrical frequencies that should be modelled by the signal simulation.
- get_q(self, node)[source]
Returns a tuple of (qx, qy) for a given node. The returned value is only valid until this simulations trace forest has been updated.
Parameters
- node
finesse.components.OpticalNode Node to get beam parameters at
Returns
- (qx, qy)
Tuple of x and y beam parameters
- node
- gouy_phase_workspaces
- initial_trace_sol
- is_component_in_mismatch_couplings(self, comp)[source]
Determines whether the connector comp is associated with any of the node couplings in the stored changing mismatch couplings.
Note
This method can be replaced if connectors eventually use more granular refill flags — i.e. per coupling refill flags. Then the check for refilling that coupling can simply include the condition
(from_node, to_node) in sim.changing_mismatch_couplings.
- is_modal
- last_parameter_change_count
- modal_update(self)[source]
Updates HOM related dependencies / properties of the model.
These updates are as follows:
Execute a beam trace on the changing trace trees
Computes the changing scattering matrices
Calculates the Gouy phase of Spaces and Laser power coefficients
Returns
- validitybool
True if the modal update was successful, or False if an unstable cavity combination prevented a beam trace from being performed.
- model
- model_settings
- name
- nodes_with_changing_q
- optical_nodes_to_use
- parameter_change_count
- post_build(self)[source]
Post build calls functions that should be called after everything else has been built. For example, detectors that might rely on components being set up.
- pre_build(self)[source]
Pre-build performs some common setup routine that should be applicable to any deriving simulation class. This method performs the following tasks:
Checks if the signal frequency (fsig) is changing and if its value is None. If so, it sets a default value of 1 Hz.
Creates a list of all the changing parameters in the simulation.
Creates a set of tunable parameters from the changing parameters.
Determines if signal computation is required based on the value of fsig.f. Sets self.compute_signals
Determines if the simulation is modal or not. Sets self.is_modal
Initializes the model settings
Initializes the simulation configuration data.
Generates carrier frequencies based on the model.
Initializes the trace forest if the simulation is modal.
Determines the changing beam parameters if the simulation is modal.
- readout_workspaces
- run_carrier(self, force=False)[source]
Runs the carrier matrix solver for the current state of the model. This will update all the C based structs with the current model state so that filling and calculations can be performed.
Parameters
- forcebool
If True, the carrier solver will be run even if no parameters have changed since the last run. This is useful for ensuring that the carrier solver is up-to-date before running the signal solver.
Returns
- validitybool
True if this was a valid run, or False if a recoverable error occurred which results in the output being invalid for this call.
- run_signal(self, solve_noises=True)[source]
Runs the signal matrix solver for the current state. This function should assume that a call to the run_carrier method has preceeded it. Many modal and parameter updates should happen in there already, so do not need to be repeated here.
- signal
- signal_frequencies_to_use
- signal_nodes_to_use
- signal_optical_frequencies_to_use
- simulation_options
- trace_beam(self)[source]
Traces the beam through the paths which are dependent upon changing geometric parameter(s).
This method will modify those entries in the
self.traceC array which were previously determined to have changing beam parameter values.Returns
- validitybool
True if the tracing was successful, or False if an unstable cavity combination prevented a beam trace from being performed.
Raises
- ex
BeamTraceException If the
"unstable_handling"entry of the associatedModel.sim_trace_configdict is"abort"and any unstable cavities were encountered.
- trace_forest
- trace_node_index
- tunable_parameters
- update_all_parameter_values(self)[source]
Loops through all workspaces to update the C structs so they represent the current model element parameter values.
- update_map_data(self)[source]
This will cycle through each map being used and if it is defined by a function it will be evaluated again.
- workspace_name_map
workspace_name_map: dict
- workspaces
workspaces: list