Lorenz
The Lorenz-63 system of convection.
- Class:
LorenzSystem - Import:
from skcomplex.systems.mathematics.dynamical_systems import LorenzSystem - Field:
mathematics/dynamical_systems - Topics:
chaos,ode,strange attractor - References:
- Lorenz 1963
- Datseris and Parlitz 2022
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.mathematics.dynamical_systems import LorenzSystem
trajectory = LorenzSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
x |
1.0 |
y |
1.0 |
z |
1.0 |
sigma |
10.0 |
rho |
28.0 |
beta |
2.6666666666666665 |
solver |
'auto' |
backend |
'auto' |
Tags
The system with its default parameters has these capability tags, which solvers and analyses check.
| Tag | Values |
|---|---|
| Time | continuous |
| Space | none |
| Laws | rate |
| Randomness | deterministic |
| Domains | real |
| Structure | fixed |
Class
The source of the class shows how it builds its components from its model parameters.
class LorenzSystem(BaseSystem):
"""The Lorenz-63 system of convection.
The system is chaotic on a butterfly-shaped attractor for its standard parameters.
The system has the states `lorenz.x`, `lorenz.y`, and `lorenz.z`.
Args:
x:
The initial convection intensity.
y:
The initial temperature difference between rising and falling currents.
z:
The initial deviation of the vertical temperature profile.
sigma:
The Prandtl number.
rho:
The Rayleigh number relative to its critical value.
beta:
The geometric factor.
label:
The label of the system, which names it when it is nested in another one.
solver:
The solver of the problem, or `'auto'` for the one the system chooses.
backend:
The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.
Examples:
>>> from skcomplex.systems.mathematics.dynamical_systems import LorenzSystem
>>> LorenzSystem(rho=20.0).prepare().system_.elements[0].rho
20.0
"""
field = 'mathematics/dynamical_systems'
topics = ('chaos', 'ode', 'strange attractor')
references = ('Lorenz 1963', 'Datseris and Parlitz 2022')
until = 50.0
dt = 0.01
def __init__(
self,
x: float = 1.0,
y: float = 1.0,
z: float = 1.0,
*,
sigma: float = 10.0,
rho: float = 28.0,
beta: float = 8 / 3,
label: str = 'system',
solver: BaseSolver | str = 'auto',
backend: BaseBackend | str = 'auto',
) -> None:
super().__init__(label, solver=solver, backend=backend)
self.x = x
self.y = y
self.z = z
self.sigma = sigma
self.rho = rho
self.beta = beta
def _prepare(self, context: Sequence[Observable] | None = None) -> None:
"""Set `system_` to the components of the system built from its model parameters."""
super()._prepare(context)
lorenz = LorenzElement('lorenz', x=self.x, y=self.y, z=self.z, sigma=self.sigma, rho=self.rho, beta=self.beta)
self.system_ = System(self.label, elements=[lorenz], interactions=[LorenzInteraction('flow')])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
LorenzElement, fromElement
Interactions:
LorenzInteraction, fromInteraction
class LorenzElement(Element):
"""An element with the three states of the Lorenz flow and its parameters.
`LorenzInteraction` gives the flow `x' = sigma (y - x)`, `y' = x (rho - z) - y`, `z' = x y - beta z`.
Args:
label:
The label of the element.
x:
The initial convection intensity.
y:
The initial temperature difference between rising and falling currents.
z:
The initial deviation of the vertical temperature profile.
sigma:
The Prandtl number.
rho:
The Rayleigh number relative to its critical value.
beta:
The geometric factor.
Examples:
>>> from skcomplex.systems.mathematics.dynamical_systems import LorenzElement
>>> LorenzElement('lorenz', rho=20.0).rho
20.0
"""
def __init__(
self,
label: str,
*,
x: float = 1.0,
y: float = 1.0,
z: float = 1.0,
sigma: float = 10.0,
rho: float = 28.0,
beta: float = 8 / 3,
) -> None:
super().__init__(label)
self.x = x
self.y = y
self.z = z
self.sigma = sigma
self.rho = rho
self.beta = beta
class LorenzInteraction(Interaction):
"""The Lorenz flow of the three states of the element it binds.
The flow is `x' = sigma (y - x)`, `y' = x (rho - z) - y`, `z' = x y - beta z`, with the parameters of the element.
For `sigma = 10`, `rho = 28`, and `beta = 8/3` its runs never settle and never repeat, the strange attractor of
Lorenz. Lorenz derived it from convection in the atmosphere, it models a laser and a water wheel, and it drives a
response system in studies of chaotic synchronization.
Args:
label:
The label of the interaction.
target:
The path of the element with the states `x`, `y`, and `z` and the parameters `sigma`, `rho`, and `beta`.
Examples:
>>> from skcomplex.core.systems import System
>>> from skcomplex.systems.mathematics.dynamical_systems import LorenzElement, LorenzInteraction
>>> lorenz = LorenzElement('lorenz', x=0.0, y=0.0, z=2.0, beta=0.5)
>>> system = System(elements=[lorenz], interactions=[LorenzInteraction('flow', target='lorenz')]).prepare()
>>> [round(float(value), 4) for value in system.simulate(until=1.0, dt=0.5).get_values('lorenz.z')]
[2.0, 1.5576, 1.2131]
"""
law_classes = (RateLaw,)
def __init__(self, label: str, *, target: Role = 'lorenz') -> None:
super().__init__(label)
self.target = target
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the rates of the three modes as the laws.
Args:
context:
The namespace of the elements a binding of the roles names.
"""
super()._prepare(context)
s = context.target
self.laws_: list[BaseLaw] = [
RateLaw(s.x, s.sigma * (s.y - s.x)),
RateLaw(s.y, s.x * (s.rho - s.z) - s.y),
RateLaw(s.z, s.x * s.y - s.beta * s.z),
]
Equations
The equations are those that symbolic returns for the system with its default parameters.
lorenz.x: diff(x_lorenz(t), t) == -sigma_lorenz*(x_lorenz(t) - y_lorenz(t))
lorenz.y: diff(y_lorenz(t), t) == (rho_lorenz - z_lorenz(t))*x_lorenz(t) - y_lorenz(t)
lorenz.z: diff(z_lorenz(t), t) == x_lorenz(t)*y_lorenz(t) - beta_lorenz*z_lorenz(t)