Particle Physics Playground

An interactive simulation exploring Coulomb forces, gravity, magnetic fields, and particle collisions. Experiment with different physics presets and create your own particle systems by clicking and dragging.

Live Simulation

Select different presets to explore various particle physics configurations. Use the controls to adjust parameters and create your own particle systems.

Physics Concepts

Coulomb Forces

Electric forces between charged particles follow Coulomb's law: \(F = k \frac{q_1 q_2}{r^2}\) where\(k\) is the Coulomb constant, \(q_1\) and \(q_2\) are charges, and \(r\) is the distance between particles.

Gravitational Forces

Newton's law of universal gravitation: \(F = G \frac{m_1 m_2}{r^2}\) where\(G\) is the gravitational constant and \(m_1\), \(m_2\) are masses.

Magnetic Fields

The Lorentz force on a charged particle in a magnetic field: \(F = q v \times B\) where\(q\) is charge, \(v\) is velocity, and \(B\) is the magnetic field.

The simulation supports both static and alternating magnetic fields. For alternating fields:\(B_z(t) = B_0 \sin(2\pi f t)\) where \(B_0\) is the amplitude and\(f\) is the frequency.

Interactive Features

Particle Spawning

  • Left-click + drag: Create negative particles (blue)
  • Right-click + drag: Create positive particles (red)
  • Middle-click + drag: Create neutral particles (gray)
  • Shift + drag: Force neutral particles

Physics Presets

  • Coulomb Chaos: Electric forces dominate
  • Mini Collider: Static magnetic field + collisions
  • Gravity N-Body: Gravitational interactions
  • Plasma in B: Charged particles in static magnetic field

Try switching to alternating magnetic fields for dynamic plasma behavior and cyclotron resonance effects!

Collision Types

  • None: Particles pass through each other
  • Elastic: Energy and momentum conserved
  • Merge: Particles combine on collision

What is the particle physics playground?

A browser-based particle playground that visualizes classical dynamics of N particles in 2D under Coulomb interactions, Newtonian gravity, and a uniform out-of-plane magnetic field Bz. The system includes optional collisions (elastic or merging), linear drag for stability, and three boundary modes (reflective walls, donut topology, or Möbius strip). Users can spawn particles via click–drag to set initial velocity, tune parameters interactively, and observe kinetic/potential energy readouts in real time.

State and Forces

Each particle i has position \(\mathbf{x}_i=(x_i,y_i)\), velocity \(\mathbf{v}_i=(v_{x,i},v_{y,i})\), mass mi, and charge qi. For a pair (i,j) with displacement rij = xj - xi, distance rij = ||rij||, and unit vector r̂ij = rij/rij, a small softening ε replaces rij² by rij² + ε².

  • Coulomb (electrostatic): \(\mathbf{F}^{\mathrm{C}}_{ij} = k\,\dfrac{q_i q_j}{r_{ij}^2+\epsilon^2}\,\hat{\mathbf{r}}_{ij}\)(repulsive for like charges, attractive for unlike).
  • Gravity: \(\mathbf{F}^{\mathrm{G}}_{ij} = -\,G\,\dfrac{m_i m_j}{r_{ij}^2+\epsilon^2}\,\hat{\mathbf{r}}_{ij}\)(always attractive).
  • Magnetic (Lorentz, B=(0,0,Bz)): acceleration\(a_x = \tfrac{q}{m} v_y B_z,\; a_y = -\tfrac{q}{m} v_x B_z\).
  • Drag: linear damping with rate γ applied to velocity to stabilize chaotic motion.

Integration and Complexity

We use a semi-implicit (symplectic) Euler step with a frame-based Δt clamped for spikes. At each step: reset accelerations ai, accumulate pairwise Coulomb + gravity, add magnetic and drag, then update vi and xi. The all-pairs evaluation is O(N²).

Boundary Modes and Collisions

Three boundary conditions are supported:

  • bounce (reflective walls): velocity components flip sign on contact
  • donut (torus topology): exiting right (top) re-enters left (bottom)
  • mobius (Möbius strip): x-axis wraps with y-flip, creating a non-orientable surface

Collision types:

  • elastic: penetration resolved along contact normal with restitution e
  • merge: coalescence conserves linear momentum and total charge

Mouse Mapping and Spawning

Click–drag on the canvas to create a particle with initial velocity along the drag vector:

  • Right-click → positive (red)
  • Left-click → negative (blue)
  • Shift/Middle → neutral (gray)

Suggested Experiments

  • Plasma spirals: set Bz > 0, low drag; launch q > 0 vs. q < 0 and compare curvature
  • Mini collider: elastic collisions, low drag; fire two opposite charges head-on
  • Gravity clustering: preset with k=0, G >> 0, merge; observe cluster growth
  • Guiding-center feel: small Bz, small drag; launch perpendicular to B and watch average drift