# What is the entropy of mixing of two ideal gases starting out with different pressures?

The entropy of mixing of ideal gas is given by this equation:

$\Delta S_{mix} = -nR(x_1\ln x_1 + x_2\ln x_2)$

1. Does this equation works only when the initial conditions of both compartments are at the same pressure?

2. If ideal gas 1 at initial conditions $n_1,P_1,V_1,T$ and ideal gas 2 at $n_2,P_2,V_2,T$ are mixed, which equation should I use to obtain $\Delta S_{mix}$ given that $P_1 ≠P_2$? Assume $V_1 + V_2 = V_{tot}$, and $T_1 = T_2 = T$. • To 1.: No you can't use this equation. Pressure has an effect on the entropy. To 2.: Have you tried anything to solve this yourself? Do you have an idea how to go about it? – Philipp Oct 20 '14 at 10:37
• @Philipp I tried dS = -RdP/P and integrate from P1 to Pavg and P2 to Pavg and summing the entropy change. – t.c Oct 20 '14 at 15:12

A strategy that often works is to look at the initial and the final states and then compare them. A good place to start is usually the Gibbs free energy of the system (with the intention to use $\Delta_{\mathrm{mix}} S = - \frac{\partial \Delta_{\mathrm{mix}}G}{\partial T} \big|_{p, \{ n_{i} \}}$ later): for isothermal and isobaric conditions it is

\begin{equation} G = \sum_{i} n_{i} \mu_{i} + \mathrm{constant} = n_{\mathrm{tot}} \sum_{i} \underbrace{x_{i}}_{= \, \frac{n_{i}}{n_{\mathrm{tot}}}} \mu_{i} + \mathrm{constant} \hspace{4em} (1) \end{equation}

with $n_{i}$, $\mu_{i}$, and $x_{i} = \frac{n_{i}}{n_{\mathrm{tot}}}$ being the amount, the chemical potential, and the mole fraction of the $i$th component in the system, respectively, and $n_{\mathrm{tot}} = \sum_{i} n_{i}$ being the total amount of gas in the system. So, now we need an expression for the chemical potential of an ideal gas. It can be shown that this is given by

\begin{equation} \mu_{i} = \mu_{i}^{0} + R T \ln\biggl(\frac{p_{i}}{P^{0}}\biggr) \hspace{18em} (2) \end{equation}

where $\mu_{i}^{0}$ is the chemical potential of the $i$th component in a given standard state, $R$ is the universal gas constant, $T$ is the temperatur, $p_{i}$ is the partial pressure of the $i$th component, and $P^{0}$ is the standard pressure (i.e. the pressure connected to the standard state). For ideal gases we can apply Raoult's law stating that

\begin{equation} p_{i} = x_{i} P_{\mathrm{tot}} \end{equation}

where $P_{\mathrm{tot}}$ is the total pressure of the system. Using this with equation (2) we get

\begin{equation} \mu_{i} = \mu_{i}^{0} + R T \ln\biggl(\frac{x_{i} P_{\mathrm{tot}}}{P^{0}}\biggr) = \mu_{i}^{0} + R T \ln x_{i} + R T \ln\biggl(\frac{P_{\mathrm{tot}}}{P^{0}}\biggr) \hspace{6em} (3) \end{equation}

Furthermore, it is known that the partial pressures in a system must add up to the total pressure, i.e.

\begin{equation} P_{\mathrm{tot}} = \sum_{i} p_{i} \end{equation}

Ok, now that the stage is set we simply have to apply equations (1) and (3) to the initial and the final state of the mixing process. At the initial state the chambers are seperated (whereby chamber $i$ contains only one sort of gas labeled by $i$) and so these subsystems are completely independent from each other. Thus, the Gibbs free energy of the total system of chambers is simply the sum of the Gibbs free energies of each chamber, whereby the gas in each of the chambers feels the pressure $P_{\mathrm{tot}} = P_{i}$ in the system (whereby $P_{i}$ is the ambient pressure in chamber $i$), since $x_{i} = 1$ (each chamber/independent subsystem holds just one kind of gas). According to equation (1) the Gibbs free energy of the $i$th chamber is then given by

