README2.TXT Collide Program

Copyright (c) 1994-1998 David Schmidling

The author is a faculty member of The Department of Chemistry of Polytechnic
University, New York City.
________________________________________________________________________________
System requirements
IBM PC/Compatible, with 80286 or higher, VGA 640x480x16 color or higher,
DOS 3.3 or higher. Fast computer suggested.

Installation
Copy COLLIDE.ZIP to a directory and unzip the file.

Packing List
COLLIDE.EXE     Main program
COLLIDE2.EXE    Performs the calculations
MESG2.DAT       Message text
PARM.DEF        Default parameters
README.TXT      Short writeup
README2.TXT     Long writeup
________________________________________________________________________________
Introduction
	This program simulates the behavior of a gas.  Classical mechanics is 
used to calculate the trajectories of individual particles.  The visual presen-
tation of the model helps the student to gain an intuitive understanding of
gases and their properties.

	Molecules are modeled as hard spheres in motion in a small container, 
bouncing off the walls and each other.  Rates of collision between particles and 
with the walls, pressure and speed distribution are calculated and compared with 
theoretical dilute gas values.

	Starting from arbitrary initial conditions, the system evolves towards 
equilibrium.  When the volume of the molecules is small compared to the volume 
of the container, behavior approaches that of an ideal gas.
________________________________________________________________________________
Program Operation

1.      The program is menu driven. Control is by Alt-(underlined letter) or
mouse, if mouse and mouse driver are installed.

2.      Menu Entries
Parameters
        Volume                          container volume in cubic nm
        Temperature                     degrees K                     
        Number of Particles             1-666(cube); 1-503(sphere)
        Particle Diameter               diameter in nm
        Particle Mass                   mass in amu
Options
        Initial Coordinates             Crystal/Random
        Initial Speeds                  Equal/One Particle/Boltzmann
        Container Shape                 Cube/Sphere
        Particle Display                Dot/Dot with Trail/Ball
        Speed Distribution Display      Instantaneous/Time Averaged
        Boundary Conditions             Reflecting/Periodic
        Random Number Seed              initialize random number generator
Run                                     starts the simulation
Run Series                              starts a series of simulations,
                                        beginning with the current volume and
                                        ending with a volume ten times larger.
Graph Series                            graph P vs V(minimum)/V shows approach
                                        to ideal gas behavior
Quit                                    stop the program and return to DOS
Help                                    one page help screen

3.      To stop the simulation, press Esc.  Note that when the number of parti-
cles is large, the simulation will take a while to halt.

4.	Halting a simulation returns you to the input screen, from which you can 
then start a new simulation or end the program.

5.      Notes
        Numerical inputs for volume, temperature and mass are 1x10^-7 to 1x10^7.
The number of particles must be in the range 1-666, with a further limit imposed
for large particles. A particle diameter of zero is permitted, but the rate of
interparticle collisions will be zero. The absolute maximum diameter for
particles depends on the number of particles, container shape and size and on
boundary condition type. They are shown here for a cube with half width W for
reflecting and periodic boundary conditions. Note that it is the center of the
particle that is confined.

BOUNDARY     N          MAX DIA      (W=5)    COMMENTS
REFLECTING   1          4W           20       CENTER
"            2          2*3^(1/2)W   17.32051 OPPOSITE CORNERS
"            3-8        2W           10.      SIMPLE CUBE
"            9          3^(1/2)W     8.66025  BODY CENTERED CUBE
"            10-14      2^(1/2)W     7.07107  FACE CENTERED CUBE
"            15-27      W            5.       2x2x2 SIMPLE CUBE
"            28-63      W/2^(1/2)    3.53553  2x2x2 FACE CENTERED CUBE
"            64-172     W*2^(1/2)/3  2.35702  3x3x3 FACE CENTERED CUBE
"            173-365    W*2^(1/2)/4  1.76777  4x4x4 FACE CENTERED CUBE
"            366-666    W*2^(1/2)/5  1.41421  5x5x5 FACE CENTERED CUBE
PERIODIC     1          2W           10.      SIMPLE CUBE
"            2          3^(1/2)W     8.66025  BODY CENTERED CUBE
"            3-4        2^(1/2)W     7.07107  FACE CENTERED CUBE
"            5-8        W            5.       2x2x2 SIMPLE CUBE
"            9-32       W/2^(1/2)    3.53553  2x2x2 FACE CENTERED CUBE
"            33-108     W*2^(1/2)/3  2.35702  3x3x3 FACE CENTERED CUBE
"            109-256    W*2^(1/2)/4  1.76777  4x4x4 FACE CENTERED CUBE
"            257-500    W*2^(1/2)/5  1.41421  5x5x5 FACE CENTERED CUBE


        The initial Coordinates option tells the program how to set the initial
