CircuitModel¶
- class photonforge.CircuitModel(mesh_refinement=None, verbose=True)¶
Model based on circuit-level S-parameter calculation.
The component is expected to be composed of interconnected references. Scattering parameters are computed based on the S matrices from all references and their interconnections.
The S matrix of each reference is calculated based on the active model of the reference’s component. Each calculation is preceded by an update to the componoent’s technology, the component itself, and its active model by calling
Reference.update
. They are reset to their original state after theCircuitModel.start()
function is called. Keyword arguents inReference.s_matrix_kwargs
will be passed on toCircuitModel.start()
.If a reference includes repetitions, it is flattened so that each instance is called separatelly.
- Parameters:
mesh_refinement (float | None) – Minimal number of mesh elements per wavelength used for mode solving.
verbose (bool) – Flag setting the verbosity of mode solver runs.
See also
Methods
cache_size
([size])Get/set the runtime cache size for mode overlaps.
Clear the runtime cache for mode overlaps, but not the file cache.
from_bytes
(byte_repr)De-serialize this model.
s_matrix
(component, frequencies[, ...])Compute the S matrix for a component using this model.
start
(component, frequencies[, updates, ...])Start computing the S matrix response from a component.
update
(*args, **kwargs)Update this model.
Attributes
Serialize this model.
parametric_function
Function used to update a parametric component.
parametric_kwargs
Keyword arguments used to update a parametric component.
random_variables
List of
monte_carlo.RandomVariable
associated to this component's parameters.- property as_bytes: bytes¶
Serialize this model.
- static cache_size(size=None)¶
Get/set the runtime cache size for mode overlaps.
- Parameters:
size (int) – Set a new cache size. A negative value removes the size limit.
- Returns:
Current cache size.
- Return type:
int
- static clear_cache()¶
Clear the runtime cache for mode overlaps, but not the file cache.
- Return type:
None
- classmethod from_bytes(byte_repr)¶
De-serialize this model.
- Parameters:
byte_repr (bytes)
- Return type:
- start(component, frequencies, updates={}, chain_technology_updates=True, **kwargs)¶
Start computing the S matrix response from a component.
- Parameters:
component (Component) – Component from which to compute the S matrix.
frequencies (Sequence[float]) – Sequence of frequencies at which to perform the computation.
updates (dict) – Dictionary of parameter updates to be applied to components, technologies, and models for references within the main component. See below for further information.
chain_technology_updates – if set, a technology update will trigger an update for all components using that technology.
**kwargs – Keyword arguments passed to reference models.
- Returns:
Result object with attributes
status
ands_matrix
.- Return type:
_CircuitModelRunner
The
'updates'
dictionary contains keyword arguments for theReference.update()
function for the references in the component dependency tree, such that, when the S parameter of a specific reference are computed, that reference can be updated without affecting others using the same component.Each key in the dictionary is used as a reference specification. It must be a tuple with any number of the following:
name: str|re.Pattern
: selects any reference whose component name matches the given regex.i: int
, directly followingname
: limits the selection toreference[i]
from the list of references matching the name. A negative value will match all list items.j: int
, directly followingi
: filter the previous list of references to only those with repetition indexj
in a reference array.None
: matches any reference at any depth.
Examples
>>> updates = { ... # Apply component updates to the first "ARM" reference in ... # the main component ... ("ARM", 0): {"component_updates": {"radius": 10}} ... # Apply model updates to the second "BEND" reference under ... # any "ARM" references in the main component ... ("SUB", "BEND", 1): {"model_updates": {"verbose": False}} ... # Apply model updates to references with component name ... # starting with "COMP_" prefix, at any subcomponent depth ... (None, "COMP.*"): {"technology_updates": {"thickness": 0.3}} ... } >>> s_matrix = component.s_matrix( ... frequencies, model_kwargs={"updates": updates} ... )