Computational Fluid Dynamics Fundamentals | Dr Aidan Wimshurst | Skillshare

Computational Fluid Dynamics Fundamentals

Dr Aidan Wimshurst, Flow and thermal performance engineer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
5 Lessons (2h 24m)
    • 1. Welcome and How to use this course

      4:21
    • 2. Introduction to Transport Equations

      30:46
    • 3. The Diffusion Equation

      42:14
    • 4. The Convection-Diffusion Equation

      30:26
    • 5. Upwind Differencing

      36:12

About This Class

An introduction to the fundamentals of Computational Fluid Dynamics (CFD) that are used to solve complex fluid dynamics problems (weather prediction, aircraft flight, turbomachinery) by researchers, scientists and engineers around the world. The course starts from first principles and you will rapidly develop your first CFD solution using the Excel sheets and Python source code provided. By the end of the course, you will understand the importance of upwind differencing, Peclet number and mesh resolution. No prior experience is required and no specific CFD code/coding experience is required!

What you will learn:

  • How to set up and solve your first CFD solution from first principles
  • The importance of central differencing, upwind differencing and Peclet number
  • A common framework to solve any scalar transport equation in CFD

Course requirements:

  • Basic vector algebra (dot product, gradient, cross product)
  • Basic differential equations
  • Basic linear algebra (matrices)

Transcripts

