Skip to content

Memristor oscillator

The simplest memristor oscillator: a capacitor, an inductor, and a memristor in series.

  • Name: memristor_oscillator
  • Field: engineering/circuits
  • Formalism: ordinary differential equations
  • References: Muthuswamy and Chua 2010; Trzaska 2023

The memristor_oscillator example

Example

Factory

@register_model(
    field='engineering/circuits',
    tags=('circuit', 'memristor', 'chaos', 'ode'),
    references=('Muthuswamy and Chua 2010', 'Trzaska 2023'),
    defaults={'until': 200.0, 'dt': 0.1},
)
def memristor_oscillator(
    v: float = 0.1,
    i: float = 0.0,
    w: float = 0.1,
    *,
    C: float = 1.0,
    L: float = 3.0,
    alpha: float = 0.6,
    beta: float = 1.5,
) -> System:
    """Return the simplest memristor oscillator: a capacitor, an inductor, and a memristor in series.

    The capacitor voltage, the inductor current, and the internal state of the memristor follow `C v' = i`,
    `L i' = -v - β (w^2 - 1) i`, and `w' = -i - alpha w + w i`. The memristor has the memristance `β (w^2 - 1)`, and the
    circuit oscillates chaotically for the default values.

    Args:
        v:
            The initial voltage of the capacitor.

        i:
            The initial current.

        w:
            The initial internal state of the memristor.

        C:
            The capacitance.

        L:
            The inductance.

        alpha:
            The decay rate of the memristor state.

        beta:
            The scale of the memristance.

    Returns:
        system:
            The model, with the states `circuit.v`, `circuit.i`, and `circuit.w`.

    Examples:
        >>> from skcomplex.models.engineering.circuits import memristor_oscillator
        >>> memristor_oscillator(L=2.0).elements[0].L
        2.0
    """
    return System(elements=[MemristorCircuitElement('circuit', v=v, i=i, w=w, C=C, L=L, alpha=alpha, beta=beta)])

Components

class MemristorCircuitElement(Element):
    """Oscillator built from a memristor, whose current depends on the flux through it."""

    def __init__(
        self,
        label: str,
        visual: VisualSpec | None = None,
        *,
        v: Annotated[object, StateSpec()] = 0.1,
        i: Annotated[object, StateSpec()] = 0.0,
        w: Annotated[object, StateSpec()] = 0.1,
        C: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 1.0,
        L: Annotated[object, ParameterSpec(domain=RealSet.open(0, oo))] = 3.0,
        alpha: Annotated[object, ParameterSpec(domain=RealSet.closed_open(0, oo))] = 0.6,
        beta: Annotated[object, ParameterSpec(domain=RealSet.closed_open(0, oo))] = 1.5,
    ) -> None:
        super().__init__(label, visual=visual)
        self.v = v
        self.i = i
        self.w = w
        self.C = C
        self.L = L
        self.alpha = alpha
        self.beta = beta

    def _get_laws(self, s: SimpleNamespace) -> list[BaseLaw]:
        """Return the rates of the states of the circuit."""
        return [
            RateLaw(s.v, s.i / s.C),
            RateLaw(s.i, -(s.v + s.beta * (s.w**2 - 1) * s.i) / s.L),
            RateLaw(s.w, -s.i - s.alpha * s.w + s.w * s.i),
        ]

Equations

circuit.v: diff(v_circuit(t), t) == i_circuit(t)/C_circuit
circuit.i: diff(i_circuit(t), t) == -((w_circuit(t)^2 - 1)*beta_circuit*i_circuit(t) + v_circuit(t))/L_circuit
circuit.w: diff(w_circuit(t), t) == -alpha_circuit*w_circuit(t) + i_circuit(t)*w_circuit(t) - i_circuit(t)