Transcript for:
Understanding the Lattice Boltzmann Method

hello everyone and welcome to my latest boltzmann lecture it's a bit unusual because i'm not with you and i'm recording this from home just on the friday before your workshops um the intention of my lecture is to give you an overview of the lattice boltzmann method for hydrodynamics my name is tim kruger i'm a reader in chemical engineering at the school of engineering at the university of edinburgh and that is the outline of my presentation first i will give you a short introduction after that a bit of background what is the kinetic theory of gases then one section about the lattice boltzmann method itself after that a bit about simple boundary conditions you can use in lattice boltzmann i have one section about the immersed boundary method which itself is not related to the latest boltzmann method but it can be coupled to the lattice boltzmann method and after that a summary if you're interested in the latest sportsman method and you would like to have further reading then i recommend our textbook the lattice boltzmann method principles and practice and you will find that many of the figures in this presentation are actually taken from from our textbook okay introduction what will happen in this lecture you will learn about what led sportsman is you will learn something about its advantages of course also disadvantages no method is perfect um how can you stimulate flows in simple geometries and also how can you in principle model soft and rigid boundaries and fluid structure interaction problems let me start with fluid mechanics or fluid dynamics at the bottom you can see a scale bar in meters and you are probably aware of micro fluid mechanics where you have let's say bacteria swimming on the scale of micrometers you can have microfluidic devices for example for a droplet generation typically tens to hundreds of micrometers in diameter then inkjet printing where the relevant length scales are approaching millimeters you have seen rain droplets droplets on leaves and so on you can think about fluid mechanics in food for example mayonnaise here where the length scale is typically centimeters or tens of centimeters when you're painting a wall uh now we're talking about meters then of course um eddies when whenever you see a plane flying when you when you're talking about wind interacting with the building the typical length scale can be 10 meters or maybe 100 meters and you can go to larger scales like wind turbines and even oceans and atmospheric air motion you can see that we are covering here 12 orders of magnitude in length and the interesting bit is that all these scales and all the fluid mechanics happening here can be described by the navy stokes equations so what are the navier-stokes equations um the navier-stokes equations are a set of partial differential equations that essentially describe the momentum conservation of a continuum in particular for fluid here where you have a viscous term and for all kinds of scientific problems you want to solve in the navy strokes equations because you want to know how the fill field looks like why don't you do this analytically well the navy stocks equations are quite complicated because you have a non-linear term in the velocity you can see that here u appears quadratically also as i said before the navier-stokes equation it's a partial differential equation rather than an ordinary differential equation which makes it much more complicated to solve and in general you have complex boundary conditions and as we all know in many problems also in quantum mechanics and the boundary conditions are actually determining what is really happening this means if you want to solve the navier-stokes equations in general for a variety of boundary conditions moving boundaries and so on this is typically not possible analytically and if you don't have the experimental equipment available or if you are interested in details that you cannot measure experimentally then you would have to resort to computational modeling now the aim is to to convince you that leader sportsman is a suitable method for field mechanics not not the only method not necessarily the best method but it is one method you can use but in order to go there we first have to understand a bit how the kinetic theory of gases looks like because the lattice boltzmann method is actually rooted in the kinetic theory of gases now what you see on this slide is another diagram that involves a few different length and also time scales in the bottom left you can see the molecular or atomic scales where everything is determined by let's say angstrom or nanometer size and the collision time scale of molecules which is typically the time it takes for molecules to collide if you are interested in describing a fluid at that scale you would typically resort to molecular dynamics domestic simulations governed by newton's laws newton's equations of motion if you're interested in fluid mechanics at larger scales let's say you want to know how fluid moves in a bucket of water where the scale is maybe 20 to 30 centimeters then you would use continuum simulations for example cfd computational fluid dynamics or you can use lattice sportsman also as you will see later in the scale in between something interesting is happening because you still have some features of the molecular scale but you are not really interested in all the molecular properties you don't really want to know where every single molecule is going you just want to have an understanding what the statistical behavior behavior is so what is happening on these scales on the microscale typically nanometers you have molecular physics which means you have to describe molecules and atoms individually and the governing equations are newton's equation numerical methods you would use molecular dynamics if you go to the macro scale typically larger than micrometers let's say one micrometer can also be a bit lesser than a micrometer um the physics is continuous this means you will not be able to distinguish atoms and you are not really interested in what single atoms are doing in this particular case the governing equations are the navy stokes equations and you would use some kind of cfd computational fluid dynamics in between we call this the mesoscale meso from greek middle the scale is somewhere between nanometer and micrometer the physics is probabilistic which means we are not really interested in single atoms but we are interested in the probability of atoms to for example have a given velocity or speed the governing equation is in the boltzmann equation and i guess that most of you have seen newton's equation of motion and the navy stokes equation but not necessarily the boltzmann equation it is a bit less common in in the literature um and methods you can use are uh for example lattice boltzmann but there are also other solvers for for the boltzmann equation and actually the lattice sportsman method is not really a solver for the boltzmann equation it is only rooted in the measure scale and it's based on the boltzmann equation but it is not really a boltzmann solver what do we have to do if we look at the mesoscale in this particular case we are interested in a length scale that is somewhere between the mean free path of molecules which is the the average distance a molecule is traveling before it's colliding with another molecule that is lmfp and l is the length scale of the entire system you are interested in now if we are looking at a scale that is somewhere in the middle that is large enough so that you can say there are quite a few molecules included in a volume that has an edge length of l average but this box itself is still smaller than the system of interest so you can discretize your entire system into a number of boxes but within each of these boxes you have many molecules right then what you can do is you can say i don't really know and i don't really want to know what each molecule is doing in each of these boxes and you can see these boxes here as an example we have four by four of these boxes and each box has on average nine molecules the only thing i really want to know is where are the molecules going on average and what is their distribution in velocity space now the important concept here is that you know from navy's talks you have time and space and variables but here we also take the velocity of molecules as a variable and this is psi psi is the molecular velocity it's basically the change of position with time for a given molecule and we want to know how many molecules in a given box are moving in a given direction um at a given time right we don't want to say it's molecule 10 and molecule 1 million four we just want to know 10 molecules are currently moving in a given direction with a given speed that is what we're interested in and this enables continuum level descriptions on a kinetic level where molecules are behaving kinetically how does it look like um some of you may have seen the boltzmann distribution so typically what you have um on the x-axis you have the speed of the molecule you are interested in and on the y-axis you have the number or the distribution of molecules having that particular speed and this is temperature dependent as you know temperature is a measure for average velocity of molecules or atoms and if you increase temperature then you would see that the average value of the velocity of your system it will increase and the curve is also getting flatter and that is because the curve is normalized right if you stretch it over a wider range then normalization kicks in and the amplitude will be lower and that is what you see here this distribution function f which tells you how many molecules do you have at a given point in space at a given time that move in a given direction with a given speed and this distribution f is normalized in a way that if you integrate over velocity space and over space then you will just get the mass of your system and you can also recover the fluid density if you just integrate over velocity space which basically says give me all molecules no matter what their velocity is then you will get the density the mass density of the system and if you compute the first moment of the distribution so if you multiply f by the speed of the molecule and then integrate over the speed you will get the momentum the average momentum of your system at in a given sub box you can do the same thing to obtain pressure but that is much more complicated what we are really interested in here is fluid density and momentum density because these are variables that occur in the navy stokes equation for the pressure later on we will get an ideal equation of state but i will not go into detail um and i will not talk really about pressure a lot the the key takeaway message here is that f contains all local fluid properties that we are interested in and if you go to the navy stokes level you only want to get the moments of f and moment means the zeroth moment would be fluid density and the first moment would be the momentum of your fluid now where does the boltzmann equation come in we have a concept we have an object f but in physics we always want to know how do these objects evolve so for example if you have the position of a particle of course you want to know how does it change in time right what what is actually the the reason for a particle moving in a given direction and accelerating and so on and that is what is dynamics now for f we have to find an evolution equation that describes how f is changing in time and that is exactly the boltzmann equation now if you take the time derivative the complete time derivative of f you can use the chain rule you have three different parameters here molecular velocity psi you have space and you have time which means you have three contributing terms here if you compute the total derivative and here the gradient appears and the spatial gradient you have the partial time derivative and the change in velocity is of course acceleration and acceleration of particles is related to the force acting on the particles so we expect forces acting on particles to pop up in the boltzmann equation and spatial gradients play a role and of course the partial time derivative now if particles were just moving without any perturbation you just let them go you have a particle cloud you give them initial conditions and just let them go and they don't collide with each other then the convective derivative of that distribution would be zero but in reality particles are colliding so what will happen the distribution function f will change not only because of these terms on the left hand side here but they will also change because particles are colliding and all these contributions that are not captured by the derivatives are collected on the right hand side it's basically the deviation from zero and that is called the collision operator so when whenever two particles or more than two particles collide you will change the way f looks like in a way that is not captured by the derivative of f directly um i will get back to that in a second so for the boltzmann equation the boltzmann equation can be written in the following way you have the total derivative of f which has to be balanced by the collision operator if you don't have collisions between molecules you just have 0 on the right hand side but we know that molecules will collide occasionally in particular in a fluid where the density sorry in a liquid where the density is larger than in a gas and the interesting bit is that the boltzmann equation can be shown mathematically to recover the navier-stokes equation under certain assumptions and certain limits i will not go through that process it's very painful we don't have to do this now um just remember that the boltzmann equation is an equation that can in some limits reproduce the navier stocks equation the navier-stokes equation is simpler than the boltzmann equation because it has only space and time as variables why the boltzmann equation also has microscopic velocity as a variable but as i told you before if you take velocity moments you integrate out all the velocity dependencies now the boltzmann equation is interesting because it doesn't have any microscopic details that you're not interested in this equation here it doesn't tell you what a given atom is doing or a given molecule but it tells you what all the molecules are doing on average right in the navier-stokes equation you don't have that kind of information at all you just know what the momentum and density is which means that the boltzmann equation gives you more information than the navy stokes equation but it gives you much much less information than a full md description of your system um the collision operator of course without collision operator you cannot really work with the boltzmann equation and that is the tricky bit here what we have just for example you have two molecules with finite size they are colliding and before collision and after collision they will have different velocities so each collision will change the way molecules are moving which will of course change the number of molecules moving in a given direction which means that your distribution function will be deformed by each collision event how this is done in detail you can actually write down for spherical particles how this looks like and the collision operator becomes a very very long monstrous term which we don't want to cover here but physics can help what we can do we can argue we can make a case and say well if we have many many many collisions happening then in principle we will get some kind of an equilibrium state after some time so if you have a distribution of molecules in velocity space and you let them collide over some time and you have many of these molecules then after some time you will get an equilibrium distribution f and this is called feq for f equilibrium and to be model the relaxation towards that equilibrium if we start from a non-equilibrium by a simple so-called bgk model that means for any distribution function f that is not an equilibrium distribution function you will recover your equilibrium distribution after some time scale toe and this time skeletal is called the relaxation time you can see that if you if you are bold enough and you look up how the collision operator actually looks like if you compare that expression with the bgk model there's a huge simplification here but the interesting bit is first of all this makes it possible to actually work with the boltzmann equation in a numerical simulation and this simplification here is enough to recover navier's talks behavior that is really important to know of course you can come up with a simple model but this simple model may be oversimplified but the bgk model despite its heavy simplicity is still enough to recover navy stocks behavior and that is everything we need in order to solve the navier-stokes equation because we will not use letter sportsman to solve the boltzmann equation we will use latest sportsman to solve the navy stokes equation now um just a bit of additional information um of course you're aware of galileo transforms and center of mass systems and so on let's say you have a box with five molecules and these molecules move somehow in in velocity space then you can define the center of mass velocity and when you subtract that center of mass velocity you get the individual velocity of molecules in the center of mass system so while psi is the absolute velocity of your molecules we define v as the center of mass velocity of these molecules in a given box where u is the velocity of the fluid in the box on average and for us it is more convenient to use u and v rather than psi u will actually be the macroscopic velocity of the liquid at a given point in space it's the average velocity of the molecules in a given area and v tells us how the molecules on an individual basis are distributed in velocity space around the velocity u now the equilibrium distribution this is something that um was shown some time ago and you know maxwell boltzmann distribution those of you who have done statistical physics and that is actually the distribution you will eventually get for these molecules the important bit is that any collision has to conserve mass if you have a closed system and you have colliding molecules the mass is of course conserved momentum is also conserved unless you have some kind of momentum sink at the boundary of your system like you have friction at the walls or whatever but if you have a gas confined in a volume each collision will conserve the total momentum of your gas inside which means no matter what you do your collision has to conserve momentum and that is newton's third law of course also energy will be conserved in total we can assume that we have elastic collisions uh which means that um particles will not lose any energy during that collision and what can can of course happen is that on a on a microscopic scale that you convert kinetic energy and that is basically encoded by um the by the velocity u it can be converted into a thermal energy and due to friction losses and so on but that doesn't mean that energy is not conserved it just means that one form of energy is converted to another form of energy um if you look at the original derivation of the maxwell boltzmann distribution is quite elegant you can make certain assumptions symmetry considerations and so on this distribution should only depend on the density on the center of mass velocity of your molecules and the temperature of your fluid and it has to be isotropic it doesn't matter in which direction in space you look so it can only depend on the magnitude of v and if you follow the entire derivation which i will not do here then you can actually write down how the equilibrium distribution should look like and it's a relatively simple function the gaussian function as function of the density of the fluid the temperature r is the gas constant and the velocity squared which means any directional dependency is actually unimportant that is in a very very small nutshell kinetic theory of gases now what have you learned here there's typically a scale separation that you can use in order to make modeling assumptions both in space and time you have your large system you're interested in and you have the small scales where the physics is happening or the the microscopic physics at least we replace molecules by distribution functions we don't know and we don't want to know what each molecule is doing we just want to know what molecules are doing on average the boltzmann equation is the governing equation for this distribution function f it contains a collision operator omega which is usually very complex in its mathematical form but we can use a simplified btk operator which requires equilibrium distributions these equilibrium distributions can be derived mathematically and they just depend on density velocity and temperature we can also compute the density momentum or velocity and the pressure in the fluid from macroscopic moments of the distribution f it's basically velocity moments and integrals over f and what is important to know is that if you do it properly in the right limit then the boltzmann equation recovers the navier-stokes equation which means we can actually use a navy stock server that is not directly discretizing the navier-stokes equation but that is rooted in the boltzmann theory and that is exactly what ladies boltzmann does so let's move on to ladder sportsman uh what is the idea use the boltzmann equation to solve the navy stocks equation and this is possible thanks to chapman-enscock which i mentioned before which means we will now simulate the evolution of the distribution function f rather than directly u and p velocity and pressure what you are normally interested in in microscopic fluid mechanics and you could say well the boltzmann equation is much more difficult it has more variables uh it should be much more difficult to do this why why do we actually bother right and the counter intuitive outcome is that lattice boltzmann if you do it right can be even more convenient than a direct discretization of the navy stocks equation what are our tasks in order to get there first of all we have to discretize the distribution function f because for any computer simulation you need some kind of discretization for example you need to lattice you need time steps and so on then of course we have to ask what is the lattice boltzmann equation so how does the governing equation look like that we will use for this particular task and also how are lattice boltzmann and the navy strokes equation linked and we will do this step by step so let's talk about the discretization first which means we are going from boltzmann to lattice boltzmann which means we have to discretize f we have three different parameters here velocity space and time space is simple we just take a lattice okay in this case in 2d but we can also do it in 1d or 3d what i show here is actually a realistic flow field that i have simulated with lattice boltzmann and just to visualize it i have created this kind of letters so what we do we we just decompose everything into small lattice nodes and we solve for the flow field on each lattice node time is discretized by having at least in the original lattice boltzmann scheme we are having a constant time step delta t we solve a ladder sportsman at a given time then we advance time by delta t we do it again we advance time by delta t and so on there are also latest boltzmann schemes where you have unstructured meshes and time steps that can be tuned dynamically but i will not talk about that and the the real novelty here is that we also have to discretize velocity space which means instead of working with an infinite number of possible velocities that a given molecule can have if you think about a molecule it can move in any direction with any speed in principle what we do we discretize f in terms of velocity space by allowing just a very small and i mean very small number of possible directions and speeds in 2d it is typically nine different speeds that we permit and on nine different velocities and in 3d as you can see here this example shows 19 different velocities that there are also moderates with for example 15 or 27. um i will not talk about spatial and temporary discretization here because that's pretty straightforward let's talk a bit more about the velocity space discretization so what i do is i say if you have a molecule or f is not really a single molecule f is giving you a bunch of molecules then instead of saying f describes how molecules can move in any direction i just say well molecules can now just move along for example the primary axis x y z or they can move along diagonals and they have to move in such a way that within one time step delta t they reach exactly one of the neighboring lattice nodes which means your velocity space discretization is such that it is perfectly aligned with your temporal and spatial discretization it's basically like a checker board where you have a pawn on a checkerboard which moves in every move exactly to one other field you cannot end up between different fields so that and that is the analogy so in a nutshell what you do um you take the integral moments that we need in order to get the density and the momentum that we need for neighbor stokes you can see integrals on the left hand side and we have to replace these integrals by finite sums that have only a few terms like 9 or 19 rather than a million or even an infinite number and the mathematical mechanism behind that is the emit expansion which i will not cover in detail here what are the outcomes in 2d i mentioned already you can end up with nine different velocities let me illustrate it you can have a molecule that is not moving at all so it is staying where it is it will not end up at a different node after one time step or you can go to one of the next neighbors in one time step so if you count then you have four directions along the primary axis you have four diagonal options and you have the option that you don't move at all which are nine in 2d and therefore we call this lattice d2q9 for 3d you have different options but what i show here is the so-called d3q19 lattice where you have 19 options including that you're not moving anywhere which is in the 0 0 component and if you take if you neglect this one then you have 18 left to reach either your next neighbors or diagonal neighbors and that is 19 in total once you have done that you are writing down um the populations discretely which means you you number them now q is the number of possible directions you allow 9 in 2d or 19 in 3d and your index i here just runs from 0 to q minus 1 or from 1 to q depending on what you prefer and now we replace an integral just by a finite sum so if you sum over all your discrete populations you get the density and if you multiply each population by its direction it's a velocity vector then that is at the first moment you get the momentum of the fluid and the lattice boltzmann equation how does it look like now i told you that instead of the collision operator the full collision operator we use the btk approximation and the resulting equation will be the lattice boltzmann equation or lbgk lattice bgk equation which looks like this and this is really what you implement later on in your code you say okay the left hand side here it's in the total change of f that is a given population i evaluated at point x in space and time t and its counterpart one time step later will have moved by c i times delta t where c i is the speed or the velocity of that population and i will illustrate it in a few slides and the collision operator is exactly what you had before you have your current distribution which will relax towards the equilibrium distribution over a time scale 1 over 2 okay and you can rewrite this also depending on how how it is simpler for you to implement but now i've rewritten it in a way that on the right hand side is everything that you know from the previous time step and on the left hand side is what you calculate for the next time step you know of course what you have at the current time step you have to in your population at the current time step and current location then you have to know what the collision operator is in this case the btk operator which i will show in a second in more detail and as a result you will get the left hand side where you have the population at the next time step at its neighboring lattice node so how does it work you start with a given distribution of population so let's say at one lattice node the one here in the middle you have nine f values each one points into one direction or you also have the one that is not moving at all which is not shown here and what you do then you compute the relaxation term which is giving you a reshift uh redistribution of your populations but they have not moved in space yet and then you propagate them to the next neighbor so basically in the first step you redistribute the f values according to the collision step at the same space same location in space and once you have done that you send your populations to the next neighbor and there's one population which is not shown that it's not moving at all because it doesn't have a velocity what are the advantages here collision is local and algebraic it's it's a very straightforward algorithm for collision and the propagation is linear and exact if you wonder what that means exactly um that is explained in our latest boltzmann textbook but essentially you are decomposing your um lattice boltzmann solver into a collision step and a propagation step some details how do you know what the viscosity of a liquid is because if you look at the navy stove equation you have a viscosity and if you look at the boltzmann or the lattice boltzmann equation you only have a relaxation time as free parameter and these two values are closely related the viscosity of your liquid is essentially the relaxation time multiplied by the so-called speed of sound the speed of sound is something that comes out of your mathematical description of the discretization of the lattice boltzmann equation and it is roughly speaking 1 over square root 3 of 1 lattice spacing over one time step and i also said that you have to take the discretized equilibrium distribution which looks like this so you have this is basically an expanded and simplified version of the maxwell boltzmann distribution and here you have the density of the liquid you have the average velocity of the liquid ci is the direction of a given population cs again speed of sound and wi is a so-called weight for a population depending on whether you travel to the next neighbor along the main axis or along the diagonal axis or you stay where you are the weight has a different value so how does it work now that is your latest sportsman equation or you can also implement it in two different steps first you compute the post collision distribution which means uh from if you take the result from your previous time step which is f i at time t at position x then you apply the collision step it involves again f i you know the relaxation time tall because you set it in a way that you get the viscosity that you want you can compute your equilibrium distribution because it completely depends on what you already know the density and velocity from the previous time step and you can compute the outcome that is called the post collision distribution and then in another step you can shift these populations to the next neighbors right or you can do it in one go it depends on what you what you prefer and sometimes depending on other boundary conditions you use you may actually have to decompose your lattice boltzmann equation into two sub steps but the final outcome is identical how does it work using your previous information previous time step or your initial condition you know what the f's are you can compute by taking the sums the moments of f the density and velocity then you compute the equilibrium distribution function which is just a function of rho and u and the velocity of component i then you collide locally once you know f i and f i equilibrium you can if you look at this equation here you can actually work out what the post collision distribution is and you will see that your populations will have redistributed in velocity space but they have not moved yet in space and then you can propagate to the max neighbors and that is described by this equation here and after that you increment your time step and you go back to step one and your new fi becomes your old fi and you repeat that's it now the question why does it work this i understand this is a very short description of what you can do why does it work because you have lattice symmetry and isotropy um you have exact conservation laws your lattice boltzmann equation actually conserves mass and momentum exactly and your chapman in scorch analysis shows you that what you have done here is enough to recover the navy's talks behavior some advantages and limitations of lattice boltzmann it is quite fast and that is because it's an explicit method and it is a linear in propagation you don't have to solve a poisson equation that you would normally have to solve for the um navier-stokes equation the possible equation is non-local since you don't have to serve it in lattice sportsman leader boltzmann is essentially a local algorithm except for the propagation to next neighbors but that is a very minor non-locality therefore you can usually parallelize that sportsman relatively easily compared to other algorithms like finite volume where you have to solve the password equation and complex geometries can be implemented relatively easily compared to other cfd methods there are some limitations and i there are more but i will just mention these here you can only simulate small knudsen numbers and you can only simulate small mach numbers at least for the original lattice boltzmann scheme there are extensions where you can go to verified gases and you can also go to compressible fluids but i will not cover that here here you just see a plot of the scalability of a lattice boltzmann code on a supercomputer where initially the scaling was not great but the developers of the code actually found out that um there was some message passing interface um algorithm uh that that was um forming a bottleneck and once that was removed you you could see that um the algorithm scaled nearly linearly up to 256 000 cores which is um something that you will for example never achieve with open form and here you see a complex geometry it's blood flow in a retinal network that has been achieved with lattice boltzmann and obviously the geometry is very complex in this case so what did we learn we learned that the distribution function f it this has to be developed in space and time and this has to be discretized in order to solve it on a computer in order to do this we need to discretize velocity space which means instead of having a continuous distribution of velocities for the molecules we allow just a small number of options we have seen that the resulting latest boltzmann equation is relatively simple to implement it's just a few lines of code for the original lattice boltzmann scheme the relaxation time in the bgk term determines the viscosity of a liquid the advantages are that letter sportsman is usually fast if you do it properly it can be paralyzed relatively easily compared to other methods and you can usually solve complex geometry problems more easily than with other methods but it really depends on the context sometimes other methods are more advantageous so then that is boltzmann ladder sportsman is not suitable in its original form for height nodes or high mach number okay so what about boundary conditions let me talk about that a bit motivation again you have seen these images before um all these problems which you will agree they they behave completely differently all these systems behave differently they are all governed by the same navy stokes equation right so what is different here the difference are boundary conditions and of course also driving forces but the essential point is that we have different boundary conditions so in order to simulate this kind of wind park or maybe ocean recirculation we need proper boundary conditions the boundary conditions are a necessity for fluid mechanics so they're not optional without boundary conditions we will never be able to model and simulate the right system um mathematically they are required and physically they are also required because all the physics is actually in the boundary conditions most of the physics and to to get back to a lot of the rings one does not simply solve the navel stocks equations without boundary conditions right now what kind of options do we have um there are various boundary conditions various types of boundary conditions available in cfd for example if you have an unstructured mesh then your sorted line here your thick solid line could be a boundary and you may have to create a measure that is somewhat following the shape of the boundary you can have a structured approach where your boundary itself is um arbitrary but your your lattice for the fluid is structured and in that case of course you have different challenges because you have to communicate between this curve boundary and your regular letters or you can approximate your boundary by having a staircase like approximation and those of you who have already used lattice boltzmann you may you may be used to the staircase bounce back approach that is visualized here typically in navier stokes you impose pressure velocity or stress or gradients of those at the boundary and what what you need to know is of course if you have a poor boundary condition implementation um your resulting uh the the quality of your results will also be poor right you cannot have the best navy stroke solver and the worst boundary conditions and hope that um that your results will be good it's the boundary conditions can spoil everything now in latter sports one um it's it's a bit of um how to say there's a zoo of boundary conditions and the reason is you have in um navier stokes fewer variables to deal with than in lattice boltzmann let's say in 3d you have four hydrodynamic fields you have pressure and you have three velocity components you also have the stress tensor which has because it's symmetric six components if it's incompressible then you have only five because you have an additional constraint but you basically have let's say six then you have only ten variables that you're really interested in but in 3d you have more populations you have maybe 19 or 27 of them which means you have more degrees of freedom in lattice boltzmann than you have in navier stokes and this means if you have a boundary condition you have more conditions to satisfy you have more conditions to impose on lattice boltzmann than in navier's talks and this gives you a lot of flexibility because you have different ways of doing that you have an underdetermined system and you need to find close closing relations closures and there are so many different approaches you can use that all kinds of people have proposed different boundary conditions that have different advantages and this disadvantages typically what you do in latin sportsman you manipulate the populations directly because velocity and pressure and stress are not a priori relevant in lattice boltzmann you can i mean you will use them for the equilibrium distribution but lattice boltzmann is an equation for the f populations not for velocity itself what happens typically at a boundary you are missing information right you have a boundary let's say you have a fluid inside your domain you have a boundary and you have something outside of your domain now for the latest sportsman algorithm to work you would have to know what comes in from the outside and the purpose of the boundary condition is to establish to fill this void to tell you okay just pretend there is an f coming in and the boundary condition tells you what the value of that f should be as a fun fact just to look how many different boundary conditions are there if you use the web of science and you search for a boundary condition that is boltzmann in the title then about five years ago i found 154 hits last year i found 22 and this year i haven't checked but it will be more so you can see that there's a relatively large number of papers in the in the literature where people look at boundary conditions and let his bolts on right and there's a wide variety of boundary conditions and i will just briefly mention them you have bounce back methods and i will talk about bounce back in more detail soon but even for bounce back you have different ones you have simple bounce back interpolated bounce back partially saturated or grey bounce back you have ghost methods which means you uh construct lattice nodes inside the solid in a way that they um give you the populations that you want to have to recover the right velocity or pressure at the boundary and you have different approaches here and of course i mentioned that at the beginning you have immersed boundary methods which are um not really lattice boltzmann related but immerse boundary method is much older than the latest sportsman method it's about 20 years older but um it can be coupled with the lattice boltzmann method now let's talk a bit about bounce back here um what you do if you want to have a no-slip wall let's say you have the fluid at the top you have a boundary and you have a solid at the bottom what is happening you start with populations pointing towards the wall i'm only showing the populations that are moving towards the wall you also have the populations moving parallel or away from the wall and then during your streaming step halfway through the time step basically these populations reach the wall and then you perform a very simple trick you just revert the direction you just turn the populations around and complete your streaming step and then the populations go back to where they came from and that automatically answers the question how do the populations have to look like that come out of the wall these are basically the bounce-back populations if you look at this you already know what the values are because you just take the old values and turn the populations back there's no reconstruction you're not injecting any new information you're just working with what you have and interestingly this treatment of the populations leads to an effective no-slip boundary condition which is really really handy because mostly boundary conditions are the most common boundary conditions we have in fluid mechanics if we deal with solid obstacles okay what are the advantages you can discretize any boundary as a staircase and you can just follow this algorithm you say it's very simple you say i start on a fluid node and if a population is streaming to another node that is not a fluid node but a solid node then turn it back and bring it back to the starting point but it has to point back in the opposite direction and if you do that consistently at all connecting links between a fluid and a solid node you will see that you have no unknowns left everything is perfectly well determined for the next time step and effectively you get up to you get some modelling errors of course and some mathematical deviations but you get a very good description of a no slip boundary condition at a curved boundary that has been approximated by a staircase that is something that has no analogy in computational fluid dynamics because in cfd you don't work with populations you work with u and p velocity and pressure directly there are no populations left sportsman gives you the option to work in a very very simple attack way with boundary conditions the disadvantage of the bounds back approach is it is not very accurate there are numerical artifacts and if you have moving boundaries it's getting arbitrarily complicated of course so what did we learn here um there's a special nozzle boundary condition in lattice boltzmann and other particle-based methods for example there's also um multi-particle collisional dynamics which also works with moving particles and you can also use bounce back there it's not only a lattice sportsman thing but it's something that doesn't exist in the cfd community where you have continuous fields and your the navier-stokes equation directly it is simple to implement in complex geometries if you accept staircases as a modeling artifact which is not very accurate but you have various extensions of the bounce back scheme where you use higher order interpolations to get smoother flow fields at curve boundaries but i will not cover that now now finally i want to say a bit about the immerse boundary method i'm also aware of time i don't want to talk for too long the idea of the immerse boundary method is that you have a regular lattice for the fluid and you have some kind of a curved boundary on top of that the the roots of the immersed boundary method go back to the early 70s by by peskin who suggested this in his dissertation and the original application was blood flow in the heart um if you're interested in the ms boundary method that's a very nice uh it's it's already a bit aged but it's still easy to read and good as a starting point it's a peskins review paper from 2002 in i think in actin america and um five years ago uh the right now it's much more the most boundary method um had nearly 600 web of science hits when you search for immerse boundary method in the title so how does it work you have a regular lattice for the fluid and you have some kind of mesh here in 2d that describes the surface of an immersed boundary the trick here is that these markers in red they can generally move in space you can have a moving boundary and the lattice is stationary right you you call the letter system uh an eulerian system it is stationary it's irregular on regular letters and the markers they can move in space in general you can also have a boundary condition where they are not moving of course but you may have moving particles suspensions or whatever and this is called a lagrangian system because in principle these particles can move in 3d it's getting a bit more complicated because you need to find some kind of surface mesh or surface representation of these marker points and depending on how you do this i have three examples here you may get slightly different results so you have to be aware of that at least and also the average distance between these marker points should be somewhere between half a lattice distance and 1.5 lattice distances roughly speaking it depends on the context but you cannot make your lagrangian mesh arbitrarily fine and have a very coarse fluid lattice or the other way around it will not work it will not work well at least the first idea is of the most boundary method that the boundary will move with the same velocity as your fluid which is the no slip condition which means your markers which have positions are they have to know what the velocity of the fluid is around them so for example this marker here is asking all the fluid nodes in its vicinity what is your velocity and then you have some kind of interpolating function that determines the velocity of lattice at the position of this marker and i will get back to that in a minute and then what you do you say because you have the no slip condition the marker should move with the same velocity as the fluid at the position of the marker so r j dot is the time derivative of the position of marker j this one and it has to be the same no slip condition as the velocity of the fluid evaluated via interpolation at the position of the marker how do you do this you if you have an infinitely fine lattice you can use your delta function to to obtain your um velocity at the position of the marker but we don't have an infinitely fine lattice which means we have to discretize the interpolation which means we have to find a discretization of the dirac delta distribution and this is usually a smooth kernel function a kernel or a stencil and our integral our convolution here becomes um a finite sum over neighboring lattice nodes uh so basically what this means is uh each marker asks a finite number of neighboring lattice nodes what is your velocity then each velocity will be weighted according to a given algorithm and you perform the weighted average of that and how is this done you have um you have this interpolation stencil that can have different forms you can have a triangular stencil here or bilinear because you have a line here and a line here or you can have something that is smoother and has a wider support typically what you find in ib application applications ib means ibm sorry ib means immerse boundary you typically have either two supporting lattice nodes along each axis of your letters or you have three or you have four and obviously the wider it is the more computationally expensive it becomes because you have to consider more calculations and more memory lookup you could say well let's make it as narrow as possible because it's more efficient which is true but you will also see more lettuce-ness now basically if your marker moves on top of the lattice sometimes the motion is not very smooth because you are changing your neighbors and there's not a very smooth transition between the interpolation of different neighbors and that is the purpose of these wider stencils where the lattice effect is smoothed out a bit more right how do you update the markers i told you that each marker should move together with a fluid but how do you do that well the simplest idea is to use a forward euler approach you take the old markup position you have in the interpolation step computed the speed of your marker you multiply it by the time step and you get the new position but we need a two-way coupling because the marker will not just follow the flow uh in that case we would not impose anything on the flow right if the flow is just deforming our boundary but the boundary has no way of telling the flow to behave differently and this is what a boundary does then um this is pointless so we need a two-way coupling we don't just have a paper ship moving along with the water a proper ship would also deform the water right so we need a two-way coupling and the second principle of ibm is that we can compute forces on each of these lagrangian marker points and these forces are then distributed to the lattice it's basically the interpolation step in reverse you give information that is known on the mesh back to the letters and this force to the fluid it appears out of nowhere it's basically a force field that is localized around the boundary and the fluid is forced to move under the influence of that force and this force is mimicking the effect of a boundary there's a subtle difference between a real boundary condition and the immersed boundary method a real boundary condition will directly impose a change in velocity and pressure for naval stalks or for the populations in lattice boltzmann but the immerse boundary method is not doing that it just kicks the fluid a bit so if the fluid is not supposed to penetrate a solid then there will be a force exerted by the by the solid on the fluid that pushes the fluid back in a way that as a net effect the fluid is not moving at the location of the boundary so the mass boundary method is not really a boundary condition it is just mimicking the effect of a boundary once you know how the force should look like and unfortunately i don't have enough time today to explain to you in detail how these forces are calculated on the mesh but once you have them you spread them to the fluid lattice in the same way you interpolate the fluid velocity just in reverse and all the physics is contained in the way you compute these forces you can for example have a stationary rigid wall or you can have moving deformable objects and that is all encoded in how you compute the forces on the lagrangian mesh now the interpolation sensor you use for the velocity interpolation is exactly the same stencil you use for the for spreading which means each fluid node will be affected by all boundary nodes that are somewhat in range okay now um there are a number of open questions and i cannot cover everything in this lecture uh the most important one is how to find the forces on the lagrangian mesh and i told you these forces determine whether you have a rigid object that is stationary a rigid object that is moving or maybe a soft object that is moving and this is how you actually achieve different boundary properties if you want to know why does it actually work why is the immerse boundary method that is not really a boundary condition but it's only mimicking a boundary condition why does it work if you want to know this go to the pesky paper from 2002 it's well explained in that paper a few advantages and disadvantages of immerse boundaries um there's no need for a real boundary condition uh the effect is completely included in external forces so any uh any navier stroke server that supports forces will work with the immerse boundary method and in principle you can use it for arbitrarily formed or arbitrarily shaped boundaries disadvantages it's a diffuse a so-called diffuse interface method which means it's not exactly that accurate compared to other more complicated boundary conditions um there's also a fluid inside your solids if you think about it you you just have the surface of the solid resolved by the immerse boundary method there are several several ways to work around that but in the eve implementation you only treat the surface of a solid and you also have fluid inside your your actual solid and if you i told you how to get the no slip condition because ibm works really well for no slip boundary conditions but if you have different boundary conditions you may have an open boundary condition then ibm is not necessarily the best option ibm is usually used if you have immersed objects that satisfy the nosler boundary condition at the surface let me summarize the the entire lecture what have you achieved in in this lecture you have hopefully understood the basics of kinetic theory and the mesoscale lattice boltzmann is a fast alternative navy stoke solver the difference is it is not discretizing navy's talks directly it is a heavily simplified discretization of the boltzmann equation but in a way that you recover the navier-stokes behavior because you don't have to solve a password equation lattice boltzmann is suitable for high performance computing and it's relatively easy to parallelize and due to the nature of the populations you have in lattice worldsman you can use the so-called bounce-back approach which is at least for the first simulations to run in a complex geometry it's definitely what you should try because it gives you very good results already a very good ideas without investing a lot of time implementing more complex boundary conditions i also covered the immersed boundary method to some extent which can be used for deforming and moving boundaries although i haven't talked about these concepts in detail and my understanding is that you will have watched this lecture recording before our live q and a session and i will see you for me at least it will be next week i will see you in the live q and a session thank you very much for watching