The Diffusion Simulator

You need to know more about how the simulation works, and the actual values of the parameters used.

We must use the pixel as the unit of distance, since I have no control of the actual size of the simulator on your screen in inches, only the size n pixels. The pixel is the smallest unit of a graphic (or any object for that matter) on your computer screen. Typically, a pixel is 1/72 of an inch, but it all depends on the make and model of your monitor and computer, or the settings for either (for example, my screen can operate at 5 settings, and the size of a pixel varies by a factor of 2 in that range). I can not be sure of the speed of the simulation on your machine, but I intended the positions to update every 0.5 seconds (it won't occur any faster than that). At each step, x and y for each atom increase or decrease by a random amount between 0 and 40 pixels, with uniform probability in that range. To find D, we use the equation:

< x ^ 2 > = 2 D t

where < x ^ 2 > is the average value for x squared in one update, and t is 0.5 sec. To find < x ^ 2 > we need to integrate x ^ 2 over the range -40 to +40 pixels, and divide by magnitude of the range, which is 80 pixels. This gives an average of 533. Dividing by 2 t gives, which is 1 sec:

D = 533 pixels ^ 2 / sec

This will enable you to predict how far a given atom will move in any time, with the complication that when atoms hit the bottom they are reflected, and when they hit a side they reappear on the opposite side .

The direction that will be of most interest is the vertical. The total height of the applet is 350 pixels, with 265 pixels being used for the container. Thus, the bottom and top sections (the number of atoms in each is displayed in the boxes on the left) are each 132 pixels high. If the downward drift velocity is 0, all the atoms will eventually diffuse up out of the container. The first few atoms will leave quickly, but the departure of the last few will take a long time, because the upward flow is driven by the concentration gradient, and as atoms spread out, this concentration gradient becomes smaller and smaller.

If you enter a downward drift velocity, the applet is a model for an atmosphere on a planet. There is constant diffusion upward, but gravity is pulling the atoms downward with a constant velocity (there is a constant force down, and the atoms are thus falling down through an environment that has a viscosity) . It is also a model for the polystyrene beads in GeneVue's DNA diagnostic, where a constant electric field is forcing the beads against the hybridizing surface, but diffusion away from the surface causes the beads to form a cloud, and not a solid layer.

To find the equilibrium distribution of atoms, we just set the flow up due to diffusion equal to the flow down due to the drift velocity, V :

J up = - D dc/dx = J down = V c

dc/dx = (-V/D ) c

The solution to this familiar differential equation, where the derivative of the function is equal to a constant times the function, is the exponential function ( the term N V / D in front of the exponential normalizes the function to one that describes the distribution of N atoms).

c = ( N V / D ) exp (- x V / D )

A natural question might be to ask: what V would cause the average atom density in the top half of the container to be 1 / e = 37 %, of that in the bottom ? As a fast approximation, we guess the exponent of e must equal -1, or:

132 V / 533 = 1

V = 4

Return