particle coordinates, which can be either a "Crystal" array or a "Random" array.
If "Random" is chosen, the program will try to find random positions in the con-
tainer for all the particles.  If the particles are small and few in number,
this will succeed.  If the particles are large in both size and number, this
attempt will probably fail, and the program will then place the particles in
the "Crystal" array.

        The Initial Speeds option gives three choices for the initial speed
distribution.  "Equal" assigns equal speeds to all particles.  "One Particle"
assigns a speed to one particle and a zero speed to all the other particles.
"Boltzmann" assigns speeds in an approximation to the Boltzmann distribution.
In each case, the directions of motion are chosen at random.

        The Particle Display option gives a choice of single points, single
points that leave a trail (allowing verification of the space-filling nature of
the particle motion) or a filled circle. When particles are large and numerous,
the execution times are dominated by the time it takes to fill in the circles.

Output

The program output consists of four parts.

Part 1
        The first part of the output is a chart of the operating conditions, ie
the input parameters. Also shown is the elapsed time on the molecular scale.

Part 2
        The second part of the output is a chart giving results of the simula-
tion and calculated dilute gas values.  The pressure, interparticle collision
rate and the collision rate with the wall are time averaged.  The average speed
is not time averaged and fluctuates.  The root mean square (RMS) speed is con-
stant (except for computer roundoff error) due to the conservation of energy.

Part 3
        The third part of the output is the speed distribution display.  If the
Speed Distribution Display option is set to "Instantaneous" it is not time
averaged and therefore never stops fluctuating.  If the Speed Distribution
Display option is set to "Time Averaged" it will converge at long times. The
display is updated periodically.  A continuous Boltzmann distribution is also
shown.

Part 4
	The fourth part of the output is a picture of the current positions of
the particles.
________________________________________________________________________________
Theory

The Kinetic Theory of Gases assumes that

1.	Gases consist of molecules in constant random motion, with an average 
kinetic energy proportional to the absolute temperature.

2.	Molecules undergo elastic collisions with the container wall and with
each other.

3.	Molecules exert no net force on one another.

4.	Molecules occupy an extremely small volume compared to the volume of 
their container.

	These rather stringent assumptions lead to the ideal gas law,
P V = n R t, where P is the pressure, V is the container volume, n is the
number of moles, R is the gas constant and t is the absolute temperature.
Here, we will use a form more convenient when the number of molecules is small,
P V = N k t, where N is the number of molecules and k is the Boltzmann constant,
which is the gas constant divided by Avogadro's number.

Derivation of the Ideal Gas Law

	Let a single particle of mass m be confined in a cube with dimension a
and have a velocity component in the (+x) direction Vx.  The particle will
bounce back and forth, colliding repeatedly with the (+x) wall.  The time
period between collisions with the (+x) wall is the time required to travel 2 a
in the x direction,

time = 2 a / Vx

	Every time it strikes the (+x) wall, the momentum changes from +m Vx
to - m Vx, for a momentum change of 2 m Vx.  Since force is the change of 
momentum per unit time, the average force exerted by the particle on the (+x) 
wall is

        Fx = (change in momentum) / time = (2 m Vx) / (2 a / Vx) = m Vx^2 / a

