A lattice gas is a system of spins that can take a value of +1 and -1. These spins do not interact with each other but they do interact with an external magnetic field, H. The Hamiltonian for this system is thus:
H(s1,s2,…,sn)=−HμN∑i=1siwhere si is the spin coordinate of the ith spin. The code in the cell below calculates the internal energy for a system of N spins in an external magnetic field, H, in units of Hμ:
We can calculate the canonical partition function for a system of n spins in a lattice gas model using:
Z=1∑s1=01∑s2=0…1∑sn=0e−βH(s1,s2,…,sn)An analytical expression for this quantity can be determined can be determined as follows:
Z=1∑s1=01∑s2=0…1∑sn=0eβHμ∑ni=1z(si)=1∑s1=01∑s2=0…1∑sn=0n∏i=1eβHμz(si)=[1∑s1=0eβHμz(s1)][1∑s2=0eβHμz(s2)]…[1∑sn=0eβHμz(sn)]=[eβHμ+e−βHμ][eβHμ+e−βHμ]…[eβHμ+e−βHμ]=[eβHμ+e−βHμ]n=2ncoshn(βHμ)Alternatively we can calculate the value of the canonical partition function at a particular temperature for a small numbers of spins numerically using the first of the expressions in the cell. The cell below thus contains a function that calculates the partition function for a system of N spins exactly. The value of the partition function for a system of 10 spins as a function of temperature is then shown plotted on a graph.
We can calculate the ensemble average of the energy for a lattice gas module using the following formula:
⟨E⟩=1Z1∑s1=01∑s2=0…1∑sn=0H(s1,s2,…,sn)e−βH(s1,s2,…,sn)In addition, this ensemble average can be found by taking the partial derivative of the logarithm of the partition function with respect to inverse temperature:
⟨E⟩=−(∂lnZ∂β)When we do this for the analytical experssion that was derived in the previous markdown cell we find that:
⟨E⟩=−(∂lnZ∂β)=−∂∂β[nln2+nlncosh(βHμ)]=−1cosh(βHμ)∂∂βcosh(βHμ)=−−Hμsinh(βHμ)cosh(βHμ)=−Hμtanh(βHμ)The alternative is to calculate the ensemble average numerically using the first formula in this markdown cell. In the cell below there is a function that calculates the ensemble average of the energy of N spins exactly. The value of the ensemble average for a system of 10 spins as a function of temperature is then shown plotted on a graph.
We can also calculate the probability of the probability of occupying a state with a particular magnetism m using
P(M=m)=1Z1∑s1=01∑s2=0…1∑sn=0δ(M(s1,s2,…,sn),m)e−βH(s1,s2,…,sn)This is done below for two different temperatures and histograms are shown
The spin-spin correlation function is calculated using:
δ(r)=⟨(si−⟨si⟩)(si+r−⟨si⟩)⟩⟨(si−⟨si⟩)2where ⟨si⟩ is the ensemble average for the spin variables. This quantity can be used to give a sense of the strength of the interaction between pairs of spins that are separated by different numbers of spins.
The code in the cell below calculates the spin-spin correlation function for a set of 10 spins in a magentic field.
Here you should explain why we can only calculate the solutions to these problems numerically when the number of sites in the model is small.