Skip to content

Oscillators

Oscillator realizations shared by the physics packages.

The package holds phase and Stuart-Landau oscillators, links, and order.

LinkElement(label, *, w=1.0, space=None, on=None)

Bases: Element

Edge of a network with a weight w.

Couplings along the edge read the weight, as the strength of a power line or of a synapse.

Parameters:

Name Type Description Default
label str

The label of the edge or the group on the edges.

required
w Annotated[object, closed_open(0, oo)]

The weight of the edge, or one weight per edge.

1.0
space BaseSpace | None

The network of the edges, or None for one edge.

None
on str | None

'edges' for one member on every edge of the network, 'hyperedges' for one on every hyperedge, or None.

None

Examples:

>>> from skcomplex.systems.physics.common.oscillators import LinkElement
>>> LinkElement('link', w=0.5).w
0.5
Source code in src/skcomplex/systems/physics/common/oscillators/_link.py
42
43
44
45
46
47
48
49
50
51
def __init__(
    self,
    label: str,
    *,
    w: Annotated[object, RealSet.closed_open(0, oo)] = 1.0,
    space: BaseSpace | None = None,
    on: str | None = None,
) -> None:
    super().__init__(label, space=space, on=on)
    self.w = w

PhaseOscillatorElement(label, *, theta=0.0, omega=1.0, size=None, space=None, on=None, values=None)

Bases: Element

Phase oscillator, a phase theta on the circle with a natural frequency omega.

The phase wraps around the circle, and PhaseRotationInteraction turns it at the natural frequency, as for a clock, a firefly, or a generator of a power grid. Couplings to other oscillators add to the rate of the phase.

Parameters:

Name Type Description Default
label str

The label of the oscillator or the group.

required
theta Annotated[object, Period(2 * pi)]

The initial phase, or one phase per member.

0.0
omega object

The natural frequency, or one frequency per member.

1.0
size int | None

The number of oscillators, or None for one or one per site of the space.

None
space BaseSpace | None

The space of the oscillators, or None for none.

None
on str | None

'edges' or 'hyperedges' for one oscillator on every link of a network, or None for its sites.

None
values Mapping[str, object] | None

Further values by name, or None.

None

Examples:

>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.common.oscillators import PhaseOscillatorElement, PhaseRotationInteraction
>>> clock = PhaseOscillatorElement('clock', omega=2.0)
>>> system = System(elements=[clock], interactions=[PhaseRotationInteraction('turn', target='clock')])
>>> float(system.prepare().simulate(until=1.0, dt=0.5).get_values('clock.theta')[-1])
2.0
Source code in src/skcomplex/systems/physics/common/oscillators/_phase_oscillator.py
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def __init__(
    self,
    label: str,
    *,
    theta: Annotated[object, Period(2 * math.pi)] = 0.0,
    omega: object = 1.0,
    size: int | None = None,
    space: BaseSpace | None = None,
    on: str | None = None,
    values: Mapping[str, object] | None = None,
) -> None:
    super().__init__(label, values=values, size=size, space=space, on=on)
    self.theta = theta
    self.omega = omega

PhaseRotationInteraction(label, *, target)

Bases: Interaction

Rotation of the phase theta of an oscillator at its natural frequency omega, theta' = omega.

The target holds the phase and the frequency, one of each per member of a group. Couplings to other oscillators add to the rate of the phase, as for a clock, a firefly, or a generator of a power grid.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the oscillator or the group of oscillators.

required

Examples:

>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.common.oscillators import PhaseRotationInteraction
>>> clocks = Element('clocks', values={'theta': 0.0, 'omega': [1.0, 2.0]}, size=2)
>>> system = System(elements=[clocks], interactions=[PhaseRotationInteraction('turn', target='clocks')])
>>> system.prepare().simulate(until=1.0, dt=0.5).get_values('clocks.theta')[-1].tolist()
[1.0, 2.0]
Source code in src/skcomplex/systems/physics/common/oscillators/_phase_rotation.py
38
39
40
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

SitedOscillatorElement(label, *, theta=0.0, omega=1.0, x=0.0, size=None, space=None, values=None)

Bases: PhaseOscillatorElement

Phase oscillator with a place x in a continuous space.

The place is named after the axis of the space, so it is the position of the oscillator, which couplings within a distance read. The phase turns at the natural frequency, and the place changes only by the rates of interactions.

