Demon simulation of the ideal gas

Introduction

Consider an extra degree of freedom called the demon that interacts with a system consisting of an ideal gas of particles. Because the gas is ideal, the only relevant coordinates are the velocities of the particles. The demon exchanges energy with the particles in the gas by choosing a particle at random and making a random change in its velocity. If the energy change of the system (the gas) is positive, the "extra" energy is given to the demon and the trial change is accepted. If the energy change of the gas is negative, the trial change is accepted if the demon has sufficient energy to give to the gas. The only constraint is that Ed, the energy of the demon, must be greater than or equal to zero.

    The total energy of the demon plus the system is fixed. The demon can exchange energy with the system as long as the demon's energy remains greater than or equal to zero. The demon is a facilitator that allows the particles in the system to indirectly exchange energy with one another even though they do not interact.

Algorithm

  1. Set up an initial microstate with the desired total energy and assign an initial energy to the demon. For simplicity, we will choose the initial demon energy to be zero. We also initially assign each particle the same initial velocity v in the x-direction, which is chosen so that the initial energy of the system is E. The initial velocity in the other directions for dimensions greater than one is set equal to zero.
  2. Make a trial change in the microstate. For the ideal gas we choose a particle at random and increase or decrease its velocity by (2r - 1)δ, where 0 < r ≤ 1 and r is generated at random. We then compute the change in the energy of the system, ΔE.
  3. If ΔE ≤ 0, the change is accepted and energy |ΔE| is given to the demon so that the total energy of the system plus the demon is constant. If Δ E > 0, the change is accepted if the demon has enough energy to give to the system, and the demon's energy is reduced by ΔE. If the trial change is not accepted, the existing microstate is counted in the averages.
  4. Repeat steps 2 and 3 many times.
  5. Compute the averages of the quantities of interest once the system and the demon have reached equilibrium.

Problems

  1. Run the simulation using the default parameters. Does the average energy of the demon approach a well-defined value after a sufficient number of exchanges with the system? One Monte Carlo step per particle (mcs) is equivalent to N trial changes, where N is the number of particles in the system.
  2. What is <Ed>, the mean energy of the demon, and <E>, the mean energy of the system? Compare the values of <Ed> and <E>/N, the mean energy per particle of the system.
  3. Fix N and increase the total energy of the system. (The initial energy of the demon is zero.) Compare the values of <Ed> and <E>/N. Does the ratio change?
  4. What is the relation of the mean energy of an ideal gas in one dimension to the temperature T? Use this relation to determine the temperature of the ideal gas considered in Problem 2. Why can we conclude that <Ed> is proportional to the temperature of the gas?
  5. Why should we expect the demon to act like a system (of one particle) in equilibrium with a heat bath? In what sense is the ideal gas in this case a heat bath if N is sufficiently large?
  6. Why does the energy of the demon characterize its microstate? Does the energy of the ideal gas characterize its microstate?
  7. We know that the probability that a system in equilibrium with a heat bath at temperature T is in microstate s with energy Es is the Boltzmann distribution:

    Ps(Es) ∝ exp(-Es/kT).

    Given this form of P(Es), what is the probability that the energy of the demon is between Ed and Ed + ΔEd? Calculate the mean value of Ed in terms of T. (Remember that Ed is a continuous variable.)
  8. Run for a sufficient number of trials so that the form of P(Ed) is well defined and verify the exponential form of P(Ed). Choose Log Scale under the View menu. Then, under the Tools menus, choose Data Tool and Autofit the data set to a Line to find the best linear fit. Estimate T from the inverse slope of ln P(Ed) versus Ed. (The units are such that the Boltzmann constant k = 1.)
  9. Explain your results for <Ed> and <E>/N.
  10. What is the initial net velocity of the system in the x-direction? What is the net velocity of the system in the x-direction after equilibrium has been established? What is the form of the velocity distribution after many energy exchanges? Explain your result in terms of the central limit theorem.
  11. Repeat your simulations for two and three dimensions. Which results change and which results do not?
  12. Consider a generalized ideal gas for which the energy per particle is proportional to pα, where p is the momentum and α is an exponent. For a classical particle α = 2 and for a strongly relativistic particle α = 1. Is there a simple relation between <Ed> and <E>/N for α = 1?

Java Classes

Updated 28 December 2009.