\begin{align} G_{i} &= n_{i} \mu_{i} = n_{i} \biggl( \mu_{i}^{0} + R T \underbrace{\ln 1}_{= \, 0} + R T \ln\biggl(\frac{P_{i}}{P^{0}}\biggr) \biggr) \\ &= n_{i} \biggl( \mu_{i}^{0} + R T \ln\biggl(\frac{P_{i}}{P^{0}}\biggr) \biggr) \end{align}

and the Gibbs free energy of the total system at the initial state is

\begin{align} G_{\mathrm{ini}} &= \sum_{i} G_{i} \\ &= \sum_{i} \underbrace{n_{i}}_{= \, x_{i} n_{\mathrm{tot}}} \biggl( \mu_{i}^{0} + R T \ln\biggl(\frac{P_{\mathrm{tot}}}{P^{0}}\biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( \underbrace{\sum_{i} x_{i} \mu_{i}^{0}}_{= \, G_{\mathrm{ini}}^{0}} + \sum_{i} x_{i} R T \ln\biggl(\frac{P_{i}}{P^{0}}\biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + \sum_{i} x_{i} R T \ln\biggl(\frac{P_{i}}{P^{0}}\biggr) \biggr) \ . \hspace{7em} (4) \end{align}

For a multicomponent system with more than two components I would simply use this equation. But for a system with exactly two components we can introduce some substitutions that will simplify the final equations a little. For that purpose we want to establish a relationship between the initial pressures $P_{1}$ and $P_{2}$ and the final pressure $P_{\mathrm{fin}}$. In order to get there we use the ideal gas law and the additivity relations for the volumes and amounts: From

\begin{equation} n_{\mathrm{tot}} = n_{1} + n_{2} \ , \qquad V_{\mathrm{tot}} = V_{1} + V_{2} \\ P_{1} V_{1} = n_{1} R T \ , \qquad P_{2} V_{2} = n_{2} R T \ , \qquad P_{\mathrm{fin}} V_{\mathrm{tot}} = n_{\mathrm{tot}} R T \end{equation}

it follows that

\begin{align} P_{1} V_{1} + P_{2} V_{2} = P_{\mathrm{fin}} V_{\mathrm{tot}} \ . \end{align}

Now, we can express $P_{2}$ in terms of $P_{\mathrm{fin}}$ by introducing the deviation factor $\alpha$ which is defined by $P_{2} = (1 - \alpha) P_{\mathrm{fin}}$ and use this in the previous equation

\begin{align} P_{1} V_{1} + P_{2} V_{2} &= P_{\mathrm{fin}} V_{\mathrm{tot}} \\ P_{1} V_{1} + (1 - \alpha) P_{\mathrm{fin}} V_{2} &= P_{\mathrm{fin}} V_{\mathrm{tot}} \\ P_{1} V_{1} &= P_{\mathrm{fin}} \bigl( \underbrace{V_{\mathrm{tot}} - V_{2}}_{= \, V_{1}} + \alpha V_{2} \bigr) \\ P_{1} &= \biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) P_{\mathrm{fin}} \end{align}

which gives us the relation between $P_{1}$ and $P_{\mathrm{fin}}$. Introducing these equations into equation (4) yields

\begin{align} G_{\mathrm{ini}} &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + x_{1} R T \ln\biggl(\frac{P_{1}}{P^{0}}\biggr) + x_{2} R T \ln\biggl(\frac{P_{2}}{P^{0}}\biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + x_{1} R T \ln\frac{\bigl( 1 + \alpha \frac{V_{2}}{V_{1}} \bigr) P_{\mathrm{fin}}}{P^{0}} + x_{2} R T \ln\frac{(1 - \alpha) P_{\mathrm{fin}}}{P^{0}} \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + x_{1} R T \ln\biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) + x_{2} R T \ln(1 - \alpha) + \underbrace{(x_{1} + x_{2})}_{= \, 1} R T \ln\biggl( \frac{P_{\mathrm{fin}}}{P^{0}} \biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + x_{1} R T \ln\biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) + x_{2} R T \ln(1 - \alpha) + R T \ln\biggl( \frac{P_{\mathrm{fin}}}{P^{0}} \biggr) \biggr) \ . \end{align}

At the final state the chambers are connected and the gases mix, so the chambers are not independent subsystems anymore and the Gibbs free energy cannot be broken down into independent parts like before. Also, the ambient pressure in the system changes to $P_{\mathrm{tot}} = P_{\mathrm{fin}}$. Now, the complete system of connected chambers must be treated via equation (1)

\begin{align} G_{\mathrm{final}} &= \sum_{i} \underbrace{n_{i}}_{= \, x_{i} n_{\mathrm{tot}}} \biggl( \mu_{i}^{0} + R T \ln x_{i} + R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( \sum_{i} x_{i} \mu_{i}^{0} + \sum_{i} R T x_{i} \ln x_{i} + \sum_{i} x_{i} \underbrace{R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr)}_{= \, \mathrm{constant}} \biggr) \\ &= n_{\mathrm{tot}} \biggl( \underbrace{\sum_{i} x_{i} \mu_{i}^{0}}_{= \, G_{\mathrm{ini}}^{0}} + R T \sum_{i} x_{i} \ln x_{i} + R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr) \underbrace{\sum_{i} x_{i}}_{= \, 1} \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + R T \sum_{i} x_{i} \ln x_{i} + R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr) \biggr) \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + R T \left( x_{1} \ln x_{1} + x_{2} \ln x_{2} \right) + R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr) \biggr) \ . \end{align}

