ExpressionTimeStepper

class photonforge.ExpressionTimeStepper(*, expressions)[source]

Expression time stepper for electrical signals.

Parameters:

expressions (dict[str, str]) – Dictionary of expression strings for all output ports, indexed by name.

Example

Example time stepper to be used on a component with 3 electrical ports: “E0”, “E1”, “E2”. The first has a 0.1 reflection coefficient, the second has no output (zero, by default), and the third has a non-linear combination of all 3 inputs.

>>> time_stepper = pf.ExpressionTimeStepper(
...     expressions={
...         "E0": "0.1 * E0",
...         "E2": "0.5 * E0 * E2 + abs(E1) * E1",
...     }
... )

Note

Expressions can use all operators supported by Expression.

Methods

reset()

Reset any internal state of the time stepper.

setup(component, time_step, *[, ...])

Initialize the time stepper.

setup_state(*, component, **kwargs)

Initialize internal state.

step([inputs, steps, time_step, show_progress])

Compute the outputs of this time stepper, given inputs.

step_single(inputs, outputs, time_index, ...)

Take a single time step on the given inputs.

update(*args, **kwargs)

Update this time stepper.

Attributes

parametric_function

Function used to update the time stepper.

parametric_kwargs

Keyword arguments used to update the time stepper.

properties

Object properties.

random_variables

Random variables associated to the time stepper's parameters.

setup_state(*, component, **kwargs)[source]

Initialize internal state.

Parameters:
  • component (Component) – Component representing the time stepper.

  • kwargs – Unused.

step_single(inputs, outputs, time_index, update_state, shutdown)[source]

Take a single time step on the given inputs.

Parameters:
  • inputs (ndarray) – Input values at the current time step. Must be a 1D array of complex values ordered according to keys.

  • outputs (ndarray) – Pre-allocated output array where results will be stored. Same size and type as inputs.

  • time_index (int) – Time series index for the current input.

  • update_state (bool) – Whether to update the internal stepper state.

  • shutdown (bool) – Whether this is the last call to the single stepping function for the provided TimeSeries.

Return type:

None