other proposed treatments it is one of the cardinal principles of natural medicine that treatment should aim not only to treat illness but also to enhance wellness. according to this ideal, a proper course of treatment should improve your sense of general well - being, enhance your immunity to illness, raise your physical stamina, and increase mental alertness, as well as resolve the specific condition you took it for. unfortunately, while there can be little doubt that this is a laudable goal, it is easier to laud it than to achieve it. conventional medicine tends to focus on treating diseases rather than increasing wellness, not as a matter of philosophical principle, but because it is easier to accomplish. probably the strongest force affecting wellness is genetics. beyond that, common sense steps endorsed by all physicians include increasing exercise, reducing stress, improving diet, getting enough sleep, and living a life of moderation without bad habits, such as smoking or overeating. beyond this, however, it is difficult to make strong affirmations, and the optimum forms of diet and exercise and other aspects of lifestyle remain unclear. in fact, they may always remain unclear, as it is impossible to perform double - blind, placebo - controlled studies on most lifestyle habits. ( for information on why such studies are irreplaceable see " why does this database depend on double - blind studies? " ) principal proposed natural treatments in order to function at our best, we need good nutrition. however, the modern diet often fails to provide people with sufficient amounts of all the necessary nutrients. for this reason, use of a multivitamin / multimineral supplement might be expected to enhance overall health and well - being, and preliminary double - blind trials generally support this view. for more information, see the article on general nutritional support. the herb panax ginseng has an ancient reputation as a healthful “ tonic. ” according to a more modern concept developed in the former ussr, ginseng functions as an “ adaptogen. ” this term is defined as follows : an adaptogen helps the body adapt to stresses of various kinds, whether heat, cold, exertion, trauma, sleep deprivation, toxic exposure, radiation, infection, or psychologic stress. in addition, an adaptogen causes no side effects, is effective in treating a wide variety of illnesses, and helps return an organism toward balance no matter what may have gone wrong. from a modern scientific perspective, it is not truly clear that such things as adaptogens actually exist. however, there is some


, attend a full schedule of groups and individual therapies at our clinical campus [ near the residential complex ], attend local community support groups in the evenings, and visit with our physicians and clinical staff regularly throughout their stay. in effect, the experience is one of providing a supportive and structured setting without the restrictive elements of a " hospital " or institutional facility. a key element in providing the support necessary to begin recovery is remaining in the company of other participants during the initial phase of the treatment. this provides both a form of supervision and a deterrent from the behavior often associated with binge eating : namely eating in isolation or alone. secondly, milestones approaches treatment from a more " holistic " perspective. doing so is best described by the acronym " serf " - spirituality, exercise, rest, and food plan. spirituality need not equate with any religious or spiritual beliefs imposed on or by anyone. in fact, spirituality at milestones simply is left up to the individual to cultivate with his or her own working definition. for most, it is a belief in a " higher power " and still for others it may be a return to some of their original religious beliefs. for everyone, it is an individual journey. exercise is individualized and represents collaboration between the resident and clinical team. it is meant to be in the service of restoring and maintaining a healthy body rather than an " intensive " means of controlling body weight. rest is simply about finding the correct balance in recovery between work and play and narrowing the gap between an " all or none ", " feast or famine " approach to daily living. the food plan suggested by milestones is a blend of structured eating and a combination of healthy, whole foods that are bought and prepared by participants with the guidance and supervision of our dietitian and ancillary staff. in brief participants select their own preferences within the guidelines of their individual food plans. the guidelines require participants to abstain from " junk foods " and eliminate most highly processed [ sugar and flour laden ] food products as well as weigh and measure portions per their food plan while in residence. it is important to mention most participants who seek treatment for most eating disorders may have a tendency to focus on " trading in the binging and / or " purging " to become better at restricting or " losing weight " and as such, it is important to understand the predisposition to replace one form of an eating disorder for another. acknowledging this is helpful to maintaining the prescribed treatment plan both during and after the residential treatment experience.


deep - space communication improved with electromagnetic radiation antenna - robert c. dye - technology transfer - ( 505 ) 667 - 3404 electromagnetic radiation antenna has potential for deep - space communication - directed energy - long - range communications - medicine ( oncology ) - radar imaging applications are countermeasure - resistant - communications can be spatially - encrypted - 4 - dimensional volumes of energy can be aimed at a single space - time point for directed energy applications - nonspherical decay of the cusp enables low - power communications and propagation over great distances los alamos national laboratory ( lanl ) researchers have developed the lightslinger, a completely new type of antenna that produces tightly - focused packets of electromagnetic radiation fundamentally different from the emissions of conventional transmitters. the device has potential applications in radar, directed - energy ( non - kinetic kill ), secure communications, ultra - long - range communications ( e. g., deep - space ), medicine ( oncology ) and astrophysics. the lightslinger functions by producing a moving polarization pattern in a ring of alumina. by careful timing of voltages applied to electrodes that surround the alumina, the polarization pattern can be made to move superluminally, i. e., faster than the speed of light in a vacuum. nobel laureate vitaly ginzberg showed both that such superluminal polarization patterns do not violate the principles of special relativity and that they emit electromagnetic radiation. once a source travels faster than the waves that it emits, it can make contributions at multiple retarded times to a signal received instantaneously at a distance. this effect is already well known in acoustics ; when a supersonic airplane accelerates through the speed of sound, a violent “ sonic boom ” is heard many miles away, even if the airplane itself is rather quiet. the lightslinger enables the same thing to be done with electromagnetic radiation ; i. e., a relatively low - power source can make an “ electromagnetic boom ”, an intense concentration of radiowaves at a great distance. the “ electromagnetic boom ” is due to temporal focusing, that is, focusing in the time domain. because of this effect, part of the emitted radiation possesses an intensity that decays with distance r as 1 / r rather than as the conventional inverse square law, 1 / r2. these nonspherically - decaying wavepackets represent a game - changing technology in the applications of electromagnetic radiation. development stage : working prototype patent status : patent pending


jim lake and maria rivera, at the university of california - los angeles ( ucla ), report their finding in the sept. 9 issue of the journal nature. scientists refer to both bacteria and archaea as " prokaryotes " - - a cell type that has no distinct nucleus to contain the genetic material, dna, and few other specialized components. more - complex cells, known as " eukaryotes, " contain a well - defined nucleus as well as compartmentalized " organelles " that carry out metabolism and transport molecules throughout the cell. yeast cells are some of the most - primitive eukaryotes, whereas the highly specialized cells of human beings and other mammals are among the most complex. " a major unsolved question in biology has been where eukaryotes came from, where we came from, " lake said. " the answer is that we have two parents, and we now know who those parents were. " further, he added, the results provide a new picture of evolutionary pathways. " at least 2 billion years ago, ancestors of these two diverse prokaryotic groups fused their genomes to form the first eukaryote, and in the processes two different branches of the tree of life were fused to form the ring of life, " lake said. the work is part of an effort supported by the national science foundation - - the federal agency that supports research and education across all disciplines of science and engineering - - to re - examine historical schemes for classifying earth ' s living creatures, a process that was once based on easily observable traits. microbes, plants or animals wer contact : leslie fink national science foundation