Now, that we have the Gibbs free energies of the initial and final state we simply need to subtract the former from the latter one in order to obtain the change in Gibbs free energy during the mixing process:

\begin{align} \Delta_{\mathrm{mix}}G &= G_{\mathrm{final}} - G_{\mathrm{ini}} \\ &= n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + R T \left( x_{1} \ln x_{1} + x_{2} \ln x_{2} \right) + R T \ln\biggl(\frac{P_{\mathrm{fin}}}{P^{0}}\biggr) \biggr) \\ &\quad - n_{\mathrm{tot}} \biggl( G_{\mathrm{ini}}^{0} + x_{1} R T \ln\biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) + x_{2} R T \ln(1 - \alpha) + R T \ln\biggl( \frac{P_{\mathrm{fin}}}{P^{0}} \biggr) \biggr) \\ &= n_{\mathrm{tot}} R T \left( x_{1} \ln x_{1} + x_{2} \ln x_{2} \right) - n_{\mathrm{tot}} R T \biggl( x_{1} \ln\biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) + x_{2} \ln(1 - \alpha) \biggr) \qquad (5) \end{align}

Now you see why we went through those substitutions for $P_{1}$ and $P_{2}$. This way the $n_{\mathrm{tot}} R T \ln\Bigl(\frac{P_{\mathrm{fin}}}{P^{0}}\Bigr)$ terms cancelled in equation (5).

Differentiating equation (5) with respect to the temperature we get the entropy of mixing since $\frac{\partial G}{\partial T} \big|_{p, \{ n_{i} \}} = - S$

\begin{align} \Delta_{\mathrm{mix}} S &= - \frac{\partial \Delta_{\mathrm{mix}}G}{\partial T} \bigg|_{p, \{ n_{i} \}} \\ &= - n_{\mathrm{tot}} R \left( x_{1} \ln x_{1} + x_{2} \ln x_{2} \right) + n_{\mathrm{tot}} R \biggl( x_{1} \ln\biggl( 1 + \alpha \frac{V_{2}}{V_{1}} \biggr) + x_{2} \ln(1 - \alpha) \biggr) \end{align}