Parameters:

Name Type Description Default
label str

The label of the oscillator or the group.

required
theta Annotated[object, Period(2 * pi)]

The initial phase.

0.0
omega object

The natural frequency.

1.0
x object

The initial place, one row per member or shared.

0.0
size int | None

The number of oscillators, or None for one.

None
space BaseSpace | None

The continuous space of the oscillators, or None for none.

None
values Mapping[str, object] | None

Further values by name, or None.

None

Examples:

>>> from skcomplex.systems.physics.common.oscillators import SitedOscillatorElement
>>> SitedOscillatorElement('unit', x=[0.0, 1.0]).x
[0.0, 1.0]
Source code in src/skcomplex/systems/physics/common/oscillators/_sited_oscillator.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def __init__(
    self,
    label: str,
    *,
    theta: Annotated[object, Period(2 * math.pi)] = 0.0,
    omega: object = 1.0,
    x: object = 0.0,
    size: int | None = None,
    space: BaseSpace | None = None,
    values: Mapping[str, object] | None = None,
) -> None:
    super().__init__(label, theta=theta, omega=omega, size=size, space=space, values=values)
    self.x = x

StuartLandauInteraction(label, *, target)

Bases: Interaction

Stuart-Landau flow of z = x + i y, z' = tau ((mu + i omega) z - kappa (1 + i beta) |z|^2 z).

The flow is the normal form of a supercritical Hopf bifurcation. For mu > 0 the oscillator settles on the limit cycle of radius sqrt(mu / kappa), which it turns at the frequency tau (omega - beta mu), and for mu < 0 it decays to the fixed point 0. The target holds the values x and y of z and the parameters mu, omega, beta, kappa, and tau, one of each per member of a group, as for a laser near threshold, a chemical oscillator, or a neuron that starts to fire.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the oscillator or the group of oscillators.

required

Examples:

>>> import math
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.common.oscillators import StuartLandauInteraction
>>> values = {'x': 0.1, 'y': 0.0, 'mu': 4.0, 'omega': 1.0, 'beta': 0.0, 'kappa': 1.0, 'tau': 1.0}
>>> flow = StuartLandauInteraction('flow', target='oscillator')
>>> system = System(elements=[Element('oscillator', values=values)], interactions=[flow])
>>> trajectory = system.prepare().simulate(until=10.0, dt=0.5)
>>> round(math.hypot(trajectory.get_values('oscillator.x')[-1], trajectory.get_values('oscillator.y')[-1]), 4)
2.0
Source code in src/skcomplex/systems/physics/common/oscillators/_stuart_landau.py
47
48
49
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

order_parameter(label, group)

Return the complex mean field of a group's phases and its modulus.

The modulus is the order parameter.

The mean field Z = <exp(i theta)> averages the unit vectors of the phases theta of the group's members, and the order parameter r = |Z| is 0 for scattered phases and 1 for locked phases.

Parameters:

Name Type Description Default
label str

The label of the order parameter. The mean field has the label <label>_field.

required
group str

The path of the group of oscillators, whose members have the phase theta.

required

Returns:

Name Type Description
observables list[Observable]

The mean field and the order parameter.

Examples:

>>> from skcomplex.systems.physics.common.oscillators import order_parameter
>>> [observable.label for observable in order_parameter('order', 'oscillators')]
['order_field', 'order']
Source code in src/skcomplex/systems/physics/common/oscillators/_order_parameter.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def order_parameter(label: str, group: str) -> list[Observable]:
    """Return the complex mean field of a group's phases and its modulus.

    The modulus is the order parameter.

    The mean field `Z = <exp(i theta)>` averages the unit vectors of the phases `theta` of the group's members, and the
    order parameter `r = |Z|` is 0 for scattered phases and 1 for locked phases.

    Args:
        label:
            The label of the order parameter. The mean field has the label `<label>_field`.

        group:
            The path of the group of oscillators, whose members have the phase `theta`.

    Returns:
        observables:
            The mean field and the order parameter.

    Examples:
        >>> from skcomplex.systems.physics.common.oscillators import order_parameter
        >>> [observable.label for observable in order_parameter('order', 'oscillators')]
        ['order_field', 'order']
    """
    return [
        Observable(f'{label}_field', _phase_vector, group=group),
        Observable(label, partial(_modulus, f'{label}_field')),
    ]