# Microscopic definition of heat in the grand canonical ensemble

For a general ensemble, we define the entropy $$S = k_B\left\langle -\ln p_i\right\rangle = -k_B \sum_i p_i \ln p_i$$ and the internal energy $$U = \left\langle \varepsilon_i \right\rangle = \sum_i p_i \varepsilon_i$$, where $$p_i$$ is the probability of state $$i$$ and $$\varepsilon_i$$ is the energy of state $$i$$.

We may split the differential of the internal energy and identify the different terms as heat and work (see the answers to this question, and a more thorough discussion in a previous question of mine): $$dU = d\big(\sum_i p_i \varepsilon_i\big) = \underbrace{\sum_i \varepsilon_i dp_i}_{\delta Q} + \underbrace{\sum_i p_i d\varepsilon_i}_{-\delta W}. \tag{1}\label{1}$$ Thus, we have the first law $$dU = \delta Q - \delta W$$, and microscopic definitions of work and heat.

In the canonical ensemble, we have $$p_i = \frac{1}{Z} e^{-\beta \varepsilon_i}$$ where $$Z = \sum_i e^{-\beta \varepsilon_i}$$. We may show using some manipulations that $$\delta Q = T\,dS$$.

Now, this doesn't work in the grand canonical ensemble. Here, $$p_i = \frac{1}{\mathcal{Z}} e^{-\beta(\varepsilon_i - \mu n_i)}$$ where $$n_i$$ is the number of particles in state $$i$$ and $$\mathcal{Z} = \sum_i e^{-\beta(\varepsilon_i - \mu n_i)}$$. I find \begin{align} \frac{dS}{k_B} &= -\sum_i dp_i \ln p_i - \sum_i p_i d\ln p_i \\ &= -\sum_i dp_i \ln p_i - \underbrace{\sum_i dp_i}_{d(\sum_i p_i) = d(1) = 0} \\ &= -\sum_i dp_i \ln p_i \\ &= \overbrace{\sum_i dp_i (\ln\mathcal{Z}}^0 + \beta \varepsilon_i - \beta\mu n_i) \\ &= \beta \sum_i \varepsilon_i dp_i - \beta\mu\sum_i n_i dp_i \\ &= \beta \delta Q - \beta\mu\sum_i n_i dp_i, \end{align} that is, $$T\,dS = \delta Q - \mu \sum_i n_i dp_i. \tag{2}\label{2}$$ Does this mean that $$\delta Q = T\,dS$$ does not hold in the grand canonical ensemble? Or does one usually modify the definitions of $$\delta Q$$ and $$\delta W$$ in \eqref{1}?

In fact the definition of $$\delta Q$$ is changed since the first law does not hold for open systems (flux of mass).
In a system that allows change of mass, first law assume the form $$dU = \delta Q - \delta W + \mu dN$$. So we have in the gran canonical ensemble:
$$\delta Q = \sum_{i} \varepsilon_i dp_i - \mu \sum_{i} n_i dp_i$$ $$\delta W = - \sum_i p_i d\varepsilon_i + \mu \sum_i p_i dn_i$$ $$dN = \sum_{i} p_i dn_i + \sum_{i} n_idp_i$$
• Thank you! However, I am confused about your quantity $\delta N$. It is not the same as $dN$, right, because $dN = \sum_i n_i dp_i + \sum_i p_i dn_i$? If I add together the expressions you give, it seems that I get $\delta Q - \delta W + \mu dN = dU + \mu \sum_i p_i dn_i$. Do I also need to modify the definition of work to $-\delta W = \sum_i p_i d\varepsilon_i - \mu \sum_i p_i dn_i$? Commented Feb 15, 2020 at 21:29