finesse.model.Model.add_parameter

Model.add_parameter(name, value, *, description=None, dtype=<class 'float'>, units='', is_geometric=False, changeable_during_simulation=True)[source]

Adds a new parameter to the Model. This can be used to add a custom parameter to the model that are not defined by elements themselves.

Parameters
namestr

Name of the parameter

valuenumeric | symbolic

The initial value of the parameter, this can be a simple numeric value or some FINESSE symbolic

desriptionstr, optional

A descritive text of what this parameter is

dtypestr, optional

The datatype, typically float, int, bool

unitsstr, optional

Units of the parameter for display purposes

is_geometricbool, optional

Whether this parameter is being used to recompute what the ABCD state of the model is. This should only be true if this is directly used to set what the ABCD matrices are. If you are just using a reference of this for another geometric parameter this does not have to be True.

changeable_during_simulationbool, optional

Whether this parameter is allowed to be changed during the simulation

add_to_model_namespacebool, optional

Whether to add this to the main model namespace or not

Examples

Here we add some new parameters:

>>> import finesse
>>> model = finesse.Model()
>>> A = model.add_parameter('A', 1, units='W')
>>> B = model.add_parameter('B', A.ref +1)

These act like normal element parameters, so references can be made to make symbolic equations and links between elements. These will be unparsed as variables in KatScript:

>>> print(model.unparse())
variable A value=1.0 units='W'
variable B value=(A+1)