The first term $- n_{\mathrm{tot}} R \left( x_{1} \ln x_{1} + x_{2} \ln x_{2} \right)$ is just the usual entropy of mixing. The second term $n_{\mathrm{tot}} R \Bigl( x_{1} \ln\Bigl( 1 + \alpha \frac{V_{2}}{V_{1}} \Bigr) + x_{2} \ln(1 - \alpha) \Bigr)$ describes the contribution of the pressure equilibration to the entropy.

• Thank you for your answer. Is it possible to use $\Delta{S} = -n_1R\ln\frac{P_{fin}}{P_1} -n_2R\ln\frac{P_{fin}}{P_2}$ and summing this entropy change and that of the one of mixing? – t.c Oct 20 '14 at 17:28
• @t.c Where does this equation for $\Delta S$ come from. – Philipp Oct 20 '14 at 17:41
• I used the ideal gas entropy change equation $\Delta{S} = C_p\ln\frac{T_2}{T_1} - R\ln\frac{P_2}{P_1} = - R\ln\frac{P_2}{P_1}$(at const T). Then I substitute in the initial pressures and the final pressure $P_{fin}$ – t.c Oct 20 '14 at 18:09
• @t.c I don't think you can use this formula for a mixing process. It doesn't account for the mixing contribution. – Philipp Oct 20 '14 at 18:20
• @Philipp You can use the formula the OP provided. It can be found in most pchem textbooks. There's no need to account for the mixing per se. That's because, at any given T, the chemical potential of an ideal gas is determined only by its own partial pressure, which is independent of the presence of any other gas(es). For example, if you take two ideal gases, each in separate 2 L containers, and mix them together (at constant T) into a single 2 L container, their partial pressures are unchanged, and thus $\Delta S = 0$ for this process. – theorist Feb 23 at 6:41

I would like to give an alternative derivation for theorist's answer. You can get the same answer with statistical mechanics using a lattice model.

Let us discretize the container into $$M_1$$ respective $$M_2$$ cells. The volume of a cell is $$V_{cell}$$. Each gas particle fits exactly into one cell and can hop from cell to cell in a discrete manner. Since we are dealing with an ideal gas, the particles ignore each other. In other words, all particles can in principle occupy the same cell, i.e. all particles can always choose from all the cells. We therefore get the following number of possible states $$\Omega$$: $$\Omega_1 = (M_1)^{N_1} \\ \Omega_2 = (M_2)^{N_2} \\ \Omega_{mix} = (M_1+M_2)^{(N_1+N_2)}$$

where $$N_i$$ is the respective number of particles. If the states are degenerated, i.e. have the same energy, we can use Boltzmann's entropy formula: $$S = k_B\ln(\Omega)$$ $$\implies\Delta S=k_B\ln(\Omega_{mix})-k_B\ln(\Omega_1)-k_B\ln(\Omega_2)$$

When we plug in all $$\Omega_i$$ and summarize with logarithmic identities, we obtain: $$\Delta S=N_1k_B\ln\left( \frac{M_1+M_2}{M_1}\right)+N_2k_B\ln\left(\frac{M_1+M_2}{M_2}\right)$$

Finally, when we plug in $$M_i = V_i/V_{cell}$$ and $$N_ik_B=n_iR$$, we obtain theorist's solution: $$\Delta S = n_1R\ln\left( \frac{V_1+V_2}{V_1}\right)+n_2R\ln\left(\frac{V_1+V_2}{V_2}\right)$$ Bonus: If we consider the constant pressure case for an ideal gas by plugging in $$V_i=n_i\cdot RT/p$$: $$\Delta S = n_1R\ln\left( \frac{n_1+n_2}{n_1}\right)+n_2R\ln\left(\frac{n_1+n_2}{n_2}\right)$$

