[MUSIC] Hi and welcome again to the fifth week of our class, simulation and modeling of physical processes. This module will be about the collision step and the BGK model, and that is both on simulations. Before we talk about the details of the collision state, let's try to understand the variables which we call the populations a little bit better. So far, we have interpreted the populations as being averages of the particles which you have in the lattice gas automaton. This is right, and this is an easy way to develop the theory of the lattice Boltzmann. But there exist an alternative interpretation, you can also actually interpret these populations as averages of molecules in a real gas. There exists a branch of physics which investigates the physics of gases, it's called kinetic theory. In which we describe gas densities as through a single variable which is called the probability density function F, which depends on space and time. But also on the molecular velocities, it describes the probability density to find a given position in space. A certain molecule with a velocity which is close to v, the equations of motion for this probability density function is given by an equation called the Boltzmann equation. And this is of course the reason why they make us keen which we developed today is called the Lattice Boltzmann method. But, back to the question what's the value of the populations or of the probability density function. Imagine that a gas is microscopically addressed. For example, the air in a room if you don't shake it or move it. If it does not move. If you look at the molecules microscopically they are moving anyway. It's just that their average value is zero. They are moving, and they have velocities which are distributed according to certain law. They are distributed at one point in space, they are distributed over the space of velocities. According to a Maxwell-Boltzmann distribution, which is just a Gaussian distribution centered around the average velocity of the Gaussian. For example, zero. When a gas is completely at rest, the molecules have an equilibrium distribution, but even when it's not at rest when it is moving, it will be close to the equilibrium, it will just be a perturbation around this equilibrium. Which means that the equilibrium distribution is the starting point for the gas at the dynamics are perturbations around the state. Therefore it makes sense to write an Omega model and in particular the collision of molecular model which is quite scattered as a perturbation around the equivalent distribution of a gas in it's rest state. This is what we are doing in Lattice Boltzmann. Today we are working with a special collision which comes from the widely used BGK Lattice Boltzmann model. There exists all the models but this is the simplest one which would be our workforce today. In this model, we say that the difference between outgoing and incoming populations in a certain direction i is proportional to the difference to the current perturbation of the populations from the equilibrium value around a given density and velocity. In this way, the actual dynamics of the graph is a relaxation to which its equilibrium stayed. The frequency of relaxation is called omega. On this part in front, on the right hand side of the equation, in front of the difference between populations and their equilibrium state. What's the meaning of this parameter on the omega? Omega is related to the viscosity of the fluid. Imagine intuitively the difference between a highly viscous and a lowly viscous fluid. Again take honey and water. Honey has high viscosity, water has low viscosity. Honey flows slowly. If you take a honey pot and a flow it over. Honey will flow out but a very slowly it will take a lot of time to reach its equilibrium state. Therefore if the relaxation parameter is small You converge directly to an equilibrium very slowly which means slow relaxation parameter means high viscosity. And high relaxation parameter means low viscosity. In other words, the fluid viscosity in general depends on the inverse of the relaxation parameter. In detail, and now I chose to write down the equation for you again without actually deriving it. The viscosity is equal to the times that delta three, times the speed of sound square. Times the difference between the inverse of the relaxation parameter at one half. This formula you probably don't want to remember and will just look it up when you need it. But the thing to remember is that the relaxation parameter in the collision model relates directly to the viscosity of the fluid. To conclude our introduction of the BGK collision model, we need also to write down the explicit form of the equilibrium term. We tell you before that equilibrium is a Gaussian distribution. It's not a Boltzmann distribution. Centered around the microscopic density and velocity of the fluid. It means that equilibrium does not depend on the details of the particle populations, but just on the value of the microscopic concentration, density, and velocity. In the BGK model, in the [INAUDIBLE] BGK model, we are not going to write the exact shape of the Maxwell-Boltzmann distribution, because it's not worth it. We'll just discretize it again using a finite development of the second order velocities of the [INAUDIBLE] Gaussian curve. The result is the equation which I have written down for you here. It has one term, which is a constant term, one term which is proportional to the velocities. It is the macroscopic velocity projected onto the corresponding lattice velocity divided by the speed of sound squared. And finally, we have a nonlinear term, which is again the scalar product between lattice velocity and macroscopic velocity squared, minus a constant times the norm of the macroscopic velocity squared. It makes sense that in our collision term, we have an expression which is nonlinear which goes like the square of the velocity. Because our goal at the end is to solve Navier-Stokes equations, and you'll remember that in the Navier-Stokes equations, on the left hand side, in the conductive term. We also had an expression which was nonlinear with respect to velocities, and we pointed out that this is the source of nonlinear effects in linear dynamics like turbulence. The same occurs here in the equilibrium term in the lattice Boltzmann model. When we defined equilibrium, before the parenthesis, we have a new constant which we call ti. This constant is there to compensate for the fact that when you look at lattice velocities some of them are longer than the other ones. The orthogonal ones are short and the diagonal ones are long. We need some lattice constant, ti, to compensate for this. For the lattice weights, ti, for the d two four nine model have a value of one nine for the orthogonal directions, one over 36 for the diagonal directions and the rest particles they have a weight of 4/9. We write this relation directly in python syntax, as an array, which goes with the same ordering as the lattice velocities. So, wanna know if 36 for the first velocity, which was, you remember, 1,1. 1/9 for the second, which was a focal one, which was 1,0 and so on. Let's switch to some more Python codes and write the equilibrium term in Python. When you write in Python we will neglect all the constants that are delta T and delta X. We will just assume that they are one, because you remember, I told you that they are It doesn't matter in which system of units you are working. You just need to make sure that the Reynold's Number, is the same in different systems. So we will make our lives easier, by not having any constants delta x and delta t, and setting them to unity. Cs squared, the speed of sound squared in this case, will just be one third, simple constants which we hard code into our program. We wrote a function which takes as arguments the macroscopic density and velocity. Or to be precise, matrices which the values of density and velocity In every point in space, and which will return the equilibrium distribution. The equilibrium distribution will be three dimension matrix with the same dimensions as the populations, nine times nx, time ny at y. To calculate the equilibrium term, we need to calculate two things, first, the norm of the velocity squared. This is independent of the lattice direction, so we compute this once for all. I do this now right away with the NumPy array based syntax because I take it around it that you understood that everything here depends on space to understand what's going on. And you have to imagine loops over the x and the y space directions. We are using the array based syntax, which is a shortcut and which implies these loops. Then we loop over all nine directions. And in every direction we calculate the scalar product of the lattice velocities times the macroscopic velocity. We need them twice, once inside the linear term, and once for the square term, in which this scalar product is taken as a square. We then calculate the equilibrium term exactly according to the formula. It is density times lattice constant. In the direction of the i-th population, times a constant term, plus a linear term, plus the two square terms. And once this loop is over, we return to equilibrium populations, a three dimensional matrix of dimensions 9 times nx times ny. Collision is even easier. We said that the BGK model takes the difference between outgoing and ingoing populations and put it equal or proportional to the difference between incoming populations and the equilibrium distribution. So if we know the equilibrium distribution, we just say with the known pi array based syntax that, Outgoing populations are equal to ingoing populations, minus relaxation parameter times the difference between ingoing, incoming, and equity bringing populations. And that's it. A single line which NumPy is a very efficient array of this syntax. This is the end of our module on the collision step and the BGK model. In the lattice Baltzman method. Stay tuned for the next model. [MUSIC]