refraction and acceleration name : christopher s. why is it that when light travels from a more dense to a less dense medium, its speed is higher? i ' ve read answers to this question in your archives but, sadly, still don ' t get it. one answer ( jasjeet s bagla ) says that we must not ask the question because light is massless, hence questions of acceleration don ' t make sense. it does, however, seem to be ok to talk about different speeds of light. if you start at one speed and end at a higher one, why is one not allowed to talk about acceleration? bagla goes on to say that it depends on how the em fields behave in a given medium. it begs the question : what is it about, say, perspex and air that makes light accelerate, oops, travel at different speeds? if you ' re dealing with the same ray of light, one is forced to speak of acceleration, no? what other explanation is there for final velocity > initial velocity? arthur smith mentioned a very small " evanescent " component that travels ahead at c. where can i learn more about this? sorry for the long question. i understand that f = ma and if there is no m, you cannot talk about a, but, again, you have one velocity higher than another for the same thing. i need to know more than " that ' s just the way em fields are! " an explanation that satisfies me relates to travel through an interactive medium. when light interacts with an atom, the photon of light is absorbed and then emitted. for a moment, the energy of the light is within the atom. this causes a slight delay. light travels at the standard speed of light until interacting with another atom. it is absorbed and emitted, causing another slight delay. the average effect is taking more time to travel a meter through glass than through air. this works like a slower speed. an individual photon does not actually slow down. it gets delayed repeatedly by the atoms of the medium. a more dense medium has more atoms per meter to dr. ken mellendorf illinois central college congratulations! on not being willing to accept " that is just the way em fields are! " the answer to your inquiry is not all that simple ( my opinion ), but i won ' t try to do so in the limited space allowed here, not to say my own limitations of knowledge. like so many " simple " physics questions, i find the most lucid


is not all that simple ( my opinion ), but i won ' t try to do so in the limited space allowed here, not to say my own limitations of knowledge. like so many " simple " physics questions, i find the most lucid, but accurate, explanation in richard feynman ' s, " lectures on physics " which most libraries will have. volume i, chapter 31 - 1 through 31 - 6, which describes refraction, dispersion, diffraction. the " answer " has to do with how matter alters the electric field of incident radiation, but i won ' t pretend to be able to do a better job than feynman. the answer is that you are not dealing with the same ray of light. in vacuum a photon just keeps going at the speed of light. in a medium, however, it interacts with the atoms, often being absorbed while bumping an atomic or molecular motion into a higher energy state. the excited atom / molecule then can jump to a lower energy state, emitting a photon while doing so. this can obviously make light appear to travel slower in a in detail, it is a very complicated question, requiring at least a graduate course in electromagnetism to begin to understand. why, for example do the emitted photons tend to travel in the same direction? best, richard j. plano click here to return to the physics archives update : june 2012


attempts to relay mail by issuing a predefined combination of smtp commands. the goal of this script is to tell if a smtp server is vulnerable to mail relaying. an smtp server that works as an open relay, is a email server that does not verify if the user is authorised to send email from the specified email address. therefore, users would be able to send email originating from any third - party email address that they want. the checks are done based in combinations of mail from and rcpt to commands. the list is hardcoded in the source file. the script will output all the working combinations that the server allows if nmap is in verbose mode otherwise the script will print the number of successful tests. the script will not output if the server requires authentication. if debug is enabled and an error occurrs while testing the target host, the error will be printed with the list of any combinations that were found prior to the error. use this to change the ip address to be used ( default is the target ip address ) define the destination email address to be used ( without the domain, default is relaytest ) or smtp - open - relay. domain define the domain to be used in the anti - spam tests and ehlo command ( default is nmap. scanme. org ) define the source email address to be used ( without the domain, default is antispam ) smbdomain, smbhash, smbnoguest, smbpassword, smbtype, smbusernamesee the documentation for the smbauth library. nmap - - script smtp - open - relay. nse [ - - script - args smtp - open - relay. domain = < domain >, smtp - open - relay. ip = < address >,... ] - p 25, 465, 587 < host > host script results : | smtp - open - relay : server is an open relay ( 1 / 16 tests ) | _ mail from : < email @ example. com > - > rcpt to : < firstname. lastname @ example. org > author : arturo ' buanzo ' busleiman license : same as nmap - - see http : / / nmap. org / book / man - legal. html


topics covered : ideal solutions instructor / speaker : moungi bawendi, keith nelson 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 : so. in the meantime, you ' ve started looking at two phase equilibrium. so now we ' re starting to look at mixtures. and so now we have more than one constituent. and we have more than one phase present. right? so you ' ve started to look at things that look like this, where you ' ve got, let ' s say, two components. both in the gas phase. and now to try to figure out what the phase equilibria look like. of course it ' s now a little bit more complicated than what you went through before, where you can get pressure temperature phase diagrams with just a single component. now we want to worry about what ' s the composition. of each of the components. in each of the phases. and what ' s the temperature and the pressure. total and partial pressures and all of that. so you can really figure out everything about both phases. and there are all sorts of important reasons to do that, obviously lots of chemistry happens in liquid mixtures. some in gas mixtures. some where they ' re in equilibrium. all sorts of chemical processes. distillation, for example, takes advantage of the properties of liquid and gas mixtures. where one of them might be richer, will be richer, and the more volatile of the components. that can be used as a basis for purification. you mix ethanol and water together so you ' ve got a liquid with a certain composition of each. the gas is going to be richer and the more volatile of the two, the ethanol. so in a distillation, where you put things up in the gas, more of the ethanol comes up. you could then collect that gas, right? and re - condense it, and make a new liquid. which is much richer in ethanol than the original liquid was. then you could make, then you could put some of them up into the gas phase. where it will be still richer in ethanol. and then you could collect that and repeat the process. so the point is that properties of liquid gas, two - component or multi - component mixtures like this can


of them up into the gas phase. where it will be still richer in ethanol. and then you could collect that and repeat the process. so the point is that properties of liquid gas, two - component or multi - component mixtures like this can be exploited. basically, the different volatilities of the different components can be exploited for things like purification. also if you want to calculate chemical equilibria in the liquid and gas phase, of course, now you ' ve seen chemical equilibrium, so the amount of reaction depends on the composition. so of course if you want reactions to go, then this also can be exploited by looking at which phase might be richer in one reactant or another. and thereby pushing the equilibrium toward one direction or the other. ok. so. we ' ve got some total temperature and pressure. and we have compositions. so in the gas phase, we ' ve got mole fractions ya and yb. in the liquid phase we ' ve got mole fractions xa and xb. so that ' s our system. one of the things that you established last time is that, so there are the total number of variables including the temperature and the pressure. and let ' s say the mole fraction of a in each of the liquid and gas phases, right? but then there are constraints. because the chemical potentials have to be equal, right? chemical potential of a has to be equal in the liquid and gas. same with b. those two constraints reduce the number of independent variables. so there ' ll be two in this case rather than four independent variables. if you control those, then everything else will follow. what that means is if you ' ve got a, if you control, if you fix the temperature and the total pressure, everything else should be determinable. no more free variables. and then, what you saw is that in simple or ideal liquid mixtures, a result called raoult ' s law would hold. which just says that the partial pressure of a is equal to the mole fraction of a in the liquid times the pressure of pure a over the liquid. and so what this gives you is a diagram that looks like this. if we plot this versus xb, this is mole fraction of b in the liquid going from zero to one. then we could construct a diagram of this sort. so this is the total pressure of a and b. the partial pressures are given by these lines. so this is our pa star and pb star. the pressures over


