4.2.9. Equations of State from Lattice Gas Models#
4.2.9.1. Motivation#
The finite volume lattice gas model can be used to estimate entropies of mixing. In these notes we will address how different lattice gas models can be used to derive equations of state.
4.2.9.2. Learning goals#
After these notes, students should be able to:
Use the Sterling approximation for natural logarithms of a factorial
Derive the ideal gas law from no-volume lattice gas model
Derive the equation of state for a fintie volume lattice gas model
4.2.9.3. Coding Concepts#
The following coding concepts are used to illustrate aspects of this lesson:
Variables
Functions
Arrays
Numpy
Plotting with matplotlib
4.2.9.4. Introduction#
4.2.9.5. Ideal Gas Lattice Gas#
We have previously seen the finite volume lattice gas. The ideal gas lattice gas is even easier. The number of ways of arranging \(N\) gas particles in \(M\) lattice sites (\(M>N\)) is
This is because every gas particle can be place in any of the lattice sites. The \(N!\) in the denominator corrects for the indistinguishable nature of these particles.
Thus, the entropy of an ideal gas with \(N\) particles in \(M\) lattice sites is
4.2.9.5.1. Example 1: Entropy of Lattice Gas#
Compute the molar entropy of a lattice gas with 5 particles and 16 lattice sites for the (a) ideal gas model and (b) finite gas model.
(a) Ideal gas model: For this model the entropy is given as the formula above
import numpy as np
from scipy.special import factorial
8.314*(5*np.log(16)-np.log(factorial(5)))
75.45330683401777
(b) Finite gas model: for this model the entropy is given as
import numpy as np
from scipy.special import factorial
8.314*np.log(factorial(16)/(factorial(11)*factorial(5)))
69.6884511418693
4.2.9.5.2. Equation of State for an Ideal Lattice Gas#
We can derive the equation of state for an ideal gas lattice gas model using the relationship
We will see where this relationship comes from during the section on classical Thermodynamics.
In order to use this relationship, we need to have an equation for \(S\) in terms of the volume of the system, \(V\). For this, we recognize that, for uniformly size grids/lattices, the volume of the system is proportional to the number of lattice sites
The proportionality constant is the volume of each lattice site which we will denote \(v\). This yields
or
Subbing this into the ideal gas lattice gas entropy equation yields
Now differentiating the above equation with respect to \(V\) and multiplying by \(T\) yields
4.2.9.6. Finite Volume Lattice Gas#
For a fintie volume lattice gas, the number of ways of arranging \(N\) gas particles in \(M\) lattice sites (\(M>N\)) is
Thus, the entropy of an finite volume gas with \(N\) particles in \(M\) lattice sites is
4.2.9.6.1. The Sterling Approximation#
A common approximation that comes up is Statistical Mechanics is the Sterling Approximation. This approximates the natural log of a factorial as
Let’s see how good of an approximation this is
# import libraries
import numpy as np
from scipy.special import factorial
import matplotlib.pyplot as plt
%matplotlib inline
# setup problem
N = np.arange(0,100,1)
def ln_N_factorial(N):
return np.log(factorial(N))
def sterling_N(N):
return N*np.log(N)-N
# setup plot
fontsize=14
fig = plt.figure(figsize=(6,6), dpi= 80, facecolor='w', edgecolor='k')
ax = plt.subplot(111)
ax.grid(b=True, which='major', axis='both', color='#808080', linestyle='--')
ax.set_xlabel("$N$",size=fontsize)
ax.set_ylabel("$\ln N!$",size=fontsize)
ax.plot(N,ln_N_factorial(N),lw=3,label="$\ln N!$")
ax.plot(N,sterling_N(N),'--',lw=3,label="Sterling Approximation")
ax2.set_ylabel('% Error', color='C3',fontsize=fontsize)
plt.tick_params(axis='both',labelsize=fontsize)
plt.legend(fontsize=fontsize)
ax2 = ax.twinx()
ax2.plot(N,np.abs(ln_N_factorial(N)-sterling_N(N))/ln_N_factorial(N)*100,lw=2,label="% error",color='C3')
ax2.tick_params(axis='y', labelcolor='C3',labelsize=fontsize)
<ipython-input-19-57d9286cb562>:11: RuntimeWarning: divide by zero encountered in log
return N*np.log(N)-N
<ipython-input-19-57d9286cb562>:11: RuntimeWarning: invalid value encountered in multiply
return N*np.log(N)-N
<ipython-input-19-57d9286cb562>:11: RuntimeWarning: divide by zero encountered in log
return N*np.log(N)-N
<ipython-input-19-57d9286cb562>:11: RuntimeWarning: invalid value encountered in multiply
return N*np.log(N)-N
<ipython-input-19-57d9286cb562>:25: RuntimeWarning: divide by zero encountered in true_divide
ax2.plot(N,np.abs(ln_N_factorial(N)-sterling_N(N))/ln_N_factorial(N)*100,lw=2,label="% error",color='C3')
From the above plot, specifically from the rapid decay of the percent error with increasing \(N\), we can see that the Sterling approximation is a good approximation in particular for large \(N\).
4.2.9.6.2. Equation of State for a Finite Volume Lattice Gas#
We can derive the equation of state for an ideal gas lattice gas model using the relationship
We will see where this relationship comes from during the section on classical Thermodynamics.
To derive an expression for \(S\) in terms of \(V\) for a finite volume lattice gas, we will start be employing the Sterling approximation to the equation for \(S\)
Now substituting that \(M=\frac{V}{v}\) yields
Now differentiating the above equation with respect to \(V\) and multiplying by \(T\) yields
At this point we need to make another approximation/assumption in order to simplify further. If we assume that the gas is dilute then the number of lattice sites \(M\) will be much much larger than the number of gas particles \(N\). This has the implication that \(M-N \approx M\) and \(\frac{V}{V-vN}\approx 1\). Applying this assumption yields
which is a somewhat standard correction to the ideal gas law for finite volume particles.