Monday, February 24, 2014

Charge Lab - Charge, Field, and Equipotential Surface Simulation in C#

For the past couple of weeks I've been playing around building a Charge Simulation in C#. The result is Charge Lab, a 2D simulator that can:

  • Simulate motion of charges due to adjacent charges
  • Fill the edges of conducting surfaces
  • Produce Field Lines
  • Measure Potential
  • Draw Equipotential Surfaces
Place charges and observe attraction and repulsion
Charges migrate to the edges of conductors and
congregate in the corners

Observe Field Lines
Observe Equipotential Surfaces and Potential Gradients

Field Strength inside a conductor is zero (nearly)

More conductors and field strengths

I'm putting a version of the program out there now even though it's not finished because it's in a usable state. My students and I have been playing around with it in class and it seems to be really valuable for observing how charges behave on conductors as well as shapes and structures in Electric Fields. But I need some help sorting out some of the remaining issues surrounding charges moving along surfaces. Any comments you have are welcome!

Issue: Charges can't slide across diagonal edges well

See the charge on the left? He's stuck on a corner between two diagonal pixels. His two buddies to the right should be pushing him down the line to the lower left, but he can't get over the edge of the pixel.

Solved Issue: Potential Gradients (and therefore Field Lines as well) were not matching theory quite right.

In order to get charges in this 2 dimensional simulation to distribute themselves around the edge of a conductor like they would in 3 dimensions, I made a modification to Coulomb's Law. Ignoring any units and constants, the two dimensional spherical surface around a charge becomes a one dimensional circumference of a circle. More discussion here.

Transforming Electrostatics Equations from 3 down to 2 Dimensions
(k' is a different constant to k)

I'm not 100% sure about these adjustments. They seem to produce charge and field behavior in 2 dimensions that matches what we expect in 3 dimensions. I'm happy to discuss this issue more if there is interest.

I'm still working on these issues, but feel free to have a stab at them. You can play around with the source files here, or download just the program here.

No comments:

Post a Comment