going from zero to one. then we could construct a diagram of this sort. so this is the total pressure of a and b. the partial pressures are given by these lines. so this is our pa star and pb star. the pressures over the pure liquid a and b at the limits of mole fraction of b being zero and one. so in this situation, for example, a is the more volatile of the components. so it ' s partial pressure over its pure liquid. at this temperature. is higher than the partial pressure of b over its pure liquid. a would be the ethanol, for example and b the water in that mixture. ok. then you started looking at both the gas and the liquid phase in the same diagram. so this is the mole fraction of the liquid. if you look and see, well, ok now we should be able to determine the mole fraction in the gas as well. again, if we note total temperature and pressure, everything else must follow. and so, you saw this worked out. relation between p and ya, for example. the result was p is pa star times pb star over pa star plus pb star minus pa star times ya. and the point here is that unlike this case, where you have a linear relationship, the relationship between the pressure and the liquid mole fraction isn ' t linear. we can still plot it, of course. so if we do that, then we end up with a diagram that looks like the following. now i ' m going to keep both mole fractions, xb and yb, i ' ve got some total pressure. i still have my linear relationship. and then i have a non - linear relationship between the pressure and the mole fraction in the gas phase. so let ' s just fill this in. here is pa star still. here ' s pb star. of course, at the limits they ' re still, both mole fractions they ' re zero and one. ok. i believe this is this is where you ended up at the end of the last lecture. but it ' s probably not so clear exactly how you read something like this. and use it. it ' s extremely useful. you just have to kind of learn how to follow what happens in a diagram like this. and that ' s what i want to spend some of today doing. is just, walking through what ' s happening physically, with a container with a mixture of the two. and how does that correspond to what gets read off the diagram under different


. and that ' s what i want to spend some of today doing. is just, walking through what ' s happening physically, with a container with a mixture of the two. and how does that correspond to what gets read off the diagram under different conditions. so. let ' s just start somewhere on a phase diagram like this. let ' s start up here at some point one, so we ' re in the pure - well, not pure, you ' re in the all liquid phase. it ' s still a mixture. it ' s not a pure substance. pa star, pb star. there ' s the gas phase. so, if we start at one, and now there ' s some total pressure. and now we ' re going to reduce it. what happens? we start with a pure - with an all - liquid mixture. no gas. and now we ' re going to bring down the pressure. allowing some of the liquid to go up into the gas phase. so, we can do that. and once we reach point two, then we find a coexistence curve. now the liquid and gas are going to coexist. so this is the liquid phase. and that means that this must be xb. and it ' s xb at one, but it ' s also xb at two, and i want to emphasize that. so let ' s put our pressure for two. and if we go over here, this is telling us about the mole fraction in the gas phase. that ' s what these curves are, remember. so this is the one that ' s showing us the mole fraction in the liquid phase. this nonlinear one in the gas phase. so that means just reading off it, this is xb, that ' s the liquid mole fraction. here ' s yb. the gas mole fraction. they ' re not the same, right, because of course the components have different volatility. a ' s more volatile. so that means that the mole fraction of b in the liquid phase is higher than the mole fraction of b in the gas phase. because a is the more volatile component. so more, relatively more, of a, the mole fraction of a is going to be higher up in the gas phase. which means the mole fraction of b is lower in the gas phase. so, yb less than xb if a is more volatile. ok, so now what ' s happening physically? well, we started at a point where we only had the


which means the mole fraction of b is lower in the gas phase. so, yb less than xb if a is more volatile. ok, so now what ' s happening physically? well, we started at a point where we only had the liquid present. so at our initial pressure, we just have all liquid. there ' s some xb at one. that ' s all there is, there isn ' t any gas yet. now, what happened here? well, now we lowered the pressure. so you could imagine, well, we made the box bigger. now, if the liquid was under pressure, being squeezed by the box, right then you could make the box a little bit bigger. and there ' s still no gas. that ' s moving down like this. but then you get to a point where there ' s just barely any pressure on top of the liquid. and then you keep expanding the box. now some gas is going to form. so now we ' re going to go to our case two. we ' ve got a bigger box. and now, right around where this was, this is going to be liquid. and there ' s gas up here. so up here is yb at pressure two. here ' s xb at pressure two. liquid and gas. so that ' s where we are at point two here. now, what happens if we keep going? let ' s lower the pressure some more. well, we can lower it and do this. but really if we want to see what ' s happening in each of the phases, we have to stay on the coexistence curves. those are what tell us what the pressures are. what the partial pressure are going to be in each of the phases. in each of the two, in the liquid and the gas phases. so let ' s say we lower the pressure a little more. what ' s going to happen is, then we ' ll end up somewhere over here. in the liquid, and that ' ll correspond to something over here in the gas. so here ' s three. so now we ' re going to have, that ' s going to be xb at pressure three. and over here is going to be yb at pressure three. and all we ' ve done, of course, is we ' ve just expanded this further. so now we ' ve got a still taller box. and the liquid is going to be a little lower because some of it has evaporated, formed the gas phase


' ve done, of course, is we ' ve just expanded this further. so now we ' ve got a still taller box. and the liquid is going to be a little lower because some of it has evaporated, formed the gas phase. so here ' s xb at three. here ' s yb at three, here ' s our gas phase. now we could decrease even further. and this is the sort of thing that you maybe can ' t do in real life. but i can do on a blackboard. i ' m going to give myself more room on this curve, to finish this illustration. there. beautiful. so now we can lower a little bit further, and what i want to illustrate is, if we keep going down, eventually we get to a pressure where now if we look over in the gas phase, we ' re at the same pressure, mole fraction that we had originally in the liquid phase. so let ' s make four even lower pressure. what does that mean? what it means is, we ' re running out of liquid. so what ' s supposed to happen is a is the more volatile component. so as we start opening up some room for gas to form, you get more of a in the gas phase. but of course, and the liquid is richer in b. but of course, eventually you run out of liquid. you make the box pretty big, and you run out, or you have the very last drop of liquid. so what ' s the mole fraction of b in the gas phase? it has to be the same as what it started in in the liquid phase. because after all the total number of moles of a and b hasn ' t changed any. so if you take them all from the liquid and put them all up into the gas phase, it must be the same. so yb of four. once you just have the last drop. so then yb of four is basically equal to xb of one. because everything ' s now up in the gas phase. so in principle, there ' s still a tiny, tiny bit of xb at pressure four. well, we could keep lowering the pressure. we could make the box a little bigger. then the very last of the liquid is going to be gone. and what ' ll happen then is, we ' re all here. there ' s no more liquid. we ' re not going down on the coexistence curve any more. we don ' t have a liquid gas


