Chua double and multiple scrolls
Chua's circuit, whose double-scroll or multiscroll attractor is chaotic.
- Class:
ChuaSystem - Import:
from skcomplex.systems.engineering.circuits import ChuaSystem - Field:
engineering/circuits - Topics:
circuit,chaos,ode,attractor - References:
- Chua, Komuro, and Matsumoto 1986
- Tang et al. 2001
- Trzaska 2023
Use this system
The block imports the class and simulates the system with its default parameters and its tuned run settings.
from skcomplex.systems.engineering.circuits import ChuaSystem
trajectory = ChuaSystem().prepare().simulate()
Parameters
The model parameters take these defaults, and set_params changes them.
| Parameter | Default |
|---|---|
x |
None |
y |
None |
z |
0.0 |
nonlinearity |
'piecewise-linear' |
alpha |
None |
beta |
None |
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 ChuaSystem(BaseSystem):
"""Chua's circuit, whose double-scroll or multiscroll attractor is chaotic.
The voltages of the two capacitors and the current of the inductor, in dimensionless form, follow `x' = alpha (y -
f(x))`, `y' = x - y + z`, and `z' = -β y`. The piecewise-linear diode has `f(x) = x + m1 x + (m0 - m1) (|x + 1| - |x
- 1|) / 2`, which gives the double scroll. The sine diode has `f(x) = -b sin(π x / (2 a))`, continued linearly
beyond `|x| = 2 a c`, which gives several scrolls side by side. The system has the states `circuit.x`, `circuit.y`,
and `circuit.z`.
Args:
x:
The initial voltage of the first capacitor, or `None` for 0.1 with the piecewise-linear diode and 1 with
the sine diode.
y:
The initial voltage of the second capacitor, or `None` for 0 with the piecewise-linear diode and 1 with the
sine diode.
z:
The initial current of the inductor.
nonlinearity:
The characteristic of the diode, `'piecewise-linear'` for the double scroll or `'sine'` for multiple
scrolls.
alpha:
The ratio of the capacitances, or `None` for 15.6 with the piecewise-linear diode and 10.82 with the sine
diode.
beta:
The ratio of the inductance to the second capacitance, or `None` for 28 with the piecewise-linear diode and
14.286 with the sine diode.
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.
Raises:
ParameterError:
The nonlinearity is neither `'piecewise-linear'` nor `'sine'`.
Examples:
>>> from skcomplex.systems.engineering.circuits import ChuaSystem
>>> ChuaSystem(nonlinearity='sine').prepare().system_.interactions[0].alpha
10.82
"""
field = 'engineering/circuits'
topics = ('circuit', 'chaos', 'ode', 'attractor')
references = ('Chua, Komuro, and Matsumoto 1986', 'Tang et al. 2001', 'Trzaska 2023')
until = 100.0
dt = 0.05
def __init__(
self,
x: float | None = None,
y: float | None = None,
z: float = 0.0,
*,
nonlinearity: str = 'piecewise-linear',
alpha: float | None = None,
beta: float | None = None,
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.nonlinearity = nonlinearity
self.alpha = alpha
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)
if self.nonlinearity not in CHUA_NONLINEARITIES:
error_msg = f"Unknown nonlinearity {self.nonlinearity!r}. Use 'piecewise-linear' or 'sine'."
raise ParameterError(error_msg)
sine = self.nonlinearity == 'sine'
start = (1.0, 1.0) if sine else (0.1, 0.0)
x = start[0] if self.x is None else self.x
y = start[1] if self.y is None else self.y
circuit = ChuaCircuitElement('circuit', x=x, y=y, z=self.z)
kind = MultiscrollChuaInteraction if sine else ChuaInteraction
settings = {
name: value for name, value in {'alpha': self.alpha, 'beta': self.beta}.items() if value is not None
}
chua = kind('chua', target='circuit').set_params(**settings)
self.system_ = System(self.label, elements=[circuit], interactions=[chua])
Components
The system uses these element and interaction classes, each with its nearest class of the core.
Elements:
ChuaCircuitElement, fromElement
Interactions:
ChuaInteraction, fromInteraction
class ChuaCircuitElement(Element):
"""Chua circuit, with the voltages `x` and `y` of its capacitors and the current `z` of its inductor.
The interactions of `ChuaSystem` and `MixedModeChuaSystem` change the three states.
Args:
label:
The label of the circuit.
x:
The initial voltage of the first capacitor.
y:
The initial voltage of the second capacitor.
z:
The initial current of the inductor.
Examples:
>>> from skcomplex.systems.engineering.circuits._circuits import ChuaCircuitElement
>>> ChuaCircuitElement('circuit', x=1.0).x
1.0
"""
def __init__(self, label: str, *, x: float = 0.1, y: float = 0.0, z: float = 0.0) -> None:
super().__init__(label)
self.x = x
self.y = y
self.z = z
class ChuaInteraction(Interaction):
"""Chua circuit with the piecewise-linear current of its diode, which gives the double scroll.
The states follow `x' = alpha (y - x - m1 x - (m0 - m1) (|x + 1| - |x - 1|) / 2)`, `y' = x - y + z`, and
`z' = -beta y`.
Args:
label:
The label of the interaction.
target:
The path of the circuit.
alpha:
The ratio of the capacitances.
beta:
The ratio of the inductance to the second capacitance.
m0:
The inner slope of the diode.
m1:
The outer slope of the diode.
Examples:
>>> from skcomplex.systems.engineering.circuits._circuits import ChuaInteraction
>>> ChuaInteraction('chua', target='circuit').alpha
15.6
"""
law_classes: ClassVar[tuple[type[BaseLaw], ...]] = (RateLaw,)
def __init__(
self,
label: str,
*,
target: Role,
alpha: Annotated[float, RealSet.open(0, oo)] = 15.6,
beta: Annotated[float, RealSet.open(0, oo)] = 28.0,
m0: float = -8 / 7,
m1: float = -5 / 7,
) -> None:
super().__init__(label)
self.target = target
self.alpha = alpha
self.beta = beta
self.m0 = m0
self.m1 = m1
def _prepare(self, context: SimpleNamespace) -> None:
"""Set the rates of the states of the circuit.
Args:
context:
The namespace of the circuit.
"""
super()._prepare(context)
s, x, y, z = context, context.target.x, context.target.y, context.target.z
self.laws_: list[BaseLaw] = [
RateLaw(x.diff(s.t), s.alpha * (y - x - s.m1 * x - (s.m0 - s.m1) * (abs(x + 1) - abs(x - 1)) / 2)),
RateLaw(y.diff(s.t), x - y + z),
RateLaw(z.diff(s.t), -s.beta * y),
]
Equations
The equations are those that symbolic returns for the system with its default parameters.
circuit.x: diff(x_circuit(t), t) == -1/2*((m0_chua - m1_chua)*(abs(x_circuit(t) + 1) - abs(x_circuit(t) - 1)) + 2*m1_chua*x_circuit(t) + 2*x_circuit(t) - 2*y_circuit(t))*alpha_chua
circuit.y: diff(y_circuit(t), t) == x_circuit(t) - y_circuit(t) + z_circuit(t)
circuit.z: diff(z_circuit(t), t) == -beta_chua*y_circuit(t)
