Thursday, November 6, 2014

ChargeLab 1.01 - Famous Last Words

"I think I'm finally done with ChargeLab."
I should have known better than to boast. In version 1.00 I re-thought how I calculate potential so that at large distances potential approached zero, and at near distances it approached + infinity. What I didn't notice is that this adjustment completely broke the way that field lines lie. I'm releasing version 1.01 with the following features and fixes
  1. Re-worked the way that field lines propagate so that they come out smoother and intersect less frequently.
  2. Reverted the method for calculating potential so that the field strength inside of charged surfaces remains zero.
  3. Remove the ability of the user to measure potential. This is really just a hack to hide the fact that the values of the potential don't work out as expected.
Reverted Potential Calculation correctly identifies the field strength in the center of a charged surface as zero. 

New Smoother Field Lines!

I think this will be the last version. Not because there is nothing left to do but because I am well and truly stuck. The problem is that the formulas we are used  to seeing for calculating potential and field strength in our three dimensional world don't seem to work in a two dimensional simulation. To adjust for the missing degree of freedom in which charges can move, I modified the formulas:

F = Force
V = Potential
k = Coulomb's constant
k' = An arbitrary constant
q = charge
r = Distance from charge's center
To transform the formulas into two dimensions I integrated with respect to distance, r. This seemed to do the trick for Force and Field Strength:

There are no negative distances in this simulation and both functions behave very similarly in the first quadrant. With these changes I got the slight change in behavior I needed. Charges spread out on the edges of surfaces and produced no field strength within surfaces.

The problem comes in when we look at the structure of Potential in 2 and 3 dimensions:

In 2 Dimensions, the natural log has much different behavior to the inverse function found in three dimensions. In 2 Dimensions there is a finite, non-zero distance from a charge where the potential is zero. Beyond this point, the potential changes sign and grows slowly to infinity. I'm struggling to understand the significance of these differences but I observe that they produce the desired potential gradients in two dimensions. 

I would be interested in hearing your thoughts on this puzzle.
  • Are the transformations above appropriate or do they only appear to work by coincidence?
  • Is there a better way to simulate forces and potentials in two dimensions?

You can download the latest version of ChargeLab here.

Source code available here.