finesse.analysis.actions.base module

Base level Actions utilities and classes.

class finesse.analysis.actions.base.Action(name, analysis_state_manager=False)[source]

Bases: object

Base class for all actions

property analysis_state_manager[source]
get_requests(model)[source]
property name[source]
plan(previous=None)[source]

Returns an expected plan for the actions that will be run in a tree form. This may not be exactly what is ran.

Returns

plan : TreeNode

class finesse.analysis.actions.base.AnalysisState(model, name='AnalysisState', parent=None, simulation_type=None, simulation_options=None)[source]

Bases: TreeNode

property action_workspaces[source]

Actions can use themselves, self, as a key to store simulation specific data and reuse it each time run is called.

Use a weakref.WeakKeyDictionary rather than a plain dict because a plain dict using id(self) as a key would:

  1. leak an entry for every transient action for the lifetime of this state

  2. allow a new action to have the same key as a stale one thus having the new action try to use the stale actions workspace

apply(action)[source]
build_model(changing_params, extra_input_nodes, extra_output_nodes)[source]
finished()[source]
property model[source]
property previous_solution[source]
set_parameter_values(parameter_values: Mapping[Parameter, float | Symbol]) None[source]

Change a collection of parameter values and recalculates the ABCD matrices if necessary. To be used inside actions which temporarily adjust parameter values, but are meant to leave the model in the same state as before the action.

This code used to be copy-pasted in different places of Finesse. At the time of writing we are not sure whether it is always necessary to call this function when you are changing parameters inside of an action (calling finesse.simulations.simulation.BaseSimulation.run_carrier() probably has the same effect), or whether this only necessary as a ‘clean-up’ at the end of an action.

Parameters

parameter_valuesdict[Parameter, float | Symbol]

Parameters and the value they need to be set to

property sim[source]
finesse.analysis.actions.base.convert_str_to_parameter(model, attr)[source]

Converts names component.parameter or component to a parameter object. Will return default parameter when component name is given.

Parameters

modelModel

Model object to look for parameter in

attr[str | Parameter]

String value for the name of an element or a parameters full name. If a Parameter is given its full name will be used to grab the equivalent parameter in this Model.

Returns

parameter

The equivalent Parameter object for the attr provided

finesse.analysis.actions.base.request_dict_reduction(A, B)[source]