Skip to content

Systems

kosh edited this page Mar 1, 2022 · 2 revisions

You can create maps and equations by using Difference and Differential and analyze the created instance.

DynamicalSystems

__init__

params (** params) is executed.

Params

  • t=None
  • u=None
  • **params

Attributes

  • dim

settle_on_attractor

A function to put the orbit on the attractor.

Calculate T_0 = 5000 times from the initial position (t0, u0) If t0 and u0 are left unspecified, make_inital will generate the initial values.

The calculation result is discarded by default. If you want to check, use notsave=False. It is stored in u_seq.

Params

  • t0=None
  • u0=None
  • *
  • T_0=5000
  • notsave=True
  • **params

Return

  • <class TU>

Examples

Shows the transition from a randomly selected initial value to the attractor.

from hundun import Drawing
from hundun.equations import Lorenz


lorenz = Lorenz()
tu = lorenz.settle_on_attractor(notsave=False)
print(tu)

u_seq = lorenz.u_seq

d = Drawing(three=True)
d[0,0].plot(u_seq[:, 0], u_seq[:, 1], u_seq[:, 2],
            linewidth=0.5, color='gray')

for j, label in zip([0, -1], ['start', 'end']):
    d[0,0].scatter(u_seq[j, 0], u_seq[j, 1], u_seq[j, 2],
                   label=label, s=40)

d[0,0].legend()
d.show()
d.close()
TU(t=0, u=array([-5.89434775, -9.53167753, 16.2837206 ]))

img:settle_on_attractor

on_attractor classmethod

Automatically use settle_on_attractor when instantiating an orbit to place it on an attractor.

Parameters

  • t0=None
  • u0=None
  • h=0.01
  • *
  • T_0=5000
  • **params

Returns

  • c: <class DynamicalSystems>

solve

Returns the result calculated using self._solve.

solve_n_times

Execute solve n times.

Params

  • n

Return

  • self.t_seq
  • self.u_seq

inf property

Even if it is one-dimensional of its own u, if it is inf, it returns True.

internal_state property

Returns the current (t, u).

t_seq property

Returns the accumulated value t of the result calculated by solve.

u_seq property

Returns the accumulated value u of the result calculated by solve.

reset_u_seq

Reset the saved u_seq.

make_inital

Randomly generate initial values with reference to dim.

get_u_seq classmethod

Get the time series of the result calculated n times.

params

  • n
  • *args
  • **kwargs

Returns

  • u_seq

Examples

from hundun import Drawing
from hundun.equations import Lorenz


u_seq = Lorenz.get_u_seq(1000)

d = Drawing(3, 1)

for i, axis in enumerate(['x', 'y', 'z']):
    d[i,0].plot(u_seq[:, i])
    d[i,0].set_axis_label('step', axis)

d.show()
d.close()

img:get_u_seq

jacobian

By defining it, the Lyapunov spectrum can be calculated based on the Jacobian Matrix.

_solve abstractmethod

equation abstractmethod


Difference

A class of discrete dynamical systems. _solve simply maps.

_solve

def _solve(self, t, u, *, h=1, **params):
    self.u = self(t, u, **params)
    self.t = t+h

    return TU(self.t, self.u)

Differential

A class of differential dynamical systems. Runge-Kutta method is performed in _solve.

_solve

def _solve(self, t, u, *, h=0.01, solver=_RK4, f=None, **params):
    sol = solver(f or self, h=h, **params)
    self.u = sol(t, _np.array(u))
    self.t = t+sol.h

    return TU(self.t, self.u)