Model¶
-
class
scampy.Model.
Model
¶ Defines the optical network to be modelled.
The Model class holds the information that defines the structure of the optical network to be modelled with scampy, along with functions for building and evaluating the model. In general only the wavelength attribute should be accessed directly by the user - all other attributes should be set through the member functions.
- Attributes
- wavelengthfloat
The vacuum (n = 1) wavelength of illuminating light.
- componentsdict
Dictionary of optical components that have been added to the model.
- detectorsdict
Dictionary of detectors that have been added to the model.
- nodesdict
Dictionary of nodes that have been added to the model.
- symbolslist
List of sympy symbols used by the model.
- equationslist
List of sympy equations used by the model.
- rhsVariableslist
List of sympy symbols that are included in the right hand side vector of the matrix equation.
- matrixVariableslist
List of sympy symbols that are included in the network matrix.
- updatedlist
List of optical components that have changed since the model was last evaluated.
- useLambdifybool
True if sympy’s lambdify functionality should be used to set right hand side vector and matrix before evaluation. If false only components that are included in the updated list are updated in the matrix equation before solving. Lambdify is currently a fallback if there is more than one sympy symbol per matrix element.
Methods
add_component
(self, component, name, nodes)Adds component to model and updates the node list.
add_detector
(self, name, node[, properties])Adds detector to model and updates list of nodes.
build
(self[, verbose])Builds network matrix from defined components.
evaluate
(self[, timing])Solve the network matrix and log optical properties at detectors.
-
add_component
(self, component, name, nodes)¶ Adds component to model and updates the node list.
- Parameters
- componentscampy.components.component
Type of component to be added.
- namestr
Unique name of component.
- nodesstr or tuple of str
Node(s) to which the component is attached.
-
add_detector
(self, name, node, properties=('amplitude', ))¶ Adds detector to model and updates list of nodes.
For details on currently implemented properties see
scampy.Detector()
.- Parameters
- namestr
Unique name of the detector.
- nodesstr
Node monitored by detector.
- propertiestuple of str
Optical properties to be logged - see
scampy.Detector()
for current options.
-
build
(self, verbose=False)¶ Builds network matrix from defined components.
The model must be built before evaluate() is called. Additionally, if components or detectors are added to the model between runs, the model must be rebuilt.
- Parameters
- verbosebool
If true details of the constructed optical network will be printed during the build process.
-
evaluate
(self, timing=False)¶ Solve the network matrix and log optical properties at detectors.
build() must have been called before the model is evaluated.
- Parameters
- timingbool
If true, the times taken to set values in the right hand side vector and network matrix (set_time), solve the network equation (solve_time) and pull out the detected values (detector_time) are returned.