# Why would there be a non-zero Gibbs energy of mixing for ideal gases?

When two ideal gases $$\ce{A}$$ and $$\ce{B}$$ mix, they don't interact. The chemical potential of each gas is independent of the other, e.g. for $$\ce{A}$$:

$$\mu_\ce{A} = \mu_\ce{A}^\circ + R T \ln \frac{p_\ce{A}}{p^\circ}\label{eqn:q1}\tag{1}$$

So if the two gases are independent, why is there a Gibbs energy of mixing? Shouldn't there be a requirement for an interaction energy in order to see a difference in Gibbs energy before and after mixing?

However, we know that the Gibbs energy of mixing of two ideal gases is non-zero, as it is given as:

$$\Delta_\mathrm{mix}G = n R T (x_\ce{A} \ln x_\ce{A} + x_\ce{B} \ln x_\ce{B}) \label{eqn:q2}\tag{2}$$

where $$x$$ is the molar ratio. In a related question about a problem set involving Gibbs energy of mixing, an answer uses \eqref{eqn:q2} in the first part and \eqref{eqn:q1} in the second.

In other words, how are \eqref{eqn:q1} and \eqref{eqn:q2} related to each other? Another way of asking is: if the Gibbs energy of mixing is non-zero even for ideal gases, how could you turn the process of mixing into a reversible process and show the maximal work that is done?

• When you joint the same containers with 2 gases, at the same T and p, than partial p of both gases decreases to 1/2 of their initial p, therefore their chem. potential decreases as well. Commented May 15, 2023 at 15:27
• For a more physical interpretation, enthalpy indeed cannot account for the change in free energy in the mixing of ideal gasses, so it must be due to entropy. Mixing is always entropically favourable - there are necessarily more mixed microstates than separate microstates - so we should expect some non-zero Gibbs free energy change. Commented May 15, 2023 at 16:00
• If you devise a process to separate the two components into separate containers each at the same pressure as the total pressure of the mixture, such a process will require you to do work on the gases. Commented May 16, 2023 at 22:08

When we talk about mixing, we usually mean that two components are in different parts of a container before mixing and then they share the entire container after mixing. In other words, the total volume does not change.

To show how you can make mixing reversible while capturing the Gibbs energy of mixing as work, you need two pistons with semi-permeable membranes. In the animation below, the green piston does not let the "green" gas particles pass, and the red piston does not let the "red" gas particles pass.

So even though the two different particles don't interact with each other, mixing them can be used to do work, as both expand from half the volume to the full volume of the container (and the partial pressures decrease, as mentioned by Poutnik in the comment to the question).

Thus, there is an outward force on the pistons. If you provide an equal opposing force (or infinitesimally smaller force) on the pistons from outside, you can use the mixing of the gases to do work. Conversely, if you use just the right amount of inward force, you can "unmix" the two gasses by pushing the pistons inward (similar to water purification by reverse osmosis, which uses a single semi-permeable membrane).

To show that the way we understand mixing matters, here is a related contraption that keeps the partial pressure of the mixed gases constant (while changing the total pressure - not clear how this is defined in this case?). If this is surrounded by vacuum, the Gibbs energy change during this process is zero, somewhat surprisingly.

### From (1) to (2)

So how do we get from equation (1) describing the chemical potential of each component to equation (2) describing the entropy of mixing. In principle, we could start with pure $$\ce{A}$$ and add $$\ce{B}$$, integrating over the two chemical potentials. This would be pretty complicated. Instead, we can place our mixture into a syringe in a surrounding that has the same pressure, and slowly push out the mixture until nothing is left. Or we can start with an empty syringe, and push in the two components at the correct mixing ratio from reservoirs at the same pressure. In either case, the chemical potential would stay constant over the entire process, and the integrals are just the change in amount times the chemical potential in the mixture.

Because this is done at constant temperature and constant pressure, the terms $$V\,\mathrm{d}p$$ and $$S\,\mathrm{d}T$$ are zero, and we only have to consider the change in amount and the chemical potentials.

For the mixture, assuming the total pressure is $$p$$, we get:

