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.

Saturday, January 18, 2014

OkTrends - The Math of Dating

OkTrends is a blog run by the folks at the matchmaking website OkCupid. Their website generates huge volumes of data on personalities, attraction, and sex and they've been crunching those numbers to see what interesting relationships pop out.

For example, in this graph Christian Rudder graphs how attractive people appear in their photos based on the time of day the photo was taken:

From OkTrends - Don't Be Ugly By Accident
In the graph, the blue line is the average attractiveness of photos grouped by time of day. Superimposed on that trend is another graph in yellow and brown of the height of the sun during the day and night. When the sun crosses the horizon that's sunrise and sunset. Mr Rudder is able to show evidence of Golden Hour; the hour after sunrise and before sunset when vivid colors fill the sky and make pictures more interesting.

There's tons of SL Math in this blog. Mr Rudder fits a sinusoidal curve to the attractiveness data in an attempt to show that photos taken in the afternoon and late at night are often most appealing.

From OkTrends - Don't Be Ugly By Accident
I'm planning to add this graph to my unit on sine and cosine. I imagine the discussion will be memorable

  • What does the trend suggest about good photos? 
  • Does the trend appear to be a good fit of the data?
  • What is the period of the graph? Would it have been reasonable to expect the period to be 24 hours?
  • If you were to perform the same study from scratch, how would you do it?

Finally, here's a graph comparing the number of (self-reported) sexual partners straight men and women have had to gay men and women:

From OkTrends: Gay Sex vs. Straight Sex
After thinking, "Wow, those trends are very similar," my next thought was, "Is that an Ogive?!" It seems like the only place I ever see Cumulative Frequency Charts is in IB exams but here's one in the wild!

Some questions I might ask students are:

  • Where do the two trends differ the most? What does that mean about the similarities and differences between the sexual habits of the gay and straight communities?
  • How many partners has the median straight/gay person had?
  • If this graph were to be turned into a frequency distribution, what shape would it have?
    • Followed up with: All of this data is self-reported. If respondents were to lie, what kinds of lies might they tell and how would that effect the shape of the expected distribution?
Some of the topics in the blog are a bit too racy for my classroom, but there are still a lot of useful gems. Honestly the whole thing is just fascinating.

Monday, October 28, 2013

Math Extension - Ancient Greek Geometry

Here's a fun puzzle I found out about recently. It's called Ancient Greek Geometry. The challenge is to create different shapes (like triangles, and circle patterns) using only a straight-edge and a compass. For example, here's a solution for a hexagon:

Hexagon Created Using a Straightedge and Compass
The program runs right in your browser and is easy to learn. Just point your students to the website (http://sciencevsmagic.net/geo/) and they'll figure out the rest.

There's also a number of other neat features from the same people at their website.

http://sciencevsmagic.net

Monday, October 21, 2013

f.lux - Use your montor's Color Temperature to help manage Sleep Schedules

We all know the importance of Sleep Schedules and getting enough sleep, especially to students. If not, check out this article discussing recent research on Sleep Deprivation and Academic Performance in Students. (SPOILER: Sleep deprivation inhibits learning).

Modern students face a double-whammy:
1)      We ask a lot from them
2)      They do their work on their computers

Together, these factors often lead our students to face their laptop screens up until they go to bed. According to this article discussing the relationships between screen brightness and sleep schedules, staring at a bright screen at night tricks your brain into thinking it’s daytime, preventing your brain from getting properly ready for bed and ruining your sleep schedule.

Enter f.lux, a program which will automatically adjust your screen’s color temperature during the day to mimic a sunset.



I've been using this program at home for years now and I love it. Before, I used to have to stop using my computer an hour before bed or I wouldn't feel tired. Now, I could fall asleep sitting up while reading at my computer. Best part: It’s free, so no harm in trying it. It takes about a day to get used to it and then you’ll wonder how you got by without it.