Suppose there are N particles of mass m.  The total force exerted on the (+x)
wall is

        Fx = (m / a) [Vx^2(1) + Vx^2(2) + ... + Vx^2(N)]

Define Ux^2 as the mean square speed in the x direction

        Ux^2 = [Vx^2(1) + Vx^2(2) + ... + Vx^2(N)] / N

The total force exerted by the molecules on the (+x) wall can be written

        Fx = (m / a) (N Ux^2)

        Pressure is force per unit area.  The area of the (+x) wall is a^2 and
the pressure exerted on the (+x) wall is

        Px = (m / a) (N Ux^2) /  a^2  =  N m Ux^2 / a^3  =  N m Ux^2 / V

where V = a^3 , the volume of the cube.

By the same arguments applied to the y and z directions

        Py = N m Uy^2 / V and Pz = N m Uz^2 / V 

Since the pressure exerted by the gas is the same in all directions, 

        P = Px = Py = Pz,   and also  Ux^2 = Uy^2 = Uz^2 

The total mean square speed is found by combining the x, y and z components

        U^2 =  Ux^2 + Uy^2 + Uz^2 = 3 Ux^2 

and therefore

        P = N m U^2 / 3 V or P V = N m U^2 /3

and also

        U^2 = 3 k t / m,   U = sqrt(3 k t / m)

The average kinetic energy is m U^2 /2, so  

	P V = (2 / 3) N (average kinetic energy)

	To convert kinetic energy to a temperature equivalent, we set the
average kinetic energy to (3 / 2) k t, and substitution in the last equation
above gives

	P V = N k t

Example:  Let N = 100, t = 273 K and the volume be 1000 nm^3 = 1.E-24 m^3.
k = 1.38066E-23 J/K. 
P = N k t / V = (100) (1.38066E-23)(J/K) (1 Newton m / J) (273 K) / 1.E-24 m^3 = 
3.769E5 Pa.

The Boltzmann distribution

	The Boltzmann distribution will not be derived here.  The probability 
distribution of speed P(s) is

        P(s) = 4 pi (m / 2 pi k t)^(3/2) s^2 exp(-m s^2 / 2 k t)

	The root mean square speed is sqrt(3 k t / m) , as found above.  The 
average speed is a bit different, and found from the integral of s P(s) from 0
to infinity.  The average speed is sqrt(8 k t / pi m).

Collision Rates

	The rate of collisions with the wall per unit area is one fourth the
        average speed times the particle density.  The collision rate in the
        simulation is over the entire surface of the container.  Then

	Rate of collisions with the wall = RATEiw 
	= (average speed) (N / V) (area) / 4 
	= P (average speed) (area) / 4 k t

Example:  Let N = 100, t = 273 K , m = 4.0026 amu and the volume be 1000 nm^3 
= 1.E-24 m^3.
For a cube 10 nm on a side, the total surface area is 600 nm^2 = 6E-16 m^2.
k = 1.38066E-23 J/K.  Avogadro's number = 6.022045E23 amu/g

The mass in Kg is (4.0026 amu / 6.0022045E23 amu/g) (1 Kg / 1000 g) = 
6.66855E-27 Kg.

The average speed is sqrt(8 k t / pi m) =
sqrt{8 (1.38066E-23 J/K) [(1 Kg m^2/sec^2 ) / J](273 K) / [ pi (6.6855E-27 Kg)]}
= 1198.2 m/sec

RATEiw = (1198.2 m/sec) (100 / 1.E-24 m^3) (6E-16 m^2) / 4 = 1.7973E13/sec

Note:  In the simulation, the root mean square speed is set by the temperature, 
while the average speed is dependent on the exact distribution of speeds.  For a
zero particle diameter, there are no collisions between particles and therefore
no redistribution of speeds.  The rate of collisions with the wall will not con-
verge to the correct ideal gas value.  Setting the speed distribution to
Boltzmann will not give an exact continuous Boltzmann distribution and the theo-
retical and simulated rates of collision with the wall will not still not agree.
Results of repeated simulations will cluster about the correct value, however.
Agreement of simulation collision rates (RATEiw or RATEij) with dilute gas
values is achievable only in the limit of small non-zero particle diameter.

	For particles with equal mass, the rate of inter-particle collisions