1. Welcome and How to use this course: Hello, Aunt. Welcome to my computational fluid dynamics fundamentals Course. Now, in this video, I just like to welcome you to the course on Explain to you how you could get the most out of this course by following along. Firstly, a small bit of background information about myself. My name is Aidan Whims Erste on I have a PhD in engineering, which I received from the University of Oxford. On over the past few years, I've been carrying out extensive computational fluid dynamics studies in riel industrial settings using a variety off CFT codes, including open phone answers fluent on answers cfx. And in this course, what you're going to receive is on understanding on background information for the fundamentals of computational fluid dynamics that are common toe all CFD codes on. By the end of this course, you'll gain a deep appreciation and understanding for what's really going on behind the scenes of CFD codes, and you will also have had an opportunity to put together and develop your own CFT code using the Excel sheets on the python code provided now, in order to get the most out of this course, what I would recommend doing is starting off by navigating to the Project on Resources Tab here on skill share on downloading the PDF guide that's there in the resources and the PDF guide you can see on screen here on Really, the best way to get the most out of this course is to follow along with the pdf guide as I go through it in these exclamatory videos on as you follow along with the PDF guide, what you'll see is opportunities for you to dive in on to use um, CFT code yourself on when those situations arise. I would advise that you download either the Excel spreadsheets or the pipe and source code that's also provided in the resources tab and used them to carry out the C F D solutions for yourself. On using this approach, you'll get the maximum amount of learning from this course and really developed a deep understanding off the C F. D code on how it's structured now. Just to give you a quick overview of how the courses structured and how the lecture is going to be delivered, the course is broken into four different chapters. The first chapter is titled Introduction to Transport Equations on. This will provide some useful background around the Naevia Stokes equations on transport equations that we're going to be solving using CFT. The second chapter in this course is titled with one D diffusion equation on this chapter will focus on using the finite volume method to describe ties and solve the diffusion and source terms in computational fluid dynamics. This approach will then be extended in Chapter three toe also include the conviction term, which is key to majority off computational fluid dynamics simulations. In the final chapter of this course, we're going to be looking at up wind difference ing on up when difference ING is essential for achieving solutions in computational fluid dynamics that are free from non physical oscillations. On In this section you will see the occurrence on onset of thes oscillations and also how to avoid them by selecting an appropriate up wind difference ing scheme. When you're carrying out your CFT simulations. Now, I'm very excited to bring you this course, and I know you'll gain a lot off useful information from it on. Once you carried out the course, please leave some feedback and some comments on the comment section below let me know how you felt it. Waas What things did you enjoy on what things would you like to see in further courses and further videos? Until then, thank you very much for watching on. I hope you gain a lot of useful information from this course. 2. Introduction to Transport Equations: Hello, Andi. Welcome to Chapter one off my fundamentals course for computational fluid dynamics. What I'm gonna do in this chapter is just run through the first section of my course, go through the equations and the thought processes so that you can follow along and then hopefully a better understanding for chapters 23 and four when we actually start solving the equations. Now, the motivation for this chapter is really to introduce to you the concept off transport equations on. We're going to start with the Naby Stokes equation because this is the most commonly used to transport equation in computational fluid dynamics. Then I'm going to introduce some other transport equations and show you how those transport equations are similar to the Navy Stokes equations and how they all have a similar form. Andi, once you being through this chapter, you should really be able to develop an understanding and see the similarities between all of these forms of equations so that you can then generalize and apply to any equation that you'd like to solve using a computational fluid dynamics framework. Now I'm going to start things off from the very basics. So for many of you. This chapter will be a recap off early courses in fluid dynamics that you may have in your engineering and school classes. So feel free. You can always skip this chapter if you want, but I'm pretty sure for some of you there be some bits in this chapter that you'll find useful or maybe a useful refresher for you anyway. So I'm going to start with the absolute basics and we're gonna develop the framework piece by piece. So the first thing we're gonna do is think of the forces acting on a solid body because usually went going through high school and college courses. We're used to thinking of equations in motion of a solid body. Then we're gonna move on to a fluid. So Newton's second law in differential form is going to be given by equation one there, which is f vector f is M a a being the acceleration vector f being the four Specter can a differential form. We write DVD T rather than the acceleration for the solid body. So just obvious reminder to you that Newton's second law says that F is that some of the forces acting on the body on, then This is equal to the mass or the inertia of the body times the rate of change of velocity of the body. Now, the first thing I want you to think about with this equation is that we usually assume that the mass of the body is constant. We have a solid, rigid body. But if for some reason the mass of the body changed with time, then really what we'd be looking at is equation two, which is the some of the forces acting on the body is the rate of change of mass multiplied by velocity or momentum. So, really, Newton's second law are telling us that the rate of change of momentum of our solid body is equal to the sum of the external forces. Acting on the body on that type of thinking is gonna be very useful for us. When we introduced the Naevia Stokes equations for a fluid. Now, of course, Equation two is a vector equation. That means in a Cartesian coordinate system, X y and zed, we're gonna have three components. So really, equation to is just a compact way of writing three separate equations, which you can see there in Equation three. So the some of the external forces in the X direction is equal to the rate of change of momentum in the X direction on DSO on for the Y and Zed directions. Now that form of Newton's second law is valid for a solid body. What do we do if we have a fluid? So if we have a fluid volume fluid being a liquid or gas something that's not a solid body , then what we do is we're going to use rather than Newton's second law. We're going to solve the now obvious Stokes equations on as you'll see the novice Stokes. Equations are very similar to Newton's second law, in that they express the rate of change of momentum off a fluid parcel or small volume of fluid within a large continuum of fluid. On What I'm gonna do now, quickly is just show you what one of those fluid parcels might be. So if we look at figure one there, we've got some free surface flow going large, massive liquid there. And if we think of a small, finite volume or parcel of fluid within that entire continuum, we're going to express the rate of change of momentum of that parcel of fluid on the way that we do that is through equation four, so you can see that there I've got on the left hand side. D by d t of m u is equal to f so house before fst some of external forces acting on the fluid parcel and then emu is the massive that parcel multiplied by its velocity. Now, when I've written it, nobody Stokes equations in this form. Some of you may not have seen the nab your Stokes equation written in this fall. It's useful because we can directly see how similar they are to Newton's second law for a solid body. Now, what you may notice is that the form of the differential operator D by D. T is now given by a capital rather than a lower case on. I'm gonna go into a little bit more detail why, that's the case for a fluid volume. But before we proceed, the first thing we're gonna do is divide Equation four by the volume of that fluid parcel there. And what that does is that leads to Equation five so D by D. T of row you so mass divided by volume is the densities we've got. Ro U is equal to f f is going to be some off the external forces per unit volume. And what does that mean for your volume? Well, if we have a total force acting on a volume, we just divide by the volume and then they give us the some of the external forces per unit volume. And it's important to note at this stage that equation five, the Naevia Stokes equations, or the rate of change of momentum as equals and some of the external forces is valid for any volume that we choose in our continuum. So if we go back to that picture and figure one got that small volume of fluid there, we could take any volume of fluid we wanted in that continuum on the Navajo Stokes equations will be valid for any of those volumes, so it doesn't matter which volume we take or what size the volume takes. The same equation is going to be valid for Alvar Williams. At this point, I'd also like to remind you that with Newton's second Law, if we know that some of the external forces acting on our body. Then what we can do is we can integrate Newton's second law or equation three there and that will give us the velocity of the body in time in X y and Zed. So if I have a body moving a constant velocity or stationary, and I apply some forces to it, then I can integrate Equation three. And that will tell me how the velocity of the body changes with time or how its motion changes with time on. The same thing could be said for the Naevia Stokes equations in equation for in Equation five. If we know that some of the external forces acting on our small parcel of fluid on we know its density, perhaps it has the density of water. Then we can integrate equation five, and that will give us the change of velocity off our fluid parcel. So the Navy Stokes equations will let us calculate the velocity or the motion of the fluid and how it moves on interacts with surrounding surfaces. So the next picture I've got for you there is just a slice through ah wing section on an airplane on the reason I've got this for you. Here is what I want to do is just have a think about how powerful solving the novel Stokes equations are numerically so if we thought about the wind that was moving around the wing section of our plane, for example on we knew the external forces acting on ALS parcels of fluid They're moving around that wing. What we could do sold the Na'vi Stokes equations toe work out the velocity on what that means is how the wind moves around the wing section and this is what engineers do in practice, we use a new miracle method toe work out what the velocity of the wind is as it moves around the wing section. And as many of you may know, from aerodynamics, we get an acceleration of the wind over the top of the air of oil, which leads to pressure and skin friction forces acting on our wing. So for an engineer, if we can solve the Navy Stokes equations, we can work out the motion of the fluid and then we can work out the forces acting on the surface. And in the case of a plane, this allows us to calculate the lift so we can work out how much force and how fast the plane needs to be going if we want it toe, take off and fly successfully. And there are a multitude of other situations where working out the forces on bodies is useful to engineers. So before we continue, we're gonna make a small side point to explain to you why the derivative was given by Capital D by D. T. There in the novel Stokes equations, whereas in Newton's second law, we used lower case D by D t there. So capital D by D. T is known as the total derivative or material derivative in mathematics, and it comes up quite a lot in fluid mechanics. And you may see this when some people express their conservation equations and the reason we do it is because as a fluid parcel moves through a continuum, the fluid parcel may accelerate in space as well as in time. Now, this may not be clear for the moment. So what I'm gonna do is illustrate this with an example. This should make things a lot more clear. And the best example to think off is the flow of water going through a garden hose. So if we look at the picture there on the water's coming through the hose from left to right on. Initially, the fluid is very slow because we're in the large hose, and then as we move into the nozzle, the water's going to accelerate, and you can try this for yourself. If you have a garden hose or pipe and you put your hand over the end, you'll see that the water comes out a lot faster as it moves out the nozzle on. The reason for this is what's happening is if we keep the flow rate in the hose the same that means the tap that you've got. If you keep the tap at the same opening, then the flow rate is not changing with time. So as the water moves through the pipe, nothing is changing. However, if we think of a small parcel of fluid that's moving through, that pipe originally starts at the left, moving quite slow. As it moves into the nozzle. It accelerates the food accelerates in space on as time is progressing as the fluid parcel moves, then the fluid parcel is also accelerating in time. Now, even though the flow through the pipe is steady, we could solve a steady equation to calculate the velocity field because the particle moves through time as it moves through space. The particle does accelerate in time, and this is expressed in the total derivative. And was the reason that we use the total derivative rather than the local time derivative. When we write the Navy Stokes equations? No. Now, if we move rather than thinking about the physical meaning off the material derivative, if we think about how it's written mathematically, we get Equation seven there. So Capital D by Capital DT could be expanded into a time derivative, partially the partial T plus the change in space on what you can see there in Equation seven is the spatial derivatives are multiplied by the velocity, and in the case of our hose pipe that we just saw there, the velocity is you X. So the velocity is moving from left to right in the X direction. So we're going to multiply the X derivative by the velocity in the X direction, and you can also check this by working through the units so meters per second multiplied by one over meters, gives units off one of a second, so it's consistent all the way through on. We can move from Equation seven to Equation eight and write more compactly in vector form, which is commonplace on then, if we replace the material derivative in our previous equation by Equation eight, we arrive at Equation nine there, which is just another way of writing the same never Stokes equations. By now, those of you who have done a lot of fluid mechanics are seeing that the equations are looking are not more familiar on the final step in the simplification between nine and 10 is an application off conservation of Mass and the product rule, which I'm not gonna go through here because it's many, many lines of just a manipulation which aren't really needed here. You can also always look that up on the Internet. But what we arrive at is Equation 10 there, which is the expanded form of the Navy Stokes equations. So remember, on the left hand side, we've got the rate of change of momentum of a volume of fluid on On the right hand side, we've got the forces of some of the forces per unit volume acting on that volume. Now, of course, for those of you who are familiar, you might think we're not. We're not fully done here because we haven't expressed all of the forces acting on our fluid volume. So that's gonna be the step I take next and will eventually arrive at the full form of the narrow Stokes equations that you may be used to seem. By now, however, it's very useful to always remember Equation 10 because it reminds us actually what the equations are saying. They're physically saying, for our volume or parcel of fluid, the rate of change of its momentum is equal to the sum of the external forces acting on it . So now let's go ahead and look at some of the external forces. So there are many different forces that could act are fluid volume on the most common forces. Acting are fluid. Volume are due to pressure viscosity, Andi gravity. And so those are the ones I'm going to include on the right hand side. There, in Equation 11 we got the pressure Grady in term, the Grady int of the shear stress, which includes in it the action of viscosity and viscous forces on, then the acceleration due to gravity there is the final term. It was always important to remember with the Navid Stokes equations that the pressure grading has a minus sign in front of it on. The reason for that is, is we have fluid will accelerate in the direction off, decreasing pressure. So if you have a high pressure region on a low pressure region, the fluid will accelerate from the high pressure to the low pressure. So the fluid accelerates in the direction off, decreasing pressure always important to remember. And that's why we have the minus sign in front of the pressure. Grady in term there. And now that just about wraps up everything for the Navy Stokes equations for now, just a final reminder that what we've got on the left hand side there Arthuis acceleration terms. So this is the acceleration or the change of momentum of that fluid volume. On the right hand side, we've got some external forces on the number of Stokes. Equations are probably one of the most complicated of all the transport equations that you'll see in fluid dynamics. On there are several reasons for this, but probably the most important one is if we look on the left hand side, we can see within the second operator. So the napoli dot ro you you term would see that this time is actually nonlinear in velocity. You so remember that the velocity is the unknown in this equation on what we've got, there is a use squared term. So this means that the marriage Stokes equations are non linear. This makes them more difficult to solve as a differential equation. But they're not what we're going to be focusing on today. What I like to do at this point is actually move on to look a mawr transport equations so that you can really see how the form of thes transport equations is very similar to the Nambia Stokes equations. And you can actually think of them all as one collective set off transport equations on the first example of a transport equation. I'm going toe introduce a lookout Is the transport equation for heat or thermal energy in a fluid? On an example, we can always think of a very easy example is if we have a hot surface or hot plate on. We have cold air moving over the surface of this hotplate. The cold air will cool down the surface and then warm up. So what we've got there is motion of a fluid being used to cool the hot surface on. If we wanted to solve this problem numerically, perhaps we have a very complicated geometry, not just a flat plate. Then we would have to solve the Naevia Stokes equations first to get the velocity field so we know how fast the air is moving across this plate. And then Secondly, we also need to solve a transport equation for the thermal energy or the heat as well. So we know how the heat eyes convicted and transported away from the hot surface by the air on. If we have air or water moving at very low velocities that we haven't in compressible flow , then the transport equation we can use to calculate the heat and the temperature of the fluid is given there in Equation 12. On most of you who have amore detailed background in fluid mechanics will know that this is a simplification off the full entropy, or total energy equation. It's a simplified form, but it's very useful for demonstration purposes here on what you'll see is that actually, this transport equation has a very similar form to the Navy. Stokes equations on on the left hand side, what we have is we have a time derivative term. So we have a rate of change off thermal energy in time, and then a second term we have is a conviction of thermal energy. You can see there within the nabila dot term. We've got a we've got a year we've got a velocity on, we've got a temperature there. So what this is telling us is that the temperature field or the thermal energy field is convicted and moved by the velocity field, so if they've lost year zero, there's going to be no conviction. But as we increase the velocity field, which we get from solving the Navis Stokes equations, the conviction or the strength off the conviction field over that hot plate is going to increase. We're gonna get increased cooling of the plate by the air. Now, on the right hand side, what we have is we have a diffusion turn on. This diffusion term occurs in pretty much all transport equations as well. On the way to think of this diffusion term is that a transported quantity like thermal energy or temperature or concentration of a species will tend to move from areas off high concentration two areas of low concentration. This is a diffuse IT process where the quantity will tend to spread out over time. And if we took out the conviction term and we just had a hot plate with no, uh, with no al velocity over the top, perhaps this was in a solid body. For example, in a solid body, we don't have any fluid moving through the solid body. We only have diffusion. Then diffusion is going to allow the heat to conduct from one part of the solid body to another. So the diffusion term is very important. Always appears in transport equations as well. And then the final term we have on the right hand side, there is s, which is a general source term which usually the user of the C F D code can use to include additional sources of heat or would have transported quantity we may have into our fluid domain. This maybe he sources due to due to fire, for example, or something. Something very hot that we haven't modeled on this general form of a transport equation allows us to account for that as well. It's also worth noting at this point that we also haven't, of course included rate he transferred by radiation. And that's a whole separate topic, which I'm not going to go on to here. So just a small recap there. What I've covered the thermal energy in the plate will be transported away from the plate into the fluid by two main mechanisms. And they are conviction on diffusion on those times about highlighted in Equation 12 on the diffusion term. There on the right hand side, some of you may notice it takes the form off a LaPlace IAM or when we consider the other terms will be a Poisson equation for temperature on. We can always expand that in Equation 13. If we want to see the derivatives in the various Cartesian directions on what I've also done here, is expanded the conviction term as well, so you can see how that term looks. If we expand the divergence operator there, we can see that the temperature field all the thermal energy field is conducted by the velocity in the X y and zed directions. So we may have a case where I have lost years entirely parallel to our surface, in which case the other derivatives will disappear. Um, and really, for those of you on familiar with conviction and what a conductive processes a nice, easy way to think about this is if you're standing by a river, for example, and you drop some leaves or some twigs into the river, then the motion of the river or the velocity field will physically transport those leaves and branches downstream in the river. And that's really what the conviction process is. Eyes modeling here on interestingly, has another side point is that conviction always increases. The rate of heat transfer on is the reason why if you have a hot drinks such as tea or coffee by blowing over the surface, you're increasing. The rate of conviction on that cools down the drink faster, so you're able to drink it. I was particularly like that example. Now I would like to do is move on and just look at a few more transport equations so you can see that. Actually, they all take a very similar form to the one for the thermal energy or the temperature field on the first I'm gonna look at is species concentration equation. Now, this is one that often appears in text books. You may have seen this and has given their in equation 16. So C is the concentration off some dye or solid particles or species in in the field and the motion off that dial. The solid particles will be governed by conviction, so solid particles or the die that you inject into a flow stream could be convicted by the motion of the stream. And they will also diffuse under their own Grady int. So if you're in debt, inject some dye or solid particles, they will tend to move from regions of high concentration, perhaps where you've injected them and spread out into regions of low concentration. On I've got a nice simple diagram for you here to help visualize that so got our died being injected at the left side. There on. As you can see, the flow field is moving from left to right, and so the concentration or the number of die particles or die dots there per unit. Volume is decreasing as we move downstream because the dyes being physically convicted and also diffuses under its own Grady int. Now, if you were to think of this situation where we turn the flow field off of lost, he was zero. The die would still tend to move downstream as it diffuses under its own ingredient. But the rate of diffusion the rate of motion, I should say, would be much slower than if we had conviction as well. So conviction always acts to accelerate the transport of these processes on is the main reason why we would use a CF decode, especially because the C F D code allows us toe workout that motions will calculate the convicted transport. And what you can probably see by now is the all of these transport equations in a CFT framework take a similar form, which is given there in Equation 17. So you have a time derivative on the left hand side, a conviction term inside the conviction term will be row you. That'll be the velocity field that convey ETS, the quantify and then on the right hand side, there's a diffusion term allowing the quantity to defuse from areas of high concentration, two areas of low concentration and then finally a source term there at the end, which gives the use of the ability toe introduce things as they see fit. Onda should also notice well that some more advanced equations, such as the turbulent transport equations, have additional terms on the right hand side there which aren't really covered in this framework on really, we can think of all of these additional terms as source terms. So s fi there. There may not be one there, maybe five or 10 of thes additional source terms. But whenever we're observing these transport equations in CFT, the three key terms the time derivative, the conviction term and the diffusion term will always appear on what I'm gonna be showing you in this course is how we deal with the conviction and the diffusion terms numerically on also a straightforward way that we can account for source terms on when we think of transport equations in this format, we can really begin to approach any form of transport equation that we encounter in CFT. Whether that be for a turbulent scaler, for energy, for entropy, temperature or concentration. We can always use the same framework toe approach, the problems of solving these, which could make our CFT solve its very general on allow us to solve new and exciting problems in the future. On what I'm gonna do now is move onto the next few chapters in this course where what we're going to do is introduce the finite volume method which is perhaps the most popular way of solving thes transport equations in CFT on. Once you've seen the final volume method applied to a transport equation, you can then easily extrapolated and see how we could also apply it to any transport equation which had the forms that we've introduced there with time derivative conviction term, a diffusion term and some source competitions. And what the equation I've chosen to look at in this course is the temperature equation or the thermal energy equation on could have chosen any equation. But I chose it specifically because conceptually, it's perhaps the easiest equation to understand, because for us to follow initially, we know where regions of high temperature are low temperature are, and various properties of the fluid, such as its conductivity, are easy to appreciate while we're learning on. Then if we moved on to then look at him a more unusual transport equation, then we already have seen the processes by how we handle the equations on allow us to approach those more detailed equations. Having already developed a good understanding in the first place on the way I've chosen to break down this course is to look first at the diffusion term in the next chapter so that you can see over all the processes in the final volume method how we go from starting with Justin Equation and how we move all the way through to a full set of matrix equations and how we solved them. And then in the third chapter, I'm going to introduce the conviction term as well, so you can see what happens when we have a transport equation with both conviction on diffusion on for many of you have seen these methods before. You may already be used to solving the diffusion equation because it's quite popular when teaching people how to solve differential equations. But the conviction term is a bit more unusual on is one that you may not have seen before and you'll see that we need some special treatment to account for the conviction term. And I think it's something you might not have seen before. Andi, in particular I'm going to show you in the final chapter is a special technique called up Wind Difference Sing that we often need to use for the conviction term to ensure that its stable at high flow velocities. And just to wrap this up by saying, I really do think you'll learn a lot from this course. I've tried to present in a very structured ways that you can really follow all the steps on hope that you've enjoyed this introduction so far should really piece everything together and how trying to bring everything together under a framework of transport equations on by the end of this course, I think, really have understood deeply how we set up and solve transport equations. And while we may not have considered problems that are as advanced as modern CFT codes do, you should have a real fundamental understanding of one of the key stages in the process so you can understand what's going on in CFB code that you're using a bit better 3. The Diffusion Equation: Okay. Welcome, Teoh. Chapter two off my fundamentals for computational fluid dynamics Course In this chapter, what we're gonna be doing is solving the one D diffusion equation for the transport of thermal energy or temperature on as a reminder. If we look at Equation 18 there, we can see that the conviction diffusion equation for the transport of temperature takes a very general form which we saw in the previous chapter. And that is on the left hand side. We've got the partial derivative with respect to time. Then we've got the conviction term or so on the left and then on the right hand side, we've got the diffusion term on then a source term for a source of thermal energy or temperature on just a reminder that this transport equation shares the same general form. Regardless of whether we're solving for temperature, species, transport, turbulent scaler or any other field in computational fluid dynamics on, we're gonna be just using the example off temperature here because it's nice and easy to follow. And we all have a good appreciation for what the temperature field actually is. Just a reminder that you can use thes same methods that were gonna be introducing in this chapter toe Any other transport equation of the conviction diffusion full. Now, folks of this chapter is going to be just the diffusion and source terms. I'm going to consider the conviction term in the next chapter. So I want to finish this one. Just go ahead and look at that one on. Then you can see how we can start to piece together the components of the diffusion equation and for simplicity here, which is gonna be thinking about one d So are only gonna be considering the X direction. But what your soon see is that you can readily just extend this to the Y and Zed directions for a general three dimensional code if you want to. The reason for choosing one day is it's a lot simpler, and we can just keep everything nice and compact, and we don't have lots and lots of terms running off the page in our equations. So starting with equation 18 the conviction diffusion equation for temperature, the first thing we're gonna do is cross out and ignore the time derivative on the conviction term. On the right hand side, which one equation 19 And that leads us to equation 20 which, as most of you will notice, is a Poisson equation for temperature, which you often see in textbooks. Now, just expanding that, Grady in on dot product operator, we reach Equation 21. Now for simplicity here, what we're gonna do is council out the winds that derivatives and just look at the X derivative. So solving the one D steady state diffusion equation in the X direction on the way we're gonna be solving this equation is with the finite volume method. Now, remember, you can use a final element method or finite difference method or spectral method to solve these equations. But the majority of CFT codes use final volume. So we're gonna be using finite volume here as you get the most understanding out of that. And as a reminder how the final volume method works is we start by integrating the entire equation of a control volume or small parcel of fluid in the full continuum of the domain. On mathematically, you can write that integration, as you can see in Equation 24 integrate the entire equation over some volume V and that's going to zero just reminded there of what we're doing with our final volume. We're taking a small piece or a chunk of the fluid continuum on. We're integrating the equation over that volume. And of course, the equation would be valued regardless of what volume choose or how large the volume is Now in one day. What does what What does this mean physically on? Easy way to think of it is if we have a bar or a rod in one D on what we're gonna be doing is taking a chunk out of that rod. And that's our control. William V there. Now, of course, the assumptions for this to be true would be that there's negligible variation across the surface area off that volume and really the temperature and the fluid properties only going to vary in the X direction now toe proceed with a final volume method. What we do is we note that integration Andi addition our communicative operations might sound quite complex to you, but basically it means it doesn't matter whether you add and then integrate or integrate and then add the's. The result is the same. And so we can split up the integral into the integral of the diffusion term on the integral , off the source term there in Equation 25. And of course, if we had a conviction term on other source terms, we could just integrate those as well and then add them in. And that's why really weaken. Just consider the terms one by one, and that's what we're gonna be doing here. So the first thing to do is deal with source toe. Now there are two different ways of dealing with source terms. You can treat them implicitly or explicitly on the way I'm going to show you. Here is the explicit treatment because it's the most straightforward on. I'll leave implicit treatment to later on on what we do. We want explicit treatment is over our control volume. What we do is we take the volume average of the source, turn over that over that volume on just gonna deny that by s bars. That's the volume average on. If we're taking the volume average, then of course, that moves outside the volume integral on. The reason for that is, of course, the value will be constant across the cell. And if it's constant, then you could just multiply it by the integral and so that moves outside an equation 26 then we reach Equation 27 which is we've now got the volume average of the source term. Multiply by the volume of the cell on just a reminder here in terms of units that the source term per unit volume will have units off what's per meter cubed. And so the product s bar multiplied by V, has units of what's so This is an energy equation or power equation, because all of the terms will end up with the units off. What's so what does this mean physically when you're applying a source home in your CFT code? Well, if you had a bar that's 10 meters long and you had 10 volumes on your source was ah, 100 watts. Then, to each of those volumes, you would apply 1/10 of that source if it was constant, because you want the volume average. If you have a linear variation, you take the variation you average over the volume. So just a reminder. That's how we deal with source times when we treat them explicitly. Now, I don't really want to talk about source terms. Too much here when I won't really want to focus on, is how we deal with the diffusion term because this is really the main key points in the final volume method. What we do to simplify this integral is we used the Divergence theorem or gases Divergence There. You may have heard it related to like that on what does gases divergence theorem say? What does it mean physically? Well, the best way to understand this is to look at a general example and then we can use that general example to apply it to our equation. So if we think of a general vector field A so they will have three components will have a component in the X direction, a component in the Y direction on a component in the Z direction. What gases Divergence theorem says physically. What it actually means is that if we have a volume or a box, which you can see there in figure nine is that the rate of accumulation off a in the volume must be balanced by the flux of a out of the volume. If there are no sources in the volume, so you take a look at Equation nine there. What we can see that gases divergence theory means is that if those blue those blue balls of those blue items, if we're getting mawr of them in the volume but none are being generated in the volume than they must be crossing the surface somewhere on the reason there are integral is there is it's the sum over all of the surface is so some of the accumulation in the volume must be equal to the sum of the accumulation over all of the surface is otherwise we're generating a from nothing on. Now that we understand what it means physically, how do we write it mathematically? Well, we write it mathematically, as you can see there in Equation 28 so the divergence of a or nabila dot a integrative. The volume is equal to the surface, integral over all of the areas in the volume off that vector field, a times by the unit normal vector pointing out of the cell that's n dot multiplied by the area on. If we write that in terms of components, we get equation 29 on, we could see that we've got the components of the divergence operator on the left on the components off the normal vector on the right. Now, of course, for this analysis, we're only considering the X direction so we can counsel out those terms in y and Zed on. We arrive at equation 30 on if we want to apply the divergence there to our diffusion term . What we do is we're going to say that vector A the general vector A that we considered previously we're going to let that represent k mortified by the Grady int of temperature. Okay, grad t so remember temperature as a scale of field, meaning it takes one value at a given point in space. But if you take the Grady int of temperature, you have d t d x d t d y and d T d said to the Grady, int of temperature is a vector field. And so general vector A we're going to use to represent que grad t. Now the component of eight x direction is K multiplied by D T d X. And so what we can do is we can go back to our final volume equation equation 27 we can see there, we got K d T d x Onda. We can use that to represent our vector a X and use the divergence there on that quantity. And what that does is it allows us to get equation 31 so it can see there. What we've now got is we've now got the integral over the surface of our control volume or a piece of bar off K time dtv x times, the normal vector pointing out of the surface at that point and then adding the source terms that we may have in the volume. Now if we want to move on further, what we do is we remember that on the surface of our one d bar, those properties are going to be constant across the surface so we can move K d t d x multiplied by the normal vector X outside of the integral. And that gives us equation 32. And the reason for that is those quantities are constant on the surface. So before we can move on further, what we need to do is go back and think off our cell. So if we go back to figure 10 here, this is our cell in our one d bar because it's one D. We're only thinking about the face on the left, on the face, on the right. We have two faces. Andi were considering the X direction going from left to right. So if you look at the diagram there, remember that the unit normal vectors always point out of the volume on what that means is that the unit normal vet on the left face is negative. Where's the unit? Normal vet on the right face is positive, so we can substitute in for an X in Equation 32 that where when we're on the left, face and X will be minus one, where's one on the right face and X will be plus one and then multiplied by the area off that face, and that allows us to arrive at Equation 33 so you can now see that we've got two terms there on. Then we've got the source term as well. On what these terms physically represent are the flux of heat by diffusion, out off the left face of the cell, on the flux of heat by diffusion, out of the right face of cell And if you add these together with source of heat in that cell, that total quantity must be equal to zero. Otherwise, we've lost or gained some heat somewhere. We're not obeying conservation off energy now to go from Equation 33 to 34. What we've done there is substituted in minus one for the normal vector on the left face on plus one for the normal vet on the right face. And I'm using the small sub script are there to denote the right face of the cell on the left face of the cell. So we're not getting confused. It's worth just remembering this notation because later on, I'm going to be introducing Capital L and Capital R on these air going to refer to values at the center roid where it's lower case is going to refer to quantities on the self faces . No, before we can proceed further to simplify Equation 34 put together on algebraic equation that we can solve rather than a differential equation, we need to think about interior cells on boundary cells in our mesh. So whenever you generate a match regardless of that one d two d or three d All of the cells and the mash are either classified as interior cells or boundary cells. Now on interior, cell is connected to other interior cells on all sides, whereas a boundary cell has one or more of its face is attached to a boundary. Now here, boundaries General on boundary can refer to a wall or an inlet and outlet or a symmetry plane boundary is just a contact with a surface that's not the face of an interior cell on . The important thing to remember with the final volume method is that we have to write a different equation for the interior cells on a different equation for the boundary cells will be very important later. So it's quite useful for you to remember that when you're actually running your CF, decode that all those cells that you see along the wall along the inlet they're actually treated differently to the remainder of the cells in the mesh and the CF decode remembers, which are interior cells on which our boundary cells. Now we're gonna start with it with the interior cells. We're gonna start with Equation 35 which is that general finite volume, discreet ization of the one D heat diffusion equation. And in this case, on L, the right in the left face are both faces off another cell on the way we're going to simplify. This is we need to get an expression for that temperature, Grady int d t d x. Because we don't want any differential terms, We only want to get algebraic terms on the way we simplify. This is we think of DT DX is a change in temperature over a distance on the way we're gonna do that by thinking further is by looking at this diagram equation in figure 12. Sorry on what we do in the final volume method in a cell centered code is that we sold for the temperature at the cell Centrowitz. So what you can see there in the diagram is that TP is the temperature of the central we're considering. And then t l is the temperature off the cell that next to ourselves on the left and T R would be the temperature of the cell that on the right of ourselves on what we know is we know the temperature of thes two century. It's we're going to Seoul for them. These are the unknowns we want. And we also know the distance between them. That's D L P there. So we've got to temperatures so we can work out our delta t on. We know the distance between the cells. We can work out Delta X going back to our equation there, using equation 36 we can see that d t d x from the left face d t x l could be written as tp minus t l as the temperature at the central we know minus the temperature of the central oId off the left cell TL divided by D. L P Amusing DLP to denote the distance between the left cell and the cell that we know now we can do exactly the same thing for the right face. That's an equation. 38 This time is going to be t R. That's the temperature of the century on the right of this cell minus T p of the d p. R. So in all of this treatment, I'm treating left to right as positive. And so now we've got expressions for those two. Grady, it's DT DX on DT DX. The left self. So substituting those back in on we get equation 39. So what you can see here in Equation 39 is now There are no derivatives anymore. We only have algebraic expressions for all of our quantities. And again, small sub script are refers to the value from the cell face and the big sub script with capital subscript denotes the value at the self central. Now what we do is rearrange this equation in terms of the temperatures at of self Centrowitz tp t l and t r. And when you do that rearrangement from equation 39 we reach Equation 40 on what you can see. Actually, if you look at these terms, they all have a fairly similar form. We've got a K on A and then a D, which is a thermal conductivity multiplied by an area divided by a distance, and that seems to be fairly common across all terms. They're on to avoid right in this quantity. Out many, many times you're going to see in this in this course, we're gonna introduce the notation off capital D, which is gonna be K over D. So Capital D is the diffuse. If flux off heat through a face on later, we're going to see other things, like the convicted flux of heat for a face. But for now, we can use capital D to the diffuse it flocks of heat for a face on. If we introduce that into equation 40 just a bit of notation. We arrive at Equation 41 there. On what you can see, we've got our unknowns there tp the temperature of the cell century that we're looking at and then t l temperature of the century on the left on t off the temperature of the century on the right. On the source term, which we know now for convenience, all I'm gonna do is rewrite equation 41 in the form of Equation 42 where a is just a coefficient multiplied by these unknown temperatures On the reason for doing this is gonna make a comparison off these coefficients later so that you can see how did the coefficients change on each of these self central roids? Whether I'm an interior sell a boundary cell is their conviction is they're not conviction on. The coefficients are underlying there in Equation 43 on their summarized in equations 44 45 on. At this stage, all the algebra of being through is quite simple. On you may find it useful to go through it yourself so that you can actually see where these terms come from. It's quite straightforward. And if you find you quite tricky or your losing pluses and minuses in certain places, just use this document toe check. You've got the right numbers and you see where they're coming from. Now what we're gonna do, we've done this for the interior cells. We're going to take the same treatment and apply it to the boundary cells where if you've been having to think so far, you may have noticed that we were looking at quantities on the left face on the right face . Now for a boundary, sell the left face, maybe a boundary. It may not be connected to another Selves. We need slightly different treatment. First we're gonna do is look at a boundary cell on the left and you can see that in the diagram there on, we can see that the temperature of the left face is actually gonna be fixed. In this case, assuming this is a wall or an inland. So t l is going to be equal to t a on ta I'm using to refer to a boundary condition that the user may specify. So this could be 100 degrees or 200 degrees. We know what this temperature is when we're gonna substitute in. Now, what you may notice from the diagram is that the distant DLP actually extends outside of the mesh. And so, actually, the distance that we want is the distance between the cell central and TP on the wall, which is going to be half of DLP that we introduced earlier. This is gonna be a factor of two introduced into the equations. Now, Now, on the right hand side, we can use the same treatment that we used before for the interior cell. But for the right self. So again, starting with Equation 46 What we're going to look at first is DTV X on the left face. So in this case, the change in temperature is tp minus t a. So the ta being the wall temperature this time on what you can see there from Equation 47 is the distances Haft in this case because the distance the wall is a lot shorter than the distance would be to the next cell central. Right? So substitute that in and we arrive. Equation 48. Where for the right face, we've used exactly the same treatment as we used for an interior cell and again to go from Equation 48 49. We're gonna introduce the notation off the diffuse it heat flux per unit area. That's capital D toe simplify things and make them a bit easier to keep hold of the terms and again rearranging in terms of the temperatures at the cell Centrowitz, tp and T aw, collecting the terms on we arrive at Equation 51 where what you're notice here is I've used the same notation as was used for the interior cell so we can keep things consistent. What you'll notice is that the coefficients actually slightly different. So the coefficient for T l A. L is zero this time because there isn't a cell on the left hand side of our boundary cell coefficient. On the right hand side, T R is the same, but this time for our teepee for our south Central we've got an additional term added in there to D l A l on this is the contribution off. The diffuse of flux from the boundary face on the left is multiplied by two because the distances Haft on what we also see an equation 51 is that our source term, which was originally s multiplied by V, now has an additional contribution from T A. So we've now got a source of heat coming into the cell from that left boundary face. And that's what into the equations through Equation 51 there. And so now, just to wrap things up, we're gonna do the same thing for the right boundary face on. This time, we're going to refer to the temperature of the wall as TB again noting that the distance to the wall is half the distance to the cell phone. Troy, that would be there if we have an interior cell on attempt, the temperature on the left face T elf. We can use the same treatment as we did for the interior cell. So starting with equation 54 we then substitute in for D t d X on the right face again noting that the temperature is TB this time multiply. Sorry. Subtracting TP divided by half of that distance DP are on substitute that into equation 54 on we arrive Equation 56 on At this point, if if you've been following along and maybe having got this yourself, you know that the next step is to rearrange this equation in terms of tp t l on source terms. So introducing the notation capital D for the diffuse of heat flux the area we arrived at Equation 57 on. If we write this in standard form again, it could be easier to see exactly what's going on on what you see that this time the coefficient TL we do have a contribution on the right hand boundary face. That's because all right boundary face is connected to a cell on the left, but it's connected to a wall on the right. That means the contribution to T R is zero because there's no cell on the right, however, because we've got a boundary face. The influence of that boundary face comes in in the source term through the coefficient AP on the left hand side. Because the distances Haft on we're going to get diffuse of flux coming through that face also. Now remember, we're getting a source term from the temperature TB of that wall, and that's coming in through the source term there in Equation 59. Now, what I've just shown you here is quite a lot of algebraic manipulation to get some equations all together in a consistent form. As you've seen in Equation 59 for example, on what have done here in in the pdf is put together all of these coefficients in a summary table. So it's nice and easy for you to refer to, and you can compare the coefficients. If you want to follow along on, do this exercise for yourself just taking a quick glance at the table. We see that on those boundary cells, we have a zero contribution to the coefficients ale on a are when that faces in contact with a wall on isn't in contact with an interior face on. We also see that the influence of that wall comes into the equation through the source terms, S U and S P. Now SP is incorporated into the coefficient in AP, which you can see there on S U has just added as an additional source, along with any additional sources per unit volume that we may choose to at no. What I like to do is I've shown you so far how, from a differential equation the one D steady state heat diffusion equation, we could arrive at a set off algebraic equations, depending if ourselves an interior or boundary cell. But what we want to do now is solved the problem for a real geometry on the way we do that as we take our real geometry and split it up into lots of different cells on as I'm sure you will know this process called mashing. So really, what you're doing with mashing is your generating a load of interior cells and you're generating some boundary cells as well, and you're going to apply different equations in the interior cells on in the boundary cells on. I've just got a few notes on mashing here, and of course, as you all know, mashing for many practical uses of CFT is really the most important part of the process, because the quality of the mash will affect the accuracy of your solution. On also how stable it is when you write your CFT code. But for the examples, I'm going to show you here, which is going to be using a quadrilateral mash so optimum mesh quality. So we're not going to be looking at the influence off mashing on accuracy and solutions. Rather, I want you to see how the equations are assembled on how the solution proceeds on. We can always talk about meshing another time. So what I'm gonna do now is take you through an example so that you can really see how this process works on. The example I'm gonna use is just this simple one D bar that we thought about before you concede there in Equation 15 on What I'm gonna do is split that bar into five cells. So what you can see in the diagram is the boundary Sell one. So So one story is a boundary cell cells 23 and four interior cells and then sell five is a boundary cell again. And what we're gonna do is we're gonna write an individual equation for each of these cells and then assemble them and solve them together on because there any five cells were gonna get five equations which we can solve straightforwardly with code. I've provided you along with this course. So in the blue box there, what we can see is we can see the equations for cell 1234 and five. On this time, notice that we're using the sub scripts to denote the cell number. So for the boundary cell on the left, this is cell number one. So the temperature at its central oId TP is gonna be given by T one on boundary cell on the left has an interior cell on the right. So we've got the term a r times t to appearing on the right hand side there and then we've got a source toe and if need be, you can always just refer back to the picture when you're right in these equations so that you ensure that you get all of the terms in that and again repeating for the interior cells . Noting that the interior cells have another interior sell on their left and right, so they have extra terms on the right hand side there. And then we've got the source terms which we haven't yet defined yet So the next stage to solving these equations is really a bit of algebraic manipulation. And the trick is, we bring all of the terms, have temperature in them to the left hand side on. That's what we get there in the next blue box, all of the terms with temperature or on the left hand side. And we leave all of those sources s you on the right hand side on. Most of you who are following along will probably see where this is going. We're gonna be assembling some matrices here on the trip to assembling the matrices is we're going to add zero values for all of the missing temperatures into those equations. So you can see so 1234 and five have five temperatures in them on their zero values for cells that are cell is not connected to. And of course, now the equations are in matrix form, which I've got for you there in equation 62. We've got the coefficient matrix there a. And then we are vector of unknowns T which are the temperatures of those five cell centuries on them. On the right hand side, we've got our source terms. Or remember, this is the source acting in each of those cells, and Equation 62 is very handy because it's in the standard form for linear algebra on much , much. Research has been carried out into linear algebra over the past few years, and there are some excellent and efficient methods for solving these equations on course. In this course, I'm not going to go through different algorithms for solving the matrices that there are plenty out there on. You could always just refer to your favorite linear algebra textbook for efficient methods of solving these equations. That's not really the focus of this course. So now it's time to fill ins and values. And let's see if we can actually generate a sensible solution using the final volume method . So the example problem we're going to consider is Baba, which has a temperature of 100 degrees at the left end on a temperature of 200 degrees at the right end on then it's gonna have a cross sectional area off 0.1 meters squared thermal conductivity of 100 and there's gonna be a constant heat source of 1000 watts per cubic meter in the bar on. Good. Just a reminder here. Of course, if you were presented with this problem, then the temperature field in the bar is gonna be governed by equations. 63 there, That's again the one D steady state diffusion equation on. We're going to solve this with the methods that we carried out previously. On the way that we do this. I'm just gonna give you the simple step by step solution process so that you can really follow along. The first thing we do is we take figure 16 and divide it into a mash of cells on. For now, I'm going to use five cells, but you're more than welcome to use as many cells as you want. It's just gonna make the major cities larger. And if we have five cells in the bars five meter long, then each of those cells is going to be one meter long on the distance between the South central raids, that D is going to be one meter. So now that you've created your mash, the next stage is going to be to assign material properties to each of those cells in the mash because you may have a match where the size and shape of the cells and the conductivity and the properties may vary within the mesh. Now, luckily for us, all our property is going to be constant along the bar. So it's nice and easy to solve, but you can see how in principle you could assign different properties to every cell if you wanted to on for simplicity here, what we're gonna do is evaluate those key parameters. So evaluate de times A, which is the diffuse if heat flux for your area, times the area and substituting in the values there gives us 10 watts per kelvin. So course these are gonna be coefficients. So when we multiplied by the temperature, we're gonna get units of what's, which is consistent across all the equations on the parameter d A. The diffuse of heat flux is gonna be the same in all of ourselves. That's gonna take a value of 10 and then the heat source per unit volume for ourselves again. Remember that we're going to we need to take that heat source and then multiply by the volume of the cell there to get the heat source in each of our cells. And then at this stage, what we can do is go back to that previous table I showed you in blue from before, where we calculated the coefficients a l a r s, p s, you and AP on. Now that we know the values for what d on a r and the source term in the volume, we could just calculate what those coefficients are there now. You could, of course, jump straight to the major cities and sold them if you want. But I find it a lot more straightforward to calculate the table of coefficients first. And that's why I'm sure you here on now that you know the table of coefficients, what we then do is paste them into the correct places in the matrices. So if we look at the first equation, for example, in the Matrix, then that diagonal term is the coefficient a p. So we have 30 there. That's as a P for the boundary cell on the left on. Then the next coefficient is going to be a are because cell one is connected to sell two on the right. So the second coefficient that is going to be the coefficient A are for the boundary shell on the left. Now, remember, at this point that we need to introduce a minus sign because we took all of those temperature terms to the other side of the equations when we did some rearranging. So make sure you keep your mind assigns in that you don't lose track of them. And then the source term on the right hand side is just s u for the boundary. So on the left, which is 2100 on what you can do, is go through the equations and assembled the matrices coefficient by coefficient on you will arrive at Equation 69 which is the final set of matrix equations that could be solved on. We can solve that with any linear algebra solver that we want. Now, of course, is a small caveat. Remember that in a real cf decode thes matrix equations are assembled and solved many, many times. So no, only will that individual equation be solved, it relatively using an attractive silver. But the equation itself is going to be solved multiple times as our overall solution proceeds. So as we stepped through time or as we step through pseudo time steps in a steady states over. We're going to be solving this temperature equation multiple times, and it's important to remember that. But for now, we're just gonna solve it once because it's a simple equation on what I've got for you. Here in this small green box is a prompt or reminder that you can actually go ahead and solve these equations yourself as well. You don't have to assemble them all by hand. As I've done here on create some coding for yourself to do it. I've actually included solutions to solve the equations. It marks off Excel form Andi in python form as well, so you can open either the Excel spreadsheet or the python code and run and get the solution yourself on what you'll see if you look at either of these. Taking the Excel sheet, for example, is I've got all the inputs at the start so you could modify the inputs. If you want to modify the conductivity or the temperatures on, then all of the stages in the previous solution process are there, so calculating the geometry of the mesh. Calculating the matrix coefficients the D. A A. L a are all calculated here so you can see exactly what's going on on. Then the assembled matrices on. Then finally at the bottom, the solution and the solution better because it's Mark Soft Excel. We just use the built in matrix. Solve it there on in another tab. Here, I've got a plot of the solution for you on. You'll find the same thing if you use the python code. So in the pipe, in code flicking over to that, all of the data is laid out the top on. Then the thing equations and the coefficients are assembled on, the matrices are solved down at the bottom. The difference with the python code is all of the output is printed to the screen so that you can see that as well. But regardless of which one you choose, we're going to get the same solution here. Yes, so the Excel spreadsheet or the python code on what you can see there is. I've got the analytical solution with the red dotted line on the C F. D code with the blue dots. So noting that we had five cells in our mesh. So we have 12345 solution points. These are the temperatures of the South central rates, and then I've added in for you there the temperatures of the boundary cells, temperature of the boundary walls at either end off the bar on what you can see for this simple problem with CFT code actually does a very good job on pretty much gets the solution bang on. But of course, you'll notice that there is some error there which you could calculate if you wanted. There's some small error between the CFT code on the analytical solution on. The reason for that, of course, is because the C F D code assumes a constant variation between self Centrowitz. So if you remember when we worked out the temperature Grady in there with a d t. D X, we have the temperature at once. L central lead on the temperature of the neighbor cell century with a linear variation between them. So here the solution is quadratic in nature. But the variation between cells is linear. So if we wanted to improve the accuracy, we'd have to increase the number of cells on that something you could do very straightforwardly in the python code. But what I've done for you is actually plotted the solution here for you with the with the original MASH resolution five cells on with the resolution increased to 20 cells on what you can see there, of course, is that with increasing resolution, as we expect, the CF decode gets amore accurate solution on the analytical solution is also given for you there. So you don't have to work out by hand. You can always plot it if you want to. Now I hope this has been a very useful introduction team for how to set up and solve the one D heat diffusion equation with the final volume method. What we're gonna do in the next chapter is include the conviction term as well. So this example for the one D diffusion equation you may have seen before. It's often used in text books and by lecturers to demonstrate many examples of final, different single final element method. But the conviction term is rarely spoken about. I'm gonna show you in the next chapter how we can consistently include the convention toe using the same framework on once again. You have example code that's already set up for you and ready to go. You can play around with it, play around with the coefficients and the numbers, see if you can manipulate the solution it all on. That's all there for you. So it's going to save you a ton of time. And I'm really sure that by carrying through these exercises and following the equations and seeing where the coefficients are, you start to piece together and understand exactly how modern CF decodes work, even though they are three D rather than one day. 4. The Convection-Diffusion Equation: Okay, here we go with chapter three. Just a reminder of what we did in the previous chapter. We solved the one day, steady state he diffusion equation, which has given their in equation 71. So we're only considering the diffusion and source terms on in this chapter. What we're gonna do is extend that analysis by including the conviction term on the left hand side as well. So the conviction, diffusion and source terms make up three of the four key components in a general scaler transport equation. Now, the form of the conviction term is given on the left hand side. There, in Equation 72 on what you can see is we've got a divergence operator. So Noblet dot on then Rosie P on the velocity on the temperature field on what we're gonna do is follow the same steps as the previous chapter and use the final volume method to solve this equation. So, as before, what we do in the final volume method is we integrate the entire equation over a small control volume or finite parcel of fluid in the continuum of the fluid domain on. Remember that because integration, an addition are commuted tive operations. That means we can do the integration on the addition in whichever order we want. We can integrate each of the terms separately and then add up the result. So integrating the conviction term the diffusion term on the source term In Equation 72 we arrive at Equation 73. Now from the previous chapter, we will use the exact same analysis for the fusion term on the source tub. But for the conviction term on the left hand side, we're also going to use the Divergence Theorem, which was introduced in the previous chapter on just a reminder for a general vector field . A We write The Divergence Theorem has written there in Equation 74. So, uh, Noblet dot a or the divergence of the vector field a integrated over. The volume is equal to the surface integral off the dot product of the vector field on the unit Normal vector pointing out off the cell on the face. And so we can use Equation 74 to simplify the conviction term in Equation 73 on to make this possible instead of the we replace the vet to field A by the term row C P. U. Multiplied by temperature on, of course, density, specific heat capacity and temperature or scale of fields on the velocity field is a vector field. So overall that quantity and brackets vector A is a vector quantity. So using the divergence there in Equation 74 arrives at Equation 75 which you can see there at the bottom of the page on What you can see is the conviction term is thesis surface integral off row CP Time is the velocity field on the temperature dot product ID with the unit normal vector on the face off the cell so pointing out of the cell as we did in the previous chapter. Now it may be useful at this point to go back and have a brief look at the previous chapter as a reminder for how we deal with three final volume integral over the faces of the cell. Now, just a reminder here. We're only going to be considering the analysis in one D. So the dot product there of the unit normal vector on the velocity field are reduces to the X component of the velocity field multiplied by the unit normal vector nxe on. That's it. That's the simplification we're making from Equation 75 to Equation 76. We just simplifying the analysis down to one D. And again we treat the source term in the same way that we did in the previous chapter. Now, as a reminder, we're considering the analysis in one D. So we're looking at either a bar, a rod or a channel where only the X direction is significant. So the properties over the cross sectional area are constant, and that means for our cell or one D sell. Only has two faces has a face on the left side and a face on the right side are so that means the surface integral there. In Equation 77 we can evaluate on the right face of the cell on the left face of the cell, which you can see that in Equation 78 the sub script are being the right face of the cell on the subscript l being the left face of the cell. Now a quick reminder. The unit normal vector always point out of the cell on because the X direction is positive going from left to right. That means the normal vector on the right face is positive or plus one on the normal vet on the left face is negative. So we get negative. Sign there on that. Simplification allows us to move from Equation 78 to Equation 79. Now, if we look closely at this equation, we notice that the diffusion and source terms on the right hand side, of course, identical to what we had in the previous chapter. Where is the conviction? Terms on the left hand sides are new on their. The terms were going to be considering in this chapter in a bit more detail. Now, what does this equation physically mean? Just as a reminder. Well, what it physically means is the convicted flux of heat out of the cell must be equal to the diffuse of flux of heat, out of the cell puffs any sources of heat that reside in the cell. So, really, once again, this is just an expression off conservation of energy for ourselves that we're not generating any additional energy from nowhere, energy, any energy that's generated inside the cell. Will I be convicted or defused out of the cell on as before? What we're going to have to do to solve this equation is to consider interior cells on boundary cells separately on. The reason for that is for a boundary. Sell one of those faces in our one D cell is gonna be connected to a wall or on opening or an inlet on will have a fixed value. Where is on the other face? We will be connected to an interior cell. Just a reminder about notation here gonna be using capital L Capital R and Capital P to denote self centuries on lower case L and lower case R to represent the faces off that cell that we're considering. There you go. That's just a quick reminder. Few there of the situation we're considering. We've got interior sell their quit in figure 19 with the temperature tp on. Then the temperature century of the cell on the left is TL and the temperature of the century of the cell on the right is T R. So starting with the interior cells in the mesh, as you can see there and figure 19 what we're going to do is we're going to consider the conviction on diffuse it terms separately and then add them up on the diffuse a term we can evaluate using the methods that we did in the previous chapter. So just a reminder that the temperature Grady int on the face would be equal to the difference between the temperatures on the cell that's adjacent to that cell on the South century, divided by the distance between them on That's how we get the fraction there tr minus tp of a dp are. And if you can't remember how to do that, just have a flip back to the previous chapter and you can see how we do the diffusion term . Now the conviction term is slightly different on the conviction term. We don't have any derivatives in that term. We only have field values with which we know. So if we take the right face, for example, that's the first term in Equation 80. We have the density road, the specific heat capacity CP, the velocity you the temperature t on the area are on. We know all of those quantities on the cell face at the moment, so we're going to be just using this small subscript R to denote those quantities. We don't have any derivatives that need simplifying here now, to simplify this equation, What we're going to do is introduce Capital D for the diffuse it heat flux per unit area, which we did in the previous chapter. On this time, we're going to introduce a quantity f, which is the convective heat flux on what you can see there is, if we use 81 82 we can simplify equation 80 quite a lot toe. Combine a lot of those extra terms together because they can be quite confusing when we have quite a lot of excess terms on we arrive at Equation 83 there. So Equation 83 is exactly the same as Equation 80. We haven't done anything special yet. We haven't done any manipulation. All we've done is used the diffuse if heat flux on the convicted heat flux just to simplify and collect the terms together. Now, before we can proceed any further, you might remember from the previous chapter that when we're solving these equations, we're solving for the temperatures at the cell Centrowitz. That's tea with a capital sub script. So tea with a capital P T Capital R and T capital l Those are the temperatures that we're solving for, but in equation 83 you can see that we've also got the temperatures on the cell faces T r and T L on. We currently don't know what the temperatures are on the cell faces, and so the way we're going to proceed to solve this equation is expressed those temperatures in terms of the temperatures at the central rates. That's the key bit of the analysis. So once we've written T on T l in terms of the temperatures with self centuries, we commend, rearrange the equation and solve using the same method as we did for the previous chapter. Now, at this point, it's worth noting that there are different ways we can. We can approach this so calculating what t R is the temperature on the right face. We can use a variety of different schemes on these often called discrete ization schemes in the final volume method. But more correctly, they should be referred to as face interpellation schemes because it's going to be the way that you interpolate the temperature on the self face from the known values at the cell Centrowitz on the approach we're gonna be using in this chapter is called Central Difference ing on central difference. Sing is the term that you'll often see in the literature. But really, all that it means is linear interpolation. We've got a diagram of linear interpolation there in figure 20. So tl the temperature on the left face is just going to be half the half or the midpoint value between the temperature of cell on the left on the temperature of the self centuries in the middle. There. So TL is 1/2 t l plus TP on. We could use the same central difference ing on the right face there on that would give us equation 85. So we're linearly interpolated the temperatures on the self faces in terms off the temperatures at the cell, central aids. And if we just take a step back and think about this, this makes sense, because conviction is the flux of a quantity into the cell over the faces. And that's why we need to work out what the face values are in order to evaluate conviction . Now, if we substitute in equation 84 or 85 we reach Equation 86. Now equation 86 might seem quite long. We've got a lot of temperatures in there. A lot of flux is. But what you can see is that actually, the problem is almost complete now because we've expressed all of our terms in terms of the unknown temperatures at the cell central roids. And so the trick to proceed is just rearrange the equation and collect all of the terms that are associating with the temperatures at the cell Centrowitz doing that, we reach Equation 87 on, then a slight bit of rearrangement of Equation 87 yields Equation 88. Now the reason for writing things in the form of Equation 88 is that the same form as we used in the previous chapter, which is there an equation? 89. So we've got coefficient AP, multiplied by the temperature at the cell center in TP and then on the right hand side, another coefficient, a l multiplied by TL and then another car. Fish in a are multiplied by tr and then a source term. And if we just look at Equation 88 we can pick off the coefficients on their given their in equations. 90 and 91 on. What you might notice from there is that the F term that's the convicted flux of heat through the cell faces is new in this chapter that arises from the conviction term. If we were to set this value of after zero, so there's no flux dude conviction through the faces of the cell, then the coefficients would reduce back to the values that we saw in the previous chapter. Will be D l A L D. On a r, which is exactly what you would expect. So that's a useful check. You've implemented the method correctly. Rearrange the equations correctly. So now what we're going to do is do the same treatment as we did in the previous chapter and consider a boundary face on, left on a boundary cell on the right and then compared to coefficient. So if we look at figure 21 we can see a boundary cell on the left of the domain on Remember was starting Equation 92 then introducing the convicted on diffuse it heat flux is capital the and capital F, and that allows us to reach Equation 93 on as before, we're going to use central difference ng for the temperature on the right face. So because this boundary sellers on the left, as you can see in the diagram there is connected to an interior cell on the right. So that means the temperature on the right face could be evaluated using the same methods that we just went through previously for the interior cell. Now what about the temperature on the left face? So if you look at Equation 93 we know that T R is going to be evaluated using central difference ING because that's the same method is the previous chapter. But T L this time is given by the temperature off the face That's t a there. So the convicted flux through that face is just going to be the temperature. That's the fixed temperature on the set on the face, their multiplied by the convicted flux term F l. And that gives us equation 95. So it's slightly different here to what we saw for the interior cell. Now, as we've done this once again, we've now eliminated all of the terms that our temperatures on the faces of the cell and we've only got temperatures off of self centering on the boundary face, so the boundary faces a temperature. T a. Now, if we take Equation 95 rearrange in terms of T P, T R and T L, we arrive at Equation 96 on Once again, we just slight bit of rearrangement and collect the terms, and that allows us to arrive at Equation 97. Now, as before, in the previous chapter of When we Have Boundary Cells, you'll notice that the coefficient for the left face that's a L In Equation 97 there is zero. That's because there's no cell on the left of our boundary sell. However, the influence of the boundary cell appears through the source terms s you, which you can see there at the end of equation 97. You got t a times by the two d l a l. So that's gonna be the diffuse if flocks of heat coming from that left face. And then we've got an additional convicted component there f l coming from the left face. We've all got also got an additional component in AP there. So it's very similar to the previous chapter, except this time we get in this additional convicted flocks term f l on. If you follow through the maths, you'll quickly be able to see him pick out why this convicted term is appearing on what we're gonna do with it. So now just gonna repeat the analysis for consistency on this time, do it for the boundary cell on the right of the domain. So as before will be able to evaluate T l there the left face of cell using central difference ing on the same methods that we used for the interior cell. But the temperature on the right face they're t R is going to be given by T B. It's a fixed value and that's the boundary condition. So if we start with Equation 102 there, we notice that the temperature on the right face is t B. Now on the temperature on the left face T l. We're going to get using central difference ing which is given that in equation 103 and now in Equation 804. We've got all of the terms in terms of the temperatures at of cell Central aids and now we have to do to finish is to rearrange and collect the terms in terms of the South Central it exactly as we did before on At this point, if you're following through, you can see it starts to get a little bit tedious, what with all the rearranging of very simple terms and just making sure you don't get me minus signs in the wrong place. And so if you are following through, feel free to just use the final values that I've got for you here will save you a bit of time. And once again, if we look at the coefficients there for the right boundary sell, what we can see is that this time the coefficient a r zero because there's no cell on the right of the boundary cell on. Once again, the source terms are where the boundary conditions are introduced into the cell. So we've got t be appearing there in the source term x you on. We also got the convicted and diffuse of flux terms there on the right face appearing on. That's how the boundary condition is convicted on diffused into the cell through S U and S P so as before in the previous chapter. What I've done is combined all of these equations and coefficients together in a convenient table for you there in blue on. What you can see is that if you compare this table to the table from the previous chapter, the table is identical except for this additional term F two and F there, which arise from the convicted flocks of heat through the faces of the cell. And, of course, if you set this time 20 there's no conviction and you'll return to the diffusion equation from the previous chapter. And what we could do here, of course, is now we can set up in real life problem on calculate what these coefficients are filling the matrices and then solve the problem. And that's exactly what we're going to do on the problem I'm going to consider. To make things consistent is exactly the same as the example problem from the previous chapter. Except now what we've got is we've got a velocity of 0.1 meters per second moving through the bar. So in addition to having fixed temperatures of both ends on a diffusion of heat in the source term, we've now got a conviction from left to right off fluid through the bar. So where you could think of this, this could be, ah, Hollow Piper. A hollow bar, for example, on you want to know what the temperature variation is? A long that hollowed pipe bath on what I'm gonna Defu here is just run through the same stages that we used in the previous chapter just to clarify how we solve these problems. And what you see is exactly the same, except for a few additional steps. So as before, the first stage is to divide the geometry into a mesh off cells on because the bars five meters long here is going to be five cells that are one meter long each, which you can see there in Figure 23. On the distance between the South Central is one meter as before and now, the key difference between the analysis here and the analysis from the previous chapter is when evaluating the material properties. In addition to evaluate in the diffuse it flocks of heat through its of the cell faces, we also need to calculate the convicted flocks of heat through the cell faces on That's given by F. And so if we look at equations 115 116 117 118 we can see that the diffuse influx of heat is given Is 10 watts per kelvin on the convicted flocks of heat is one What per Kelvin. So it's per Kelvin, Remember, because the equation has units off. What? This is a coefficient that we multiplied the temperature by. So what's per Calvin? Can we have the source time there? So it's worth noting at the moment that for this problem, the velocity is very low. So 0.1 meters per second on, in this case for the convicted flocks of heat through the face of the cell, his 1/10 of the diffuse of flux. So we're gonna have a diffusion dominated process here on later, I'm gonna show you what happens when that changes and conviction becomes stronger than diffusion on some interesting things will happen. So now that we've calculated the Material Properties D and F on the source term, we can fill in and calculate all of the coefficients that we're going to need to fill in on matrices on as before. I've put the values for you there in a table. So if you get confused, or perhaps if you get a minor sign in the wrong place so you're following along, you've got a record of what the actual value should be on. Remember that the values you can calculate using this previous summary of the car efficient . They're just pasting in D L A l and F there. So now that we've got the coefficients, what we're going to do is paste them in the correct location in the matrices. On remembering that the S u turn there, that's going to be be vector on the right hand side, the coefficient. AP is going to be the diagonal term on then a l and A. Are there going to be the off diagonal terms remembering to put a minor sign there? Because in the previous chapter we took those terms to the other side of the equation. So there's now a minus sign in there. Be careful not to forget that. And when you set up your matrices, these this is how the matrices will look so again it's got a diagonal banded structure With that AP coefficient down, look down the diagonal and then the off diagonal terms that you can see there are related to the cell neighbors. So because our cell has to sell, neighbors has a neighbor on the left and a neighbor on the right. There are two off diagonal coefficients you can see there on. Those of you who have been following along avidly will, of course, extrapolate this and realized if we have a three D measure to D mesh on, we have, let's say six cell neighbors than the bandage structure is going to have six coefficients that span the diagonal there. So, really, the solution method, regardless of its one d two d or three D, extends to two D and three D simulations easily. Now, now that we've got the major cities or we have to do is solve them on, we can get a solution on. As before, I've provided for you Excel sheets and python source code so that you can run the problem yourself and you don't need toe spend ages setting up these problems for yourself on If I just sit over to the Excel sheet, for example, we've got the inputs here. The connectivity he capacity temperatures on also noticing here that we've got the flow velocity, which is 0.1 meters per second on. We're going to look at what happens when the flow velocity is increased later on. So what are the results? Hey, is the temperature variation in the ball and you may remember from the previous chapter Actually, this solution is incredibly similar to the solution from the previous chapter. The temperature is almost identical to what it was when we only had diffusion in the bar. And the reason for this is conviction is at the moment much weaker than diffusion in the bar on. What I'm going to look at now is what happens as we slowly increase the strength off the conviction. So the second plot I've got for you here in the pdf is what happens when you increase the flow velocity from 0.1 meters per 2nd 2.1 meters per second. So multiplying the velocity by 10 so that the strength of diffusion and conviction on now the same in the problem on the way we would do this is going into the flow velocity, sell their on just changing that 2.1 meters per second and then looking at the plot on. What you can see is that the temperature profile has now changed quite quite significantly . And looking at these results, what do we see? Remember that the temperature of the boundaries on the left is 100 on on the right is 200 so the temperature of the boundaries aren't changed. It's only the distribution of temperature in the geometry that's going to change on. Remember that the flow velocity is going from left to right. So with increasing X on what you can see is that shifts the temperature profile to the right in the direction of the velocity field. As you expect on. If you wanted to solve this using python, you could do the same thing from your command line or pied Piper gooey. Whatever you choose to use on there, we have the original temperature field on. If you go to the source code on increased the flow velocity 2.1 meters per second, run the code again. You'll see exactly the same results, so it doesn't matter whether you want to use the python code or the Excel sheet. Both of these are fine and we'll give you the same answer. So at this point, you can see that the strength off conviction and diffusion are about the same on the code. Is fine is able to cope with that. However, in modern CFT codes, for a lot of flow situations, the strength of conviction is often far stronger than the strength of diffusion. So this ratio that we've been thinking about the ratio of the conductive heat flux to the diffuse of heat flux is called the cell pep. Let number, which is given P e on. We considered now considered Pat let numbers of 0.1 on one. And what I'm gonna show you next is what happens if we increase the path. Let number above 12 Let's say three on the way. We do that, of course, it just increase the flow velocity. We'll change some of the other parameters on If we do that. What happens is we get a solution that looks like this on just a reminder that Patrick number is greater than two. Now on what you can see from the plot is that the temperature at the left end, the bar still 100 the temperature at the right end of the bison out 200. However, the solution is not smooth anymore. What you can see is we've got unstable oscillations in the solution on the reason for these oscillations is the central difference ING scheme that we used for the conviction. Term is unstable at high pet. Let numbers on this is fairly common in CFB codes. On is the main reason why central difference ing or linear interpolation is not chosen for the conviction term unless you're doing large eddy simulation. But that's not something will consider today. So for the variety of Rand's codes, you want to not to use simple central difference ing, and you have to use a different difference ING scheme that is not prone to these unstable oscillations that you will see in the central difference in scheme. On one common choice of a difference ing scheme that you could use is an up wind difference ing scheme or a linear up when difference in scheme or variety off others. On what I'm going to show you in the next chapter is how we might include an upward difference ing scheme on what we're going to do then it's one exactly the same problem and you'll see that for the upward difference ing scheme, we get a smooth solution, so the upward difference ING scheme does not lead to these oscillations in the solution. And of course, if you want to look at these and observe them for yourself, just head on over to the Excel Sheet or the mat lab code. Sorry, the python code on Change the flow velocity from 0.1 to a higher flow velocity, say 0.3 meters per second and you'll see that the oscillations then appear in the solution as you expect. So that's it for this chapter. Stay tuned for the next chapter where what we're going to do is replace that central difference ing scheme with an up one difference ing scheme which will remove and get rid of those oscillations and get us a smooth, stable solution. 5. Upwind Differencing: Okay, here we go with chapter four off my fundamentals course for computational fluid dynamics on in this chapter, what we're going to be doing is looking again at the conviction diffusion equation that we looked at in the previous chapter. But this time, we're going to be using up with difference ng for the conviction term rather than central difference ing or linear interpolation. So as a reminder, Equation 122 is the one day steady state conviction diffusion equation that we're looking at here on the final volume. Discreet ization of this equation is given in Equation 2123 on just a reminder again of what we did in the previous chapter. It's the temperature on the left face of the cell and the temperature on the right face of cell that we would like to express in terms of temperatures at the cell Centrowitz on when we used Central difference ing or linear interpolation, we use Equation 124 an equation 125 there to express the temperatures. T little L and T Little are in terms off temperatures at the cell Centrowitz, TL tp and T R. Now just reminder of what we saw at the end of the previous chapter was that when the cell peck let number is greater than two. This difference ING scheme is leads to non physical oscillations in the solution. So for our example problem, we expected a smooth solution in the temperature field. But when we used Central difference ing, we arrived at non physical oscillations, which we don't want in our solution, because they can lead Teoh unsteadiness and in some cases, divergence off the equations. So what is the cell packed? Let number as a reminder. That's the ratio off the convective heat flux through the face of ourselves to the diffuse . It heat flux through the face of our cell on the pep. Let number increases when the flow velocity increases. And that's why at high velocities that we typically see in cf decodes pet. Let number is high on central difference. Ing is not appropriate unless we have a very fine mesh resolution. So what we're going to do in this chapter is look at a different way. We can specify the temperatures on the cell faces on. We're going to be using up wind different. Sing now to understand how up when difference ing works. What we're going to do is look at figure 26 So in figure 26 were considering the cell in the middle The dark blue cell This is our interior cell on figure 26 a Shows the situation when the flow direction is left to right on figure 26 b shows the situation when the flow direction is right to left on What we're going to do first is considered the temperature on the left face T l now what up? When difference ing does physically is we take the temperature on the cell face t l as equal to the temperature off the up wind or upstream sell central eat So when the flow direction is left to right that figure 26 a We can see that the temperature on the faith t l will take the value off the cell century off the left Sell t l Now, if the flow direction is the other way from right to left, then the temperature on the left face is going to take the temperature of the cell century TP so with up win difference ing we care about the flow direction on the value on the face takes the value of the central oId that is upstream off that face locally. So we're going to need to know for ourselves whether the flow is going into the cell or out of the cell through that face. Now, if we return to the previous slide, the way that we write this mathematically is sort of a conditional statement which we see there in Equation 126 t little l is going to be equal toe t l. If the flow direction is left to right or is going to be equal to TP if the flow direction is right to left on the way we express these left to right or right to left is by the sign off the convective heat flux. So capital f there remember from the previous chapter that the convective heat flux is equal to row CP multiplied by the velocity on multiplied by the area off of cell. So because we've got the velocity in there, the velocity is what gives the conductive heat flux. It's signed or its direction. So if we go back to the figure and figure 26 remembering that the X direction is positive. So left to right, I would give a positive velocity you. So if the velocity is positive on the left face, that means the convicted heat flux F is also going to be positive on that face on because it's positive. Then if we look at Equation 100 26 we can see that we're going to take T l as the temperature on that face because the flocks is going into the cell. Now, if the velocity is going the other way right to left, the velocity is negative. So we're getting a flux out of the cell, in which case the temperature is going to take T p the temperature at the South Central on . We could do exactly the same thing for the right face of the cell, This time in figure, a flow direct. If the flow direction is left to right, we see that the temperature on the right face takes the up wind or the upstream temperature , which is TP now. If the flow direction is right to left, we see that the opposite occurs on T R will take the temperature off of cell century. That's on the right of the cell. And again, we can write that condition as 100 figure equation 127 there, which you can see on this type of form for up when different sing. You'll often see ifs in CFT code user manuals on user guides. But at this point, it's not entirely clear how you would implement Equation 126 on Equation 127 into your CF decode. And that's why I'm going to show you now for the final volume method. So starting off once again with the general finite volume discreet ization of the one D steady state conviction diffusion equation. That's Equation 128. Once again, we're going to be considering interior cells first and then exterior than sorry and then boundary cells later on. So once again, to simplify this equation introduced Capital D and Capital F from the previous chapter there, the diffuse it heat flux per unit area on the convective heat flux. And so the previous equation could just be written quite simply as Equation 129. And at this time we haven't introduced any conditions about the flow direction on what I'm going to do. To really show this to you clearly about how you develop the equation is to consider flow directions left to right on right to left separately. So we're gonna think of the time when the flow direction is going left left to right and then separately consider the case when the flow direction is going right to left and look at the equations and compare them. So starting off with the flow going from left to right, that means that on the left face of the cell, the convective heat flux is going into the cell on on the right face of the cell, the convective heat flux is going out of the cell. Now, before we look at the equations, let's just go back and have a look at are diagrams again. What? We're going to be looking at this case a here, so the flow direction is left to right on what we want again as a reminder is the temperature on the left face of the cell and the temperature on the right face of itself. And we can see from the diagrams that he's going to be t l and T P so substituting those in on we get equation 130. We've substituted in t l and T P for those 1st 2 terms on the left hand side there of the final volume. Discreet ization on that appears very simple. We haven't done any linear, interpolation anything else. We haven't used any other functions. And so the equation looks quite simple on For those of you who've been following along closely, you remember that Stages now are exactly the same. We have an equation in terms of the temperatures at the cell central AIDS only, and so we can rearrange equation 130 to collect those terms on. We arrive at Equation 131. As usual, we've got TP on the left hand side. That's the temperature central ride on then T Allen tr on the source term on the right hand side. And once again, when you rearrange that first home slightly to give it in the standard form. Now what you can see in equation 133 on, we could look at the coefficients a, l, A, R. P, and source terms on what you'll see. Remembering that the flow direction is going left to right this time thinking about the diagram. That's case a Remember, the flow director is going left to right. We can see that the left face there is going to get a convicted contribution from the left cell. However, the right face T R is not going to get a contribution connective contribution from another cell. And so how this looks in the equation there. If you look at Equation 134 you can see the A. L has a diffuse it contribution from the left cell, and it also has a convicted contribution from the left cell because the flow is going into the cell. So we get convicted contribution there. But on the right face, we only have the diffuse if contribution. And that's because on the right face, because the flow is going left to right, the flow is going out of the cell. So the F term does not appear there in Equation 134 on. What we would do next, in this analysis is flip and consider the case where the flow direction is right to left instead. So this camp, this time flicking that to the figure we're looking at figure be here in Figure 26 figure 27. Now. This time, as the flow direction is right to left, we can see on the left face the temperature is just going to be tp on on the right face. We can see that the temperature is going to be T R. That's the temperature of the central, it on the right face on once again because the flow direction is right to left. We are going to get a convicted contribution from the right cell here, but we're not going to get a convicted contribution from the left cell because the flow is going out of the cell on that left face. And so how did the equations look we take? The same approach is before substituting for those two temperatures on the left hand side of Equation 136. That's the two convicted terms and then rearranging in terms off the temperatures at the cell central roots T L, T R and T P. We arrived at Equation 138 and again, if we look at the coefficients, as were in standard form. That's Equation 141 141. We can see that the coefficient a l for the left face is only a diffuse if contribution. De l A l. Where is on the right face? We do have a contribution from the convicted flux that f r on remembering, of course, that the reason there is a minor sign here eyes because of the flow direction on the unit vectors point in opposite directions on the left and the right faces. So now that we've considered the flow direction left to right on the flow direction right to left, let's see if we can combine those two cases and write them in a concise form. That's easy for us to interpret later on. The convenient way of writing this is to use a max limiter. Andi, the coefficients there are summarized for you in equations 143 through to 147 on these coefficients capture both flow directions left to right on right to left. So if we think of the case where the flow direction is left to right, that means F L is going to be positive. The flow is going to be coming in through the left and then out through the right, we can see that a L coefficient is going to get a contribution from the conductive heat flux. But if the flow is going the other way because of the max limiter, zero is greater than negative. F l. So we're not going to get a contribution from the convective heat flux there. Now the opposite occurs on the right face. This time, the max limiter has the negative sign in there because the flow direction is in negative X there. And remember, it's always the contribution off the convective heat flux coming into the cell on this. The reason why we have the negative sign there. So when the flows right to left, the conductive heat flux F R. Is negative because of the direction of the velocity you on that Max limiter will evaluate so that there is a contribution from the convicted heat flux into the cell, and the other terms are exactly the same. So this Max limiter is a very convenient way of us to actually write those up win difference in terms in a form that CFD code can actually recognise on. What you've probably noticed here is that we could actually extend this to a general cell if we wanted, because we insist that we get a contribution from the convicted heat flux when the local convicted heat flux is going into the cell on. That would mean us evaluating the dot product off the local velocity field onto the unit normal. And if that contribution was into the cell, we would add a convicted heat flux contribution. But if we weren't then we wouldn't take a convicted contribution. Now, as with previous chapters, what we're going to do is consider that to boundary cells the boundary, sell it the left on the boundary sell at the right. On as before, I'm going to consider the flow directions left to right and right to left separately. So starting with the boundary shell on the left, which you can see there in the diagram in Figure 28 at the top. If the flow direction is left to right, that means that the temperature at the left end of the cell is going to be t A. That's the boundary temperature on the temperature of the right face. TR is going to be the temperature off the central oId because the flux is now going out of the right face on. If the flow direction were from right to left, the temperature on the right face would be t R on the temperature at the boundary face. That's TL would now be TP rather than the boundary temperature. That's very important to remember, because the flux off heat would be going out of the cell in this case. And so how do we write those cases mathematically? Once again, what we do is we start with the general final volume, discreet ization for the boundary cell, and it's going to be the TR and the T L on the left hand side that we're going to be replacing with appropriate temperatures, depending on the flow direction. So when the flow is left to right, we substitute in T A on the left face and TP on the right face on we arrive Equation 150. Now, once again, we're ready. We could just rearrange this in terms off the temperatures at the Cell Central aids. And of course, remember, you've got the pdf's at this stage. If you want to follow along by, write in the equation to yourself, you can go ahead to be very careful with your minus signs and not missing any terms out and right in this equation in standard form equation 100 50 to weaken. Quite quickly, see are coefficients on these coefficients are going to be quite tricky once again. So the contribution a l on the left face is going to be zero because remember that this is a boundary face and we don't have a cell on the left off boundary cells. And so the contribution ale is zero on the contribution on the right face is going to be equal to a are on this time. Remember, what was what we're starting to see? Is that the Because we're in a boundary face a boundary Sell. Sorry. This time the convicted heat flux comes in through the source terms S u and S P we can see we've got that flux term f l. This is when the flow direction is from left to right. The contributions coming in through the source terms. But what happens if the flow direction is right to left. Gonna do exactly the same thing again, starting by replacing those temperatures on the left hand side of Equation 156 with TP for the left face and t r for the right face. That leads us to Equation 158. And once again, we now have our equation in terms off temperatures at the self central raids on. We can rearrange in terms off those temperatures, and that allows us to arrive in Equation 160 which once again, is in standard form. So let's take another look at the coefficients for the left boundary face. Once again, the coefficient A L for the cell is on the left is zero. There is no cell there, but the car efficient A are so this is the car fishing represents. The right cell has a diffuse if contribution D R A. R. It always will. On it will have a contribution from the convicted heat flux if the flocks on that faces coming into the cell on because in this case, we've said the flow direction is right to left. We are getting a contribution into the cell, so we got on minus F our that way. Remember, the minus sign comes in because our coordinate system is positive left to right. And we said the flow direction is coming from right to left. So that's why we got the negative sign in there on this time. In the source terms, we've got no contribution from the left boundary face on the reason for that. So sorry we do have a contribution from the diffuse of flux from that left face, as always, but the source home contribution from the convicted term on the left boundary face is zero . And that's because the flux is going from right to left so that that temperature is not convicting through to ourselves when we use our up wind difference ing scheme. Andi, as before, What we're going to do now is combined these together conveniently to cover both flow directions from left to right on right to left on what you'll see in equations 165 through 269 is, of course, the left coefficient ale is always zero, but then the car fishing on the right face A are always has a diffuse it contribution but will only have a convicted contribution when that flux is coming into the cell on. Otherwise the max limiter evaluates to zero. So we're only going to get flux a convicted flux into ourselves when the flow direction is coming into the cell on the same thing happens for the source terms. Spn s. You were only going to get the convicted flux from that boundary into the cell when the flow direction is left to right this time and not right to left. So I've considered the boundary face at the left of the domain now going to consider the boundary sell at the right of the domain on. As you might guess, most of this is going to follow in the exact same manner. So starting with figure 29 there what we can see start. If the flow direction is left to right, then the temperature on the left face is going to be T l on. The temperature on the right face is going to be tp now. If the flow direction is right to left, that's figure 29 b. The temperature on the left face is going to be tp on the temperature at the boundary face is going to be t B. That's the boundary cell temperature of 200 degrees, which we applied before So again, starting with the general final volume. Discreet ization. You know the drill. You probably know exactly what we're going to do now. We're going to substitute for those temperatures on the left hand side. T r T l. And if for any point you're finding this quite quick or difficult to follow is definitely worth you. Just grabbing a pen and paper and just trying maybe one of these cases for yourself so you can actually follow through where the terms are, and then the rest will follow quite straightforwardly from that. So again, substituting for temperatures. The left temperature is T l on the right temperature eyes going to be tp there on. Then we have the final volume discreet ization and rearranging for the temperatures at central roids. And again, once it in standard form, we can pick out the coefficients there in 176 on 177 now. This time, of course, we've got the boundary faces swapped. So we're at the right of the domain this time, so the coefficient A are zero and this time the coefficient a l will always have a diffuse of contribution de L A l but if the flow is going into the cell, we get a contribution F l as well. You can see there in equation 176 on the contribution from the boundary in the source terms is just going to be given by the diffuse if flux this time because the flow is left to right now breezing quickly through the flow direction from right to left. If you quickly go back to the diagram, you'll see that the temperatures on the left and the right faces our teepee and T B TB being the boundary face on the right. 200 degrees, say, and we can substitute those in on, Then pick out the coefficients there. When we've written in standard form, you can see in equations 184 185. As always, when were at the right of the domain, there is no cell on the right of that boundary, Celso A are zero and we're gonna get a diffuse of flux through the left face. Now, in this case, the flow direction is right to left on. That means that we're going to be getting the contribution of the boundary on the right. Coming in through the source terms. You can see the f are there, which is going to be the convicted flocks of that boundary temperature into ourselves. Once again, we can combine both cases for the flow directions left to right, right to left by using theme axe limiters that we saw before Andi quite straightforwardly Thekla Fischer A. R is always zero because there is no cell on the right of ourselves. But the left face of the cell will get a convicted heat flux when the flow is going out off of cell. Sorry into the cell. Always gonna get that right around when the flood, when the convicted flux is coming into the cell. So f l is positive flow direction is left to right. As you can see there from my short slip up, you always need to make sure that you get your flow directions. Correct. If you want to make sure you get these conditions the right way around on, the contribution of the boundary is only going to affect the source terms when the convicted flux is going right to left. So when you go on F are there in the max limiter. Now, what I've been through here are a lot of different cases and a lot of different conditions . But conveniently for us, or what I've done is I've condensed all of these down into a useful summary table. There s so we've got the boundary seven left the boundaries of the right to the interior cell and then the coefficients a. L. A are on source terms. And as a quick sanity check as always, if there's no conviction, then this table of coefficients reduces to the table of coefficients we saw in Chapter two . So if you make the f the connective heat flux zero in all of those terms, you get the same coefficients as you did in the previous chapter. But notice in all of the coefficients when we have a connective contribution, there's a max limiter there, so we're only going to be getting contributions when the flocks on that faces coming into the cell. So now that we've seen through the table of coefficients and you may have tried one or two of these for yourself there Quite tricky. What we're going to do is go back to the same problem that we solved before. So as a reminder, we've got our heat flux through our bar on. We've got conviction on diffusion transporting heat through the bar on. Initially, the velocity is 0.1 meters per second on we're going to use exactly the same approach to solve this equation as we did before. The only difference to the previous chapter is that the coefficients in the matrices are going to be slightly different because of the equations that we set up. So as before, what we can do is we divide our geometry in tow. Amash five cells here on. Then we calculates the material properties the diffuse if heat flux d A and the convicted heat flux f through the faces on Just a reminder that for this flow condition, we've got a pack let number of 0.1, because the convective heat flux is one on the diffuse of heat. Flux is 10. So strength of conviction is only 10% of diffusion in this initial problem, but later we're going to increase the flow velocity to show the effect of increasing the convective heat flux into the cell. Now, at this point, what we're going to do is calculate the matrix coefficients on. If you go back to that previous summary table that I introduce, you can calculate and fill out each of those coefficients one by one. Or alternatively, you could just use the Excel sheet for the python code I've provided that does thistle for you now is a check. What I've got for you is the blue box at the top there, which summarizes the coefficients that you should have calculated on as a further comparison below is we've got the blue box, which is the same coefficients which were calculated using central difference ing from the previous chapter on What you can see there by comparing the two tables of coefficients is that the numbers are very similar. But there are slight differences between them in a low coefficients. A l, a r a p, and the source terms are all slightly different on the reason for the slight difference, of course, is remembering that for this problem at the moment, the convective heat flux is much smaller than the diffuse of heat flux. So the effect of changing the discreet ization scheme on the conviction has a relatively small effect on the overall matrices. But this will change when the strength of conviction increases. And, of course, now what we can do, we've got the coefficient is we can fill in the matrices. So we're ready to solve the equations, of course, always remembering that the source term X Q is going to appear on the right hand side. We've got the coefficients, a p down the leading diagonal, and then the off diagonal coefficients represent the connectivity to the cells on the left and right of our cell on. Of course, the first equation is this t one equation. At the top is the boundary cell on the left. On the bottom equation is the boundary shell on the right. And these equations, of course, only have one off diagonal coefficient. That's because they only have one neighbor. So now what we can do is go ahead and solve these equations. You can solve the equations yourself, or just use the Excel sheet for the python code on The result we get is a plot which looks like this figure 31 you can waste zip over here to the Excel sheet. Look at the solution or just go ahead, Open up python code in your gooey or text answer on Run the python code on What you see is we get the same result on Remember, this is for a flow velocity of 0.1 meters per second or packet. Number of 0.1 on you may remember from the previous chapter. Actually, this solution looks extremely similar to the solution we had before and at first glance it might appear like we've got the right answer. But actually, if we compare the vector of temperatures, that's the solution. Vector in equation 201 there you can see the Actually, the up wind scheme is actually slightly different to the central difference ing scheme on. Actually, we've got slight error there. The central difference ING scheme is more accurate than the upward difference ing scheme. So it's always important to remember that when we choose an up wind scheme, we're going to get a reduction in accuracy compared to the central difference ing scheme on the reason we get that reduction in accuracy is because we've assumed a constant variation of temperature across the cell. So we have the temperature itself Central oId. But if we look back, any of our previous diagrams se figure 29 for example, you can see there that the variation in temperature between the boundary face on central is constant. So the scheme is order One is a first order scheme. We have a constant variation in temperature across the cell. Now, when we use the Central Difference ing scheme In the previous chapter, we had a linear variation between the cell face on the century. So central difference thing is called a second order accurate scheme. Can you give us a more accurate results? But what you may also remember from the previous chapter is that with central difference ing if we increase the flow velocity so the pet let number is too high. We get that unstable solution on. What we're going to do now is show. Actually, the upward scheme is still able to get a solution. If we increase the flow velocity, so going back to either the excel, she or the python code if we now increase the flow velocity from 0.1 meters per 2nd 2.3 meters per second. A pack let number is now. Three. We can see that the upward scheme is able to compute a stable solution, so it's got a smooth variation of temperature there between the two boundaries on, we don't have any oscillations. So this is the price that we pay for. Using an up wind scheme is that four flows with high velocity or large meshes. When the pet let number is high, we are able to get a solution with up when difference ing schemes. But always remember that when you're using an up when scheme, the variation between the South central in the faces constant. So we've got a reduction in accuracy and you're always going to find a small error there when you're using an upward scheme on. This is a problem that is being around in CFT safety codes for a long time on a lot of research has gone into finding schemes that are both stable. Andi, accurate at high peck lit numbers on In whatever CFT code you choose to use, you may see a variety of options for different discreet ization schemes For the conviction term on these may include linear up with different sing or gamma difference ing on some form of limited linear difference ing, for example. But regardless of which of these schemes you use as we've seen here in the examples, what you're trying to achieve is a balance between the accuracy of the solution on getting a stable solution when the peck let number is high. So that really just about wraps up the main things I wanted to talk to you about in this course. Hopefully you've had some fantastic examples to go through and you really seen how a CFT solution is built from those first initial differential equation through to the final volume. Discreet ization on then how the matrices are assembled and also how the different conviction discreet ization schemes affect the overall matrices on the solution that we get of the end. We've also had a little bit of a look at the effects off mesh resolution as well on shown how up win different sing, which is a key factor in CF decodes leads to stable solutions where central difference ing may not be possible on at this point, I'd really like to thank Thank you for watching this course, and I'm sure you have. And I hope you've gained a lot of useful information from it. I certainly did. In making the code on. Of course, you got access to the python code in the Excel sheets toe. Play around as you want. Maybe you can investigate the effects of other parameters. And at this point, I'd like to say another Thank you on a suggestion that is there anything about the course that you particularly enjoyed or particularly, didn't like things that you think could be improved on? I'd love to hear your feedback on. Please just drop me an email or leave a comment on any of my YouTube videos for things if if you've got any great ideas, because I'd love to improve this type of content even more so I can deliver even better quality solutions for you guys, cause I've got lots of ideas of things I'd love to produce, and I really want to try and produce the most valuable thing that we possibly can to make some indispensable resource is because there's really not a lot of great information out there that's clear for computational fluid dynamics. So if you enjoyed the course, got some suggestions, things you loved things, anything that's fantastic or things that you think could be improved upon. Just drop me an email or leave a message in any of my YouTube videos on once again. Thank you very much for watching.