Electric fields & potentials
Place and drag charges. The field, potential, equipotentials and field lines are computed by superposition of Coulomb's law in SI units. Check Gauss's law with a movable surface, or launch a test charge and watch it conserve energy.
Physics
Fields add linearly (superposition). For point charges:
$$ \mathbf E(\mathbf r) = \sum_i \frac{q_i}{4\pi\varepsilon_0}\frac{\mathbf r-\mathbf r_i}{|\mathbf r-\mathbf r_i|^3},\qquad V(\mathbf r) = \sum_i\frac{q_i}{4\pi\varepsilon_0|\mathbf r-\mathbf r_i|},\qquad \mathbf E = -\nabla V .$$Infinite line charges (λ per unit length, perpendicular to the screen) are true 2D electrostatics:
$$ \mathbf E = \sum_i \frac{\lambda_i}{2\pi\varepsilon_0}\frac{\mathbf r-\mathbf r_i}{|\mathbf r-\mathbf r_i|^2},\qquad V = -\sum_i\frac{\lambda_i}{2\pi\varepsilon_0}\ln|\mathbf r-\mathbf r_i| .$$Methods
- Field lines are integrated with RK4 along \(\hat{\mathbf E}\). They start on positive charges, and the number per charge is proportional to |q|.
- Equipotentials are drawn by marching squares on a grid of V.
- Gauss's law is checked by integrating \(\oint \mathbf E\cdot\hat{\mathbf n}\,dl\) numerically over 2000 points on the circle.
- Test charges (m = 10 mg, q = ±1 nC) move by velocity-Verlet integration of \(m\ddot{\mathbf r} = q\mathbf E\). Their total energy \(\tfrac12 mv^2 + qV\) is shown and stays constant.
Why two geometries?
The screen is a 2D slice. For line charges, everything in the slice is exact 2D physics. Gauss's law holds in the plane: \(\oint \mathbf E\cdot\hat{\mathbf n}\,dl = \lambda_{enc}/\varepsilon_0\). The density of field lines is also exactly proportional to |E|.
For point charges, the field falls off as 1/r², and the flux through a circle in the plane does not equal \(q/\varepsilon_0\): Gauss's law needs a closed 3D surface. Toggle the Gauss circle in both modes and compare. This is a common misconception that the simulation makes visible.
Things to try
- Parallel plates: the field is uniform between them, falls off outside, and the equipotentials are evenly spaced.
- +3 and −1: some field lines from +3 escape to infinity, since the net charge is +2. Find the neutral point where E = 0.
- Launch a negative test charge near a positive charge to get bound orbits. In 3D mode with 1/r² forces, the orbits are Kepler ellipses.