M L Aiello-Nicosia 1985 Eur. J. Phys. 6 148

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

European Journal of Physics

You may also like


- Superposing tidal force fields
Computer simulation of a two-dimensional ideal Jens Højgaard Jensen

gas: a simple molecular dynamics method for - Non-linear energy conservation theorem in
the framework of special relativity
Ginés R Pérez Teruel
teaching purposes
- Problem-based labs and group projects in
an introductory university physics course
To cite this article: M L Aiello-Nicosia and R M Sperandeo-Mineo 1985 Eur. J. Phys. 6 148 Antje Kohnle, C Tom A Brown, Cameron F
Rae et al.

View the article online for updates and enhancements.

This content was downloaded from IP address 132.248.181.15 on 05/04/2024 at 02:43


Eur. J. Phys. 6 (1985) 148-153. Printed in Northern Ireland

148

Computer simulation of a two-


dimensional ideal gas: a simple
molecular dynamics method for
teaching purposes
M L Aiello-Nicosia and R M Sperandeo-Mineo
Istituto di Fisica, Universita di Palermo and Gruppo Nazionale Didattica della Fisica-CNR,
Via Archirafi, 36, 90123-Palermo, Italy

Received 24 July 1984

Abstract A simpletwo-dimensionalmodel of an ideal Riaseunto Questolavorodescrive un semplicemodello


gas is described in order to study the time evolution of bidimensionale di gas perfetto, all0 scopo di studiare la
speed distribution in the framework of newtonian evoluzione temporale della distribuzione delle velocitk,
mechanics. The results of a computer simulation of a nell’ ipotesi della dinamica Newtoniana. I1 modello b
system of 16 particles are shown. The approach to utilizzato per una ‘computer simulation’ a scopo didat-
equilibrium is followed by observing changes in the tico, e Sono descritti in dettaglio i risultati ottenuti con
experimentally obtained values of Boltzmann’s H. un sistema di 16 particelle. L‘approssimarsi all’equilibrio
Anexampleof a possible way to use this simulation del sistema b seguito osservando la evoluzione dell’ H
program in an introductoryphysicscourseisalso given. di Boltzrnann. E’ inoltre descritta una possibile utiliz-
zazione didattica del programma di simulazione in un
corso introduttivo di fisica per studenti universitari.

1. Introduction
The understanding of microscopic disordered mo- different probability distributions for collisions be-
tion in gases is usually a difficult problem for most tween pairs of molecules and ‘scattering generators’
science students following typical introductory (Novak and Bortz 1970,Egerand Kress 1982,
physics courses. The Maxwell-Boltzmann distribu- FtkEnik et al 1983, Bonomo and Riggi 1984).
tion function is usually presented as merely an Well structured teaching courses should cover all
empirical formula. In fact the analytical approach possible links betweendifferent fields of physics,
connecting the results of the kinetic theory of gases yetthe associations between dynamics andther-
and the dynamic behaviour of simple systems (e.g. modynamics and between dynamics and statistical
hard spheres colliding elastically) is not straightfor- physics are topics which are usually insufficiently
ward. related in introductory physics books. Sauer (1981)
Mechanical apparatus is often used to illustrate provided evidence for the pedagogical value of a
the behaviour of molecules in gases, but the need computer simulation demonstrating disordered
to continuously supplyenergy to the system can motion of gases in the framework of newtonian
introduce misconceptions about the meaining of an mechanics. He also used a Monte-Carlo procedure
isolated system (Iona and Hastings 1970, Eaton et for the simulation of statistical ensembles and com-
al 1979). The use of computer simulations in the pared the results of the two methods. He proposed
microphysical area is, however, more interesting, a one-dimensionalmodelin which neighbouring
since thesesimulations can supply ‘experimental’ particles had different masses in order to allow for
support for physical theories. Many interesting thermalisation.
computer simulations of ideal gases have been pub- Many studies in moleculardynamics have already
lished forteachingpurposes.Most of these use used computer simulations to study equilibrium and
totally or partially stochastic approaches, assuming nonequilibrium properties of models of molecular

0143-0807/85/030148+06%2.25 01985 The Institute of Physics & the European Physical Society
Computer simulation of an ideal gas 149

systems (Alder and Wainwright 1959, 1963, Molecular dynamic methods (Erpenbeck and
Erpenbeck andWood 1977). These studies solve Wood 1977) usually apply periodic boundary con-
numerically the equations of motion for a many- ditions in such away that for each particle i at r,, in
bodied system and follow the trajectories of a few the primary (one- two- or three-dimensional) cell
hundred particles. To study systems containing as of edge L, 'image' particles are located at positions
many as several hundred interacting particles, high r, +vL for all the vectors v having integer compo-
speed computers with a large memory capacity are nents --a?<v,<-a?. We used a simplified version of
required. these periodic boundary conditions because of the
The characteristics and the versatility of personal limitations imposed by the memory capacity and
computers have been evaluated as satisfactory and speed of the computer.
effective for educational purposes. The implemen-
tation of amolecular dynamics calculation on a
personal computer requires not only a reduction of 2.1. Method
the number of particles that can be handled but (i)The initial configuration is set up. The
also a simplification of the numerical analysis, as machinecancalculate exactly, tothe number of
well as an evaluation of the appropriate boundary significant figures carried, the particle trajectories.
conditions in order to have small systems repres- All the trajectories are straight until two particles
enting macroscopic systems as closely as possible. collide or one particle crosses a wall.
In this paper we discuss amodelsimulatinga (ii) For each pair of particles i and j a collision
two-dimensional gas. Hard-core interaction is time rii is calculated ignoring the presence of other
assumed and a molecular dynamics method is used. particles. Introducing (Erpenbeck and Wood 1977)
By startingfrom different initial conditionsa relative coordinates and velocities
computer simulation of the development of speed rI1. = I " - Ir
distribution as it approaches a Maxwell-Boltzmann I

distribution is shown for systems containing a low particles i and j are approachingeach other if
number of particles. The changes in the experimen- rii uii < O . Otherwise the collision time is defined as
tally determined values of Boltzmann's constant H infinite
are also shown in order to study the approach to
hi = m for ril. uii 0.
equilibrium. The programhas been written in
BASIC and will be described in detail. The hardware For each pair of particles that are approaching,
used consists of the Apple I1 Europlus (64 K). A n the collision time is given by the time required to
example of a possible way to use this software in an reach a separation of D (where D is the diameter
introductory physics course will be also shown. of the particles). But someapproaching particles
can never reach a separation of D. From simple
kinematic considerations it can be shown that this
2. Model and computer simulation occurs when
The system studied consists of N identical
bi>D2
two-dimensional hard-sphere particles (hard discs)
contained in atwo-dimensional 'volume' V. We where
assume hard-core interaction: u ( r )= 0 for r > U and
b t = r;-[(rti U ~ ~ ) / U , ~ ] ~ .
u(r) = m for r <a,where r is the separation of the
centres of a pair of particles and U is the collision If this is the case we define hi =m.
diameter (in this case the diameter D of the discs). Finally the collision time is computed
Given the initial positions and velocities of
the particles and having statedthe boundary
conditions, thefuture behaviour of the system is
determined.
In order to represent a macroscopic system as Moreover, each particle i has a time t: at which,
closely as possible with a small number of particles inabsence of other particles, it would cross a
containedina volume V we imposeperiodic boundary of the primary cell. This boundary cros-
boundary conditions, i.e. we imagine space to be sing time can be calculated from simple kinematic
flled by indefinite replications of the volume V and considerations.
its constituent particles. The primary volume V is a (iii) Among all the N(N - 1)/2 collision times and
box with penetrable walls andthe particles are the N crossing times calculated the minimum value
constrained in such a way that their number in the r, is selected and the phase is advanced to t+t,
box remains constant. A particle which leaves the using the straight-line trajectory
box throughone wall is caused tore-enter with
unchanged velocity through the
opposite wall.
r,(t+~,)=r,(t)+t,oi(r) for i = 1 , 2 , ..., N
Consequently particles interact only with other (iv) If r, is given by t: the appropriate coordinate
particles. of the particle i is translated by L. If t, is given by
150 M L Aiello-Nicosia and R M Sperandeo-Mineo

til the post-collision velocities of the particles i and the ring (in the u,--u, plane) lying between the
j are computed onthe basis of momentum and circles of radius u k and Uk +AV. The approach of
energy conservations. Consequently the experimental value of H to that calculated if
the speeds of the N particles were those expected
from the Maxwell-Boltzmann distribution gives a
measure of the approach to equilibrium.

and the post-collision velocities are


3. Results
v : = v, +AV, v : = U, +AV,.
The prepared software follows the time evolution
By iteration of the last three steps the phase can be of the spatial distribution as well as of the speed
advanced indefinitely. distribution of N equal particles. The characteris-
Although our method is very simple, it requires a tics and the initial conditions are chosen from menu
lot of computations for the various steps. Conse- and the system evolution is followed in detail until
quently, very few particles can be treated ina an average of 10-20 collisions per particle have
reasonable time. A great saving in computing time occurred, in orderto show how the model is
can be made by defining a table of the collision and working.
the boundary-crossing times. Figure 1 shows a computer display of the posi-
New tii and t: are calculated onlyfor particles tion advancement from t to t + t,,,; figure l ( a ) shows
that just collided or crossed the wall and these a case in which the calculated t, is a collision time
values are inserted in the table if they are less than and figure l ( b ) shows a case in which the calculated
the largest ti, present on the table. All the other t,, t, is a boundary crossing time.
and t: are only diminished by the t , previously Because therelevant part of the system is in
computed (Alder and Wainwright 1959). momentum space, after a selected number of colli-
After each collision between two particles the sions thespeeddistributionsalone are displayed.
new speed distribution is calculated (given the cut- Looking at the instantaneous speed distributions it
off velocity U, and the width of the interval Au). An is easily seen that momentum and energy are soon
averagedistribution after aselectednumber of distributedamong all the particles in an irregular
particle collisions can beplotted and compared manner. The comparison of 'snapshots' of velocities
with the theoretical Maxwell-Boltzmann distribu- taken at different times shows that no reasonable
tion.
For the two-dimensional case j ( u ) physical information can be drawn about the nature
U exp(-uZ/(uz)) where (U') denotes the mean quad- of thedistributionfunction.We need to reduce
ratic velocity. fluctuations and consequently we need a larger
In order to have information about the decay of sample.
the speed distribution towards the Maxwell-Boltz- Alargersample size can behandled, without
mann distribution, the program calculates the ratio increasing computing time prohibitively, we if
n(u)/nM(u) (number of particles in a given speed choose to look atthe time averagedistribution.
interval divided by the expected equilibrium Figure 2 shows different time averages of the speed
number in the same interval). Moreover, it calculates distributions for the following experiment. Sixteen
the average M of these ratios on all intervals identical particles were given equal initial velocity
analysed and the standard deviation. In order to magnitude U" = 1, with a random selection of the
better evaluate the system as it approaches equilib-
rium,Boltzmann's constant H is evaluated at
various points. A discrete form of H is
Figure 1 Images of 16 particles in the primary cell and
of their trajectories in the time t,. (a),Two colliding
k particles (t,,,=cOllision time); ( b ) , a particle crossing the
boundary (t, = crossing time).
where j(Vk)a3Uk is the number of particles in a cell
in the neighbourhood of VI, and the sum is over
these cells. Taking into account the isotropy in
velocity and the two-dimensionality of our velocity
space, we obtain
l

where U, is the cut-off velocity of the simulated


distribution, n(uk) is the number of particles with
speed between u k and u k +Au and AS is the area of
Computer simulation of an ideal gas 151

0 1 2 0 1 2
I I A I

-1.8

.l .4
F i v e 2 Evolution of the average speed distribution of
16 particles. Initially all particles had equal velocity a
magnitude U,, = 1 and random directions. The cut-off
speed is 2.5 and AV is 0.125. N ( u ) / N is the fraction of
the total particles for each speed interval. ,,U is the
root mean square of velocity. A is the average number
of collisions per particle. Broken curves represent the
theoretical Maxwell-Boltzmann distribution. ( a ) , 6 = 10;
( b ) , A = 40; (c), ri = 100; ( d ) , A = 200.

Figure 3 Distribution of the ratio between the number


of particles in a given speed interval and the expected
equilibrium number in the same interval. 0, values after
80 collisions (A = lo), m = 0.79, U = 0.57; m,values
after 1600 collisions (A =200), m =0.95, U = 0.142.

two direction cosines on the plane; the density was tribution more closely as ii increases. In the first
equalto 0.05 with respect to close packing; the two plots an anomaly is evident at v = 1, this being
initial position was randomly selected on a square a remainder of the initial distribution. The ratios
box. The different plots refer to averages of differ- n(u)/nM(u)havebeen calculated for two of the
enttotalnumbers of collisions (respectively 80, simulated distributions reported in figure 2.
320, 800 and 1600) and consequently of different Figure 3 is a plot of the distributions of this ratio.
numbers of collisions per particle ii. The histograms It also gives the average values M and the standard
arethe simulateddistributions, andthe dashed deviations. It can easily be seen that the spreading
curves represent the Maxwell-Boltzmann distribu- of these ratios is much greater for 80 collisions (10
tion. It is clearly shown that the simulated histog- collisions per particle) than for 1600 collisions (200
ram approximates the Maxwell-Boltzmann dis- collisions per particle).
152 M L Aiello-Nicosia and R M Sperundeo-Mineo

Figure 4 Average distributions of particle speeds among speed intervals for ( a ) , N = 9, ti = 500; ( b ) , N = 25; ti = 100.

Different initial conditions, corresponding to the fact, good fits depend on the equilibrium conditions
same total energy of the system, have led to the as well as onthe totalnumber of particles used
same final result. These observations justify that to average the speed distributions.
the macrostatereached after alargenumber of Oncethe velocity distributionhasbeen deter-
collisions can be called equilibrium state. mined it is easy to evaluate H. Figure 5 shows the
Different numbers of particles have been handled decrease in H as the number of collisions increases,
by the program. Figure 4 shows two speed distribu- for the same experimentas shown in figure 2. It
tions for N = 9 and N = 25 particle systems. The also shows that H approximates the equilibrium
initial conditions were the same as the experiment value in 10-15 mean collisions per particle. Ifwe
described in figure 2. Good fits were obtained start at this time to average the speed distributions
with different numbers of collisions per particle of the particles we can obtain a distribution where
(A = 500 for N = 9, and fi = 100 for N = 25). In the remainder of the initial distribution is reduced.
Figure 6 ( a ) shows the speeddistribution ob-
tained by averaging fromthe 81st tothe 320th
collision for the sameexperiment as shown in figure
Figure 5 Ratio between the Ebltzmann H and the H 2. Deviations from the theoretical values are nearly
equilibrium values HMplotted against the number of randomly distributed but the fit is not yet very good
collisions per particle. because of the low number of ‘snapshots’ of particle
velocities. In orderto reducethese deviations
the results of 10 different simulations (concerning
equal systems of N particles with thesametotal
energy but different directions of the initial
velocities) have been summed and the average dis-
tribution has been calculated. The result is shown
in figure 6 ( b ) andthe fit can be considered quite
good.
Good fittings can be obtained by averaging the
results of different groups of students using approp-
riate initial conditions.

4. Conclusions
The educational interest of our computer simula-
tion lies in the possibility of obtaining the Maxwell-
**. . S .
Boltzmanndistribution using only the framework
l of newtonian mechanics. The Maxwell-Boltzmann
distribution is regarded as a good fit to observation
Collisions per partlcle and the computersimulation gives ‘experimental’
support to the theoretical distribution.
0 10 20 30 40 The trial version of the software has been used
Computer simulation of an ideal gas 153

0.1

-
I
-2
3

VIVrms v / vrms
0 1 2 0 1 2

Figure 6 Average distribution of particle speeds among speed intervals for 16 particles. ( a ) ,The distribution
obtained by averaging from the 81st to the 320th collision for the same experiment as shown in figure 2. ( b ) , The
distribution obtained by averaging 10 simulations like that of ( a ) .The 10 systems were identical unless the
directions of the initial velocities were different.

by first year science students of our University. Ahwled!gIOellt


Students worked in groups of two or three with the The present work was supported by Consiglio Nazionale
assistance of a tutor, as in their usual laboratory delle Ricerche and MP1 local fundings.
class. A manual isin preparation explaining how
the simulation works and how to use the keyboard
toenterdata.Inorderto reduce the computing References
time a BASIC compiler was used for students'exper- Adler B J and Wainwright T 1959 J. Chem. Phys. 31
iments'. In this way one hour is enough to calculate 459
about 300 collisions for the system of 16 particles. -1963 The ManyBody Problem ed. J K Percus
Students can carry out a complete simulation and (New York: Wiley)
write on file their final distribution. They can suc- Bonomo R P and Riggi F 1984 Am. J. Phys. 52 54
cessively average their data with that obtained by Eaton B G, Finstad R G and Lane P D 1979 Am. J.
other students and analyse longerruns using the Phys. 41 132
data previously recorded on file by the teacher or Eger M and Kress M 1982 Am. J. Phys. 50 120
Erpenbeck J J and Wood W W 1977 Statistical
by themselves. Mechanics B ed. B J Berna (New York: Plenum)
Students have shown a great interest in using the F t C d J, Lichard P and PiSut J 1983 Eur. J. Phys. 4 68
simulation programs and we feel that this kind of Iona M and Hastings R M 1970 Am. J. Phys. 38 1353
computer simulation gives substantial supportto Novak J and Bortz A B 1970 Am. J. Phys. 38 1402
the learning process. Sauer G 1981 Am. J. Phys. 49 13

You might also like