### 2.5 Calculation of the grand canonical ensemble

Maximize

 \begin{equation*} S' = -k \sum_i p_i \ln(p_i) \end{equation*} (2.25)

with the restrictions

 \begin{equation*} 0 = \sum_i p_i U_i -U \quad \mbox{, and} \quad 0 = \sum_i p_i - 1 \quad \mbox{, and} \quad 0 = \sum_i p_i N_i - N \quad . \end{equation*} (2.26)

Introducing the Lagrange parameters $$\alpha$$, $$\beta$$, and $$\gamma$$ the variation of the function

 \begin{equation*} \delta \left[ S' - k \alpha \left( \sum_i p_i -1 \right) - k \beta \left( \sum_i p_i U_i - U \right) - k \gamma \left( \sum_i p_i N_i - N \right) \right] = 0 \end{equation*} (2.27)

without restrictions leads to

 \begin{equation*} - \ln(p_i) - 1 - \alpha - \beta U_i - \gamma N_i = 0 \qquad . \end{equation*} (2.28)

Defining again

 \begin{equation*} \frac{1}{Z} = \exp(- 1 - \alpha) \end{equation*} (2.29)

we find

 \begin{equation*} p_i = \frac{1}{Z} \exp(-\beta U_i - \gamma N_i) \quad \mbox{and} \quad Z(\beta, V, \gamma) = \sum_i \exp(-\beta U_i - \gamma N_i) \quad . \end{equation*} (2.30)

We get

 \begin{equation*} U = \sum_i p_i U_i = \frac{\sum_i \exp(-\beta U_i - \gamma N_i) U_i}{\sum_i \exp(-\beta U_i - \gamma N_i)} = - \left( \frac{\partial \ln(Z)}{\partial \beta} \right):= U(\beta, V , \gamma) \end{equation*} (2.31)

and

 \begin{equation*} N = \sum_i p_i N_i = \frac{\sum_i \exp(-\beta U_i - \gamma N_i) N_i}{\sum_i \exp(-\beta U_i - \gamma N_i)} = - \left( \frac{\partial \ln(Z)}{\partial \gamma} \right):= N(\beta, V , \gamma) \end{equation*} (2.32)

i.e.

 \begin{equation*} S = k \ln(Z) + \beta k U + \gamma k N \qquad . \end{equation*} (2.33)

The total derivative is:

 \begin{equation*} \begin{split} \frac{dS}{k} & = \left( \frac{\partial \ln(Z)}{\partial \beta} \right) d\beta + \left( \frac{\partial \ln(Z)}{\partial \gamma} \right) d\gamma + \left( \frac{\partial \ln(Z)}{\partial V} \right) dV + U d\beta + \beta dU + N d\gamma + \gamma dN\\ & = \left( \frac{\partial \ln(Z)}{\partial V} \right) dV + \beta dU + \gamma dN \end{split} \end{equation*} (2.34)
So
 \begin{equation*} S=S(V,N,U) \end{equation*} (2.35)

and $$S$$ is the Legendre transformed of $$k \ln(Z)$$.
Let

 \begin{equation*} \left( \frac{\partial S}{\partial U}\right) := \frac{1}{T} \quad \mbox{and} \quad \left( \frac{\partial S}{\partial N}\right) := - \frac{\mu}{T} \quad . \end{equation*} (2.36)

So

 \begin{equation*} \beta = \frac{1}{kT} \quad \mbox{, and} \quad \gamma = -\frac{\mu}{kT} \quad . \end{equation*} (2.37)

Following again the procedure for the calculation of the free energy we find

 \begin{equation*} \Omega = U - \mu N- T S \end{equation*} (2.38)

and

 \begin{equation*} \Omega(T,V,\mu) = -k T \ln(Z(T, V, \mu)) \qquad . \end{equation*} (2.39)

© J. Carstensen (Stat. Meth.)