 So if we want to be able to calculate the entropy for other types of processes in addition to just heating something up or cooling something down, one of the other one processes that we'll run into frequently is when two substances mix or combine together. Either gas is mixing to form a mixed gas or two solutions mixing to form a solution. And that's easiest to think about in the case of gases. So let's illustrate what I mean by mixing. Let's say we have a gas, let's say I've got some number of moles of gas A, or molecules of gas A in some volume, so that's the volume that A, the gas A occupies. And I'm going to allow, let's first, instead of considering mixing, let's just let that gas expand. Let's say there's some bigger container and I'm going to remove this wall between the left half of the container and right half of the container. So after I remove the wall, it expands into some total volume. Let's go ahead and say the left half of the box has volume VA, the right half of the box has volume VB. So the total volume is VA plus VB. So after I remove this partition, the gas expands to fill its container. The N sub A molecules of gas A have now expanded to fill this larger volume. So I still have N sub A molecules, they just occupy a larger volume. We know how to calculate the entropy of expansion of an ideal gas, particularly, well, let's say, if I go back to the Clausius theorem, the change in entropy is going to be related to the change in heat. And what we do know how to do is calculate the heat of a reversible isothermal expansion of an ideal gas. So if this gas expands isothermally, so the 1 over T is just 1 over T, the heat dq for reversible isothermal expansion of an ideal gas we've seen before, that was nRT over V times the change in volume. The T's in this expression cancel, so this is just nR over V dV. That's the differential change in the entropy. If I want to know the actual change delta S, I just have to integrate integral of dS is delta S, integral of nR over V dV. On the right side, that's going to give me n times R, integral of 1 over V is natural log of V. If I integrate that from some initial to some final volume, I'm going to get log of the final volume over the initial volume. So that's a new expression since we know how to calculate heat of a reversible isothermal expansion. Now we know how to calculate the entropy change for the expansion of an ideal gas, isothermal expansion of an ideal gas. If we apply that new result to this case, gas A expanding from volume A to the total volume, so the change in entropy of that gas A is moles of gas A times R times the natural log of the final volume, V total, over the initial volume, V A. So that's the entropy of the expansion of an ideal gas. To talk about mixing of two gases, now let's say before I remove that partition, there were some molecules of a different gas and some B molecules of a different gas on the right hand side of the container. So after the partition is removed, that gas also expands to fill the entire container. So now the container has a mixture of gas A and gas B. From the point of view of gas B, all it's done is expanded from this initial volume into a larger volume, so its entropy changed. The change in entropy of gas B is also moles times R times natural log of final volume over initial volume. The only difference is I have N sub B moles of gas B and it expanded from this initial volume of V sub B into the total volume. The total entropy, in fact what we'll call that is the entropy of the mixing, if I combine those two terms N A R log V total over V A plus N B R log V total over V B. That would be the total entropy change for the process or we call that the entropy of mixing because it's the entropy when gas A and gas B mix together. I just removed the partition, they both mixed together in the same total volume. The total volume didn't change, just the volume occupied by each individual gas changed. So that result is correct, that result is fine. We can clean that up and make that look a little more appealing by doing a couple of things. First of all, when I write this next line, so the volumes of this gas that we're talking about here, if I rewrite each of those volumes using the adiogas law, N R T over P as the volume, then I'll rewrite the entropy of mixing as N sub A R, so in this fraction I have a volume over a volume, the volume in the numerator, the total volume, I'll use the adiogas law, so the total volume becomes total number of moles times R times the temperature over the pressure. In the denominator I've got the volume A, the volume before the system expanded, so that was moles of A times R T over P. So if I do that, I'm going to have cancellation, R T and P, all will cancel and what I have left is just ratio of total number of moles to the moles of A. The same thing is going to happen in the second term. I have N B times R times the natural log V total over V B, that's the same as N total over N B. So when I rewrite that, that simplification will happen. In this next line, let me go ahead and say, if I divide through by the total number of moles, and we'll see in just a second why I'm doing that, but essentially what I've done by dividing by total number of moles is turn this extensive entropy into an intensive quantity. If I divide by the total number of moles, that will give me the intensive entropy of mixing. So dividing through by N total, I've got N A R times this log of a ratio divided by N total, and that ratio is N total over N A. Second term, I also have to divide by N total. I've got N sub B divided by N total times R log N total over N B. That's really the reason I divided by N total is now you can see this quantity moles divided by total number of moles. Here's a different moles divided by total number of moles. Inside the natural log, I've got moles underneath the total number of moles, moles underneath the total number of moles. If we define quantity of the mole fraction, so the mole fraction of any substance is the moles of that substance divided by the total number of moles, just what fraction of the total moles are that particular gas. Then I can write each of these ratios N over N as a mole fraction. So this delta S of mixing, I can write as the mole fraction of A times R log. This is now an upside down mole fraction. Moles of A is in the denominator, total number of moles is in the numerator. So that's one over a mole fraction. Second term looks like mole fraction of B times R natural log of one over mole fraction of B. N sub B is in the denominator, total number of moles is in the numerator. Now actually this is delta S mix over N total. If we factor some things out, in fact what I'll do here is I'll factor out an R. So both of these terms have an R in them. So I'll factor an R out of that whole expression. I'm going to move the N total back over to the right hand side. So I'd rather write this as moles times the gas constant. And then what's left after I've factored out that factor of R is I've got a X sub A log one over X. But log of one over something is just the negative of the log of something. So I'd rather write it as X A log of X A with a negative sign and X B log of X B, which also brings out a negative sign. So I've factored those two negative signs out of the parentheses as well. And now this will be the last way in which I rewrite the expression. The total entropy of mixing is going to be minus moles times R. So I've got X log X for gas A, X log X for gas B. If I had done this for three gases, if I had three separate containers and I allowed them all three to combine or ten separate gases that I allowed to mix together, each one of them is just going to expand from its initial volume into the total volume. So each of these terms that looks like entropy of expansion of gas A and gas B, I just have one term like this for each of the gases. So even if I have more than two gases, I can write this as sum of mole fraction times the log of a mole fraction, just summed over all the gases that I'm allowing to mix together. So here's an expression that at the moment we only know is true for an ideal gas. Turns out that same expression is true for an ideal combination of liquids as well. For example, if we wanted to, and this is just an illustration, we'll talk more about mixing of fluids later on. Let's say I have a beaker with liquid A and another beaker with liquid B and I want to pour those liquids together into a larger beaker and make a solution, a mixture of liquid A and B together. If I want to calculate the entropy of mixing those two liquids with one another, I could go about that by saying, let's make a lattice model. Let's divide the liquid up into a bunch of lattice boxes. In this liquid, every box is filled with a molecule of liquid A. In this beaker, every lattice is filled with a molecule of liquid B. In the combined, in the mixed solution, some of them are A's and some of them are B's. If we calculate the entropy of mixing those two things together, we'd also get the same result. It also turns out to depend only on mole fractions of A and B in this form x log x sum together. It turns out this is a more general expression than just for ideal gases, although all we've done for right now is derive it for an ideal gas, a mixture of ideal gases. You'll notice also that this expression looks a little bit familiar. Entropy being related to the sum of x log x, that's very reminiscent of entropy being negative Boltzmann constant times the sum of p log p, which is an expression we've used for the entropy ever since we first defined that quantity. This is a way of calculating the entropy now for a mixing process. At this point, we can calculate the entropy for several different types of processes.