 now we are going to do the grand canonical ensemble and grand canonical ensemble I will not do in great detail so now the way this is constructed is the following so we already said and this is something you really should need to understand and the best place to understand these things I have done try to do a good job in explanation these things but another person who has done a good job no didn't have the figures and pictures is the Terrell Hill that's the second best place to look into other than my book so now what we did in doing the canonical partition function we put the large number of systems characterized by NVT but each of them have different energy levels because energy is not constant in NVT we put them together in contact with each other and then we put it in a bath and we let the temperature go to constant T when the temperature has equilibrated we take it out and then we put an insulation around this so that becomes with these large number of systems so the micro canonical ensemble becomes the whole micro canonical ensemble becomes a super system in a canonical now I put a canonical ensemble by making so my insulated system is now forms a system of my micro canonical the whole idea of doing going back from canonical to micro canonical is that I can use the principles of micro canonical ensemble which is essentially s equal to kv ln omega but now because of my construction of super ensemble and super system I am now handicapped with two constraints one is the total number of systems that constitute my ensemble is ns total ns then and the energy is also conserved so I need to go to conservation of energy because I need to go back to micro canonical ensemble if I do not go to micro canonical ensemble I cannot use s equal to kv ln omega so I go that and then I put omega the way to distribute now each system has a different energy so I distribute but so nj is the in index nj is the number of systems in energy level j so it is the different nj is not what you have usual thing so it is this whole system that we are considering and the system has energy level ej so nj so with that the constraint and the combinatorics the multinomial expression of the total omega we go on and did the calculations going back and forth between micro canonical ensemble and the canonical and we derived all that we derived and it is a formidable exercise next level then now I want to let so I have allowed energy to fluctuate in lieu of the intensive variable temperature now I am going to let total number of particles fluctuate because that is very important in many many application the total number of particles like here you are undergoing a chemical transformations or phase transition total number of particles not conserved like you have a gas liquid at equilibrium then the molecules are exchanged between the two phases that is so when we allow that the next level I allow the fluctuation of number or change of number then that is the canonical ensemble and so we do the again the same thing we put my grand canonical things and we now replace the wall like be in a canonical we let the system interact energetically so the walls are porous to exchange energy but not number now I make the walls porous that number of particles can also exchange then I do I take my all these porous system put them together put it in a kind of chemical potential bath so that I ensure by the particles coming whatever particle want to come in come back they equilibrate in addition I have the thermal bath so the system has now constant energy constant chemical potential and constant temperature and the huge number of that so from grand canonical I first go to canonical then from canonical I go to macro canonical so the before I had one step now I have two step process and then I play the same game that I played which is I had two constant now I have three constant because not only the total number I also have energy and as a result of that I will now have three undetermined multipliers one of them again becomes alpha one is beta and this gamma and the form that comes in at the end of the day I have instead of having one sum which is sum over g levels I also have because each system has different number of particles so I have sum over n and this is the conservation condition that comes in I am not going to do through the whole thing but it just parallels the whole thing that I am not going to do so now I in addition to having so now I have the following double probability probability that my system in energy level Ej so j is the index for the energy of the system and n is the index for the number of particles in the system so pj is now defined by nj by n which is the normalization so if I this condition is my probability bare probability then I have to normalize it by summing over all these things and this comes from the undetermined multiplier so probability a system as n number of particles and in energy level j is now given by things e to the power minus gamma n and beta is one over kbt then one under goes through another exercise and the derivation at the end of the day one shows that this e to the power minus gamma you know what is the quantity to the minus gamma so what happens that yeah so e to the power gamma n so yeah so this becomes one is a chemical potential another is becomes fugacity so e to the power minus gamma that becomes z fugacity but I can also write gamma is the chemical potential as you correctly said so beta is one over kbt and this is the chemical potential though I usually like mu but I think one has followed the notation of mac query here so this is the probability distribution and this is the canonical potential function then one does the realize here that I take let me write down that since this is the kind of repeat is the same thing we did in so okay there are many possible notations of this canonical potential function the okay I have used this one the reason is that Z is taken away I will explain to why Z is capital Z is taken away so this is now number of energy levels then this e to the power minus beta e j e to the power minus gamma z is put in e to the power minus gamma which is the this fugacity this is the potential then this is now this e j so I can take the sum out I can take the sum e j I can do beta e j so this energy of a system at a character is by n and v so this is then is the canonical potential function so this thing is now is really very nice so this is the definition of the canonical potential function you know I don't want to go through the detail because it is more elaborate but essentially repetition of what we did and it just will bore you and will rob you of the beauty of the whole thing but this expression is just beautiful this is a rotation I always use and now one can play the same game again same thermodynamics that you played before by going over all the way back and forth again you have to write the entropy but now entropy you will write as entropy is pj ln pj which is now a function of also vn and same thing you will do and then you come to this beautiful relation that in grand canonical ensemble so we call this term kbtln is the thermodynamic potential so let me write down all three you will see the beautiful symmetry and I mentioned before that all these things was just done by one person so s equal to kb a actually many people say you will put it like that so this is micro canonical this is canonical and this is grand canonical and everywhere you have to get the extremum of the quantity so on the left hand side that I have written is the quantity that has to be maximized why because partition for the system is something quite remarkable but that is that you have you have to find the macroscopic state of the system and so macroscopic state of the system many times when we try to say the crystal transition we said the going to iron going to fcc lattice from the melt then what do you do you have to find out which state is most stable or you want to understand utilization the formation of the critical droplet or you want to do osmosis or all this phenomenon that we study which equilibrium we treat them as equilibrium phenomena nucleation as a dynamic part but we will do that later in that case you have to find out okay so why do I decrease the temperature and melt will go to a crystal or liquid will go to a crystal that has to be selected how is it selected I go and maximize the thermodynamic potential and that principle or maximum will will bring out that state which is given by the density or other order parameter or characteristics function these calculation will show that how it will select because if I plot the free energy then free energy against let just be very simple gas liquid so density then at a coexistence they have the same free energy but when I go below so this is liquid this is gas but when I go to lower temperature temperature this is the control parameter then this becomes like that so when I now do my statistical mechanics and calculate the free energy and minimize the free energy or maximize thermodynamic potential if I am in grand canonical then I have to maximize pd okay then I will see this thing will that maximum will give you a solution which is will give the low temperature will be the liquid state okay so it is a principle of extremum that controls the thermodynamics and that is what we call the free energy has to be minimum which essentially we are saying that state will be selected which has the maximum partition function and yes sure this is extremely good question I should talk about it tomorrow so that is the answer to this question will be answered in it will be answered in many different ways one of them is that when you go to grand canonical partition function you are allowing number fluctuation what can be shown that this number fluctuation is decreases when n goes to infinity so that is a very strong theorem essentially comes from poverty theory that in the limit of infinite system predictions of all three becomes the same for example if you try to do gas liquid equilibrium even in computer simulation in in a canonical ensemble you will never see the flat isotherm you always see a Maxwell loop which is unrealistic Maxwell correctitude that because the fluctuations that are necessary are not captured in the canonical ensemble the number fluctuations you can of course get rid of the loop if you go to the limit of infinite system and you can see by increasing system size that artificial loop goes down because fluctuations are coming in so the answer to your question that as you go to infinite system size beneath all the systems micro canonical canonical grand canonical and there is one little bit will dwell on tomorrow is isothermal isobaric ensemble then there is a Gibbs ensemble all these ensembles they all become if the grand canonical is still mu vt you know we still have to replace the extensive variable one is remaining the v that has to be replaced by p when you do mu pt that is a Gibbs ensemble an isothermal isobaric is npt so there are two more ensembles that people use so npt is the one which is most of the time computer simulation people use okay and however the thermodynamic potential which is so uniquely comes out in these three partition functions do not come there but there are ways to think about it so answer to your question in fact when in the limit of infinite system size all the ensembles give identical result and that can be proven that's a mathematical statement but this is really formidable and beautiful construction that gives deep sitting quietly alone is one of the most powerful theoretical framework that we use anything else in molecular dynamics in grand canonical i have not known people must have done but i don't know what kind of see how does molecular dynamics simulation go molecular dynamics go through introducing thermostat introducing barostat barostat takes care of the pressure thermostat takes care of the temperature so these are the kind of coupling to the bath you introduce remember how do you reintroduce thermostat whenever velocity of your one particle and when the temperature goes up you scale the velocity of every particle very artificial way and when temperature goes down you upscale the velocity of every particle this is called void scaling now if you come to pressure similarly whenever fluctuation pressure becomes less you barostat you lower the volume and when the pressure becomes large you release the volume that is the allowing volume fluctuation that's how your pressure barostat works okay just like piston just like piston so now you have to think of how to get the number of particles so you need another like thermostat barostat what knows one number stat so number stat will allow you to increase the fluctuation now if i am doing a simulation in a grand canonical ensemble where number of particles can leave the system then you have to use a a reservoir rule now barrel you know thermostat we use valet rule and some other rules pressure we use berenzen and nosy hoover there must be have been done but i don't know that in grand canonical what is happen when you do barrel stat or you do nosy hoover there are certain rules coming from conservation which allows you to write an equation so you need to write an equation that your pressure goes up then that there is a systematic way to bring it back down thermostat there is a systematic way to bring the temperature back you know it is not heuristic it has to obey certain rules those rules or equations whether they have been done for grand canonical ensemble i have certainly it has done but it certainly not a popular way i have never in my entire life use molecular dynamics in grand canonical if because i think we do canonical then isothermal isobaric and micro canonical i have not seen but you can do the literature such if anybody has done