Skip to content

jdhoffa/maxwell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maxwell

Interactive terminal-based visualizer for building intuition about Maxwell's equations. v1 covers 2D electrostatics and steady-state current — both reduce to the same elliptic PDE (∇²V = 0) on a uniform grid, with the mode distinction living entirely in which cells are held as Dirichlet boundary conditions. Watching a scene relax makes the difference visible.

demo

Quick start

cargo run

Requires a terminal that renders true-color and the ▀ / arrow glyphs (any modern macOS / Linux terminal is fine).

Controls

Key Action
space single relaxation sweep
r run / pause
R reset field
m toggle mode (electrostatic ↔ steady current)
1/2/3 load scene preset
a toggle E-field arrow overlay
/ adjust V+ (primary potential)
/ adjust V− (secondary potential)
[/] scale σ
,/. halve / double sweeps per frame
q quit

Presets

  1. Parallel plates — canonical capacitor. Watch V ramp linearly between the plates; the panel's Q0, Q1 show equal-and-opposite surface charges.
  2. Point charge near a grounded plane — image-charge geometry. In 2D the potential falls as log(r), not 1/r.
  3. Resistor bar — two electrodes bracketing a conductive bar. Defaults to steady-current mode (E ≠ 0 inside the bar; the panel shows I and P). Press m to toggle into electrostatic equilibrium on the same geometry — the bar's bulk snaps to a single equipotential and E → 0 inside.

The resistor-bar mode toggle is the main pedagogical moment: same PDE, same geometry, different pinned cells, qualitatively different fields.

Tests

cargo test

Covers E = −∇V on a known linear field, the analytic linear ramp between parallel plates, and monotonic V decrease along the resistor bar.

Regenerating the demo GIF

The demo above is produced from demo.tape with VHS:

cargo build --release
vhs demo.tape

About

Interactive TUI for 2D electrostatics and steady-state current — building intuition for Maxwell's equations

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages