Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
In introductory physics courses for science students, the kinetic theory of gases is an important subject
which provides the foundations of thermodynamics and statistical physics. A general description is
given on the wikipedia page:
This theory explains the macroscopic properties of gases, such as pressure, temperature, entropy, etc…
by considering their compositions and particle motions. Of primary importance is the Maxwell-
Boltzmann (MB) distribution function which gives the probability distribution function of particle
speeds in the gas:
This is usually presented as an empirical formula with little or no discussion of its physical origin. In
general students are asked to accept the fact that the distribution of speeds in a gas is given by the MB
formula, but the whole concept remains an abstraction to many. The distribution of speeds is related to
the temperature of the gas T, as illustrated in the figure below:
In this project, you will simulate a 2-dimensional gas and recover the MB distribution of velocities. The
goal is to develop some understanding as to where the MB distribution comes from microscopically.
Your simulation will start with some arbitrary velocity distribution (very non-MB ) and you will
observe that the final velocity distribution will always be a MB distribution.
The redistribution of energy in a gas is done through elastic collisions (collisions can be inelastic, but it
is not relevant for the goal of this project). This means that every time two particles in a gas collide,
you will have to calculate the new velocities according to the conservation of energy and momentum.
There is a simple formula which allows you to do this:
If v1, v2 , x1, x2 are respectively the velocities and positions of particles 1 and 2, then the new velocities
after collision will be:
v1’=v 1u2212
u27e8 v1u2212v 2,x1u2212x2u27e9
||x1u2212x2||2 (x1u2212x2)
v 2’=v 2u2212
u27e8 v2u2212v1, x2u2212x1u27e9
||x1u2212x2||2 (x2u2212x1)
where the <A, B> refers to the dot product between vectors A and B. We have assumed that the two
particles are circles and have the same mass. The collision configuration is shown in the following
diagram:
You will write a program: collisions.py which follows the collisional motions of particles in a
box (see setup instructions below).
Your code should generate several output files:
x1 x2u00a0v2 v2u2019 v1u2019 v1
1) An animation: collisions.mp4 that shows the particle positions over each of the time steps
(one frame for every step).
2) After all the steps have completed, it should create a plot with two panels, showing the
probability distribution of speed f(v) of all particles on one panel, and the probability
distribution of kinetic energy, g(E) of all particles (where E=1/2 mv2 ) in the other. The plots
should be in a file called distributions.pdf.
In two dimensions, the analytical expressions for f(v) (called the Maxwell-Boltzmann
distribution of speed) and g(E) (called the Boltzmann distribution) are at the heart of classical
statistical physics, they are given by:
where kB = 1.38 x 10-23 kg s-2K-1 is the Boltzmann constant and T is the temperature of the gas.
Your code should also fit the analytical f(v) to the histogram generated by your simulation to
find the temperature T and plot the fitted function on top of the histogram. Using this same T, it
should plot the analytical g(E) on top of the corresponding histogram.
3) Finally, in a file called collisions.txt your code should write a sentence giving the value
of the temperature you found when fitting the speed distribution.
Note that all your histograms should be normalized to unity for the analytical formulae to work.
Create a new directory somewhere in your home directory with the name
yourusername_project_4 to store the files you will create for this project.
1) Start with the template program below, which prepares the gas particle distribution with following
setup:
where the left half of particles are blue, the right half are red. The template assigns the initial velocity
of the blue particles to +500 m/s and the red particles to -500 m/s along the x axis. Use the following
characteristics for the simulations:
number of particles: 400
number of time steps: 1000
time step Dt = 0.00002 s
particle size radius = 0.0015 m
particle mass (this is the mass of an O2 molecule) = 2.672 x 10-26 kg
2) Implement the particle-particle collision physics (velocity change) using the itertool.combination()
method introduced above to identify the pairs of particle that undergo a collision. The instruction to
measure distances between particles is already in the program template, you need to build it from there.