\begin{align} G &= n_\ce{A} \left(\mu_\ce{A}^\circ + R T \ln \frac{p_\ce{A}}{p^\circ}\right) + n_\ce{B} \left(\mu_\ce{B}^\circ + R T \ln \frac{p_\ce{B}}{p^\circ}\right) + C \\ &= n_\ce{A} \left(\mu_\ce{A}^\circ + R T \ln \frac{x_\ce{A}p}{p^\circ}\right) + n_\ce{B} \left(\mu_\ce{B}^\circ + R T \ln \frac{x_\ce{B}p}{p^\circ}\right) + C \tag{3} \end{align}

where we've expresssed the partial pressure of each component $$p_\ce{A}$$ as the mole fraction $$x_\ce{A}$$ times the total pressure $$p$$. This is true for an ideal gas.

For the state before mixing (with the same reference point for zero), both sections of the mixture have the same pressure $$p$$, and we get:

$$G = n_\ce{A} \left(\mu_\ce{A}^\circ + R T \ln \frac{p}{p^\circ}\right) + n_\ce{B} \left(\mu_\ce{B}^\circ + R T \ln \frac{p}{p^\circ}\right) + C \tag{4}$$

To get the Gibbs energy of mixing, we have to subtract $$(4)$$ from $$(3)$$:

$$\Delta G_\mathrm{mix} = n_\ce{A} R T \ln x_\ce{A} + n_\ce{B} R T \ln x_\ce{B}$$

Factoring $$n R T$$ with $$n = n_\ce{A} + n_\ce{B}$$, the total amount of particles, we get:

$$\Delta G_\mathrm{mix} = n R T \left(\frac{n_\ce{A}}{n}\ln x_\ce{A} + \frac{n_\ce{A}}{n} \ln x_\ce{B} \right)$$

The ratios of amounts can also be written more succinctly as mole fractions $$x$$:

$$\Delta G_\mathrm{mix} = n R T (x_\ce{A} \ln x_\ce{A} + x_\ce{B} \ln x_\ce{B})$$

to arrive at expression (2).

• Really nice animation. Found or created? Commented May 15, 2023 at 16:13
• @Poutnik Powerpoint has a new morph slide transition where all objects that change positions are moved along a linear path during the transition. This makes some types of animations really easy to create (and then you turn them into an animated GIF with free or expensive software).
– Karsten
Commented May 15, 2023 at 16:15
• @Karsten Very nice. A couple of comments: your second- and third-last equations are the same. I guess the point is that $p_\ce{A}$ and $p_\ce{B}$ before and after are not the same. Also, I think it'd be great to show that 'bit of reformatting', i.e. explicitly expressing the change in partial pressures in terms of the mole fractions. I'll offer to do the edits if you like, or leave it to you. Commented May 15, 2023 at 23:17
• @orthocresol I changed it to standard pressure to make it easier, fixed the second expression, and added the missing bit. Good to hear from you, by the way, doc!
– Karsten
Commented May 16, 2023 at 2:13
• @Karsten No, it was good to see this Q&A. :) I still felt the maths was a bit inaccurate, or to be precise, I think it was making an implicit assumption that the container pressure $p$ was equal to standard pressure $p^\circ$. That assumption isn't needed to arrive at the right result, so I made some changes to generalise it a bit. I hope I didn't take too many liberties with your answer, but if you feel I did, you know what to do! Commented May 16, 2023 at 15:48

With your reply you seem to have answered part of your question. I would like to add a bit about the other part. I will have to do it mathematically first, there is no other shortcut, but then we will come back and try to connect the idea. I will be precise on where the thermodynamic properties are evaluated, using parenthesis everywhere.

[OP] In other words, how are (1) and (2) related to each other?

The connection between Eqs. (1) and (2) was established by Gibbs himself, it is named Gibbs theorem. Simply put, he was trying to connect the properties of the pure species (as ideal gases) to the properties of the mixture (still an ideal gas). One possible formulation is the following:

A partial molar property of a species in an ideal-gas mixture is equal to its molar property as a pure substance, evaluated at the temperature of the mixture but at its partial presure in the mixture. The exception of this is the partial molar volume.

