Slashdot Mirror


Simple, Portable Physics Simulations

ttsiod writes "I want to 'lure' my nephews/nieces towards Science and Engineering (to whatever extent that's possible, in the age of consoles). To that end, I have coded simple physics simulations, like falling snow, exploding fireworks, and 1D/2D wave simulations. My efforts are here, in the form of portable SDL mini-programs (GPL code, compilable under Windows, Linux, Free/Net/OpenBSD, Mac OS/X and basically every OS with GCC and SDL). Try them out, and do offer any suggestions on other programs that can trigger scientific interest in young minds. Myself, I am teaching them Python, so that they can code 'fireworks' on their own."

32 of 145 comments (clear)

  1. wot? by sammyF70 · · Score: 4, Interesting

    I seriously have to ask : what does a 1-Dimensional wave look like????

    --
    "DRM is like the Ford Pinto: it's a smooth ride, right up the point at which it explodes and ruins your day."-C.Doctorow
    1. Re:wot? by FlyByPC · · Score: 5, Informative

      I seriously have to ask : what does a 1-Dimensional wave look like????

      A compression wave. Think of a sound wave traveling along a very slender rod, after a hammer hits the end.

      --
      Paleotechnologist and connoisseur of pretty shiny things.
    2. Re:wot? by NoMoreFood · · Score: 2, Interesting

      Think guitar string for 1D. Think ripple from rock being dropped in water for 2D. Think cell phone transmission for 3D.

    3. Re:wot? by History's+Coming+To · · Score: 4, Informative

      Nope, you're a dimension out (fencepost error?!).

      1D: Compression wave in a single dimension, like the "striking a rod" example above.

      2D: Guitar string. A string is a single dimension (eg left to right) but you need a second dimension for it to vibrate up and down.

      3D: Ripples in a pond. The pond surface is a plane (2D, left/right, forward/back) but the wave is a displacement in a third dimension (up/down).

      --
      Please consider this account deleted, I just can't be bothered with the spam anymore.
    4. Re:wot? by Compholio · · Score: 2, Informative

      I seriously have to ask : what does a 1-Dimensional wave look like????

      A compression wave. Think of a sound wave traveling along a very slender rod, after a hammer hits the end.

      If you want to demonstrate this phenomenon visually in the real world you can use a slinky. Just tape down one end and confine it to a track with a couple of boards, push the free end and watch the compression wave travel down the slinky.

    5. Re:wot? by gardyloo · · Score: 5, Informative

      Actually, your parent poster is correct: a transverse wave like on a string can be parametrized by one coordinate, since the displacement isn't a dimension. So both compressional and transverse waves on a string can be said to be 1D _in_space_: give an x-coordinate, I can tell you the displacement at a given time (or, if you're masochistic, take the one spatial dimension to be the length along the string from some origin).

          2D: ripples on a pond. Need an (x,y) to specify the location; the other number is the displacement (or density, or velocity; doesn't matter).

          3D: ripples in a volume, such as sound waves in an unbounded medium, electromagnetic waves in space, etc. There are two ways to be "off" by one dimension in problems such as these:
                          1) count time as a needed dimension (usually, it's treated as a parameter, especially for time-harmonic problems, but sometimes it's really needed, as in SR and GR);
                          2) not take advantage of symmetries in the problem, which can sometimes collapse the problem to a lower dimension (or _almost_ lower dimension).

    6. Re:wot? by BitterOak · · Score: 2, Informative

      Does that mean cell phone transmission is 4D? How do we visualize that?

      Nope. It's 3D as well. Unlike the other examples provided, the vibrations here are in the same 3D space in which the wave propagates. The electric and magnetic field vectors are in 3D space, transverse to the direction of propagation.

      --
      If I can be modded down for being a troll, can I be modded up for being an orc, or a balrog?
    7. Re:wot? by Manchot · · Score: 2, Informative

      It's really kind of misleading to say that a guitar string is a 2D wave, or a ripple on a pond is a 3D wave. Really, there are two separate concepts: the dimensionality of the domain of the wave, and the dimensionality of the wave itself. A compression wave and a guitar string are both one-dimensional waves in a one-dimensional space. A ripple on a pond is a one-dimensional wave on a two-dimensional space. Sound in a room is a one-dimensional wave in a three-dimensional space. Electromagnetic waves are six-dimensional waves in a three-dimensional space.

  2. Age/Goal? by DDDKKK · · Score: 2, Informative

    Looking at the summary as well as at the webpage it does not become clear how old the mentioned kids are and if the goal is really understanding science and engineering. For a younger age things like http://www.crazymachinesgame.com/ which give a more playful introduction to physics might be better. Programming for kids has been addressed multiple times on Slashdot.

    1. Re:Age/Goal? by Brian+Gordon · · Score: 2, Informative

      Don't forget the excellent Phun physics sim. Check out some of the things that are possible.. the standard environment is powerful enough to support rockets and springs, but it's also fully scriptable.

  3. FreeBASIC by FlyByPC · · Score: 3, Informative

    OK, so it doesn't have "teh s3xy" of Java, Python, or Ruby -- but BASIC is very easy to pick up, and with modern dialects like FreeBASIC, you can write good, modular, maintainable programs. It's also a lot of fun, which seems to be especially important; you can write a quick simulation of whatever you're interested in, without a lot of work.

    This isn't your father's BASIC; it has support for lots of memory, 32-bit graphics, user data types, functions and subroutines (including passing by reference or value), and even multithreading including mutexes. Or you could use it to run older QBasic programs from the Dark Ages, complete with line numbers, LET statements, GOTOs, and all that.

    Pick up FBIDE while you're there, too.

    ...Oh, and did I mention that both FreeBASIC and FBIDE are free?

    --
    Paleotechnologist and connoisseur of pretty shiny things.
    1. Re:FreeBASIC by K.+S.+Kyosuke · · Score: 4, Insightful

      In order to save children from the hell called Basic, Seymour Papert created a nice language called Logo.

      --
      Ezekiel 23:20
    2. Re:FreeBASIC by Lorkki · · Score: 2, Funny

      Hey, if it's old-fashioned stuff you find t3h l33t, why not teach the kids Brainfuck? It's essentially the same language as P", devised by the man Böhm himself in 1964, way before all of this pish posh about how to conveniently build non-trivial programs, but also including the modern concepts of input and output. Make no mistake, however - with only eight operations to choose from, it's about as simple as you can get, and many a programmer will attest that it's fun to play with!

  4. Chaos, Computers, and Physics by lawnboy5-O · · Score: 2, Insightful

    When I was attending Syracuse U. in the early nineties, a cool elective class came up for us physics nerds attempting to align with the dawn of computer programing en masse. For a nerd like myself, this was absolutely appealing. It included small programs simulating exactly what you note, and beyond.

    I would say your efforts need to include the real world though - getting kids excited about mapping physics and mathematical colloquialisms on a computer also needs to have roots in the physically applicable world. It was this connection that kept me, and keeps me, interested in natural sciences and mathematics to this day.

  5. Physics Simulators by brycef · · Score: 5, Informative

    It is not programming, but Phun is a good 2-D physics simulator for kids.

    Another that takes a bit more work is Google's Sketchup with the SketchyPhysics plugin.

    1. Re:Physics Simulators by Chris+Shannon · · Score: 2, Informative

      Kde's Step is a good basic physics simulator. It is part of kde's education project.
      From their description:
      Step is an interactive physics simulator. It works like this: you place some bodies on the scene, add some forces such as gravity or springs, then click "Simulate" and Step shows you how your scene will evolve according to the laws of physics. You can change every property of bodies/forces in your experiment (even during simulation) and see how this will change the outcome of the experiment. With Step you can not only learn but feel how physics works !

      --
      "Follow me" the wise man said, but he walked behind.
    2. Re:Physics Simulators by anthony.vo · · Score: 2, Informative

      There's this game called Crayon Physics where you draw objects in order to get a ball to the end point. It sounds simple but it challenges you to overcome various physical obstacles like getting your ball uphill, or to get your ball into a little catapult, and creating a counterweight to launch it to the end point. Neat game, check it out. http://www.crayonphysics.com/

  6. Paul Falstad Applets by Wookie+Monster · · Score: 5, Informative

    A much larger and cooler collection of physics applets can be found at http://www.falstad.com/mathphysics.html

  7. Try NetLogo by Anonymous Coward · · Score: 2, Interesting

    You might want to take a look at NetLogo (http://ccl.northwestern.edu/netlogo/). To quote the documentation: "NetLogo ... comes with a Models Library, which is a large collection of pre-written simulations that can be used and modified. These simulations address many content areas in the natural and social sciences, including biology and medicine, physics and chemistry, mathematics and computer science, and economics and social psychology."

    The models demonstrate some nice concepts and are easy to modify and a great source of material on how to implement your own models (see http://ccl.northwestern.edu/netlogo/models/ and scroll down a bit for the list).

    Phun is great too...

  8. Simple games by Anonymous Coward · · Score: 2, Insightful

    Make a simple game that involves particle physics. Wave physics is a bit too complicated, unless your nephews are in later classes of high school. I would suggest something like Scorched Earth.

  9. Just buy some... by oh2 · · Score: 4, Insightful

    ...real fireworks for them instead. The real thing beats just about everything and eyebrows grow back, you know. :)

    --

    Now the world has gone to bed, Darkness won't engulf my head, I can see by infra-red, How I hate the night.

  10. The kids might enjoy VPython by magneticstorm · · Score: 5, Informative

    Since you have a strong interest in visualizations of physics phenomena, and you're already teaching your nieces and nephews how to write Python, I'd like to suggest that you check out VPython, which is a series of 3D extensions to Python. In particular I think you'll be intrigued by these examples which visualize everything from wave superposition, to magnetic fields, to concepts from relativity. For immediate gratification, the author of that examples page also has Wiimote integration, so you can bridge interest that your relatives might have in video games into an interactive experience in your physics environment.

    Good luck!

  11. Good work, but... by Mike+Rice · · Score: 5, Interesting

    Simulations that are useful for learning must be grounded in reality. They must give the learner a chance to extrapolate principles from their own personal hands-on observations to the simulation.

    Without original personal observation of physical phenonema, simulations are little more than 'das blinken lights' to the learner.

    Don't get me wrong, the stuff offered by the OP is good. And if the kids in question already have an interest in the subject, its great.

    But to spark an original interest takes hands-on, thought provoking experiments that the learner may manipulate in any way they wish (some of which you probably never thought of).

    Example. Electromagnetism. My 8th grade grandson (yup I'm an old geezer who cut my teeth on vacuum toobs and RTL) learned a lot about the interplay between electric and magnetics fields just today. I suspended a magnet on a string, over an aluminum plate, and just left it there for him to find, and play around with. After he had done so, he asked why when the plate was present the pendulum swiftly assumed a stable position, whereas when the plate was absent the pendulum assumed a rather chaotic motion... even though the magnet was obviously not attracted to aluminum.

    After explaining it to him and allowing him to further explore the physics with magnet wire and batteries, he came away with a firmer grasp on electromagnetism, a grasp I highly doubt he would have gotten from a canned simulation. Now that he has made a connection in his mind between the seen (magnetic damping of the pendulum motion) and the unseen (electrical currents in the aluminum plate, and the ensuing magnetic field), a simulation would allow him to further explore the subject without requiring expensive laboratory equipment.

      So, Kudos for the work, but you have to get out there and actively, physically engage them with hands-on experiments. After, that is really what science is about!

    1. Re:Good work, but... by Alsee · · Score: 2, Interesting

      I had wondered about the earth's magnetic field too, but I think get it now.

      Any charge imbalance gets very very quickly evened out.

      Evening out a charge imbalance means a movement of electric charge. That is an electric current, which creates a magnetic field. Magnetic fields induce electric fields. In the extreme case of light a collapsing electric field creates a magnetic field which then collapses into an electric in a self sustaining cycle. In a theoretical lossless situation any initial electric or magnetic field in a conductor with create a self sustaining cycle. A magnet will self-sustainingly levitate above a super conductor because the magnet induces a lossless electric current and lossless opposing magnetic field. So in the ideal lossless situation even the slightest initial electric or magnetic imbalance in the earth would result in a self sustaining cycle.

      The earth, or a sphere of mercury, are normal conductors, and obviously have resistive losses. Any electric or magnetic field will tend to decay to zero unless you have an energy input. Thermal convection is that energy input sustaining thecycle. Now consider this - if an energy input can sustain that cycle then a larger energy input can amplify that cycle. In the ideal zero field case convection will amplify a zero field back to a zero field, but even the slightest random non-zero field influence will get amplified into a larger non-zero field. Any non-zero electric or magnetic influence from the sun or a meteor or a lightening or anything else will get amplified by that thermal convection energy input.

      sphere of mercury with a heat source at the middle making the mercury convect... What's different about a planet-sized glob of stuff with an outer core of molten iron?

      Scale. A one mile per hour water current in a puddle contains a minuscule amount of energy and will decay to zero in seconds due to friction losses. A one mile per hour water current in the Atlantic ocean constitutes a colossal store of inertial energy, and losses to friction are (relatively) negligible.

      Resistance losses go up as the square of the rate of current. The earth is so huge that even the most minuscule rate of current flow represents an enormous quantity electrons and generates a significant magnetic field. Any laboratory-scale sphere of mercury would need a vastly larger rate of current flow to generate a measurable magnetic field, and field decay to resistance would dominate at the square of the rate of current.

      Looking at it graphically, decay effects are like a U shaped curve. A laboratory scale blob of convecting mercury constitutes a fairly small gross quantity of convection energy flow, and will quickly resistance-settle to the immeasurably close to the exact bottom of that U almost immediately. Scaling things up to planet size is like taking a microscope to the virtually flat bottom at the middle of the U. The gross quantity of convection energy input is enormous, and it will feed into any variation from zero and push it pretty far off of the zero point. It will amplify it until the square-of-current resistance energy losses become large enough to balance the convection energy input.

      -

      --
      - - You can't take something off the Internet! That's like trying to take pee out of a swimming pool.
  12. Computer simulations?!? by Anonymous Coward · · Score: 5, Insightful

    No, no, no.

    To get kids interested in Physics - or anyone for that matter, a physical real world demonstration is the way to go. The most popular physics professor at MIT is known for his lecture theatrics.

    Shooting metal balls across the room and having them derive an equation will teach them something.

    Computer simualtions are boring! It's worse than watching TV and they will learn nothing. No. Have them create experiments, duplicate classic ones - some of the classic E&M experiments are a hoot and they're easy to build and best of all, they're not a computer simulation. They are REAL LIFE.

    1. Re:Computer simulations?!? by robbarrett · · Score: 2, Insightful

      Totally agree. For me (I eventually became a research physicist), the connection point was a simple experiment in a high-school physics class where we were able to predict the equilibrium temperature of the combination of a heated brass weight and a styrofoam cup of water. It was the connection between the math and the reality that was amazing to me -- that you could know pretty much exactly what the result would be ahead of time...and the you could design a particular outcome and make it happen. I guess it is the mark of nerddom, but I was hooked.

  13. Another reseource by fermion · · Score: 2, Informative

    For those who wish additional simulation, check out The PhET Simulations.

    --
    "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
  14. Physics 2000 by StarDrifter · · Score: 3, Informative

    The University of Colorado has something called Physics 2000 that has a bunch of applets. Click on "Applet Thumbnails" in the top-left frame. One of my favorites is "Satellite orbits" (click on "Upcoming Applets"). You can try to find stable orbits around the Earth. You can try to find stable orbits around the Moon (although I don't think there are any). You can try launching some objects clockwise and some counter-clockwise and see if it is easier to get things in a stable orbit one way or the other. You can launch a bunch of objects in random directions with random velocities and watch most of them die an early death and a few stick around much longer. Sometimes you can see Orbital resonance. The simulation extends beyond the visible portion of the screen so you can even get objects in orbits with very long periods that are only visible for a very short portion of their orbit as they dip close to the Earth and then sail away again.

  15. Dust is pretty amazing by drerwk · · Score: 2, Interesting

    My 10 year old showed this to me : http://dan-ball.jp/en/javagame/dust It is not exactly physically accurate, but it is really pretty cool and fun, and much more accurate than I expected.
    And can I say fast for what I thought one could get from Java.

  16. Demoscene by gandhi_2 · · Score: 2, Insightful

    Isn't that what the Demoscene was doing back in the later-BBS days?

  17. Mobinet by Hufo · · Score: 2, Informative

    Mobinet is an open-source platform for mobile objects programming (simulation, games, graphics, maths-physics, ...). It is developed by INRIA Grenoble in France and used to initiate students (from high school to university) to games programming, or more generally to provide them with a concrete intuitive and fun version of the notions seen in math and physics course.

  18. Do real experiments, not simulations! by Cliff+Stoll · · Score: 2, Interesting

    Want your kids to learn physics? Throw away the computer simulations. Build things with them. Run experiments. Observe and think about the results.

        To teach physics, start with things like C-clamps, string, rubber bands, wire, springs, low-friction carts, compasses, magnets, thermometers, balloons, weights, scales, and pulleys.

        More advanced stuff: a voltmeter/ammeter (analog stuff), an old oscilloscope, an air table (a kids' hockey table), vacuum pump & bell jar, countdown timer/photogate, etc. Many of these things show up on craigslist for cheap (I picked up two free oscilloscopes and have given them to my sharp high school students).

        Computer simulations? Naw. Have your kids do real physics:

        A pendulum made of a bowling ball and rope. Time the pendulum swings and then ask: which will change the period - changing the lenghth of the swings, changing the weight, or changing the length of the rope?

        Fool around with a signal generator, an oscilloscope, and a microphone. What's a sound wave look like? How is frequency related to period?

        Play with thermometers, ice, water, and fire. What's the temperature of ice and water? Can you get water colder than this? How hot is water from the kettle? Can you get water hotter than this?

        Get a voltmeter, wire, and some magnets. Can you really induce a voltage by moving a magnet nearby?

        Don't sidetrack your kids with simulations & computer graphics. Real physics starts by fooling around with reality.

        Obs Feynman quote: "It doesn't matter how beautiful your theory is, it doesn't matter how smart you are. If it doesn't agree with experiment, it's wrong."