Skip to content

Avalanches

Avalanches shared by the physics packages.

They are the toppling that relaxes the sites of a sandpile.

TopplingInteraction(label, *, target, state='x', threshold=1.0, share=0.0, mode='redistribute', drive=None, neighborhood=None)

Bases: Interaction

Cascade of the members whose state reaches a threshold.

These members relax and pass shares to their neighbours. At every step the drive changes the state, and then every member whose state reaches threshold relaxes, all at once, until no member does. In the mode 'redistribute' a relaxing member loses threshold and each of its neighbours gains share. In the mode 'reset' a relaxing member falls to 0 and each of its neighbours gains share times the state it relaxed from. In the mode 'random' a relaxing member loses threshold in parcels of share, and every parcel goes to one of its neighbours drawn at random. Neighbours outside a fixed boundary take no share, so it leaves the system, and the mode 'random' treats every lattice as bounded. Every cascade is recorded as an event with its size, the number of relaxations, its duration, and its area.

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 group on the nodes or sites.

required
state str

The name of the state of the members.

'x'
threshold float

The value of the state at which a member relaxes, fixed during a run.

1.0
share float

What a neighbour of a relaxing member gains, an amount, a fraction of the state in the mode 'reset', or the amount of one parcel in the mode 'random', fixed during a run.

0.0
mode str

'redistribute', 'reset', or 'random'.

'redistribute'
drive Callable[..., Array] | None

A function f(values, *, random, **kwargs) of the array of the states, the random generator of the simulation, and the other keywords of a rule of an UpdateLaw, that returns the states after the drive of a step, or None for no drive. A cascade with a drive draws numbers.

None
neighborhood BaseNeighborhood | None

The neighbourhood of the member itself first and its neighbours, or None for the von Neumann neighbourhood of a square lattice with its centre. A network takes AdjacencyNeighborhood(center=True), and the mode 'random' takes a lattice neighbourhood.

None

Raises:

Type Description
ValidationError

The mode is unknown, the drive is not callable, the neighbourhood leaves out the member itself, or the mode 'random' has no lattice neighbourhood or a threshold that is not a whole number of parcels.

Examples:

>>> from skcomplex.systems.physics.common.avalanches import TopplingInteraction
>>> cascade = TopplingInteraction('cascade', target='sites', state='height', threshold=4, share=1)
>>> cascade.mode
'redistribute'
Source code in src/skcomplex/systems/physics/common/avalanches/_toppling.py
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
def __init__(
    self,
    label: str,
    *,
    target: Role,
    state: str = 'x',
    threshold: float = 1.0,
    share: float = 0.0,
    mode: str = 'redistribute',
    drive: Callable[..., Array] | None = None,
    neighborhood: BaseNeighborhood | None = None,
) -> None:
    super().__init__(label)
    self.target = target
    self.state = state
    self.threshold = threshold
    self.share = share
    self.mode = mode
    self.drive = drive
    self.neighborhood = neighborhood