Skip to content

Lorenz

dissmodel.models.sysdyn.lorenz.Lorenz

Bases: Model

Lorenz system — deterministic chaos model.

Models the Lorenz attractor, a system of three coupled ordinary differential equations originally derived from atmospheric convection. Despite being fully deterministic, the system exhibits chaotic behavior: tiny differences in initial conditions lead to vastly different trajectories over time.

Parameters:

Name Type Description Default
x float

Initial value of the X variable, by default 1.0.

required
y float

Initial value of the Y variable, by default 1.0.

required
z float

Initial value of the Z variable, by default 1.0.

required
delta float

Integration time step (Euler method), by default 0.01. Smaller values increase accuracy but require more steps.

required
sigma float

Prandtl number — controls the rate of rotation, by default 10.0.

required
rho float

Rayleigh number — controls convection intensity, by default 28.0.

required
beta float

Geometric factor, by default 8/3.

required
Notes

The @track_plot decorators register x, y, and z for automatic live plotting. Any :class:~dissmodel.visualization.Chart connected to the same environment will plot all three variables at every step without any extra configuration.

The system is integrated using the forward Euler method:

.. math::

\dot{x} = \sigma (y - x)

\dot{y} = x (\rho - z) - y

\dot{z} = x y - \beta z

Examples:

>>> from dissmodel.core import Environment
>>> env = Environment(end_time=3000)
>>> model = Lorenz()
>>> env.run()
Source code in dissmodel/models/sysdyn/lorenz.py
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
@track_plot("X", "blue")
@track_plot("Y", "orange")
@track_plot("Z", "red")
class Lorenz(Model):
    """
    Lorenz system — deterministic chaos model.

    Models the Lorenz attractor, a system of three coupled ordinary
    differential equations originally derived from atmospheric convection.
    Despite being fully deterministic, the system exhibits chaotic
    behavior: tiny differences in initial conditions lead to vastly
    different trajectories over time.

    Parameters
    ----------
    x : float, optional
        Initial value of the X variable, by default 1.0.
    y : float, optional
        Initial value of the Y variable, by default 1.0.
    z : float, optional
        Initial value of the Z variable, by default 1.0.
    delta : float, optional
        Integration time step (Euler method), by default 0.01.
        Smaller values increase accuracy but require more steps.
    sigma : float, optional
        Prandtl number — controls the rate of rotation, by default 10.0.
    rho : float, optional
        Rayleigh number — controls convection intensity, by default 28.0.
    beta : float, optional
        Geometric factor, by default 8/3.

    Notes
    -----
    The ``@track_plot`` decorators register ``x``, ``y``, and ``z``
    for automatic live plotting. Any :class:`~dissmodel.visualization.Chart`
    connected to the same environment will plot all three variables at
    every step without any extra configuration.

    The system is integrated using the forward Euler method:

    .. math::

        \\dot{x} = \\sigma (y - x)

        \\dot{y} = x (\\rho - z) - y

        \\dot{z} = x y - \\beta z

    Examples
    --------
    >>> from dissmodel.core import Environment
    >>> env = Environment(end_time=3000)
    >>> model = Lorenz()
    >>> env.run()
    """

    #: Current value of the X variable.
    x: float

    #: Current value of the Y variable.
    y: float

    #: Current value of the Z variable.
    z: float

    #: Integration time step.
    delta: float

    #: Prandtl number.
    sigma: float

    #: Rayleigh number.
    rho: float

    #: Geometric factor.
    beta: float

    def setup(
        self,
        x: float = 1.0,
        y: float = 1.0,
        z: float = 1.0,
        delta: float = 0.01,
        sigma: float = 10.0,
        rho: float = 28.0,
        beta: float = 8.0 / 3.0,
    ) -> None:
        """
        Configure the model parameters.

        Parameters
        ----------
        x : float, optional
            Initial value of X, by default 1.0.
        y : float, optional
            Initial value of Y, by default 1.0.
        z : float, optional
            Initial value of Z, by default 1.0.
        delta : float, optional
            Integration time step, by default 0.01.
        sigma : float, optional
            Prandtl number, by default 10.0.
        rho : float, optional
            Rayleigh number, by default 28.0.
        beta : float, optional
            Geometric factor, by default 8/3.
        """
        self.x     = x
        self.y     = y
        self.z     = z
        self.delta = delta
        self.sigma = sigma
        self.rho   = rho
        self.beta  = beta

    def execute(self) -> None:
        """
        Advance the system by one time step using the Euler method.

        Computes the derivatives from the Lorenz equations and updates
        x, y, z by the integration step :attr:`delta`.
        """
        dx = self.sigma * (self.y - self.x)
        dy = self.x * (self.rho - self.z) - self.y
        dz = self.x * self.y - self.beta * self.z

        self.x += self.delta * dx
        self.y += self.delta * dy
        self.z += self.delta * dz

execute()

Advance the system by one time step using the Euler method.

Computes the derivatives from the Lorenz equations and updates x, y, z by the integration step :attr:delta.

Source code in dissmodel/models/sysdyn/lorenz.py
122
123
124
125
126
127
128
129
130
131
132
133
134
135
def execute(self) -> None:
    """
    Advance the system by one time step using the Euler method.

    Computes the derivatives from the Lorenz equations and updates
    x, y, z by the integration step :attr:`delta`.
    """
    dx = self.sigma * (self.y - self.x)
    dy = self.x * (self.rho - self.z) - self.y
    dz = self.x * self.y - self.beta * self.z

    self.x += self.delta * dx
    self.y += self.delta * dy
    self.z += self.delta * dz

setup(x=1.0, y=1.0, z=1.0, delta=0.01, sigma=10.0, rho=28.0, beta=8.0 / 3.0)

Configure the model parameters.

Parameters:

Name Type Description Default
x float

Initial value of X, by default 1.0.

1.0
y float

Initial value of Y, by default 1.0.

1.0
z float

Initial value of Z, by default 1.0.

1.0
delta float

Integration time step, by default 0.01.

0.01
sigma float

Prandtl number, by default 10.0.

10.0
rho float

Rayleigh number, by default 28.0.

28.0
beta float

Geometric factor, by default 8/3.

8.0 / 3.0
Source code in dissmodel/models/sysdyn/lorenz.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def setup(
    self,
    x: float = 1.0,
    y: float = 1.0,
    z: float = 1.0,
    delta: float = 0.01,
    sigma: float = 10.0,
    rho: float = 28.0,
    beta: float = 8.0 / 3.0,
) -> None:
    """
    Configure the model parameters.

    Parameters
    ----------
    x : float, optional
        Initial value of X, by default 1.0.
    y : float, optional
        Initial value of Y, by default 1.0.
    z : float, optional
        Initial value of Z, by default 1.0.
    delta : float, optional
        Integration time step, by default 0.01.
    sigma : float, optional
        Prandtl number, by default 10.0.
    rho : float, optional
        Rayleigh number, by default 28.0.
    beta : float, optional
        Geometric factor, by default 8/3.
    """
    self.x     = x
    self.y     = y
    self.z     = z
    self.delta = delta
    self.sigma = sigma
    self.rho   = rho
    self.beta  = beta