going to be gone. and what ' ll happen then is, we ' re all here. there ' s no more liquid. we ' re not going down on the coexistence curve any more. we don ' t have a liquid gas coexistence any more. we just have a gas phase. of course, we can continue to lower the pressure. and then what we ' re doing is just going down here. so there ' s five. and five is the same as this only bigger. and so forth. ok, any questions about how this works? it ' s really important to just gain facility in reading these things and seeing, ok, what is it that this is telling you. and you can see it ' s not complicated to do it, but it takes a little bit of practice. ok. now, of course, we could do exactly the same thing starting from the gas phase. and raising the pressure. and although you may anticipate that it ' s kind of pedantic, i really do want to illustrate something by it. so let me just imagine that we ' re going to do that. let ' s start all in the gas phase. up here ' s the liquid. pa star, pb star. and now let ' s start somewhere here. so we ' re down somewhere in the gas phase with some composition. so it ' s the same story, except now we ' re starting here. it ' s all gas. and we ' re going to start squeezing. we ' re increasing the pressure. and eventually here ' s one, will reach two, so of course here ' s our yb. we started with all gas, no liquid. so this is yb of one. it ' s the same as yb of two, i ' m just raising the pressure enough to just reach the coexistence curve. and of course, out here tells us xb of two, right? so what is it saying? we ' ve squeezed and started to form some liquid. and the liquid is richer in component b. maybe it ' s ethanol water again. and we squeeze, and now we ' ve got more water in the liquid phase than in the gas phase. because water ' s the less volatile component. it ' s what ' s going to condense first. so the liquid is rich in the less volatile of the components. now, obviously, we can continue in doing exactly the reverse of what i showed you. but all i want to


component. it ' s what ' s going to condense first. so the liquid is rich in the less volatile of the components. now, obviously, we can continue in doing exactly the reverse of what i showed you. but all i want to really illustrate is, this is a strategy for purification of the less volatile component. once you ' ve done this, well now you ' ve got some liquid. now you could collect that liquid in a separate vessel. so let ' s collect the liquid mixture with xb of two. so it ' s got some mole fraction of b. so we ' ve purified that. but now we ' re going to start, we ' ve got pure liquid. now let ' s make the vessel big. so it all goes into the gas phase. then lower p. all gas. so we start with yb of three, which equals xb of two. in other words, it ' s the same mole fraction. so let ' s reconstruct that. so here ' s p of two. and now we ' re going to go to some new pressure. and the point is, now we ' re going to start, since the mole fraction in the gas phase that we ' re starting from is the same number as this was. so it ' s around here somewhere. that ' s yb of three equals xb of two. and we ' re down here. in other words, all we ' ve done is make the container big enough so the pressure ' s low and it ' s all in the gas phase. that ' s all we have, is the gas. but the composition is whatever the composition is that we extracted here from the liquid. so this xb, which is the liquid mole fraction, is now yb, the gas mole fraction. of course, the pressure is different. lower than it was before. great. now let ' s increase. so here ' s three. and now let ' s increase the pressure to four. and of course what happens, now we ' ve got coexistence. so here ' s liquid. here ' s gas. so, now we ' re over here again. there ' s xb at pressure four. pure still in component b. we can repeat the same procedure. collect it. all liquid, put it in a new vessel. expand it, lower the pressure, all goes back into the gas phase. do it all again. and the point is, what you ' re doing is walking along


the same procedure. collect it. all liquid, put it in a new vessel. expand it, lower the pressure, all goes back into the gas phase. do it all again. and the point is, what you ' re doing is walking along here. here to here. then you start down here, and go from here to here. from here to here. and you can purify. now, of course, the optimal procedure, you have to think a little bit. because if you really do precisely what i said, you ' re going to have a mighty little bit of material each time you do that. so yes it ' ll be the little bit you ' ve gotten at the end is going to be really pure, but there ' s not a whole lot of it. because, remember, what we said is let ' s raise the pressure until we just start being on the coexistence curve. so we ' ve still got mostly gas. little bit of liquid. now, i could raise the pressure a bit higher. so that in the interest of having more of the liquid, when i do that, though, the liquid that i have at this higher pressure won ' t be as enriched as it was down here. now, i could still do this procedure. i could just do more of them. so it takes a little bit of judiciousness to figure out how to optimize that. in the end, though, you can continue to walk your way down through these coexistence curves and purify repeatedly the component b, the less volatile of them, and end up with some amount of it. and there ' ll be some balance between the amount that you feel like you need to end up with and how pure you need it to be. any questions about how this works? so purification of less volatile components. now, how much of each of these quantities in each of these phases? so, pertinent to this discussion, of course we need to know that. if you want to try to optimize a procedure like that, of course it ' s going to be crucial to be able to understand and calculate for any pressure that you decide to raise to, just how many moles do you have in each of the phases? so at the end of the day, you can figure out, ok, now when i reach a certain degree of purification, here ' s how much of the stuff i end up with. well, that turns out to be reasonably straightforward to


phases? so at the end of the day, you can figure out, ok, now when i reach a certain degree of purification, here ' s how much of the stuff i end up with. well, that turns out to be reasonably straightforward to do. and so what i ' ll go through is a simple mathematical derivation. and it turns out that it allows you to just read right off the diagram how much of each material you ' re going to end up with. so, here ' s what happens. this is something called the lever rule. how much of each component is there in each phase? so let ' s consider a case like this. let me draw yet once again, just to get the numbering consistent. with how we ' ll treat this. so we ' re going to start here. and i want to draw it right in the middle, so i ' ve got plenty of room. and we ' re going to go up to some pressure. and somewhere out there, now i can go to my coexistence curves. liquid. and gas. and i can read off my values. so this is the liquid xb. so i ' m going to go up to some point two, here ' s xb of two. here ' s yb of two. great. now let ' s get these written in. so let ' s just define terms a little bit. na, nb. or just our total number of moles. ng and n liquid, of course, total number of moles. in the gas and liquid phases. so let ' s just do the calculation for each of these two cases. we ' ll start with one. that ' s the easier case. because then we have only the gas. so at one, 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


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


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


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


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


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


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 potentials. and then we ' ll look at non - ideal solution mixtures next time. see you then.


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 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


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


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


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 tester as returning a boolean, it ' s either gonna be true or false, because something ' s either equal to or not. in many languages, comparisons also return booleans, which is why i went down this slippery slope. for many languages, either it ' s greater than or it ' s not. but python is different. python use cmp, in fact


. in many languages, comparisons also return booleans, which is why i went down this slippery slope. for many languages, either it ' s greater than or it ' s not. but python is different. python use cmp, in fact it has a built in cmp, which is what we ' re relying on here. where am i, right there. and what cmp returns is 1 of 3 values. given 2 objects, it says if the first one is less than the second one, it returns - 1, if it ' s equal it returns 0, if it ' s greater than, it returns 1. so it allows you this broader range of comparisons. and if you think about it, cmp, you could apply on integers, you could apply it on floats, apply it on strings. so it ' s overloaded, it has the ability to do all of those. and in this case what we ' re saying is, given 2 objects, let ' s create a tuple of the first, sorry, family and first name of ourselves, and other is another object, family and first name of that, and then just use cmp to compare them. all right, so it ' s going to use the base pieces. ok, so it gives me a way of doing comparisons. and str we saw last time as well, this is cmp does comparison, and str is our printed representation. ok. so what we ' ve got now, is a simple little class. we ' ve also got two methods there. i want to look at them, we ' re gonna come back to them, but they start to highlight things we can do with our classes. so i ' ve built one simple version of it here, which is per. and notice i ' ve got another method, right up here, called say. and say takes two arguments, for the moment the second argument, or the first argument ' s, not going to make a lot of sense, but say takes two arguments besides itself. it ' s going to take another object to which it ' s saying something and the thing to say. since i only have one object here, i ' m going to have person talk to himself. you may have met a few other undergraduates who have this behavior. i ' ll have him talk to himself and say, just some random message the faculty members occasionally worry about. ok, what does this thing do? now you ' re going to see some of the power of this


