Showing posts with label cloning. Show all posts
Showing posts with label cloning. Show all posts

Thursday, August 8, 2013

A Simple Model of Diffusion

  This Scratch project is an over-simplified look at the physical process that occurs when a drop of ink is placed in a very thin layer of water.        
   The ink molecules perform random walks. Over time, the molecules drift from the center and diffuse throughout the water. 
   In the following short video, I demonstrate how to add a drop of red food coloring to a very thin layer of water and then watch as the coloring diffuses in a near perfect circle. Several billions of red-colored particles are involved in the video and the statistics that govern the random walks of such a large number of particles accounts for the circular diffusion.
   The following Scratch project is my first look at 'cloning', available in the new 2.0 version of Scratch. Years ago I did this same project in Starlogo


   Starlogo has a crt X command (create turtles X) that commands the X number of turtles to execute (in parallel) the same procedure. If you 'See inside' to look at the code, I think you will see that  I used 'clone sprite 1' to the same effect in this project.
   Here's a very short video of the Scratch project in action.
   The maximum number of particles I can clone in Scratch 2.0 is 300 so there aren't the billions of particles in the Scratch simulation that there are in the actual food coloring demonstration.
Still, even with such a low number of particles, one can see the diffusion away from the center and the roughly circular shape emerging from the random walks.
   This is the link to the project.
   The ability to 'clone' a sprite means only one script has to be written and it controls all of the clones!
   Notice that this project is an extension from the one-dimensional random walk on the integer number line (see previous post) to the the two-dimensional plane.