per unit time for a dilute gas is calculated as

        RATEij = sqrt(1/2) sigma (average speed) N^2 / V

where sigma  = pi d^2, the cross section of the particle.

Example:  Let N = 100, t = 273 K , m = 4.0026 amu and the volume be 1000 nm^3 
= 1.E-24 m^3.
Let the particle be a helium atom, with diameter 0.26 nm.
Then sigma  = pi d^2 = 0.21 nm^2 = 2.1E-19 m^2; average speed = 1198.2 m/sec
(from the previous example), and

RATEij = sqrt(1/2)(2.1E-19 m2)(100^2)(1198.2 m/sec) / 1.E-24 m3 = 1.8E12 / sec
________________________________________________________________________________
Advanced Theory

	In this simulation, gases with particle densities up to solid state
levels can be investigated.  Computer simulations using the hard sphere model
have been published [B. J. Alder and T. E. Wainwright, J. Chem. Phys. 31, 459
(1959), J. Chem. Phys. 33, 1439 (1960)].

Equations of State

	In the hard sphere model, departure from the ideal gas law is a matter
of excluded volume, and can be expressed in terms of a virial series:

        PV / n k t = 1 + B2(N / V) + B3 (N / V)^2 + B4 (N / V)^3 + ...

	B2 is due to excluded volume due to particle pairs (i.e. the volume
which is excluded for one particle by the presence of a second); B3 is due to
triplets, etc. The virial coefficients up to B7 have been calculated for the
hard sphere model [F.H. Roe and W. G. Hoover, J. Chem. Phys. 46, 4181 (1967)]:

B2 = b0 = 2/3 pi d^3
B3 = 5/8 b0^2
B4 = 0.2869 b0^3
B5 = 0.110010(+/-)0005 b0^4
B6 = 0.038610(+/-)0004 b0^5
B7 = 0.013810(+/-)0004 b0^6

        The following simple equation of state for hard spheres has been pro-
posed [N. F. Carnahan and K. E. Starling, J. Chem. Phys. 51, 635 (1969);
J. Chem. Phys. 53, 600 (1970); Phys. Rev. A1, 1672 (1970)]:

        PV / N k t = (1 + eta  + eta^2 - eta^3) / (1 - eta )^3

where eta = N b0 / 4 V = sqrt(2) pi V0 / 6 V,  V0 = N d^3 / sqrt(2).
V0 is the volume occupied by N close packed spheres of diameter d.

Example:  The lattice constant for fcc buckminsterfullerene is 1.417 nm, so the 
van der Waals diameter can be taken to be about 1.417 nm / sqrt(2) ~ 1 nm.
Let d = 1.0 nm exactly.  Then b0 = 2/3 pi d^3 = 2.0944 nm^3.  For N = 666 and
V = 1000 nm3^, eta = N b0 / 4 V = 0.348718. Then
PV / N k t = (1 + eta  + eta^2 - eta^3) / (1 - eta )^3 = 5.16886

Collision Rates

	The inter-particle collision rate can be calculated [D. Enskog, Kgl.
Svenska Ventenskapsakad. Handl. 64, No. 4 (1922)] as

        G / G0 = (P V / N k t - 1) / (N B2 / V) = (P V / N k t - 1) / 4 eta

where G0 is the collision rate for the dilute gas.	

Correction for small N

	The virial coefficients must be corrected for small values of N.  This
has been done for periodic boundary conditions [J. Oppenheim and P. Mazur, 
Physica 23, 197 (1957)] with the results for the first two coefficients (taken
to be approximately applicable here)

        B2(N) = B2(1 - 1/N),    B3(N) = B3[1 + (1 / 5 N) - (6 / 5 N^2)]

