Skip to content

Waves

Wave systems.

The package covers strings, chains of springs, quantum wave packets, and abelian and non-abelian lattice gauge fields.

ChargedSchrodingerSystem(n_sites=256, *, length=80.0, D=0.5, q=1.0, momentum=0.0, width=2.0, A_x=0.0, A_t=0.0, E=1.0, duration=2.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A Gaussian wave packet of a charge in a prescribed electromagnetic potential.

The system follows Schwichtenberg 4.3.

The wave function follows the Schrödinger equation with the covariant derivatives d - i q A, (d_t - i q A_t) psi = i D (d_x - i q A_x)^2 psi, on a periodic line with spectral derivatives. A mode of wave number k turns at the frequency D (k - q A_x)^2 - q A_t, so the packet moves at the group velocity 2 D (k - q A_x). A constant A_x is a pure gauge that only shifts the canonical momentum, while the electric field E switched on for duration changes A_x and accelerates the packet at the rate 2 D q E. The system has the real part packet.u and the imaginary part packet.w of the wave function.

Parameters:

Name Type Description Default
n_sites int

The number of sites of the periodic lattice.

256
length float

The length of the periodic line, centered on 0.

80.0
D float

The coefficient of the Laplacian, ħ / (2 m).

0.5
q float

The electric charge.

1.0
momentum float

The mean wave number k of the packet.

0.0
width float

The width of the packet.

2.0
A_x float

The vector potential at time 0.

0.0
A_t float

The scalar potential.

0.0
E float

The electric field.

1.0
duration float

The time the electric field is on.

2.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.physics.waves import ChargedSchrodingerSystem
>>> ChargedSchrodingerSystem(64, E=0.5).prepare().system_.interactions[0].E
0.5
Source code in src/skcomplex/systems/physics/waves/_charged.py
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def __init__(
    self,
    n_sites: int = 256,
    *,
    length: float = 80.0,
    D: float = 0.5,
    q: float = 1.0,
    momentum: float = 0.0,
    width: float = 2.0,
    A_x: float = 0.0,
    A_t: float = 0.0,
    E: float = 1.0,
    duration: float = 2.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_sites = n_sites
    self.length = length
    self.D = D
    self.q = q
    self.momentum = momentum
    self.width = width
    self.A_x = A_x
    self.A_t = A_t
    self.E = E
    self.duration = duration

ChargedWaveFunctionElement(label, *, u=0.0, w=0.0, space=None)

Bases: Element

Sites of the wave function psi = u + i w of a charge, held as its real part u and its imaginary part w.

Parameters:

Name Type Description Default
label str

The label of the wave function.

required
u object

The initial real part, one value per site or one for all.

0.0
w object

The initial imaginary part, one value per site or one for all.

0.0
space BaseSpace | None

The lattice of the sites, or None for one site.

None

Examples:

>>> from skcomplex.systems.physics.waves import ChargedWaveFunctionElement
>>> ChargedWaveFunctionElement('site', u=1.0).u
1.0
Source code in src/skcomplex/systems/physics/waves/_charged.py
51
52
53
54
def __init__(self, label: str, *, u: object = 0.0, w: object = 0.0, space: BaseSpace | None = None) -> None:
    super().__init__(label, space=space)
    self.u = u
    self.w = w

ColorLinkElement(label, *, U=tuple(COLOR.identity), space=None, on=None)

Bases: Element

Link of a lattice with an SU(3) matrix U.

The matrix is the parallel transport of color along the link.

Parameters:

Name Type Description Default
label str

The label of the link or the group on the links.

required
U Annotated[object, COLOR]

The real components of the matrix of the link, the identity by default.

tuple(identity)
space BaseSpace | None

The cell complex whose edges hold one link each, or None for one link.

None
on str | None

'edges' for one link per edge of the space.

None

Examples:

>>> from skcomplex.systems.physics.waves import ColorLinkElement
>>> len(ColorLinkElement('link').U)
18
Source code in src/skcomplex/systems/physics/waves/_yang_mills.py
61
62
63
64
65
66
67
68
69
70
def __init__(
    self,
    label: str,
    *,
    U: Annotated[object, COLOR] = tuple(COLOR.identity),
    space: BaseSpace | None = None,
    on: str | None = None,
) -> None:
    super().__init__(label, space=space, on=on)
    self.U = U

DrivenAnchorInteraction(label, *, target, k=1.0, center=0.0, amplitude=0.0, omega=1.0)

Bases: HarmonicPotentialInteraction

Spring that ties a particle to an anchor point.

The anchor oscillates transversally as amplitude sin(omega t).

The energy is k |x - center - (0, amplitude sin(omega t))|² / 2, and a zero amplitude gives a fixed anchor.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the particle.

required
k Annotated[float, open(0, oo)]

The stiffness of the spring.

1.0
center ArrayLike

The rest position of the anchor.

0.0
amplitude float

The amplitude of the transverse motion of the anchor.

0.0
omega Annotated[float, closed_open(0, oo)]

The angular frequency of the anchor.

1.0

Examples:

>>> from skcomplex.systems.physics.waves import DrivenAnchorInteraction
>>> DrivenAnchorInteraction('end', target='mass_0', center=[0.0, 0.0], amplitude=0.1).amplitude
0.1
Source code in src/skcomplex/systems/physics/waves/_strings.py
303
304
305
306
307
308
309
310
311
312
313
314
315
def __init__(
    self,
    label: str,
    *,
    target: Role,
    k: Annotated[float, RealSet.open(0, oo)] = 1.0,
    center: npt.ArrayLike = 0.0,
    amplitude: float = 0.0,
    omega: Annotated[float, RealSet.closed_open(0, oo)] = 1.0,
) -> None:
    super().__init__(label, target=target, k=k, center=center)
    self.amplitude = amplitude
    self.omega = omega

GaugeLinkElement(label, *, theta=0.0, space=None, on=None)

Bases: Element

Link of a lattice with an angle theta.

The angle is the U(1) or Z_N variable of a lattice gauge theory.

Parameters:

Name Type Description Default
label str

The label of the link or the group on the links.

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

The angle of the link, or one angle per link, which wraps around the circle.

0.0
space BaseSpace | None

The cell complex of the links, or None for one link.

None
on str | None

'edges' for one link on every edge of the complex, or None.

None

Examples:

>>> from skcomplex.systems.physics.waves import GaugeLinkElement
>>> GaugeLinkElement('link', theta=0.5).theta
0.5
Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
68
69
70
71
72
73
74
75
76
77
def __init__(
    self,
    label: str,
    *,
    theta: Annotated[object, Period(2 * math.pi)] = 0.0,
    space: BaseSpace | None = None,
    on: str | None = None,
) -> None:
    super().__init__(label, space=space, on=on)
    self.theta = theta

GaugeObservablesResult(values, value) dataclass

Gauge observable of a link state at every frame.

Parameters:

Name Type Description Default
values Array

The link states, with one row per frame.

required
value Array

The observable of every frame.

required

HarmonicPotentialInteraction(label, *, target, k=1.0, center=0.0, states='x')

Bases: PotentialEnergyInteraction

Harmonic potential that pulls a particle towards a center.

The energy is k * |x - center|**2 / 2.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the particle.

required
k Annotated[float, open(0, oo)]

The stiffness.

1.0
center ArrayLike

The center. A number applies to every component.

0.0
states str

The name of the vector state that holds the position of the particle.

'x'

Examples:

>>> from skcomplex.systems.physics.waves import HarmonicPotentialInteraction
>>> HarmonicPotentialInteraction('trap', target='ball', k=2.0).k
2.0
Source code in src/skcomplex/systems/physics/waves/_strings.py
174
175
176
177
178
179
180
181
182
183
184
185
def __init__(
    self,
    label: str,
    *,
    target: Role,
    k: Annotated[float, RealSet.open(0, oo)] = 1.0,
    center: npt.ArrayLike = 0.0,
    states: str = 'x',
) -> None:
    super().__init__(label, target=target, states=states)
    self.k = k
    self.center = center

IsospinLinkElement(label, *, U=tuple(ISOSPIN.identity), space=None, on=None)

Bases: Element

Link of a lattice with an SU(2) matrix U.

The matrix is the parallel transport of isospin along the link.

Parameters:

Name Type Description Default
label str

The label of the link or the group on the links.

required
U Annotated[object, ISOSPIN]

The real components of the matrix of the link, the identity by default.

tuple(identity)
space BaseSpace | None

The cell complex whose edges hold one link each, or None for one link.

None
on str | None

'edges' for one link per edge of the space.

None

Examples:

>>> from skcomplex.systems.physics.waves import IsospinLinkElement
>>> len(IsospinLinkElement('link').U)
8
Source code in src/skcomplex/systems/physics/waves/_yang_mills.py
 97
 98
 99
100
101
102
103
104
105
106
def __init__(
    self,
    label: str,
    *,
    U: Annotated[object, ISOSPIN] = tuple(ISOSPIN.identity),
    space: BaseSpace | None = None,
    on: str | None = None,
) -> None:
    super().__init__(label, space=space, on=on)
    self.U = U

LatticeGaugeFieldsSystem(size=32, *, dimension=2, n=None, beta=2.0, dynamics='monte-carlo', charges=None, angles=None, amplitude=0.1, seed=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Link variables on the cell complex of a periodic lattice.

The variables are sampled or evolved in real time.

With Monte Carlo dynamics, link angles sample the Wilson action -beta sum_p cos(theta_p) under discrete time, as U(1) angles or as the angles 2 pi k / n of Z_n. With Hamiltonian dynamics, a potential on the links follows the lattice Maxwell equations A_t = -E and E_t = codifferential(dA) under continuous time, from static charges on the sites and a transverse wave. In two dimensions the U(1) mean plaquette at large size is I_1(beta) / I_0(beta).

Parameters:

Name Type Description Default
size int

The number of sites along every axis.

32
dimension int

The number of axes of the lattice.

2
n int | None

The order of the Z_n group, or None for U(1).

None
beta float

The inverse coupling of the Wilson action.

2.0
dynamics str

'monte-carlo' or 'hamiltonian'.

'monte-carlo'
charges Sequence[float] | None

The static charge of every site, of total 0, or None for none, with Hamiltonian dynamics.

None
angles Sequence[float] | None

The initial link angles, or None for random angles, with Monte Carlo dynamics.

None
amplitude float

The amplitude of the initial transverse wave, with Hamiltonian dynamics.

0.1
seed int

The seed of the initial link angles.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Raises:

Type Description
ValidationError

The dynamics are unknown, or the charges do not hold one value per site of total 0.

Examples:

>>> from skcomplex.systems.physics.waves import LatticeGaugeFieldsSystem
>>> [element.label for element in LatticeGaugeFieldsSystem(4).prepare().system_.elements]
['links']
>>> system = LatticeGaugeFieldsSystem(4, dynamics='hamiltonian').prepare().system_
>>> [element.label for element in system.elements]
['links', 'charges']
Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
def __init__(
    self,
    size: int = 32,
    *,
    dimension: int = 2,
    n: int | None = None,
    beta: float = 2.0,
    dynamics: str = 'monte-carlo',
    charges: Sequence[float] | None = None,
    angles: Sequence[float] | None = None,
    amplitude: float = 0.1,
    seed: int = 0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.size = size
    self.dimension = dimension
    self.n = n
    self.beta = beta
    self.dynamics = dynamics
    self.charges = charges
    self.angles = angles
    self.amplitude = amplitude
    self.seed = seed

simulate(until=None, *, dt=None, initial_state=None, random_state=None, observables=(), observers=(), invariants=None, schedule=None, clock=None, checked=False, record_draws=False, replay=None)

Simulate the prepared system, for 50 units of time every 0.5 with Hamiltonian dynamics by default.

The arguments are those of BaseSystem.simulate, whose end time and time between frames default to those of the dynamics.

Parameters:

Name Type Description Default
until float | None

The end time, or None for 50 with Hamiltonian dynamics and the tuned one otherwise.

None
dt float | None

The time between frames, or None for 0.5 with Hamiltonian dynamics and the tuned one otherwise.

None
initial_state Mapping[str, object] | None

Initial values by dotted state name, such as {'ball.x': 20.0}, or None for the tuned or the declared ones.

None
random_state int | Generator | None

The seed or the generator of the random numbers of the run, or None for fresh entropy.

None
observables Sequence[Observable]

The observables to record, or none for the tuned ones.

()
observers Sequence[BaseObserver]

The observers that watch the run, such as a Rerun recording.

()
invariants Mapping[str, float] | None

The tolerance of each observable that must stay constant, or None for the tuned ones.

None
schedule Mapping[str, Callable[[float], float | ArrayLike]] | None

The functions of time that drive parameters, by dotted name, or None for the tuned ones.

None
clock BaseClock | None

The clock that paces the run, or None to run as fast as possible.

None
checked bool

Whether every frame checks that states stay in their domains.

False
record_draws bool

Whether the run records its random draws.

False
replay Trajectory | None

A trajectory whose recorded draws the run replays, or None.

None

Returns:

Name Type Description
trajectory Trajectory

The states and observables of the run at every frame.

Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
def simulate(
    self,
    until: float | None = None,
    *,
    dt: float | None = None,
    initial_state: Mapping[str, object] | None = None,
    random_state: int | np.random.Generator | None = None,
    observables: Sequence[Observable] = (),
    observers: Sequence[BaseObserver] = (),
    invariants: Mapping[str, float] | None = None,
    schedule: Mapping[str, Callable[[float], float | npt.ArrayLike]] | None = None,
    clock: BaseClock | None = None,
    checked: bool = False,
    record_draws: bool = False,
    replay: Trajectory | None = None,
) -> Trajectory:
    """Simulate the prepared system, for 50 units of time every 0.5 with Hamiltonian dynamics by default.

    The arguments are those of `BaseSystem.simulate`, whose end time and time between frames default to those of
    the dynamics.

    Args:
        until:
            The end time, or `None` for 50 with Hamiltonian dynamics and the tuned one otherwise.

        dt:
            The time between frames, or `None` for 0.5 with Hamiltonian dynamics and the tuned one otherwise.

        initial_state:
            Initial values by dotted state name, such as `{'ball.x': 20.0}`, or `None` for the tuned or the declared
            ones.

        random_state:
            The seed or the generator of the random numbers of the run, or `None` for fresh entropy.

        observables:
            The observables to record, or none for the tuned ones.

        observers:
            The observers that watch the run, such as a Rerun recording.

        invariants:
            The tolerance of each observable that must stay constant, or `None` for the tuned ones.

        schedule:
            The functions of time that drive parameters, by dotted name, or `None` for the tuned ones.

        clock:
            The clock that paces the run, or `None` to run as fast as possible.

        checked:
            Whether every frame checks that states stay in their domains.

        record_draws:
            Whether the run records its random draws.

        replay:
            A trajectory whose recorded draws the run replays, or `None`.

    Returns:
        trajectory:
            The states and observables of the run at every frame.
    """
    if self.dynamics == 'hamiltonian':
        until = MAXWELL_UNTIL if until is None else until
        dt = MAXWELL_DT if dt is None else dt
    return super().simulate(
        until,
        dt=dt,
        initial_state=initial_state,
        random_state=random_state,
        observables=observables,
        observers=observers,
        invariants=invariants,
        schedule=schedule,
        clock=clock,
        checked=checked,
        record_draws=record_draws,
        replay=replay,
    )

LatticeHamiltonianInteraction(label, *, target, D=0.5)

Bases: Interaction

Hamiltonian -D laplacian + V of a particle on the sites of a lattice.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the particle, whose Hilbert space holds the operators laplacian and potential.

required
D Annotated[float, open(0, oo)]

The coefficient of the Laplacian, ħ / (2 m).

0.5

Examples:

>>> from skcomplex.systems.physics.waves import LatticeHamiltonianInteraction
>>> LatticeHamiltonianInteraction('kinetic', target='packet').D
0.5
Source code in src/skcomplex/systems/physics/waves/_quantum.py
178
179
180
181
182
183
184
185
186
187
def __init__(
    self,
    label: str,
    *,
    target: Role,
    D: Annotated[float, RealSet.open(0, oo)] = 0.5,
) -> None:
    super().__init__(label)
    self.target = target
    self.D = D

LatticeYangMillsSystem(size=6, *, dimension=4, extent=None, colors=2, beta=2.3, width=0.5, hits=4, links=None, seed=0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

SU(2) or SU(3) matrices on the links of a periodic lattice.

The matrices are sampled by the Wilson action.

The link matrices sample the Wilson action -(beta / N) sum_p Re tr U_p under discrete time, where U_p is the ordered product of the link matrices around the plaquette p, with the inverse of a link traversed against its orientation. Every sweep proposes hits Metropolis moves per link, each a product with a random matrix of the group near the identity, and projects the links back onto the group. SU(2) is the isospin connection of the weak force, and SU(3) the color connection of the strong force, so that SU(3) is pure lattice QCD. The last axis has extent sites, the inverse temperature of the lattice, along which the Polyakov loop winds. In two dimensions the plaquettes are independent, and the SU(2) mean plaquette at large size is I_2(beta) / I_1(beta).

Parameters:

Name Type Description Default
size int

The number of sites along every axis but the last.

6
dimension int

The number of axes of the lattice.

4
extent int | None

The number of sites along the last axis, or None for size.

None
colors int

The degree N of the group SU(N), 2 or 3.

2
beta float

The inverse coupling of the Wilson action, 2 N / g^2.

2.3
width float

The spread around the identity of the matrices that move a link.

0.5
hits int

The number of moves proposed per link and sweep.

4
links ArrayLike | None

The initial link matrices, one N by N complex matrix per link, or None for matrices drawn from the Haar measure of the group.

None
seed int

The seed of the initial link matrices.

0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Raises:

Type Description
ValidationError

The number of colors is not 2 or 3, or the initial links do not hold one matrix of the group per link.

Examples:

>>> from skcomplex.systems.physics.waves import LatticeYangMillsSystem
>>> [element.label for element in LatticeYangMillsSystem(2, dimension=2).prepare().system_.elements]
['links']
>>> type(LatticeYangMillsSystem(2, dimension=2, colors=3).prepare().system_.elements[0]).__name__
'ColorLinkElement'
Source code in src/skcomplex/systems/physics/waves/_yang_mills.py
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
def __init__(
    self,
    size: int = 6,
    *,
    dimension: int = 4,
    extent: int | None = None,
    colors: int = 2,
    beta: float = 2.3,
    width: float = 0.5,
    hits: int = 4,
    links: npt.ArrayLike | None = None,
    seed: int = 0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.size = size
    self.dimension = dimension
    self.extent = extent
    self.colors = colors
    self.beta = beta
    self.width = width
    self.hits = hits
    self.links = links
    self.seed = seed

MaxwellInteraction(label, *, target)

Bases: Interaction

Lattice Maxwell equations of a potential A on the links of a cell complex.

The potential follows A'' = -codifferential(dA), so its velocity A' = -E and the field E follows E' = codifferential(dA), as light in a vacuum or a wave on a crystal lattice.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the links with the potential A.

required

Examples:

>>> from skcomplex.systems.physics.waves import MaxwellInteraction
>>> MaxwellInteraction('maxwell', target='links').target
'links'
Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
173
174
175
def __init__(self, label: str, *, target: Role) -> None:
    super().__init__(label)
    self.target = target

MaxwellLinkElement(label, *, A=0.0, space=None, on=None, values=None)

Bases: Element

Link of a lattice with a vector potential A.

Its velocity A' is the field -E.

Parameters:

Name Type Description Default
label str

The label of the link or the group on the links.

required
A object

The initial vector potential, or one per link.

0.0
space BaseSpace | None

The cell complex of the links, or None for one link.

None
on str | None

'edges' for one link on every edge of the complex, or None.

None
values Mapping[str, object] | None

Further values by name, such as the initial velocity A', minus the electric field, or None.

None

Examples:

>>> from skcomplex.systems.physics.waves import MaxwellLinkElement
>>> MaxwellLinkElement('link', A=0.5).A
0.5
Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
109
110
111
112
113
114
115
116
117
118
119
def __init__(
    self,
    label: str,
    *,
    A: object = 0.0,
    space: BaseSpace | None = None,
    on: str | None = None,
    values: Mapping[str, object] | None = None,
) -> None:
    super().__init__(label, values=values, space=space, on=on)
    self.A = A

MinimalCouplingInteraction(label, *, target, D=0.5, q=1.0, A_x=0.0, A_t=0.0, E=0.0, duration=1.0)

Bases: Interaction

The Schrödinger equation of a charge q minimally coupled to a uniform electromagnetic potential.

The wave function psi = u + i w of the target follows (d_t - i q A_t) psi = i D (d_x - i q A_x)^2 psi. The vector potential A_x(t) = A_x - E min(t, duration) holds a uniform electric field E from time 0 to duration, and the scalar potential A_t is constant. Expanded, the equation is psi_t = i D psi_xx + 2 D q A_x psi_x + i (q A_t - D q^2 A_x^2) psi.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the wave function, with the real part u and the imaginary part w.

required
D Annotated[float, open(0, oo)]

The coefficient of the Laplacian, ħ / (2 m).

0.5
q float

The electric charge.

1.0
A_x float

The vector potential at time 0.

0.0
A_t float

The scalar potential.

0.0
E float

The electric field.

0.0
duration Annotated[float, open(0, oo)]

The time the electric field is on.

1.0

Examples:

>>> from skcomplex.systems.physics.waves import MinimalCouplingInteraction
>>> MinimalCouplingInteraction('coupling', target='packet').q
1.0
Source code in src/skcomplex/systems/physics/waves/_charged.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
def __init__(
    self,
    label: str,
    *,
    target: Role,
    D: Annotated[float, RealSet.open(0, oo)] = 0.5,
    q: float = 1.0,
    A_x: float = 0.0,
    A_t: float = 0.0,
    E: float = 0.0,
    duration: Annotated[float, RealSet.open(0, oo)] = 1.0,
) -> None:
    super().__init__(label)
    self.target = target
    self.D = D
    self.q = q
    self.A_x = A_x
    self.A_t = A_t
    self.E = E
    self.duration = duration

PositionDephasingInteraction(label, *, target, gamma=0.1, n_sites=1)

Bases: Interaction

Dephasing of a particle in the position basis.

There is one dissipator per site projector at the rate gamma.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the particle, whose Hilbert space holds the site projectors site_<k>.

required
gamma Annotated[float, closed_open(0, oo)]

The dephasing rate.

0.1
n_sites int

The number of sites.

1

Examples:

>>> from skcomplex.systems.physics.waves import PositionDephasingInteraction
>>> PositionDephasingInteraction('dephasing', target='packet', gamma=0.5).gamma
0.5
Source code in src/skcomplex/systems/physics/waves/_quantum.py
227
228
229
230
231
232
233
234
235
236
237
238
def __init__(
    self,
    label: str,
    *,
    target: Role,
    gamma: Annotated[float, RealSet.closed_open(0, oo)] = 0.1,
    n_sites: int = 1,
) -> None:
    super().__init__(label)
    self.target = target
    self.gamma = gamma
    self.n_sites = n_sites

PotentialEnergyInteraction(label, *, target, potential=None, states='x')

Bases: GradientInteraction

Potential energy of the positions of particles.

Its force on every particle changes its velocity.

The force -dU/dx on every particle, divided by its mass m, gives the second derivative of its position, x'' = -dU/dx / m. A subclass binds one role per particle and returns the energy from _get_potential, or a user passes the energy as potential.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the particle or particle group.

required
potential Callable[[SimpleNamespace], object] | None

A function of the namespace that returns the energy, or None for a subclass that returns it.

None
states str | tuple[str, ...]

The name of the vector state that holds the position of every particle.

'x'

Examples:

>>> import numpy as np
>>> from skcomplex.core.components.elements import Element
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.physics.waves import PotentialEnergyInteraction
>>> ball = Element('ball', values={'x': np.array([1.0]), 'm': 2.0})
>>> trap = PotentialEnergyInteraction('trap', target='ball', potential=lambda s: s.target.x[0] ** 2)
>>> system = System(elements=[ball], interactions=[trap]).prepare()
>>> round(float(system.simulate(until=np.pi, dt=np.pi).get_values('ball.x')[-1][0]), 3)
-1.0
Source code in src/skcomplex/systems/physics/waves/_strings.py
136
137
138
139
140
141
142
143
144
def __init__(
    self,
    label: str,
    *,
    target: Role,
    potential: Callable[[SimpleNamespace], object] | None = None,
    states: str | tuple[str, ...] = 'x',
) -> None:
    super().__init__(label, target=target, states=states, potential=potential, inertia=True)

SchrodingerInteraction(label, *, target, D=0.5)

Bases: Interaction

The Schrödinger equation i psi' = -D laplacian(psi) + V psi of a wave function psi = u + i w.

The real and imaginary parts of the target follow u' = -D laplacian(w) + V w and w' = D laplacian(u) - V u, where V is the potential of the target.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the wave function, with the real part u, the imaginary part w, and the potential V.

required
D Annotated[float, open(0, oo)]

The coefficient of the kinetic energy, hbar / (2 m).

0.5

Examples:

>>> from skcomplex.systems.physics.waves import SchrodingerInteraction
>>> SchrodingerInteraction('evolution', target='packet').D
0.5
Source code in src/skcomplex/systems/physics/waves/_quantum.py
138
139
140
141
def __init__(self, label: str, *, target: Role, D: Annotated[float, RealSet.open(0, oo)] = 0.5) -> None:
    super().__init__(label)
    self.target = target
    self.D = D

SchrodingerSystem(n_sites=256, *, length=40.0, D=0.5, momentum=2.0, width=1.0, omega=0.0, formulation='fields', gamma=0.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A Gaussian wave packet that follows the Schrödinger equation.

The packet is written as its real and imaginary parts.

The wave function psi = u + i w follows psi_t = i D laplacian(psi) - i V psi, written as u_t = -D laplacian(w) + V w and w_t = D laplacian(u) - V u, on a periodic lattice with spectral derivatives. In units with ħ = 1, D = 1 / (2 m). The potential is the harmonic well V = omega² x² / (4 D), or zero for a free packet. A free packet of momentum k moves at the group velocity 2 D k and spreads, and its norm sum(u² + w²) is conserved.

The operator formulation builds the same particle as one quantum subsystem whose basis states are the sites, with the Hamiltonian -D laplacian + V of the same spectral Laplacian, normalised so that |psi|² is the probability of every site. It runs with the quantum solvers, and it accepts position dephasing at the rate gamma, which turns the state into a density matrix. The system has the real part packet.u and the imaginary part packet.w of the wave function, or the quantum state <label>.state of the operator formulation.

Parameters:

Name Type Description Default
n_sites int

The number of sites of the periodic lattice.

256
length float

The length of the periodic box, centered on 0.

40.0
D float

The coefficient of the Laplacian, ħ / (2 m).

0.5
momentum float

The mean wave number of the packet.

2.0
width float

The width of the packet.

1.0
omega float

The angular frequency of the harmonic well.

0.0
formulation str

'fields' for two real fields, or 'operators' for a particle on the sites of the lattice.

'fields'
gamma float

The rate of position dephasing of the operator formulation.

0.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for exponential steps of 0.01 of the fields and the quantum solver of the operators.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Raises:

Type Description
ValidationError

The formulation is unknown, or the field formulation has a dephasing rate.

Examples:

>>> from skcomplex.systems.physics.waves import SchrodingerSystem
>>> SchrodingerSystem(64).prepare().system_.elements[0].space.discretization
'spectral'
Source code in src/skcomplex/systems/physics/waves/_quantum.py
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
def __init__(
    self,
    n_sites: int = 256,
    *,
    length: float = 40.0,
    D: float = 0.5,
    momentum: float = 2.0,
    width: float = 1.0,
    omega: float = 0.0,
    formulation: str = 'fields',
    gamma: float = 0.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_sites = n_sites
    self.length = length
    self.D = D
    self.momentum = momentum
    self.width = width
    self.omega = omega
    self.formulation = formulation
    self.gamma = gamma

SpringChainSystem(n_masses=15, *, length=1.0, k=1.0, mass=0.01, pluck=0.05, pluck_at=0.5, amplitude=0.0, omega=2.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

Masses joined in a row by springs of zero rest length between two anchors.

The chain is a discrete string.

The masses start evenly spaced between the anchors at 0 and length, stretched, so the chain carries tension. With pluck, the masses start on a triangle of that height peaking at the fraction pluck_at of the length, the pluck of a guitar string. With amplitude, the left anchor moves transversally as amplitude sin(omega t) and sends a transverse wave along the chain. Springs of zero rest length are linear, so the transverse modes are independent, with frequencies 2 sqrt(k / m) sin(n pi / (2 (N + 1))). The system has the masses mass_<i> and their positions mass_<i>.x in two dimensions.

Parameters:

Name Type Description Default
n_masses int

The number of masses between the anchors.

15
length float

The distance between the anchors.

1.0
k float

The stiffness of every spring.

1.0
mass float

The mass of every mass.

0.01
pluck float

The initial transverse displacement of the plucked point.

0.05
pluck_at float

The plucked point, as a fraction of the length.

0.5
amplitude float

The amplitude of the transverse motion of the left anchor.

0.0
omega float

The angular frequency of the left anchor.

2.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for velocity Verlet with the step 0.01.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.physics.waves import SpringChainSystem
>>> len(SpringChainSystem(4).prepare().system_.interactions)
5
Source code in src/skcomplex/systems/physics/waves/_strings.py
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
def __init__(
    self,
    n_masses: int = 15,
    *,
    length: float = 1.0,
    k: float = 1.0,
    mass: float = 0.01,
    pluck: float = 0.05,
    pluck_at: float = 0.5,
    amplitude: float = 0.0,
    omega: float = 2.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_masses = n_masses
    self.length = length
    self.k = k
    self.mass = mass
    self.pluck = pluck
    self.pluck_at = pluck_at
    self.amplitude = amplitude
    self.omega = omega

SpringInteraction(label, *, first, second, k=1.0, length=0.0, states='x')

Bases: PotentialEnergyInteraction

Spring between two particles.

The energy is k * (|x_first - x_second| - length)**2 / 2, and its gradient moves both particles.

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
first Role

The path of the first particle.

required
second Role

The path of the second particle.

required
k Annotated[float, open(0, oo)]

The stiffness.

1.0
length Annotated[float, closed_open(0, oo)]

The rest length.

0.0
states str

The name of the vector state that holds the positions of the particles.

'x'

Examples:

>>> from skcomplex.systems.physics.waves import SpringInteraction
>>> SpringInteraction('spring', first='a', second='b', k=3.0, length=1.0).length
1.0
Source code in src/skcomplex/systems/physics/waves/_strings.py
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
def __init__(
    self,
    label: str,
    *,
    first: Role,
    second: Role,
    k: Annotated[float, RealSet.open(0, oo)] = 1.0,
    length: Annotated[float, RealSet.closed_open(0, oo)] = 0.0,
    states: str = 'x',
) -> None:
    super().__init__(label, target=first, states=states)
    self.first = first
    self.second = second
    self.k = k
    self.length = length

StandingWavesSystem(n_sites=99, *, length=2.0, c=1.0, mode=1, amplitude=1.0, label='system', solver='auto', backend='auto')

Bases: BaseSystem

A string with fixed ends on [-length / 2, length / 2].

The string vibrates as a standing wave.

The displacement follows the wave equation u'' = c² laplacian(u) on a lattice whose edges hold the string at zero. The string starts at rest in the mode amplitude sin(mode pi (x + length / 2) / length), which oscillates in place with the period 2 length / (mode c), up to the discretization. The system has the displacement string.u and the velocity string.u'.

Parameters:

Name Type Description Default
n_sites int

The number of sites inside the string.

99
length float

The length of the string.

2.0
c float

The speed of the waves.

1.0
mode int

The number of half wavelengths along the string.

1
amplitude float

The initial amplitude.

1.0
label str

The label of the system, which names it when it is nested in another one.

'system'
solver BaseSolver | str

The solver of the problem, or 'auto' for the one the system chooses.

'auto'
backend BaseBackend | str

The backend that evaluates the compiled functions, or 'auto' for the one the system chooses.

'auto'

Examples:

>>> from skcomplex.systems.physics.waves import StandingWavesSystem
>>> trajectory = StandingWavesSystem(9).prepare().simulate(until=0.1)
>>> trajectory.get_lattice('string.u').shape
(3, 9)
Source code in src/skcomplex/systems/physics/waves/_strings.py
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
def __init__(
    self,
    n_sites: int = 99,
    *,
    length: float = 2.0,
    c: float = 1.0,
    mode: int = 1,
    amplitude: float = 1.0,
    label: str = 'system',
    solver: BaseSolver | str = 'auto',
    backend: BaseBackend | str = 'auto',
) -> None:
    super().__init__(label, solver=solver, backend=backend)
    self.n_sites = n_sites
    self.length = length
    self.c = c
    self.mode = mode
    self.amplitude = amplitude

StaticChargeElement(label, *, q=0.0, space=None)

Bases: Element

Site of a lattice with a static electric charge q.

Parameters:

Name Type Description Default
label str

The label of the site or the group on the sites.

required
q object

The electric charge, or one charge per site.

0.0
space BaseSpace | None

The cell complex of the sites, or None for one site.

None

Examples:

>>> from skcomplex.systems.physics.waves import StaticChargeElement
>>> StaticChargeElement('site', q=-1.0).q
-1.0
Source code in src/skcomplex/systems/physics/waves/_gauge_fields.py
141
142
143
144
145
146
147
148
149
def __init__(
    self,
    label: str,
    *,
    q: object = 0.0,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, space=space)
    self.q = q

WaveFunctionElement(label, *, u=0.0, w=0.0, V=0.0, space=None)

Bases: Element

Sites of the wave function psi = u + i w of a particle with the potential V.

Every site holds the real and imaginary parts of the wave function and the potential there.

Parameters:

Name Type Description Default
label str

The label of the wave function.

required
u object

The initial real part, one value per site or one for all.

0.0
w object

The initial imaginary part, one value per site or one for all.

0.0
V object

The potential, one value per site or one for all.

0.0
space BaseSpace | None

The lattice of the sites, or None for one site.

None

Examples:

>>> from skcomplex.systems.physics.waves import WaveFunctionElement
>>> WaveFunctionElement('site', V=1.0).V
1.0
Source code in src/skcomplex/systems/physics/waves/_quantum.py
 99
100
101
102
103
104
105
106
107
108
109
110
111
def __init__(
    self,
    label: str,
    *,
    u: object = 0.0,
    w: object = 0.0,
    V: object = 0.0,
    space: BaseSpace | None = None,
) -> None:
    super().__init__(label, space=space)
    self.u = u
    self.w = w
    self.V = V

WaveStringElement(label, *, u=0.0, space=None)

Bases: Element

Sites of a string, with the transverse displacement u.

Parameters:

Name Type Description Default
label str

The label of the string.

required
u object

The initial displacement, one value or one per site.

0.0
space BaseSpace | None

The lattice of the sites, or None for one site.

None

Examples:

>>> from skcomplex.systems.physics.waves import WaveStringElement
>>> WaveStringElement('site', u=0.5).u
0.5
Source code in src/skcomplex/systems/physics/waves/_strings.py
53
54
55
def __init__(self, label: str, *, u: object = 0.0, space: BaseSpace | None = None) -> None:
    super().__init__(label, space=space)
    self.u = u

WaveTensionInteraction(label, *, target, c=1.0)

Bases: Interaction

Tension of a string, which accelerates its displacement as the wave equation u'' = c^2 laplacian(u).

Parameters:

Name Type Description Default
label str

The label of the interaction.

required
target Role

The path of the string.

required
c Annotated[float, open(0, oo)]

The wave speed.

1.0

Examples:

>>> from skcomplex.systems.physics.waves import WaveTensionInteraction
>>> WaveTensionInteraction('tension', target='string', c=2.0).c
2.0
Source code in src/skcomplex/systems/physics/waves/_strings.py
79
80
81
82
83
84
85
86
87
88
def __init__(
    self,
    label: str,
    *,
    target: Role,
    c: Annotated[float, RealSet.open(0, oo)] = 1.0,
) -> None:
    super().__init__(label)
    self.target = target
    self.c = c

WilsonSamplingInteraction(label, *, target, beta=2.0, state='theta', group=None, move='rotate', width=1.5, rule='metropolis', schedule='colored', hits=1)

Bases: Interaction

Boltzmann weight of link variables under the local Wilson action of the plaquettes of a link.

For link angles the action is -beta sum_p cos(theta_p), where theta_p is the oriented sum of the link angles around the plaquette p. It is the objective of every link, which the MetropolisSolver of the system moves, such as MetropolisSolver(moves={'links.theta': 'rotate'}, schedule='colored', width=1.5) for U(1) or moves={'links.theta': 'random-value'} for Z_N. For the matrices of a group SU(N) the action is -(beta / N) sum_p Re tr U_p, where U_p is the path-ordered product of the link matrices around p, and the interaction sweeps the links itself: the move 'rotate' multiplies a link by a random matrix of the group near the identity of spread width, and 'random-value' draws a uniform matrix of the group, hits times per link.

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 edges of a cell complex.

required
beta Annotated[float, closed_open(0, oo)]

The inverse coupling of the Wilson action.

2.0
state str

The name of the state that holds the link angles or matrices.

'theta'
group MatrixGroupSpec | None

The matrix group of the links, or None for link angles.

None
move str | Callable[..., object]

The move of matrix links, 'rotate' or 'random-value', or a function of the matrices and the random generator.

'rotate'
width float

The spread of a rotation of matrix links.

1.5
rule str

The acceptance of the moves of matrix links, 'metropolis' or 'glauber'.

'metropolis'
schedule str

The order of the moves of matrix links, 'colored' or 'random-sequential'.

'colored'
hits int

The number of moves proposed per matrix link and sweep.

1

Examples:

>>> from skcomplex.systems.physics.common.fields import WilsonSamplingInteraction
>>> WilsonSamplingInteraction('wilson', target='links', beta=2.0).beta
2.0
>>> from skcomplex.core.components import MatrixGroupSpec
>>> color = WilsonSamplingInteraction('wilson', target='links', state='U', group=MatrixGroupSpec('SU', 3))
>>> color.group.degree
3
Source code in src/skcomplex/systems/physics/common/fields/_wilson_sampling.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
def __init__(
    self,
    label: str,
    *,
    target: Role,
    beta: Annotated[float, RealSet.closed_open(0, oo)] = 2.0,
    state: str = 'theta',
    group: MatrixGroupSpec | None = None,
    move: str | Callable[..., object] = 'rotate',
    width: float = 1.5,
    rule: str = 'metropolis',
    schedule: str = 'colored',
    hits: int = 1,
) -> None:
    super().__init__(label)
    self.target = target
    self.beta = beta
    self.state = state
    self.group = group
    self.move = move
    self.width = width
    self.rule = rule
    self.schedule = schedule
    self.hits = hits

gauge_observables(source, *, kind, space, variables=None, extents=(1, 1), charges=None, group=None)

Return a gauge observable of a link state on a periodic lattice's cell complex.

There is one value per frame.

The kind 'wilson' is the mean cosine of the oriented sum of the link angles around the rectangles of given extents in every plane. The kind 'polyakov' is the mean cosine of the sum of the link angles along the last axis. The kind 'charge' is the sum over the plaquettes of a two-dimensional lattice of the oriented sums wrapped into one period around 0, over 2 pi. The kind 'gauss' is the largest absolute value of the codifferential of an electric link state minus a site charge.

An array of one dimension holds one snapshot, and an array of two dimensions one frame per row.

With a matrix group, the link states are the real components of the link matrices, and a loop is the path-ordered product of the link matrices around it. The kind 'wilson' is then the mean of Re tr W / N over the rectangles of every plane, and the kind 'polyakov' the modulus of the mean of tr P / N over the loops P that wind once along the last axis, the order parameter of deconfinement. An array of two dimensions then holds one snapshot, with the components of every link on the last axis, and an array of three dimensions one frame per row.

Parameters:

Name Type Description Default
source object

A trajectory, or an array of link states.

required
kind str

'wilson', 'polyakov', 'charge', or 'gauss'.

required
space CellComplexSpace

The cell complex of the links.

required
variables str | None

The dotted name of the state of a trajectory, or None for a source that is an array.

None
extents tuple[int, int]

The sides of the rectangles of the kind 'wilson'.

(1, 1)
charges Sequence[float] | None

The charge of every site for the kind 'gauss', or None for none.

None
group MatrixGroupSpec | None

The matrix group of the links, or None for link angles.

None

Returns:

Name Type Description
result GaugeObservablesResult

The link states and the observable of every frame.

Raises:

Type Description
AnalysisError

The kind is unknown, the space is not the cell complex of a periodic lattice, the charge is asked of a lattice that does not have two dimensions, or a kind other than a loop is asked of matrix links.

Examples:

>>> import numpy as np
>>> from skcomplex.core.components.spaces import CellComplexSpace, LatticeSpace
>>> from skcomplex.systems.physics.waves import gauge_observables
>>> space = CellComplexSpace(LatticeSpace((4, 4))).prepare()
>>> gauge_observables(np.zeros(32), kind='wilson', space=space).value.tolist()
[1.0]
>>> from skcomplex.core.components import MatrixGroupSpec
>>> group = MatrixGroupSpec('SU', 2)
>>> identity = np.tile(group.identity, (32, 1))
>>> gauge_observables(identity, kind='polyakov', space=space, group=group).value.tolist()
[1.0]
Source code in src/skcomplex/systems/physics/waves/_yang_mills.py
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
def gauge_observables(
    source: object,
    *,
    kind: str,
    space: CellComplexSpace,
    variables: str | None = None,
    extents: tuple[int, int] = (1, 1),
    charges: Sequence[float] | None = None,
    group: MatrixGroupSpec | None = None,
) -> GaugeObservablesResult:
    """Return a gauge observable of a link state on a periodic lattice's cell complex.

    There is one value per frame.

    The kind `'wilson'` is the mean cosine of the oriented sum of the link angles around the rectangles of given extents
    in every plane. The kind `'polyakov'` is the mean cosine of the sum of the link angles along the last axis. The kind
    `'charge'` is the sum over the plaquettes of a two-dimensional lattice of the oriented sums wrapped into one period
    around 0, over `2 pi`. The kind `'gauss'` is the largest absolute value of the codifferential of an electric link
    state minus a site charge.

    An array of one dimension holds one snapshot, and an array of two dimensions one frame per row.

    With a matrix group, the link states are the real components of the link matrices, and a loop is the path-ordered
    product of the link matrices around it. The kind `'wilson'` is then the mean of `Re tr W / N` over the rectangles of
    every plane, and the kind `'polyakov'` the modulus of the mean of `tr P / N` over the loops `P` that wind once along
    the last axis, the order parameter of deconfinement. An array of two dimensions then holds one snapshot, with the
    components of every link on the last axis, and an array of three dimensions one frame per row.

    Args:
        source:
            A trajectory, or an array of link states.

        kind:
            `'wilson'`, `'polyakov'`, `'charge'`, or `'gauss'`.

        space:
            The cell complex of the links.

        variables:
            The dotted name of the state of a trajectory, or `None` for a source that is an array.

        extents:
            The sides of the rectangles of the kind `'wilson'`.

        charges:
            The charge of every site for the kind `'gauss'`, or `None` for none.

        group:
            The matrix group of the links, or `None` for link angles.

    Returns:
        result:
            The link states and the observable of every frame.

    Raises:
        AnalysisError:
            The kind is unknown, the space is not the cell complex of a periodic lattice, the charge is asked of a
            lattice that does not have two dimensions, or a kind other than a loop is asked of matrix links.

    Examples:
        >>> import numpy as np
        >>> from skcomplex.core.components.spaces import CellComplexSpace, LatticeSpace
        >>> from skcomplex.systems.physics.waves import gauge_observables
        >>> space = CellComplexSpace(LatticeSpace((4, 4))).prepare()
        >>> gauge_observables(np.zeros(32), kind='wilson', space=space).value.tolist()
        [1.0]
        >>> from skcomplex.core.components import MatrixGroupSpec
        >>> group = MatrixGroupSpec('SU', 2)
        >>> identity = np.tile(group.identity, (32, 1))
        >>> gauge_observables(identity, kind='polyakov', space=space, group=group).value.tolist()
        [1.0]
    """
    if kind not in KINDS:
        error_msg = f'gauge_observables has kind={kind!r}. Use one of {", ".join(KINDS)}.'
        raise AnalysisError(error_msg)
    place = getattr(space, 'space', None)
    if not isinstance(place, LatticeSpace) or place.boundary != 'periodic':
        error_msg = f'gauge_observables reads the cell complex of a periodic lattice, not {space!r}.'
        raise AnalysisError(error_msg)
    if group is not None and kind not in MATRIX_KINDS:
        error_msg = f'The kind {kind!r} reads link angles. Matrix links take the kind wilson or polyakov.'
        raise AnalysisError(error_msg)
    if kind == 'charge' and len(np.ravel(place.shape)) != CHARGE_DIMENSIONS:
        error_msg = f'The topological charge is defined on a two-dimensional lattice, not on {place!r}.'
        raise AnalysisError(error_msg)
    space.prepare()
    if isinstance(source, Trajectory):
        values = np.asarray(source.get_values(str(variables)), dtype=float)
    else:
        values = np.asarray(source, dtype=float)
        frame = 1 if group is None else 2
        values = values[None] if values.ndim == frame else values
    if group is not None:
        if kind == 'wilson':
            return GaugeObservablesResult(values, _matrix_wilson(space, values, group, extents))
        return GaugeObservablesResult(values, _matrix_polyakov(space, values, group))
    return GaugeObservablesResult(values, _angle_observable(space, values, kind, extents, charges))