If a system is open, the number of moles of the components changes, $n_i$. The functions $U, H, A, G$ become dependent on $(T,P,n_i)$, $G=G(T,P,n_1,n_2,n_3,.....,n_k)$

\begin{equation} dG=\left(\frac{\partial G}{\partial T}\right)_{p,n_j}dT + \left(\frac{\partial G}{\partial P}\right) {T,n_j}dP + \left(\frac{\partial G}{\partial n_1}\right)_{T,p,n_{j\neq n_1}}dn_1 + .......+ \left(\frac{\partial G}{\partial n_k}\right)_{p,n_{j \neq k}}dT \end{equation}

Whereas, $\left(\frac{\partial G} {\partial T}\right)_{P,n_i}=-S$ and $\left(\frac{\partial G}{\partial P}\right)_{T,n_i}=V$, the equation above can be written as: \begin{equation} dG=-SdT+VdP+\sum_{i=1}^{k}\left(\frac{\partial G}{\partial n_i}\right)_{T, P,n_{j \neq n_i}}dn_i \end{equation}


\begin{equation} \mu_i=\left(\frac{\partial G}{\partial n_i}\right)_{T,P, n_{j\neq i}} \end{equation}

that defines the chemical potential of component i.

Substituting into the expression for dG:

\begin{equation} dG=-SdT-VdP+\sum_{i=1}^{n}\mu_{i}dn_{i} \end{equation}


\begin{eqnarray} dU & = & TdS-PdV+\sum_{i=1}^{n}\mu_{i}dn_{i}\\ dH & = & TdS+VdP +\sum_{i=1}^{n}\ mu_{i}dn_{i}\\ dA & = & -SdT -PdV +\sum_{i=1}^{n}\mu_{i}dn_{i}\\ dG & = & -sdT + VdP + \sum_{i=1}^{n}\mu_{i}dn_{i} \end{eqnarray}