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.

Monday, February 17, 2014

Superposition, Interference, and Audio Engineering

When musicians record in the studio, the will often record each instrument separately. Each recording would be stored in some sort of loss-less format, an example of which is .wav

A portion of a .wav file shown in Audacity
I'm not sure if the .wav file is a record of pressure over time or velocity over time, but either way it's a record of the sound wave received by the microphone. Each part (vocals, guitar, bass, drums, etc) will have one or more records and the Audio Engineer's job is to use superposition to combine all those parts into one file for the consumer.

For a demonstration of sound and superposition, I found a sample set of these separate recordings for Iron Maiden's "Run to the Hills" and used Audacity to combine them into three different files:

  • The complete song sample with all the parts
  • The song sample with all the parts except for the lead vocals (this is like a karaoke version)
  • An inverted version of the instruments-only song sample.
The normal Instrumental song and the inverted song side-by-side

I can then use Audacity to re-play those files in different combinations. I like to get the students to think about:

  1. Will the inverted instruments only file sound different to the sound wave when it's right-side-up?
  2. What will it sound like when the inverted instrumental track is played with the right-side-up track simultaneously? Audacity can load multiple files and play them all at once so we can test this out
  3. What will happen if I play the complete song and the inverted instrumental simultaneously?
If you'd like to run this demonstration you just need Audacity (or something similar) and the song files, which you can download here:

Thursday, February 13, 2014

Sinusoidal Components of a Square Wave

One of those mind-blowing things you learn studying Engineering is that functions can be expressed as a sum of sinusoids. The math is pretty well beyond most high school math and physics students but I have had some success presenting the idea and observing the phenomenon. I put together a quick simulation in excel that can be used to generate a sequence of higher-and-higher frequency sine waves that add up to a square wave.

You have to copy the entire column D, and paste it repeatedly into adjacent columns. You can keep going through the graphs into columns I, J, K, etc if you want.

Each column is a sine wave. As we move right through the columns, the frequency increase and the amplitude decreases. You can see all the sine waves together on the lower graph.

On the upper graph, we have the sum of all the superimposed waves. The more higher-frequency waves we add, the more square-like the sum becomes.

If you're curious, have a look at the formulas used to calculate the sine waves. You can also read more about the frequency components of sine waves here.

Standing Wave Formation Simulation

The latest version of Java has thrown a huge wrench into my classroom-machine. It won't allow me to run un-signed applets unless I add them to a whitelist. That's all well and good except that the permissions that my school assigned to my account prevent me from making changes to that whitelist. Grrrr.

Anyway, I can no-longer run many of my favorite physics applets in class, including this awesome simulation of a standing wave forming in a string with reflection.

From: Walter Fent
I've been learning a lot about VBA in Excel recently and decided to have a go at re-making the simulation in Excel. The result is a little rough-around the edges but it will work for my purposes:

You must enable macros to use the simulation. You can use the wavelength box to adjust the width of the waves. The sheet is protected, but there's no password so if you want to muck around you can unlock the sheet and play with the VBA code. I'm sure there are improvements to be made.