Chaos in Magnetic Pendulum (Magnetic Decision Maker)

An interactive simulation of a magnetic pendulum system with multiple magnets, demonstrating chaotic dynamics and Lyapunov exponent analysis. Explore the sensitive dependence on initial conditions and the beautiful fractal-like attractors that emerge from magnetic interactions.

Live Simulation

Adjust the parameters to explore different magnetic configurations and observe the chaotic behavior. The simulation includes real-time Lyapunov exponent calculation to quantify the sensitivity to initial conditions.

Chaos in a Magnetic Pendulum

Abstract

Author: Hosein (Mohammad-Hossein) Gholami
Course: Complex Systems Studies
Instructor: Prof. Afshin Montakhab
Date: Summer 2018
© 2018 Hosein Gholami

We study a magnetic pendulum with a rigid string of length \(\ell\) moving in the horizontal plane above \(N\) fixed magnets placed on a circle of radius \(R\). The bob's vertical position is constrained by\(x^2+y^2+z^2=\ell^2\). Each magnet exerts a central attractive force that decays as \(1/\rho^3\), where \(\rho\) is the bob-magnet distance in 3D (including a vertical offset \(d\)). Linear viscous friction with coefficient \(\mathrm{FC}\) and gravity \(g\)are included, with a switchable small-angle (linear) or nonlinear gravity term. We integrate the equations with RK4 and visualize chaos using a finite-time Lyapunov estimate based on the growth of separations between three nearby trajectories.

Introduction

Despite its simple construction, the magnetic pendulum exhibits sensitive dependence on initial conditionsand intricate basins of attraction. Small changes in starting position can lead to qualitatively different final magnets captured, providing a compact laboratory for chaos.

Modeling

Magnet layout

Magnets are equally spaced on a circle:

\[ \theta_i = \frac{2\pi i}{N}, \quad (x_i,y_i) = (R\cos\theta_i, R\sin\theta_i), \quad i=0,\dots,N-1 \]

The bob moves in-plane at \((x,y)\); by the rigid string constraint:

\[ z = \sqrt{\ell^2 - x^2 - y^2} \]

The effective vertical gap to each magnet includes a constant offset \(d\):

\[ z_i = d + \ell - z \]
Forces

Let \(\Delta x_i = x_i - x\), \(\Delta y_i = y_i - y\), and:

\[ \rho_i = \sqrt{\Delta x_i^2 + \Delta y_i^2 + z_i^2} \]

The magnetic attraction (dipole-like far field) is modeled as:

\[ F_{x,i} = k\frac{\Delta x_i}{\rho_i^3}, \quad F_{y,i} = k\frac{\Delta y_i}{\rho_i^3} \]

Linear viscous drag: \(\vec{F}_D = -\mathrm{FC}(\dot{x}\hat{\imath} + \dot{y}\hat{\jmath})\)

Gravity contributes an in-plane restoring component. Two options:

\[ G = \begin{cases} 1, & \text{linear small-angle} \\ \frac{z}{\ell} = \sqrt{1-\frac{x^2+y^2}{\ell^2}}, & \text{nonlinear} \end{cases} \]
Equations of motion

Summing magnet forces and adding gravity and drag yields the 2D equations for \((x,y)\):

\[ \ddot{x} = -\mathrm{FC}\dot{x} + \sum_{i=1}^{N} k\frac{x_i-x}{((x_i-x)^2 + (y_i-y)^2 + z_i^2)^{3/2}} -\frac{g}{\ell}xG \]
\[ \ddot{y} = -\mathrm{FC}\dot{y} + \sum_{i=1}^{N} k\frac{y_i-y}{((x_i-x)^2 + (y_i-y)^2 + z_i^2)^{3/2}} -\frac{g}{\ell}yG \]

with \(z = \sqrt{\ell^2 - x^2 - y^2}\) and \(z_i = d + \ell - z\).

Numerical Method

  • Integrator: classical RK4 on \((x,y,\dot{x},\dot{y})\)
  • Step control: the UI step \(\Delta t\) is multiplied by a speed factor; internally we sub-step so the micro-step is \(\lesssim 0.002\,\text{s}\) for stability
  • Constraint safety: numerical drift can push \(r=\sqrt{x^2+y^2}\) slightly above \(\ell\); we softly clamp to \(0.999999\,\ell\) and damp velocity a bit when that happens
  • Singularity avoidance: nonzero \(d\) keeps \(\rho_i\) away from zero near a magnet

Parameters & Initial Conditions

Defaults (matching the Mathematica demo):

\[ N=3, \; R=0.90, \; \ell=25, \; d=0.15, \; g=10, \; \mathrm{FC}=0.05, \; k=1 \]

Three nearby starting points:

\[ (1.200,1.000), \quad (1.210,0.990), \quad (1.205,0.995) \]

The interactive UI also provides \(N\in\{2,3,4,5,6,10,20,100\}\), long trails, zoom, and speed up to \(100\times\).

Finite-Time Lyapunov Indicator

