# Chemical Potential and Gibbs Energy

In my reading of thermodynamics, the chemical potential $$\mu$$ of a system is often defined as the Gibbs free energy per unit particle (or mole, for my chemist friends) of substance. Then, for a system composed of $$N$$ chemical species, we have $$G = \sum_{j = 1}^N\mu_j\cdot n_j$$, where $$n_j$$ is the number of particles of the $$j^{th}$$ species.

Now, regarding the $$n_j$$'s as the independent variables, the differential of $$G$$ is given by $$dG = \sum_{j = 1}^N \mu_j\cdot dn_j. \tag{1}$$

However, if we appeal to another definition of $$G$$, namely that $$G:= U + PV - TS$$, and recognize that the First Law for a multi-component system takes the form $$dU = dq - dw + \sum_{j = 1}^N \mu_j \cdot dn_j$$, we are at once led to the conclusion that

$$dG = VdP - SdT + \sum_{j = 1}^N \mu_j\cdot dn_j. \tag{2}$$

It $$seems$$ to be the case that (1) and (2) are at odds. How is it possible for both of the equations to simultaneously be true?

Starting from $$U=TS-pV+\sum \mu_j N_j$$ it is true that when you define the Gibbs potential as $$G=U-TS+pV$$ then $$G=\sum \mu_j N_j \tag{1}$$ and also $$dG = dU-TdS-SdT+pdV+Vdp=\sum \mu_j dN_j+\sum N_j d\mu_j\tag{2}$$ Apply the Gibbs-Duhem equation $$SdT-Vdp+\sum N_j d\mu_j=0$$ to Eq. (2), after rearrangement you get $$dG +SdT-Vdp=dU-TdS+pdV = \sum \mu_j dN_j\tag{3}$$ or $$dG =-SdT+Vdp+ \sum \mu_j dN_j\tag{4}$$ If and only if the process is isothermal, $$dT=0$$, and isobaric, $$dp=0$$, is also true that $$dG = \sum \mu_j dN_j\tag{5}$$
This is actually a really great question, and the answer is not at all obvious. First of all, the first equation $$G = \sum_j \mu_j n_j$$ before (1) is correct, and equation (2) is correct. Equation (1) is only valid for isothermal and isobaric processes (for which $$G$$ tells you spontaneity). The underlying reason that both of these equations are consistent is because the fundamental thermodynamic relation $$dG = -SdT + VdP + \sum_k \mu_k dn_k$$ tells us that the Gibbs free energy is a function of the temperature, the pressure, and the various numbers of moles of each particle type. Of these, only the number of moles of particles are actually extensive variables. Via some not terrible, but non-trivial, arguments it is possible to show that the extensive thermodynamic state functions (such as the Gibbs free energy) are 1st order homogeneous functions of their extensive variables, meaning that they obey the relation, $$f(\lambda \{x_E \}, \{ x_I \}) = \lambda f(\{x_E \}, \{ x_I \})$$ where $$\lambda$$ is a scaling constant and the subscripts $$E$$ and $$I$$ refer to the sets of extensive and intensive variables, respectively. Then, as a consequence of Euler's homogeneous function theorem, this means that we can rewrite the extensive function as, $$f (\{x_E \}, \{ x_I \}) = \sum_j^{N_E} x_j \frac{\partial f}{\partial x_j}$$ where $$N_E$$ is the number of extensive variables and $$j$$ only runs over extensive variables. This can be proven with just a bit of annoying calculus. By applying this to the Gibbs free energy, we obtain, $$G = \sum_j \mu_j n_j$$ which was the equation giving you trouble. Note that you can do this with all of the other thermodynamic potentials as well to obtain the somewhat surprising relationships for the enthalpy $$H$$ and the Helmholtz free energy $$F$$, $$H = TS + \sum_j n_j \mu_j$$ $$F = -PV + \sum_j n_j \mu_j$$