This expression can be reformed to OP's formula by applying logarithmic identities and $$x_i=n_i/n_{tot}$$: $$\Delta S = -n_{tot}R(x_1\ln x_1 + x_2\ln x_2)$$

• I think there's a problem with your derivation. When I subsititue your expressions for $\Omega_1$, $\Omega_2$, and $\Omega_{mix}$ into your expression for $\Delta S$, I don't get my solution; instead, I get $R \log \left((V_1+V_2)^{n_1+n_2}\right)-R \log \left(V_1^{n_1}\right)-R \log \left(V_2^{n_2}\right)$. Also, note that the number of cells in volume 1 (V1) is not the same as V1 (same for V2 and total), and that you should start with $S = k_B \ln(\Omega)$. – theorist Feb 24 at 8:13
• @theorist $log(x^y)=y\cdot log(x)$ and $log(x)-log(y)=log(x/y)$ – Kexanone Feb 24 at 8:17
• Actually, I was using those identities; the problem is I didn't combine terms correctly. So yes, I agree, you do get the correct result. But I'm still not quite comfortable with the derivation. – theorist Feb 24 at 8:24
• It's actually the beauty of statistical mechanics that you can rationalize thermodynamic relations with relative simple models and statistics. – Kexanone Feb 24 at 8:29
• My concern isn't the simplicity, it's the conceptual issues with the derivation. For instance, when you write your expressions for omega, there the V's aren't volume, they're the number of cells. But when you write your final answer, you've switched the meaning of V (without explanation) from no. of cells to volume. And in determining omega, it should be the number of cells raised to the number of particles, not to moles. [continued] – theorist Feb 25 at 2:14

There's a simple way to solve this: We know that, for an ideal gas at constant T: $$\Delta S = -nR \ln \frac{p_f}{p_i}= nR \ln \frac{p_i}{p_f}$$

And since ideal gases ignore each other, we can calculate the entropy change for gas 1 and gas 2 separately, and simply sum the two. [At any given $$T$$, the chemical potential of an ideal gas is determined only by its own partial pressure, which is independent of the presence of any other gas(es).] Thus:

$$\Delta S = \Delta S_1+ \Delta S_2 = n_1R \ln \left( \frac{p_{1, initial}}{p_{1, final}} \right )+n_2R\ln \left( \frac{p_{2, initial}}{p_{2, final}} \right),$$

where $$p_{1, final}$$ and $$p_{2, final}$$ are the respective final partial pressures of gases 1 and 2. If we don't know the pressures, we can substitute the following into the above expression:

$$p_{1, initial} = \frac{n_1 R T}{V_1}$$ $$p_{1, final} = \frac{n_1 R T}{(V_1+V_2)}$$ $$p_{2, initial} = \frac{n_2 R T}{V_2}$$ $$p_{2, final} = \frac{n_2 R T}{(V_1+V_2)}$$

After simplifying, this gives us the following:

$$\Delta S = n_1R \ln \left( \frac{V_1+V_2}{V_1} \right )+n_2R\ln \left(\frac{V_1+V_2}{V_2} \right)=n_1R \ln \left( \frac{V_{total}}{V_1} \right )+n_2R\ln \left(\frac{V_{total}}{V_2} \right)$$

• One can also formally consider 2 steps like 1/ Each gas reaching independently the final gas mixture pressure by isothermal expansion/compression 2/ Performing isobaric mixing. So entropy change computation would be the sum of the OP mentioned mixing change and isothermal expansion/compresssion changes. – Poutnik Feb 23 at 8:41
• How does it come that the two entropy terms aren't weighted by the respective amounts of substance? – Kexanone Feb 23 at 20:47
• @Kexanone Good catch! I inappropriately combined two terms. I just fixed it. – theorist Feb 24 at 5:33