undergraduates who have this behavior. i ' ll have him talk to himself and say, just some random message the faculty members occasionally worry about. ok, what does this thing do? now you ' re going to see some of the power of this. again, remember, i ' m down here, i ' m sending this the message say, it ' s going to go up the chain to find the say message in person. and what does say do, it says given another object and some string, it ' s going to return, oh, and interesting things, part of which you can ' t see on the screen. first what it does, is it gets first name of self. remember self is pointing to this instance, so it ' s simply looks up that binding, which is frank. it ' s going to create a string in which it adds to that the family name of self, and then another thing that says to, and then ah, i ' m now going to send a message to the other object, saying give me your first name. going to add that to the second piece, and you can see in this case it happens to be the same first and family name. and then at the end of it, which you can ' t see here but you can see in your handout, i just append the whole string, so it spits it out. what ' s the point of this, other than i can get it to say things? notice, i can now reference values of the instance. but i can also get values of other instances, by sending in a message. and that ' s why we have that form right there. and then it glued all together. if you think about this for a second, you might say, wait a minute, actually you might have said wait a minute a while ago, why am i just using the variable name there in the function over here? well in fact, i could ' ve used the function here, first name open close, right? it would have done the same thing. but because i know i ' m inside the instance, it ' s perfectly reasonable to just look up the value. ok, i could have, although i don ' t want you to do it, have done the same thing there and used underbar, sorry, first name underbar, sorry, first underbar name, but that ' s really breaking this contract that i want to happen. i should send the message to get the method back out. so again the standard


there and used underbar, sorry, first name underbar, sorry, first underbar name, but that ' s really breaking this contract that i want to happen. i should send the message to get the method back out. so again the standard practices is if you know you ' re inside the object, you can just access the values. if you ' re doing it with any other objects, send it a message to get it out. ok, now, that gives you an ability to say, let ' s look at one more example here, and then we ' re going to start building our hierarchy, which is, that this person can also sing. and we ' ve got a little sing method here. and notice what it does, it ' s going to sing to somebody, i guess you ' re part of the chorallaries. you ' re going to sing something, and notice what it does, it ' s simply going to use its say method, but add at the end of whatever ' s being said, just tra la la at the end. so this is now an example of a method using another method. why would you want that? it ' s nice modularly. i have one method that ' s doing saying, i have another method that ' s just building on it. so if i have is person sing to themselves, not a highly recommended activity, it would help if i had it sing to itself, not sing to sing, sorry about that. notice what it does. looks like exactly like a say method, except it ' s got tra la la at the end. don ' t worry i ' m not going to sing to you. i ' ll simply say the words. power of this, other than the silly examples. you see how i can access variables of the instance, how i can access variables of other instances, going to come back to that, and how i can use versions of my own methods to implement other methods. in this case sing is using say as part of what it wants to get out. ok, so we got a simple little example. now, let ' s start adding some other pieces to this. ok, and what do i want to add. find my spot here. ok, we ' re going to add an mit person. sorry, machine is - - do this, let ' s go down. ok so i ' m going to add an mit person. look at the code for second. aha! notice what this says. mit person


to add an mit person. sorry, machine is - - do this, let ' s go down. ok so i ' m going to add an mit person. look at the code for second. aha! notice what this says. mit person says it inherits from person. that is, that ' s the first thing in parens up there. it says, you know, class of mit person is person. what that is saying is, that this is a specialization of the person class. or another way of saying it is, we have a super class, in this case it ' s person. and we have a subclass, in this case its mit person. and we ' re going to walk through some examples, but what it says is that that subclass of mit person can inherit the attributes of the person class. can inherit the methods, it can inherit variables. ok, what does mit person do? well, here ' s 1 of the new things it does. it has a local variable called next id num, which is initially set to 0. see that up there. and then it ' s got some methods, it ' s got an init method, a get id method, a few other things. ok, let ' s run this. in particular, i go back down to this one. let me just uncomment this and do it here. assuming my machine will do what i want it to do, which it really doesn ' t seem to want to do today. try one more time. thank you, yep. still not doing it for me, john. ok, we type it. no idea what python doesn ' t like me today, but it doesn ' t. so we ' re gonna define p 1, i ' ve lost my keyboard, indeed i have. try one more time. p 1 mit person, see how fast i can type here - - ok, now, let ' s look at what the code does, because again it ' s going to highlight some things. i called mit person, push this up slightly, it ' s going to create an instance down here, i called p 1. and when i would do that, i ' m gonna initialize it. so i ' ve got, right up here, an initializer, init for mit person, takes in the family name and the first name. notice what it does. huh. it says, if i ' m sitting here at mit person, i ' m going to go up and


here, an initializer, init for mit person, takes in the family name and the first name. notice what it does. huh. it says, if i ' m sitting here at mit person, i ' m going to go up and inherit from person its init function and call it. and what am i calling it on? i ' m calling it on self, which is pointing to this object, so i ' ve still got it, and then i ' m then going to apply the base initialization. and that does exactly what you ' d expect, which is just going to create a binding for family name down here. as well as some other things. so this is an example of inheritance. mit person inherits the init method from person, can get access to by simply referring to it, and i refer to it right there. and it ' s take the person class, get its init and apply it to my instance plus those things. so i ' m just using the same piece of code notice the second thing it does. it says inside of self, i ' m going to bind the local variable id name to the value of next id name in mit person. self is down here, id num, sorry, not id name. i ' m going to bind that to the value that i find my going up to here, which is 0, and having done that, i simply increment that value. ok? so what has this done? it says i now have captured in the class, a local variable that i can keep track of. and when i use it, every time i generate an example, let me build another one. i make p 2 another mit person. ok, i can do things like saying, what is the id number for each of these. first one is 0, second one is 1, which makes sense, right? i ' m just incrementing a global variable. now, things i want you to see about this. now that i ' ve got a beginning of a hierarchy, i have this notion of inheritance. i can ask a function inside one class to use a function from a class that it can reach by going up the chain. i just did it there. i can ask it to go get values of variables, right, so that looks good. what else do we have in person or mit person? well, we can get the id number, we just did. we have a thing to do with this string. notice it ' s


get values of variables, right, so that looks good. what else do we have in person or mit person? well, we can get the id number, we just did. we have a thing to do with this string. notice it ' s going to print out something a little different. in fact, there ' s a kind of funky form there. which just says, if i want to print it out, i ' m gonna create, what this says to do is, i ' m gonna create an output template that has that structure to it, but where i see that percent s i ' m going to substitute this value for the first one, that value for the second. so if i say, what is p 1? it says ok, mit person fred smith. on the other hand, if i said, what is per, which is that thing i build earlier, it had a different string method, which is just print out person, those pieces. all right, one last piece to this and we ' re going to add to it. suppose i want fred to say something. say something to jane. ok, he said it. where ' s the say method? ok, fred is an instance of an mit person. where ' s the say method? well, there isn ' t one there, but again, that ' s where the hierarchy comes in. fred is this object here, i ' m sending it the message say. that turns into going up the chain to this object, which is the class object, and saying find a say method and apply it to that instance. fudge - knuckle, it ain ' t here. don ' t worry about it, because it says if i can ' t find one there, i ' m going to go up the chain to this method, sorry to this class, and look for a method there. which there was one, i have a say method. it ' s going to use that say method. apply to it. well, you might say, ok, what happens if it isn ' t there? well, that ' s where, remember i defined person to be an instance of an object, it will go up the chain one last time to the base object in python to see is there a method there or not. probably isn ' t a say method for an object, so at that point it ' s going to raise an exception or throw an error. but now you again see this idea that the inheritance lets you capture methods. now you might