With three trajectories \(A,B,C\), define pairwise separations \(d_{12},d_{13},d_{23}\). Put:

\[ L(t) = \frac{d_{12}(t)+d_{13}(t)+d_{23}(t)}{3}, \qquad L_0 = L(0) \]

Our finite-time estimate averages the growth:

\[ \lambda(t) \approx \frac{1}{t}\frac{1}{3}\sum_{\{ij\}\in\{12,13,23\}} \ln\!\left(\frac{d_{ij}(t)}{d_{ij}(0)}\right) \]

We also plot \(L/L_0 \approx e^{\lambda(t)\,t}\) and \(\log L\). (This is a convenient proxy; the rigorous maximal LLE typically uses a tangent-space renormalization scheme.)

Observations

  • Sensitive dependence: tiny changes among the three initial points quickly separate the trajectories
  • Basins & multistability: different magnets act as attractors; the basin boundaries are fractal-like
  • Effect of damping: increasing \(\mathrm{FC}\) shortens transients and reduces peak \(L/L_0\)
  • Gravity model: the nonlinear option \(G=z/\ell\) slightly shifts frequencies and can alter capture routes

Reproducibility & Controls

  • Speed ×: multiplies the integrator step (visual time)
  • Magnets N: discrete values up to 100; magnets at angle \(2\pi i/N\)
  • R, ℓ, d, g, FC, k: as defined above
  • Random triple: samples three Gaussian-perturbed points around a chosen location (clamped to \(r<0.95\,\ell\))
  • Lyapunov panel: choose \(\lambda(t)\), \(L/L_0\), or \(\log L\); the bottom axis shows total elapsed time

Chaos, Determinism, and Predictability

The equations used throughout are ordinary differential equations (ODEs) with explicit forces (gravity, magnetic, drag). As such, the dynamics are deterministic: a given initial condition yields a unique trajectory. Nevertheless, for multiple magnets the system exhibits sensitive dependence on initial conditions (chaos), which we quantify by a finite-time or asymptotic Lyapunov exponent.

For the maximal Lyapunov exponent (MLE), the textbook definition is:

\[ \lambda = \lim_{t\to\infty}\,\lim_{\delta Z_0\to 0}\,\frac{1}{t}\,\ln\frac{\delta Z(t)}{\delta Z_0} \]

where \(\delta Z(t)\) is the phase-space separation between two trajectories evolved from initially nearby states. A positive MLE indicates chaos; \(\lambda\le 0\) indicates non-chaotic (periodic/quasi-periodic or contracting) behavior. In the demo and in the original report we estimate afinite-time indicator using three nearby trajectories and the average of their pairwise separations.

Key questions addressed in the project include: Is the system chaotic with multiple magnets? What happens with asingle magnet? How do linear vs. nonlinear gravity and the magnet geometry/number affect chaos? (See also the ensemble-based formulation in the appendix of the report.)

Large-N Limit and Single-Magnet Reduction

Consider \(N\) identical magnets placed uniformly on a circle of radius \(R\). Two asymptotic regimes are informative:

  1. Continuous ring field (\(N\to\infty\) at fixed \(R\)). The discrete sum over magnets tends to an azimuthal integral, yielding an effectively axisymmetric in-plane force field. The resulting symmetry reduces scattering irregularities compared with small \(N\).
  2. Single-magnet limit (\(N\to\infty\), \(R\to 0\) with total strength fixed). The ring collapses to a point at the origin and the net field approaches that of a lone magnet at the center. Numerically, this reduction reproduces the qualitative behavior of the one-magnet system.

In the report's numerical experiments, the large-\(N\), small-\(R\) regime doesnot maintain sustained exponential separation: the log-separation curves do not exhibit a persistent positive slope, and the deviation grows primarily along a single effective direction while remaining bounded otherwise. This is consistent with a non-chaotic single-magnet problem (no positive MLE), whereas multi-magnet configurations (e.g., three and above) do exhibit sensitive dependence and fractal-like basins of attraction.

Numerical note

The finite-time Lyapunov panel in the web demo reflects the same conclusions. Switching to large \(N\)(e.g., \(N=100\)) and shrinking \(R\) trends the measured \(\lambda(t)\)toward non-positive values, while moderate \(N\) with nonzero \(R\) yields intermittent positive \(\lambda(t)\) segments typical of chaotic transient capture.

References

  1. R. Temam, Infinite Dimensional Dynamical Systems in Mechanics and Physics, Springer (1988)
  2. Claudius Gros, Complex and Adaptive Dynamical Systems: A Primer, 4th ed., Springer (2015)
  3. Standard magnetic pendulum lab materials and articles (various)

Interactive Features

Parameter Controls

  • • Adjust magnet count and arrangement
  • • Modify magnetic and gravitational strength
  • • Control friction and string length
  • • Change simulation speed and time step

Visualization

  • • Real-time trajectory trails
  • • Lyapunov exponent plotting
  • • Interactive zoom and pan
  • • Multiple initial condition testing