In mathematical form, for a generic thermodynamic property of species $$j$$ named $$M_j$$, we have $$\bar{M}_j^\pu{ig}(p,T) = M_j^\pu{ig}(p_j,T) \tag{1}$$ Eq. (1) is almost all that we need to obtain the Eq. (2) of your post. The other one is the summability relation that connects a thermodynamic property $$M$$ (of the whole mixture) to the partial molar property of all the species in the mixture $$M(p,T,y_1, y_2,..., y_N) = \sum_k y_k \bar{M}_k(p,T,y_1, y_2,..., y_N) \tag{2}$$ Eq. (2) is general and is not restricted by the behaviour imposed over the mixture. The derivation of this equation is not that important here.

We will calculate the partial molar enthalpy, partial molar entropy, and then obtain the partial molar Gibbs energy by its definition.

1. The enthalpy is easy, because for an ideal gas the enthalpy is independent of the pressure, and by Gibbs theorem we have $$\bar{H}_j^\pu{ig}(p,T) = H_j^\pu{ig}(p_j,T) = H_j^\pu{ig}(p,T) \tag{3}$$
2. Applying Gibbs theorem to the entropy yields $$\bar{S}_j^\pu{ig}(p,T) = S_j^\pu{ig}(p_j,T) \tag{4}$$ We would like to have evaluated the right-hand side at $$p$$ rather than $$p_j$$. This can be done by remembering the entropy of an ideal gas as a function of pressure and temperature, and evaluating the change for an isothermal process at temperature $$T$$ \begin{align} \require{cancel} dS_j^\pu{ig} &= \frac{c_\pu{P}^\pu{ig}}{T} \; dT - \frac{R}{p} \; dp \\ dS_j^\pu{ig} &= -\frac{R}{p} \; dp \\ \int_{S_j^\pu{ig}(p_j,T)}^{S_j^\pu{ig}(p,T)} dS_j^\pu{ig} &= -R\int_{p_j}^{p} \frac{dp}{p} \\ S_j^\pu{ig}(p,T) - S_j^\pu{ig}(p_j,T) &= -R\ln\left(\frac{p}{p_j}\right) \\ S_j^\pu{ig}(p_j,T) &= S_j^\pu{ig}(p,T) + R\ln\left(\frac{p}{p_j}\right) \\ S_j^\pu{ig}(p_j,T) &= S_j^\pu{ig}(p,T) + R\ln\left(\frac{\cancel{p}}{y_j \cancel{p}}\right) \\ S_j^\pu{ig}(p_j,T) &= S_j^\pu{ig}(p,T) - R\ln(y_j) \tag{5} \end{align} In the last line I just related the partial pressure to the pressure of the mixture. Combining Eqs. (4) and (5) $$\bar{S}_j^\pu{ig}(p,T) = S_j^\pu{ig}(p,T) - R\ln(y_j) \tag{6}$$

We can obtain the partial molar Gibbs energy just by definition, multiplying both sides by the total number of moles $$n$$, and then differentiating both sides at constant $$p$$, $$T$$, and all moles except the species $$j$$ \begin{align} G &= H - TS \\ nG &= nH - TnS \\ \left[\frac{\partial (nG)}{\partial n_j}\right]_{p,T,n_k\neq j} &= \left[\frac{\partial (nH - TnS)}{\partial n_j}\right]_{p,T,n_k\neq j} \\ \bar{G}_j &= \left[\frac{\partial (nH)}{\partial n_j}\right]_{p,T,n_k\neq j} -T\left[\frac{\partial (nS)}{\partial n_j}\right]_{p,T,n_k\neq j} \\ \bar{G}_j &= \bar{H}_j - T\bar{S}_j \tag{7} \end{align}

