Skip to content

Signals

Signal realizations shared by the engineering packages.

They are the pulses that set states at given or periodic times.

PulseInteraction(label, *, target, reset, times=(), period=None, start=0.0, count=None)

Bases: Interaction

Pulses that set states of the target to new values at given or periodic times.

Engineering names them pulses or impulses, as the kicks of a sampled controller or of a pulsed circuit. The pulses fall at every time of times and, with a period, at start + j * period for j from 0, count times or without end. A pulse at the initial time of a run does not fire. The new values are functions of the namespace, which holds namespace.target, the states and parameters of the target, and the time namespace.t. A name with primes sets a derivative, so {"x'": lambda s: s.target.x.diff(s.t) + 1.0} kicks the rate of x. A pulse sets the states of every member of a group at once, and the trajectory records every pulse among its events, under the label of the interaction.

Parameters:

Name Type Description Default
label str

The label of the interaction, unique among the components of its system.

required
target Role

The path of the element or group whose states the pulses set.

required
reset Mapping[str, Callable[[SimpleNamespace], object]]

A mapping from the name of a state of the target, or of its derivative such as "x'", to the function f(namespace) of its new value.

required
times Sequence[float]

The times of the pulses.

()
period float | None

The period of the periodic pulses, or None for none.

None
start float

The time of the first periodic pulse.

0.0
count int | None

The number of periodic pulses, or None for pulses without end.

None

Raises:

Type Description
ValidationError

The pulses set no state, a new value is not a function, the pulses have no time, the period is not positive, or the count is not a positive integer.

Examples:

>>> from skcomplex.systems.engineering.common.signals import PulseInteraction
>>> reset = {'c': lambda s: s.target.c + 1.0}
>>> dose = PulseInteraction('dose', target='body', reset=reset, period=8.0, count=3)
>>> dose.start
0.0
Source code in src/skcomplex/systems/engineering/common/signals/_pulse.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
def __init__(
    self,
    label: str,
    *,
    target: Role,
    reset: Mapping[str, Callable[[SimpleNamespace], object]],
    times: Sequence[float] = (),
    period: float | None = None,
    start: float = 0.0,
    count: int | None = None,
) -> None:
    super().__init__(label)
    self.target = target
    self.reset = reset
    self.times = times
    self.period = period
    self.start = start
    self.count = count