there or not. probably isn ' t a say method for an object, so at that point it ' s going to raise an exception or throw an error. but now you again see this idea that the inheritance lets you capture methods. now you might say, why not just put a say method inside of mit person? well, if you wanted it to do something different, that would be the right thing to do. but the whole notion here ' s that i ' m capturing modularity, i ' ve got base methods up in my base class. if i just want to use them i ' m just going to inherit them by following that chain, if you like, basically up the track. ok, so we ' ve got an mit person, we can use that. let ' s add a little bit more to our hierarchy here. i ' m going to create, if i can do this right, a specialization of an mit person, which is an undergraduate. a special kind of mit person. all right, so if i go back up here, even though my thing is not going to let me do it, let ' s build an undergraduate. ok, there ' s the class definition for an undergrad. we ' re just starting to see some of the pieces, right, so in an undergraduate, where am i here, an undergraduate. ok, it ' s also got an initialization function. so if i call undergrad, i ' m gonna make an undergrad here, again let me go back down here, line ug 2 it ' s making undergrad, jane doe. now, what happens when i do the initialization here? notice what goes on. it simply calls the person initialization method. all right, so i ' m down here. i ' m going to call the person initialization method, what did do? sorry, the mit person method, it calls the person method. just walking up the chain, that ' s going to do exactly what i did with all the other ones, so i now have a family name and a first name. so i can, for example, say family name and get it back out. all right? and then, other things that i can do, well i can set what year the person ' s in, i can figure out what year they ' re in, there ' s this unfortunate overflow error if you ' ve hung around too long, but that ' s not going to happen to you. and i ' ve now got a say method


in, i can figure out what year they ' re in, there ' s this unfortunate overflow error if you ' ve hung around too long, but that ' s not going to happen to you. and i ' ve now got a say method here, so let ' s look what happens if i ask the undergraduate to say something. ok, it ' s not a realistic dialogue i know, but, what did this method do? i asked this object to do a say. and notice what it does. it simply passes it back up to mit person. there ' s that inheritance again. it ' s saying, i ' m going to have my base say method say something. i ' m going to say it to a person, but all i ' m going to do because undergraduates in my experience, at least, are always very polite, i ' m going to put " excuse me but " at the front of it. ok, what am i trying to show you here? i know the jokes are awful, but what am i trying to show you here? that i can simply pass up the chain to get it. in fact, what method does the final say here? what class does it come from? person class, yes, thank you. it goes all the way up to person, right, because mit person didn ' t have a say. so i can simply walk up the chain until i find the method i want to have. now this is an example of shadowing. not a great example, but it ' s a beginning example of shadowing, in that this same method for an undergraduate, shadows the base say method, it happens to call it, but it changes it. it puts " excuse me but " at the front, before it goes on to do something. now again, i could have decided here to actually copy what the original say method did, stitch all the other things together. but again, that loses my modularity. i ' d really to only have to change it in one place. so by putting my say method up in person, i can add these nuances to it, and it lets me have something that has that variation. if i decide i want to change what say does, i only have to change it in one place. it is in the person class definition, and everything else will follow through for free. ok, so now i ' ve got an undergrad, right? let ' s look at a couple of variations of what happens here. so first of all


. it is in the person class definition, and everything else will follow through for free. ok, so now i ' ve got an undergrad, right? let ' s look at a couple of variations of what happens here. so first of all, i can - - yes? professor 2 : shadowing here is often sometimes called overriding. professor : yes, thank you, because i ' m going to do a pure example of shadowing in a second, john right. also called overriding. part of the reason i like the phrase shadow is, if you think about it as looking at it from this direction, you see this version of init before you see the other ones, or you see that version of say, but it is overriding the base say example. ok, so i can say, what does p 1, sorry, yes, what does undergrad look like? and i said wait a minute, mit person, not undergrad, is that right? well, where ' s the str method? i didn ' t define one in undergrad, so it again tracks up the chain and finds the str method here, so it ' s ok undergrads are mit people most the time, so it ' s perfectly fine. ok, now, i have built into this also these cmp methods. so i ' ve got two examples. i ' ve got undergrad, or ug. and then i ' ve got poor old frank foobar back there, per person. so suppose i want to compare them? what do you think happens here? compare sounds weird, right, i compare an undergraduate to a person. i don ' t know what that ' s doing, some kind of weird psychological thing, but what do you think happens in terms of the code here if i run this. i know it ' s a little hard because you got a lot of code to look at. do i have a cmp method defined somewhere? yeah. so, it ' s hard to know what it ' s going to do, but let ' s look at it. hmm. now sometimes i type things and i got errors i don ' t expect, this one i did expect. so what happened here? well let ' s talk about what happens if i do that comparison i was doing, what was i doing? ug greater than per? what unwinds into is, i ' m going to send to ug, that instance, a cmp method. this is really going to


if i do that comparison i was doing, what was i doing? ug greater than per? what unwinds into is, i ' m going to send to ug, that instance, a cmp method. this is really going to become something like ug dot under under cmp under under applied to per. i think that ' s close. what does that do? it says starting in ug, i ' m going to look for the first cmp method i could find, which is actually sitting here. i had a cmp method in mit person. if you look at your code, what does it do? it looks up the id numbers to compare them. well the, ug has an id number because it was created along this chamber. remember per over here was just created as a person. it doesn ' t have an id number, so that ' s why it complaints. ok, happens if i do that? compare per to ug. how many people think i get an error? wow. how many people think i ' m going to get either true or false out of this? a few brave hands. why? can i ask you, please? why do you think i ' m going to get a, doesn ' t matter whether it ' s true or false, why am i going to have something work this time that didn ' t work last time? professor : yeah, exactly. and in case you didn ' t hear it, thank you, great answer, sorry, terrible throw. in this case i ' m using per, that ' s the first part, so it ' s not symmetric. it ' s gonna use per to do the look up. and as it was said there, per over here goes up and finds a cmp method here which it can apply. in that case, it simply looked at, remember, it took the tuples of first and last name which are both defined here, and did some comparison on that. so this is a way of again pointing out to you that the things are not always symmetric, and i have to be careful about where do i find the methods as i want to use them. ok? all right. let ' s add, i ' m gonna do two more classes here. let ' s add one more class, some people debate whether these are really people or not, but we ' re going to add a class called a professor. ok. now what am i doing? i ' m creating another version of class down here


let ' s add one more class, some people debate whether these are really people or not, but we ' re going to add a class called a professor. ok. now what am i doing? i ' m creating another version of class down here. which again is an instance, or a subclass, sorry, not an instance, a subclass of an mit person. i see that because i built it to be there. again i ' ve got an initialization that ' s going to call the person initialization, which we know is going to go up - - i keep saying that - - going to call the mit person initialization, which is going to go up and call this one. so again i ' m going to be able to find names. and i do a couple of other different things here. i ' m gonna pass in a rank, full professor, associate professor, assistant professor, which i ' m just going to bind locally. but i ' m gonna add one other piece here, which is i ' m gonna add a little dictionary on teaching. so when i create a professor, i ' m gonna associate with it a dictionary that says, what have you been teaching? and then notice the methods i create. i ' ve got a method here called add teaching, takes, obviously a pointer to the instance. a term, which will just be a string, and a subject. and let ' s look at what it does right here. ok. in fact the call i ' m going to make, i ' m not certain i ' m going to be able to get away with it, my machine is still wonderfully broken, all right, it is, let me just show you what the calls would look like. as you can see here i ' m not going to be able to do them. but i ' m going to add teaching, as a method call with this with a string for term, and a subject number. what is this going to do? yeah, i know i ' m just worried if i restart python, i may not be able to pull the thing back in, so i ' m going to try and wing it, john, and see if i can make it happen. right, what does that teaching do? it ' s got one of those try except methods. so what does it say it ' s going to do? it ' s going to go into the dictionary associated with teaching, under the value of term, and get out a list. and it ' s


s got one of those try except methods. so what does it say it ' s going to do? it ' s going to go into the dictionary associated with teaching, under the value of term, and get out a list. and it ' s going to append to the end of the list the new subject. so it ' s going to be stored in there, is then going to be term, and a list of what i taught, in case i teach more than one thing each term. it ' s going to do that, but notice it ' s a try. if in fact there is no term currently in the dictionary, started out empty, it ' s going to throw an error, sorry, not throw an error, it ' s going to raise an exception. which is a key error, in which case notice what i ' m going to do, i ' m not going to treat it as an error. i ' m simply going to say, in that case, just start off with an empty, with an initial list with just that subject in and put it in the dictionary. as i add more things in, i ' ll just keep adding things to this dictionary under that term. and if i want to find out what i ' m doing, well i can use get teaching, which says given the term, find the thing in the dictionary under that term and return it. if i get an error, i ' m going to raise it, which says there is nothing for that term, and in that case i guess i ' m just going to return none. ok? and then the other two pieces we ' re going to have here, and we want to look at a little more carefully, i just wanted to show you that example, is a professor can lecture, and a professor can say something. look at the say method, because this now add one more nuance to what we want to do here. and i think in interest of making this go, let me actually, since i ' m not going to get my machine to do this right, let me create a couple of professors. if i look at what that is, it ' s an mit person because i didn ' t have any separate string thing there, and we will create a more important professor. what rank do you want, john? do you want to stay full? professor 2 : undergraduate. professor : undergraduate, right, a lot more fun i agree. sorry about that, and we can again just see what that looks like.


professor. what rank do you want, john? do you want to stay full? professor 2 : undergraduate. professor : undergraduate, right, a lot more fun i agree. sorry about that, and we can again just see what that looks like. and that of course, we ' ll print out, he ' s also an mit person. but now here ' s what i want to do. i want to say something to my good colleague professor guttag. actually i ' m going to start a separate - - i ' m going to say something to a smart undergraduate. so if i say, remember we have ug defined as an undergraduate, let me do something a little different here. well let, me do it that way. it says, i don ' t understand why you say you were enjoying 6. 00. not a good thing to say, right, but if i say to my good colleague professor guttag. i have to spell say right, i know, i need help with this, what can i say? we flatter each other all the time. it ' s part of what makes us feel good about ourselves. why is the sky blue? i enjoyed your paper, but why is the sky blue? ok, terrible examples, but what ' s going on here? one more piece that i want to add. here ' s my say method for professor, and now i ' m actually taking advantage of to whom i am saying something. notice again, what does it do? there ' s the self argument, that ' s just pointing to the instance of me. i ' m passing in another argument, going to call it to who, in one case it was ug, in one case it was guttag. and then the thing i want to say, ah, look what it does, it says, check the type. and the type is going to take that instance, i had an instance, for example, of a professor down here, and it ' s going to pick up what type of object it is. so if the type of the person i ' m speaking to is undergrad, let ' s pause for second. remember i started away back saying we ' re building abstract data types. well, here ' s a great example of how i ' m using exactly that, right? i ' ve got int, i ' ve got float, i now have ug, it ' s a type. so it ' s says if the object to whom i ' m speaking is an under


i ' m using exactly that, right? i ' ve got int, i ' ve got float, i now have ug, it ' s a type. so it ' s says if the object to whom i ' m speaking is an undergrad, then use the same method from person where i ' m going to put this on the front. on the other hand, if the object to whom i ' m speaking is a professor, then i ' m going to tag this on the front and use the underlying say method. on the other hand, if i ' m speaking to somebody else, i ' m just going to go lecture. all right, and when a professor lectures, they just put it ' s obvious on the end of things, as you may have noticed. what ' s the point i want you to see here? i ' m now using the instances to help me to find what the code should do. i ' m looking at the type. if the type is this, do that. if the type is this, do something different, ok? and i can now sort of build those pieces up. ok, i said one more class. notice what we ' re doing. i know they ' re silly examples, but, sorry, they are cleverly designed examples to highlight key points. what i ' m trying to do is show you how we have methods inherit methods, how have message shadow methods, how we have methods override methods, how we can use instances as types to define what the method should do. let me show you one last class, because i ' m gonna have one more piece that we want to use. and the last class is, sort of, once you ' ve got a set of professors, you can have an aggregate of them. and i don ' t know, if a group of geese are gaggle, i don ' t know what a set of professors are, john. flamers? i, you know, we ' ve got to figure out what the right collective noun here is. we ' re going to call them a faculty for lack of a better term, right? now the reason i want to show you this example is, this class, notice, it only is going to inherit from object. it actually makes sense. this is going to be a collection of things, but it ' s not a subclass of a particular kind of person. and what i want the faculty to do, is to be able to gather together a set of faculty. so if


sense. this is going to be a collection of things, but it ' s not a subclass of a particular kind of person. and what i want the faculty to do, is to be able to gather together a set of faculty. so if i go down here, grab this for second, and pull it down so you can see it. it looks like i ' m not going to be able to run this because my machine is broken, but basically i ' m gonna define a set of professors, and then i ' m gonna create a new class called faculty. there ' s the definition of it. it ' s got an init. you can kind of see what it does. it ' s going to set up an internal variable called names, which is initially an empty list, internal variable called ids, which is empty, an internal variable called members, which is empty, and another special variable called place, which we ' re going to come back to in a second, initially bound to none. ok, i ' ve got a method called add which i ' m going to use down here to add professors to the course 6 faculty. here ' s what i want to add to do. first of all, notice i ' m going to check the type. if this is not a professor, i ' m gonna raise an error, a type error, it ' s the wrong type of object to pass in. the second thing i ' m gonna do is say, if that ' s okay, then let me go off and get the id number. now remember, that ' s right up here, so i ' m asking the instance of the professor to go up and get the id number. and i want to make sure i only have one instance of each professor in my faculty, so if the id number is in the list of ids already, i ' m going to raise an error, sorry, raise an exception as well, saying i ' ve got a duplicate id. ok? and the reason that ' s going to come up is, notice what i do now. inside of the instant self, i take the variable names and i add to it the family name of the person i just added. ok, notice the form. i ' m using the method, there ' s the parens to get the family name of the person. i ' m just adding it to the list. i ' ve got the id number, i ' ve added the ids, and i add the object itself into members


, there ' s the parens to get the family name of the person. i ' m just adding it to the list. i ' ve got the id number, i ' ve added the ids, and i add the object itself into members. so as i do this, what am i doing? i ' m creating a list, actually several lists : a list of ids, a list of the actual instances, and a list of the family names. and as a cost i want to add, that ' s why i can check and see, is this in here already or not? now, the last reason i want to do this is, i want to be able to support things like that. this is now different, right, this instance is a collection. i want to be able to do things like, for all the things in that collection, do something, like print out the family names. and to do that, i need two special forms : iter and next. ok, now let me see if i can say this cleanly. whenever i use a for, in structure, even if it was on just a normal list you built, what python is doing is returning an, what is called an iterator. which is something that we talked earlier. it ' s keeping track of where are you in the list, and how do i get to the next thing in the list? i ' m going to do the same thing here, and i ' m going to create it for this particular structure. so this little thing iter, when i call a for something in, one of these instances, it calls iter, and notice what it does. it initializes place to 0. that was that variable i had up there. that ' s basically saying i ' m at the beginning of the list. it ' s a pointer to the beginning of the list, and it returns self. just gives me back a pointer to the instance. that now allows me at each step in that loop to call next. and what does next do? next says, check to see if that value is too long, if it ' s longer than, for example, the list of names, raise an exception called stop iteration, which the for loop will use to say ok, i ' m done. i ' m going to break out of the for loop. otherwise, what am i going to do? i ' ll increment place by 1, that ' s going to move me to the next place in


ok, i ' m done. i ' m going to break out of the for loop. otherwise, what am i going to do? i ' ll increment place by 1, that ' s going to move me to the next place in the list, and then in this case i ' ll just return the instance itself, right? members is a list of instances, place i ' ve incremented by 1, i take 1 off of it, i get to it. so iter and next work together. iter creates this method, that ' s going to give you a pointer to the place in the structure, and then next literally walks along the structure giving you the next element and returning elements in turn so you can do something with it. right, so now what that says is, i can have classes that just have local variables. i can have classes that get methods from other variables, and i can also have classes that are collections. and i ' ve supported that by adding in this last piece. ok once you have all of that, in principle we could start doing some fun things. so let ' s see what happens if we try and make all of this go. and let me, since i ' m not going to be able to run it, let me simply do it this way. if i have my undergraduate, ug. i can - - sorry, let ' s not do it that way - - i can have undergraduate say things like - - all right, what did i just do wrong here? do i not have undergrad defined? i do. oh, i didn ' t have grimson, sorry, it ' s me, isn ' t it? thank you. the undergraduate very politely asks why he didn ' t understand, you can have the professor respond. again, it simply puts a different thing into there. on the other hand, if professor guttag asks me something about understanding, i say i really like this paper on, you do not understand, it ' s a deep paper on programming languages 5, i think, john, isn ' t it? what else can you do with this thing, right? you can have an undergraduate talk to an undergraduate, in which case they ' re still polite. or you could have - - sorry, let me do that the other way - - you could also have an undergraduate simply talk to a normal person. all right, but the good news is you know eventually you get it done, and when you ' re really done you


- - sorry, let me do that the other way - - you could also have an undergraduate simply talk to a normal person. all right, but the good news is you know eventually you get it done, and when you ' re really done you can have the undergraduate be really happy about this, and so she sings to herself. ok it ' s a little silly, but notice what we ' ve just illustrated. and this is where i want to pull it together. with a simple set of classes, and the following abilities, an ability to inherit methods from subclasses, sorry from superclasses, that is having this hierarchy of things. i can create a fairly complex kind of interaction. i can take advantage of the types of the objects to help me decide what to do. and if you think about that, i know it sounds very straightforward, but you would do exactly that if you were writing earlier code to deal with some numerical problem. all right, if the thing is an integer, do this, if it ' s a float, do that, if it ' s a string, do something else. i ' m now giving you exactly the same ability, but the types now can be things that you could create. and what i ' ve also got is now the ability to inherit those methods as they go up the chain. so another way of saying it is, things that you want to come away from here, are, in terms of these classes. we now have this idea of encapsulation. i ' m gathering together data that naturally belongs as a unit, and i ' m gathering together with it methods that apply to that unit. just like we would have done with float or int. ideally, we data hide, we don ' t happen to do it here, which is too bad. basically we ' ve got the idea of encapsulation. the second thing we ' ve got is this idea of inheritance. inheritance both meaning i can inherit attributes or field values. i can inherit methods by moving up the chain. i can also the shadow or override methods, so that i can specialise. and i do all of that with this nice hierarchy of classes. so what hopefully you ' ve seen, between these two lectures, and we ' re going to come back to it in some subsequent lectures, is that this is now a different way of just structuring a computational system. now, you ' ll also get arguments, polite arguments from faculty members or other experts about which is a better


talk : 20. 109 ( f12 ) pre - proposal : engineering viral magnetic nanoparticles for magnetic hyperthermic cancer therapy - this is a brainstorming page. you are very welcome to write any crazy / non - crazy / inventive / conventional / knowledgeable ideas or information you may have about our project. some key words : magnetic nanoparticles ( mnp ), viruses, magnetic hyperthermia, bioengineering what is magnetic hyperthermia? how it works? under an alternating magnetic field, mnp releases heat due to relaxation of magnetic moments ( hysteresis ). this can cause an increase in temperature to the range of 41c to 47c. since tumor cells are more heat sensitive than normal cells, they will be killed by this thermal dissipation. here is an interesting tidbit from a paper i was reading : " in addition to the expected tumor cell death, hyperthermia treatment has also induced unexpected biological responses, such as tumor - specific immune responses as a result of heat - shock protein expression. these results suggest that hyperthermia is able to kill not only local tumors exposed to heat treatment, but also tumors at distant sites, including metastatic cancer cells. " ( kobayashi ) - clinical trials in prostate cancer - shows promising results when coupled with irradiation on breast cancer ( mouse ) current limitations ( this information will help us shape and define the problem. ) ( 1 ) to achieve the necessary rise in temperature with minimal dose of mnp. - in other words, this means : - high specific loss power / specific absorption rate ( slp ) of the mnp. - why is higher applied dosage bad? > leads to unnecessary heat dissipation ( 2 ) lack of knowledge about the metabolism, clearance, and toxicity of mnp. biomedical potentials of mnp - could be used as early detection for the following using mri : - drug delivery - cellular labeling and tissue targeting - purifying and separating cells and dnas - transfection by magnetic nanoparticles - tissue repair - magnetic resonance imaging ( mri ) types of relevant viruses 1. tobacco mosaic virus ( tmv ) - 18nmx300nm, helical - can withstand high temperatures up to 50c for 30mins ( conventional hyperthermia involves heating up to 50c from an external source - safe for human consumption - mann group has active research on it - 2130 molecules of coat protein 2. m13 bacteriophage -