This equation is general, not resctricted to an ideal-gas behaviour. Now we can combine Eqs. (3), (6), and (7) to obtain the partial molar Gibbs energy (note that between lines one and two we use Gibbs theorem over the enthalpy and entropy) \begin{align} \bar{G}_j^\pu{ig}(p,T) &= \bar{H}_j^\pu{ig}(p,T) - T\bar{S}_j^\pu{ig}(p,T) \\ \bar{G}_j^\pu{ig}(p,T) &= H_j^\pu{ig}(p_j,T) - TS_j^\pu{ig}(p_j,T) \\ \bar{G}_j^\pu{ig}(p,T) &= H_j^\pu{ig}(p,T) - T[S_j^\pu{ig}(p,T) - R\ln(y_j)] \\ \bar{G}_j^\pu{ig}(p,T) &= [H_j^\pu{ig}(p,T) - TS_j^\pu{ig}(p,T)] + RT\ln(y_j) \\ \bar{G}_j^\pu{ig}(p,T) &= G_j^\pu{ig}(p,T) + RT\ln(y_j) \tag{8}\\ \end{align} Finally we combine the summability relation Eq.(2) with Eq. (8), since we are summing, now we convert the subscript $$j$$ to $$k$$ \begin{align} G^\pu{ig}(p,T, y_1, y_2, ..., y_N) &= \sum_k y_k [G_k^\pu{ig}(p,T) + RT\ln(y_k)] \\ G^\pu{ig}(p,T,y_1, y_2, ..., y_N) &= \sum_k y_k G_k^\pu{ig}(p,T) + RT\sum_k y_k\ln(y_k) \\ G^\pu{ig}(p,T, y_1, y_2, ..., y_N) - \sum_k y_k G_k^\pu{ig}(p,T) &= RT\sum_k y_k \ln(y_k) \end{align} the left side, by definition is the Gibbs free energy of mixing. We are subtracting the value of the Gibbs energy of the mixture and the mole-fraction-weighted Gibbs energy of all the species involved. Finally

$$\boxed{\Delta_\pu{mix}G = RT\sum_k y_k \ln(y_k) <0} \tag{9}$$

[OP] So if the two gases are independent, why is there a Gibbs energy of mixing? Shouldn't there be a requirement for an interaction energy in order to see a difference in Gibbs energy before and after mixing?

Even in the absence of intermolecular forces between the species, there is a change in the Gibbs energy when we mix them. IMHO (I cannot prove this), this was what Gibbs foresaw before doing all this:

1. He knew that for an ideal gas the enthalpy will not be modified. Thus, for a mixing at constant $$p$$ and $$T$$, there will not be heat exchanged with the surroundings.
2. He knew that the mixing could not violate the second law.

Therefore, he visioned $$N$$ non-interacting particles separated at $$p$$ and $$T$$, and then they got mixed at $$p_k$$ and $$T$$. This decrease in pressure is the effect wanted by Gibbs, because it inevitably increases the entropy. As a consequence, it inevitably decreases the Gibbs free energy (his energy), and mixing of ideal gases is always a spontaneous process. Likewise, unmixing is also always a non-spontaneous process. This is really near to what Poutnik said in the comments when he made a difference between both pressures:

[Poutnik] When you joint the same containers with 2 gases, at the same T and p, than partial p of both gases decreases to 1/2 of their initial p, therefore their chem. potential decreases as well.

[OP] How could you turn the process of mixing into a reversible process and show the maximal work that is done?

You visualized this in the images in your post. The calculation of the maximum work is automatic. The maximum work that can be done by the system to the surroundings at the same temperature $$T$$ as the system is

$$\boxed{W^\pu{ideal} = \Delta_\pu{mix} G^\pu{ig} < 0} \tag{11}$$

so mixing of ideal gases can be used to obtain work from the outside.

Final Comment When I said that there was a connection between Eqs. (1) and (2), it is implicit in here, but we can show it more clearly. For a constant temperature process and a pure substance we have \begin{align} dG_j^\pu{ig} &= V_j^\pu{ig}dp - S_j^\pu{ig}dT \\ dG_j^\pu{ig} &= V_j^\pu{ig}dp \\ dG_j^\pu{ig} &= \frac{RT}{p} dp \\ \int dG_j^\pu{ig} &= RT \int \frac{dp}{p} \\ G_j^\pu{ig}(p,T) &= G_{j,0}^\pu{ig} + RT\ln(p) \\ \end{align} The jump to your Eq. (1), is by Gibbs theorem in order to change $$p$$ for $$y_jp$$ \begin{align} \bar{G}_j^\pu{ig}(p,T) &= \mu_{j,0}^\pu{ig} + RT\ln(y_jp) \\ \mu_j^\pu{ig}(p,T) &= \mu_{j,0}^\pu{ig} + RT\ln(y_jp) \\ \end{align} If not, there is no way we can write your equation (with $$p_\mathrm{A}$$ in your case), and arrive at an expression for the partial molar Gibbs energy, also known as the chemical potential.