Skip to content

Kinetics

Define the kinetic encounters that the systems of several fields share.

Distributions over the values of a trait meet in pairs and change class.

EncounterInteraction(label, *, candidate, field=None, rate=None, kernel=None, outcome='conservative', state='x', cross_section=None, factor=None)

Bases: Interaction

An interaction where members of two distributions meet and change class.

A distribution is a group of NonnegativeElement with one member per class of a trait. A candidate at class h meets the field at class k at the rate rate[h, k], and the outcome says what follows:

  • 'conservative': the candidate moves to class i with the probability kernel[h, k, i].
  • 'destructive': the candidate is removed.
  • 'proliferative': the candidate creates a new candidate at class i with the probability kernel[h, k, i], or at its own class without a kernel.

The rate and the kernel are functions of the namespace, which holds namespace.candidate, namespace.field, and the parameters. On a PhaseSpace encounters pair classes at the same position. Without a field the encounter is a linear redistribution between classes. With a cross_section the rate is the binary collision integral of kinetic theory, evaluated by a fast spectral method, which keeps the density exactly and the momentum and energy to spectral accuracy.

Unlike the bilinear form of the core, which its rate laws hold, it names the outcomes of an encounter and builds the rates and kernels from them. Choose it when the change of a population comes from binary meetings of its members.

It appears in many fields. Traders exchange wealth when they meet, people shift their opinion after a conversation, immune cells destroy tumour cells they meet, and gas molecules change velocity when they collide.

Parameters:

Name Type Description Default
label str

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

required
candidate Role

The path of the group of the candidate density.

required
field Role | None

The path of the group of the field density, or None for a linear redistribution.

None
rate Callable[[SimpleNamespace], object] | None

The function rate(namespace) of the encounter rate, a number or an expression, or an array eta[h, k] of them, or eta[h] without a field, or None with a cross-section.

None
kernel Callable[[SimpleNamespace], object] | None

The function kernel(namespace) of the array kernel[h, k, i] of the probabilities of the class of the moved or created candidate, or kernel[h, i] without a field, or None for a destructive encounter or the candidate's own class.

None
outcome str

'conservative', 'destructive', or 'proliferative'.

'conservative'
state str

The name of the state of the densities.

'x'
cross_section Callable[..., object] | None

The function B(speed, cosine) of arrays of the relative speed and the cosine of the deflection angle, or None for encounters at a rate.

None
factor Callable[[SimpleNamespace], object] | None

A function of the namespace that returns a factor of the collision frequency, such as a function of the density moment, or None for none.

None

Raises:

Type Description
ValidationError

The outcome is unknown, the state is no name, a function is not callable, a conservative encounter has no kernel, an encounter without a field is not conservative, an encounter has neither a rate nor a cross-section, or a cross-section comes with a rate, a kernel, a field, or an outcome.

Examples:

>>> import numpy as np
>>> from skcomplex.systems.general.kinetics import EncounterInteraction
>>> kernel = np.full((3, 3, 3), 1 / 3)
>>> mixing = EncounterInteraction(
...     'mixing', candidate='population', field='population', rate=lambda s: 1.0, kernel=lambda s: kernel
... )
>>> mixing.outcome
'conservative'
>>> collide = EncounterInteraction('collide', candidate='gas', cross_section=lambda speed, cosine: 1.0)
>>> collide.rate is None
True
Source code in src/skcomplex/systems/general/kinetics/_encounter.py
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def __init__(
    self,
    label: str,
    *,
    candidate: Role,
    field: Role | None = None,
    rate: Callable[[SimpleNamespace], object] | None = None,
    kernel: Callable[[SimpleNamespace], object] | None = None,
    outcome: str = 'conservative',
    state: str = 'x',
    cross_section: Callable[..., object] | None = None,
    factor: Callable[[SimpleNamespace], object] | None = None,
) -> None:
    super().__init__(label)
    self.candidate = candidate
    self.field = field
    self.rate = rate
    self.kernel = kernel
    self.outcome = outcome
    self.state = state
    self.cross_section = cross_section
    self.factor = factor