# Demon simulation of the Einstein solid

## Introduction

Consider an extra degree of freedom called the demon that interacts with a system of noninteracting particles whose energies are restricted to the positive integers. That is, each particle may have energy 0, 1, 2, …. The only relevant coordinate is the integer characterizing each particle.

Such a system of distinguishable particles is sometimes called an Einstein or harmonic solid. The particles are equivalent to quantum mechanical harmonic oscillators, which have energy εn = (n + 1/2) hν. If we measure the energies from the lowest energy state, hν/2, and choose units such that hν = 1, we have εn = n.

The demon exchanges energy with the particles in the system by choosing a particle at random and making a random change of ±1 in its energy. If the energy change of the particle is positive, the "extra" energy is given to the demon and the trial change is accepted. If the energy change of the particle is negative, the trial change is accepted if the demon has sufficient energy to give to the system. The only constraint is that Ed, the energy of the demon, must be greater than or equal to zero.

See: [Introduction to STP] and [Introduction to Ideal Thermometer]

## 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 and assign the total desired energy (which must be an integer) to one of the particles.
2. Choose a particle at random and increase or decrease its energy by ±1. If ΔE = -1, we accept the change, and give energy +1 to the demon so that the total energy of the system plus the demon is constant. If Δ E = 1, we accept the change if the demon has enough energy to give to the system, and reduce the demon's energy by 1. If the trial change is not accepted, the existing microstate is counted in the averages.
3. Repeat step 2 many times.
4. 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. In what ways does the demon act like an ideal thermometer? 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 Einstein solid a heat bath if N is sufficiently large? Discuss why the energy of the demon characterizes its microstate.
4. 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).

Run for a sufficient number of trials so that the form of P(Ed) is well defined. Use the Enable log scale button to verify the exponential form of P(Ed). Estimate T from the inverse slope of ln P(Ed) versus Ed. (The units are such that the Boltzmann constant k = 1.)
5. Are the quantities <Ed> and <E>/N proportional to the temperature T that you found in Problem 2? Increase the total energy E for fixed N and plot <Ed> versus T. Discuss the qualitative behavior of the plot.
6. What are the possible values of the energy of the demon? What are the possible values of the energy of each particle in the system? Show that <Ed> can be expressed as

<Ed> = (1/Z) Σn n e-n/kT ,

where

Z = Σn e-n/kT.

Evaluate Z and <Ed>. (It is necessary to do the sum only for Z, and then take the appropriate derivative to find the other sum.) Is <Ed> ∝ T in this case? Why is the dependence of <Ed> on T different than it is for an ideal gas?

Updated 20 March 2020.