text
stringlengths
59
1.12k
all gas. It says pure gas in the notes, but of course that isn't the pure gas. It's the mixture of the two components. So. How many moles of A? Well it's the mole fraction of A in the gas.
Times the total number of moles in the gas. Let me put one in here. Just to be clear. And since we have all gas, the number of moles in the gas is just the total number of moles. So
this is just yA at one times n total. Let's just write that in. And of course n total is equal to nA plus nB. So now let's look at condition two. Now we have to look a little more
carefully. Because we have a liquid gas mixture. So nA is equal to yA at pressure two. Times the number of moles of gas at pressure two. Plus xA, at pressure two, times the number of moles of liquid at
pressure two. Now, of course, these things have to be equal. The total number of moles of A didn't change, right? So those are equal. Then yA of two times ng of two. Plus xA of two times n liquid
of two, that's equal to yA of one times n total. Which is of course equal to yA of one times n gas at two plus n liquid at two. I suppose I could be, add that equality. Of course,
it's an obvious one. But let me do it anyway. The total number of moles is equal to nA plus nB. But it's also equal to n liquid plus n gas. And that's all I'm taking advantage of here. And
now I'm just going to rearrange the terms. So I'm going to write yA at one minus yA at two, times ng at two, is equal to, and I'm going to take the other terms, the xA term. xA of
two minus yA of one times n liquid at two. So I've just rearranged the terms. And I've done that because now, I think I omitted something here. yA of one times ng. No, I forgot a bracket, is what
I did. yA of one there. And I did this because now I want to do is look at the ratio of liquid to gas at pressure two. So, ratio of I'll put it gas to liquid, that's ng of
two over n liquid at two. And that's just equal to xA of two minus yA at one minus yA at one minus yA at two. So what does it mean? It's the ratio of these lever arms. That's what
it's telling me. I can look, so I raise the pressure up to two. And so here's xB at two, here's yB at two. And I'm here somewhere. And this little amount and this little amount, that's that difference. And
it's just telling me that ratio of those arms is the ratio of the total number of moles of gas to liquid. And that's great. Because now when I go back to the problem that we were just looking at,
where I say, well I'm going to purify the less volatile component by raising the pressure until I'm at coexistence starting in the gas phase. Raise the pressure, I've got some liquid. But I also want some finite amount of
liquid. But I don't want to just, when I get the very, very first drop of liquid now collected, of course it's enriched in the less volatile component. But there may be a minuscule amount, right? So I'll raise the
pressure a bit more. I'll go up in pressure. And now, of course, when I do that the amount of enrichment of the liquid isn't as big as it was if I just raised it up enough to barely have
any liquid. Then I'd be out here. But I've got more material in the liquid phase to collect. And that's what this allows me to calculate. Is how much do I get in the end. So it's very handy. You
can also see, if I go all the way to the limit where the mole fraction in the liquid at the end is equal to what it was in the gas when I started, what that says is that there's
no more gas left any more. In other words, these two things are equal. If I go all the way to the point where I've got all the, this is the amount I started with, in the pure gas phase,
now I keep raising it all the way. Until I've got the same mole fraction in the liquid. Of course, we know what that really means. That means that I've gone all the way from pure gas to pure liquid.
And the mole fraction in that case has to be the same. And what this is just telling us mathematically is, when that happens this is zero. That means I don't have any gas left. Yeah. PROFESSOR: No. Because, so
it's the mole fraction in the gas phase. But you've started with some amount that it's only going to go down from there. PROFESSOR: Yeah. Yeah. Any other questions? OK. Well, now what I want to do is just put
up a slightly different kind of diagram, but different in an important way. Namely, instead of showing the mole fractions as a function of the pressure. And I haven't written it in, but all of these are at constant temperature,
right? I've assumed the temperature is constant in all these things. Now let's consider the other possibility, the other simple possibility, which is, let's hold the pressure constant and vary the temperature. Of course, you know in the lab, that's
usually what's easiest to do. Now, unfortunately, the arithmetic gets more complicated. It's not monumentally complicated, but here in this case, where you have one linear relationship, which is very convenient. From Raoult's law. And then you have one non-linear
relationship there for the mole fraction of the gas. In the case of temperature, they're both, neither one is linear. Nevertheless, we can just sketch what the diagram looks like. And of course it's very useful to do that, and
see how to read off it. And I should say the derivation of the curves isn't particularly complicated. It's not particularly more complicated than what I think you saw last time to derive this. There's no complicated math involved. But
the point is, the derivation doesn't yield a linear relationship for either the gas or the liquid part of the coexistence curve. OK, so we're going to look at temperature and mole fraction phase diagrams. Again, a little more complicated
mathematically but more practical in real use. And this is T. And here is the, sort of, form that these things take. So again, neither one is linear. Up here, now, of course if you raise the temperatures, that's where
you end up with gas. If you lower the temperature, you condense and get the liquid. So, this is TA star. TB star. So now I want to stick with A as the more volatile component. At constant temperature, that
meant that pA star is bigger than pB star. In other words, the vapor pressure over pure liquid A is higher than the vapor pressure over pure liquid B. Similarly, now I've got constant pressure and really what I'm looking
at, let's say I'm at the limit where I've got the pure liquid. Or the pure A. And now I'm going to, let's say, raise the temperature until I'm at the liquid-gas equilibrium. That's just the boiling point. So if
A is the more volatile component, it has the lower boiling point. And that's what this reflects. So higher pB star A corresponds to lower TA star A. Which is just the boiling point of pure A. So, this is
called the bubble line. That's called the dew line. All that means is, let's say I'm at high temperature. I've got all gas. Right no coexistence, no liquid yet. And I start to cool things off. Just to where I
just barely start to get liquid. What you see that as is, dew starts forming. A little bit of condensation. If you're outside, it means on the grass a little bit of dew is forming. Similarly, if I start at
low temperature, all liquid now I start raising the temperature until I just start to boil. I just start to see the first bubbles forming. And so that's why these things have those names. So now let's just follow along
what happens when I do the same sort of thing that I illustrated there. I want to start at one point in this phase diagram. And then start changing the conditions. So let's start here. So I'm going to start
all in the liquid phase. That is, the temperature is low. Here's xB. And my original temperature. Now I'm going to raise it. So if I raise it a little bit, I reach a point at which I first start
to boil. Start to find some gas above the liquid. And if I look right here, that'll be my composition. Let me raise it a little farther, now that we've already seen the lever rule and so forth. I'll raise
it up to here. And that means that out here, I suppose I should do here. So, here is the liquid mole fraction at temperature two. xB at temperature two. This is yB at temperature two. The gas mole fraction.
So as you should expect, what's going to happen here is that the gas, this is going to be lower in B. A, that means that the mole fraction of A must be higher in the gas phase. That's one
minus yB. So xA is one minus -- yA, which is one minus yB higher in gas phase. Than xA, which is one minus xB. In other words, the less volatile component is enriched up in the gas phase. Now,
what does that mean? That means I could follow the same sort of procedure that I indicated before when we looked at the pressure mole fraction phase diagram. Namely, I could do this and now I could take the gas
phase. Which has less of B. It has more of A. And I can collect it. And then I can reduce the temperature. So it liquefies. So I can condense it, in other words. So now I'm going to start
with, let's say I lower the temperature enough so I've got basically pure liquid. But its composition is the same as the gas here. Because of course that's what that liquid is formed from. I collected the gas and separated
it. So now I could start all over again. Except instead of being here, I'll be down here. And then I can raise the temperature again. To some place where I choose. I could choose here, and go all the
way to hear. A great amount of enrichment. But I know from the lever rule that if I do that, I'm going to have precious little material over here. So I might prefer to raise the temperature a little more.
Still get a substantial amount of enrichment. And now I've got, in the gas phase, I'll further enriched in component A. And again I can collect the gas. Condense it. Now I'm out here somewhere, I've got all liquid and
I'll raise the temperature again. And I can again keep walking my way over. And that's what happens during an ordinary distillation. Each step of the distillation walks along in the phase diagram at some selected point. And of course
what you're doing is, you're always condensing the gas. And starting with fresh liquid that now is enriched in more volatile of the components. So of course if you're really purifying, say, ethanol from an ethanol water mixture, that's how
you do it. Ethanol is the more volatile component. So a still is set up. It will boil the stuff and collect the gas and and condense it. And boil it again, and so forth. And the whole thing can
be set up in a very efficient way. So you have essentially continuous distillation. Where you have a whole sequence of collection and condensation and reheating and so forth events. So then, in a practical way, it's possible to walk
quite far along the distillation, the coexistence curve, and distill to really a high degree of purification. Any questions about how that works? OK. I'll leave till next time the discussion of the chemical potentials. But what we'll do, just
to foreshadow a little bit, what I'll do at the beginning of the next lecture is what's at the end of your notes here. Which is just to say OK, now if we look at Raoult's law, it's straightforward to
say what is the chemical potential for each of the substances in the liquid and the gas phase. Of course, it has to be equal. Given that, that's for an ideal solution. We can gain some insight from that. And
then look at real solutions, non-ideal solutions, and understand a lot of their behavior as well. Just from starting from our understanding of what the chemical potential does even in a simple ideal mixture. So we'll look at the chemical
Topics covered: Encapsulation, inheritance, shadowing Instructor: Prof. Eric Grimson, Prof. John Guttag OPERATOR: The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make
a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu. PROFESSOR: Last lecture we were talking about classes, and object-oriented programming, and we're going to come back to it today. I'm going to remind
you, we were talking about it because we suggested it is a really powerful way of structuring systems, and that's really why we want to use it, It's a very common way of structuring systems. So today I'm going to
pick up on a bunch of more nuanced, or more complex if you like, ways of leveraging the power of classes. But we're going to see a bunch of examples that are going to give us a sense. I'm going
to talk about inheritance, we're going to talk about shadowing, we're going to talk about iterators. But before get to it, I want to start by just highlighting, sort of, what was the point of classes? So I'll remind you.
A class, I said, was basically a template for an abstract data type. And this was really to drive home this idea of modularity. I want the ability to say, I've got a set of things that naturally belong together,
I'm going to cluster them together, I want to treat it like it's a primitive, I want to treat it like it's a float or an int or a string. Is this going to be a point or a segment
or something different like that. So it's really a way, as I said, of just trying to cluster data together. And this is a notion of modularity slash abstraction where I'm treating them as primitives. But the second thing we
talked about is that we also have a set of methods, using the special name method because we're talking classes. But basically functions that are designed to deal with this data structure. We're trying to group those together as well.
So we cluster data and methods. Second key thing we said was, in the ideal case, which unfortunately Python isn't, but we'll come back to that, in the ideal case, we would have data hiding, and by data hiding, which
is sort of a version of encapsulation, what we meant was that you could only get to the internal pieces of that data structure through a proscribed method. Proscribed meaning it's something I set up. So data hiding saying, you
would only access the parts through a method. And as we said, unfortunately Python does not enforce this. Meaning that I could create one of these data structures, ideally I'd have a method, that I'm going to see some examples
of that I used to get the parts out, unfortunately in Python you could take the name the instance dot some internal variable you'll get it back. It is exposed. And this is actually just not a good idea. So
I suggested in my very bad humor, that you practice computational hygiene and you only use appropriate methods to get the parts out. OK didn't laugh the joke last time, you're not going to laugh at it this time, I
don't blame you. All right, and then the last piece of this is that we said the class is a template. When we call that class, it makes an instance. So class is used to make instances, meaning particular versions,
of that structure, and we said inside the instances we have a set of attributes. Internal variables, methods, that are going to belong to that structure. OK, so with that in mind, here's what I want to do. I'm going
to show you a set of examples, and I want to warn you ahead of time, the code handout today is a little longer than normal because we want to build essentially an extended example of a sequence of examples
of classes. We're going to see the idea, of which we're gonna talk about, of inheritance or hierarchy, in which we can have classes that are specializations of other classes. We're gonna see how we can inherit methods, how we
can shadow methods, how we can use methods in a variety of ways. So this is a way of suggesting you may find it more convenient to put notes on the code handout rather than in your own notes. Do
whatever you like, but I just wanted to alert you, we're going to go through a little more code than normal. So, the little environment I'm going to build is an environment of people. I'll build a simple little simulation
of people. So I'm going to start off with the first class, which I've got up on the screen, and it's on your handout as well, which is I'm going to build an instance, or a class rather, of persons.
I'm going to draw a diagram, which I'm gonna try and see if I can do well, over here, of the different objects we're going to have. So I've got, a class, and by the way a class is an
object. Instances are also objects, but classes are objects. We're gonna see why we want that in a second. Because I'm gonna build an object, sorry a class, called a person. Now, let's walk through some of the pieces here.
The first one is, there's something a little different. Remember last time we had that keyword class and then a name, that name, in this case, person says this is the name for the class, and then we would have
just had the semicolon and a bunch of internal things. Here I've got something in parens, and I want to stress this is not a variable. All right, this is not a def, this is a class. I'm going to
come back to it, but what this is basically saying is that the person class is going to inherit from another class, which in this case is just the built-in Python object class. Hold on to that thought, it's going
to make more sense when we look at a little more interesting example, but I want to highlight that. All right now, if we do this, as I said before, we can create a version of a person, let me
just call it per, person. OK? And what we said last time is, when we wanted to create an instance inside of this class definition, we've got one of those built-in things called init. I'm gonna again remind you, some
of the methods we have, Underbar underbar init is going to be the thing that creates the instance. Actually slightly misspeaking, actually Python creates the instance, but it's one thing that fills it in. So in this case, I'm going
to give it 2 arguments: Frank Foobar Now, you might have said, wait a minute, init here has 3 arguments: self, family name, and first name. So again, just to remind you, what we said happens here is that when
I call this class, person, I'm creating an instance. We'll draw a little instance diagram down here. I'm going to give it the name per. And I should have said inside of person, we've got a set of things. We've
got our underbar underbar init, we've got, what else do I have up there? Family name. And a bunch of other methods, down to say. What happens inside of Python is, when we called the class definition, person, it creates
an instance, there it is. Think of it as a pointer to a spot in memory, and then what we do is, we call, or find, that init method, up here, and we apply it. And the first argument self,
points to the instance. So this object here is what self looks at. Now you can see what init's going to do. It says, oh, inside of self, which is pointing to here, let me bind a variable, which was,
can read that very carefully, it's family underbar name, to the value I passed in, which was 4. Same thing with first name. OK, so the reason I'm stressing this is, self we do not supply explicitly, it is supplied
as pointing to the instance, it's giving us that piece of memory. And that is what then gets created. So here's, now, the instance for per. OK, and I put a little label on there, I'm going to call that
an isALink, because it is an instance of that class. God bless you. All right, so once we got this, let's look at what we can do with person. That's why I built person here. And as I said, I've
already bound basically, those two pieces. If I want to get a value out, I can give person, or per, rather, this instance, a messaging. In this case I want to get family, what did I say, family name out,
now, again I want to stress, what is happening here? per is an instance, it's this thing here. When I say per dot family name, I'm sending it a message, in essence what that does is, it says, from here
it's going to go up the chain to this class object and find the appropriate method, which was family name. It is then going to apply that to self, which points to this instance. And that allows it, therefore, is
you can see on the code, to look up under self, what's the binding for family name, and print it back up. So self is always going to point to the instance I want and I can use it. OK
what else do we have in here? We can get the first name, that's not particularly interesting. We've got 2 other special methods: that's cmp and str. All right, cmp is our comparison method. And since I, I was about
to say I blew it last time, I misspoke last time, a wonderful phrase that politicians like to use, I misspoke last time. Let me clarify again what cmp will do. Underbar underbar cmp is going to be the method
you're going to use to compare two instances of an object. Now, let's back up for second. If I wanted to test equality, in fact I could use underbar underbar eq, under under. It's natural to think about an equality