System
Define systems, which compose elements, interactions, and nested systems on a space, in a time.
System(label='system', *, elements=(), interactions=(), systems=(), space=None, time=None)
Bases: BasePart[BaseSpace, SimpleNamespace]
Composition of elements and the interactions between them, with nested systems, on a space, in a time.
A system is defined by its parts and by nothing about how it runs. An interaction refers to an element by its path
relative to the system that holds the interaction, so forest/foxes names the element foxes of the nested system
forest. Groups and nested systems without a space of their own live on the space of the system.
Attributes:
| Name | Type | Description |
|---|---|---|
laws_ |
Sequence[BasePart]
|
The laws the system contributes for the namespace of its last run. |
Examples:
>>> from typing import Annotated
>>> from types import SimpleNamespace
>>> from sage.all__sagemath_symbolics import var
>>> from skcomplex.core.elements import Element
>>> from skcomplex.core.laws import RateLaw
>>> from skcomplex.specs import StateSpec
>>> from skcomplex.core.system import System
>>> class DecayElement(Element):
... def __init__(self, label, x: Annotated[float, StateSpec()] = 1.0):
... super().__init__(label)
... self.x = x
...
... def _get_laws(self, namespace):
... return [RateLaw(namespace.x, -namespace.x)]
>>> system = System(elements=[DecayElement('decay')]).check().prepare()
>>> namespace = SimpleNamespace(decay=SimpleNamespace(x=var('x')))
>>> [type(law).__name__ for law in system.run(namespace).laws_]
['RateLaw']
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
The label of the system, which names it when it is nested in another one. |
'system'
|
elements
|
Sequence[BaseElement]
|
The elements and groups. |
()
|
interactions
|
Sequence[BaseInteraction]
|
The interactions between the elements. |
()
|
systems
|
Sequence[System]
|
The nested systems. |
()
|
space
|
BaseSpace | None
|
The space the elements live on, which gives vector states their dimension, or |
None
|
time
|
BaseTime | None
|
The time the system evolves in, |
None
|
Source code in src/skcomplex/core/system.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |