 open all the programs there is one small error in program lab 3.4 add one line into the program in this lab 3.4 line number 300 go to line number 300 there is one rms error which is written here which is blinking right now delete that and write this word write this word here instead of rms error rms delete rms error and write unstudiness note that this lab 3 under 4 2d advection dot sci line number 300 at the last moment we were doing some corrections so my mistake it is this needs to be deleted so I will let me write down what I want it needs to be just type this unstudiness is equals to 1 e to the power 6 otherwise when you run the code you may get some error you have to type this either you delete this rms error or you type this I will repeat it again later on let us open the lab sheets open the lab sheet all of you please open the lab sheet let us do the following first I will explain the lab problem then you can start working pay attention and understand because many times you ask asking questions without listening what is said here the initial part this is same what I had discussed in the last lab session that you have here problem as well as answer sheet and there is an instruction how to save the figure by this time you already know that how to do it then the first problem is on computational heat conduction and in this problem you are note that all the code which we are giving you is two dimensional and steady state code in Cartesian coordinate system you are solving some problem but you can modify the boundary condition then you can solve some other problem but only you can solve two dimensional Cartesian coordinate system problem so then do not think that this is the software by which you can solve any CFD problem but I think for a first course in CFD this is good enough for a beginner this is good enough at least you get a confidence that how softwares are build up so this is the first step in this direction that direction how okay so let us first start with basically this lab session there are from yesterday evening we had lecture on computational heat conduction correct after yesterday lab session on grid generation the first lecture in the evening was computational heat conduction where we had shown you solution for two class of problem one all Dirichlet boundary condition which is shown as case a here with volumetric heat generation 0 and here we have made another case c where you have some non-zero volumetric heat flux this I had not done in my lecture but this is additional thing but basically there are two types of boundary condition one all Dirichlet and second left wall 100 bottom wall insulated right wall constant heat flux and top wall convective boundary condition two standard boundary condition with volumetric heat generation without volumetric 4 cases you have to simulate and which program you have to use note that because sometimes you start running the wrong program and then you ask it is this program you have to run it is the first problem so the name is 3 underscore 1 here you are you have to plot temperature for the 4 different cases a b c d you have to prepare a table for heat transfer I had written what we mean by the positive values and the negative value from the different walls left wall right wall bottom wall top wall there is a total heat transfer you have to make when you run the code the code displays that on the different wall what is the heat transfer you have to just type that in a table you also type the volumetric heat generation total heat gain total heat loss so you get an idea about the energy balance I will show you what is the solution and you have to discuss the effect of volumetric heat generation on the results I will show you the solution so you get a feel what I am saying this is the solution four figures for four different cases isotherm okay note that this four cases you have to run the program four times and boundary condition in this code is given as switches okay let me let me first show the result then I will show you the code also so that today I want to give you feel of the code also so what is a is the temperature contour for case A for case B this is the temperature contour for case B this is for case C and this is for case D so by just looking into the figure you can understand case C and D are what with volumetric heat generation A and B is what without volumetric heat generation so just see what is the difference of the volumetric generation in the two figures I will not say more you have to discuss about it where you will discuss after this there is a table for we have already drawn a table and we have put some blank spaces you just have to type the values here okay so the answer sheet format is completely ready you have to only paste the figure or write at some space caption table caption figure caption those are already provided to you finally you have to discuss the effect limited in this text box only then we have for multi-solid heat conduction for multi-solid heat conduction you have to solve the multi-solid heat conduction I think only for two cases which are those two cases case A and B which is volumetric heat generation okay so in this case also you have to draw the temperature contours like this again you have to prepare table as in the first problem okay so these are the two things which you have to do for second problem for non-linear heat conduction the problem states that this is the same problem which here you will get k0 and you have to run the program for three different values of B this is the values of B I had shown in the lecture slide B is equals to 0, B is equals to 1 and B is equals to minus 0.01 you have to enter k0, rho, Cp note then in earlier problem also you have to enter this thermo physical property because when you run the code it will ask what is the density what is the specific heat thermal conductivity to make sure that you enter this numbers properly for this multi-solid you do not have to enter the property because there are four material you will take lot of time in entering the value so all these properties we have hard coded in the code but in the first problem you have to enter the properties for non-linear conduction also you have to enter this property values you have to run this program note for a particular for each program there is a for each problem there is a particular program okay so run this problem 3 under code 3 non-linear conduction and you have to in this case you have to run the code for three different values of B and then plot temperature is a function of x so you will get three figures and you have to discuss the nature of variation for positive and negative values of B using Fourier law of heat conduction okay and I will show you the result how it should look like finally these are the three temperature profile this is for B is equals to 0 read the caption and the second is that B is equals to 1 and this is at B is equals to minus 0.01 and then you have to discuss the result here on the fourth problem so this completes the conduction, conduction we have three problem single solid conduction multi-solid conduction non-linear conduction and here what we are showing is a steady state solution in the fourth problem it is computational heat advection where you have left wall non-dimensional temperature 1 bottom wall 0 problem which I had shown earlier and this are the different advection schemes this is I will show you the caption first order of wind scheme second order quick scheme temperature contour and the velocity profile along vertical center line all these are first column is temperature contour second column is variation of temperature and the vertical center line first row is first order of wind second order of wind and the last row is quick scheme here you have to discuss the results also there is a text box for that the last problem is convection slug flow last problem is slug flow in a plane channel length of the channel is 6 height is 1 unit velocity is equals to 1 v is equals to 0 the initial condition is 0 in this case ok maybe in 1 or 2 problem you may have to enter initial condition let us say I think in advection what is the boundary value 0 and 1 so you can enter any initial condition you should get same result but the computational time may vary this is only in initial condition if your boundary values are 0 and 1 good initial condition is 0.5 so for the slug flow you have to plot the steady state temperature contours for the different advection scheme and then finally you have to plot the temperature profiles which are used for benchmarking so the data for benchmarking which is obtained from the analytical solution is already hard coded in the code so this is the study so here again you have two columns first column represents the temperature control second column represents the temperature profile at different axial location and first row corresponds to this is first order of plane scheme this is quick scheme this you have to do at round number of 10 and here you have to discuss this result ok now before you start doing it let me show you the code because yesterday some of you have suggested that if I can take the code line by line and try to explain you what is there in the code so just to show you that this code is indeed implemented whatever I thought in the lecture slides so what is there in this code let us try to understand I had given you pseudo code but here you have to use certain intakes intakes may vary so here there is a command display display command means that whatever you write here within code this will be displayed when you run the program so what will be displayed enter the following data for the conducting medium what you have to do what you have to then it density will come so you have to enter the value of density then you will ask for specific thermal conductivity and then this is a thermo physical property entry well there will be second entry what will be second entry enter the geometrical details for the domain length of the domain in the two direction then there will be third entry enter the grid details maximum number of grid point in x and y direction then this is the command to calculate the delta x and delta y value okay what is the expression delta x equals to length in the x direction divided by I max minus 2 because if there were 7 grid points there were 5 division then this is volume delta x into delta y this is the equation used to calculate the stability criteria 0.5 delta x square delta y square divided by k by in fact in case the diffusion coefficient is alpha k by rho cp this is basically that stability criteria which is actually in the slide and this is the initialization of that temperature as I said that when you run a transient code at each your time step you need two temperature value one is the old and there is a new value this t is the new and t old is the old so this is the initialization of both the matrices this is the initialization of as I said that in this code for an easy understanding on the code development we are also creating matrices for qx and qy note that the size of the matrix for temperature and qx and qy are different because if you remember there were 7 by 7 circles in my implementation detail and the green squares were 6 in the x direction 5 in the y direction inverted triangles were 5 in the x direction 6 in the y direction so the size of the matrix were different that is why they are different here then I think this is used later on for plotting because finally when you plot you need transpose of the temperature this is correct so this is to convert the final temperature value which you get to convert into a transpose form this xp is the coordinate of the vertices or self-centered extreme vertices so basically this is a you can say the part of the grid generation here the x coordinate and y coordinate of the vertices are calculated and this is the initial condition like if you have left 100 bottom 200 right 300 top 400 then you have to put initial condition the best initial condition in this case is 100 plus 200 plus 300 plus 400 divided by 4 which is 250 degree centigrade you will be asked enter the initial condition whether you had enter initial condition as 250 or 100 or 400 or 1000 steady state temperature will not change note that only the animation which you will create will change because the transient will vary but the steady state solution will be same note that steady state solution is independent of initial condition in CFD however the transient varies from the initial condition this is a now boundary condition is starting so we started with thermo physical property then when we entered to the user has to enter the grid size then the geometry the x coordinate and y coordinate of the vertices were completed the initial condition got then the next is the boundary condition here for each boundary we have put switches what are this these are switches first switch for constant wall temperature second for insulated or symmetry third for convective wall heat convective heat transfer fourth for constant heat flux so for each wall it ask you that whether what we use the boundary condition you have to have four switches one two three four whatever you pick it takes the value appropriately if you enter first which then it will ask you what is the temperature if you act second switch it's an insulated so it will not ask you anything because when it's insulated you don't have to enter anything it's a constant heat plus it will ask you what is the heat flux value if it's a convective heat transfer then it will ask you two things what is that what is the infinity for each wall this the switches have been incorporated all these are boundary conditions along with switches it takes a lot of lines in the code this is the function to calculate the RMS to check for steady state condition actually to make the language simple what I had done is that although we are calculating RMS error but for easy understanding later on what I am doing is that I am defining a term and unstreadiness okay and literally what we mean is that rather than saying RMS error less than let us say zero practically zero based on your convergence criteria I had defined a literal term which I called as unstreadiness later on that I quit that unstreadiness to the RMS error okay so this is a while loop to check whether this unstreadiness which is basically the RMS error but before you start this loop note that you have to initialize it otherwise it will not go inside this loop so you initialize it like a very large value so that even if somebody gives a very large convergence criteria let us say 10 to power 5 also then also it will go inside this code however we expect that this convergence criteria should be of the order of 10 to power minus 3 minus 4 minus 5 or so on before you do the next time step computation you take the present time value as the old time value this is the time-marching step this is this is the main loop for the explicit method iteration this is the application of the boundary condition okay now what is this can anyone tell me note the loop this is for heat flux in the x direction qx you remember the way we had discussed the formulation first we calculate qx qy then do a balance then calculate the temperature this is a loop for that green square how many green square we have 6 in the x direction 5 in the y direction that way if you look into the loop it is 1 i is 1 to i max minus 1 7 minus 1 6 1 to 6 and on the j direction vertical direction 2 to 7 minus 1 2 to 6 which makes it 5 okay so this way and note that there is a something different here what is this if i is equals to 1 and i max minus 1 which are border values the distance between the cell center is 1 green sorry 1 yellow and 1 blue and the distance is half of the cell width whether you got what I am saying near to the boundary what I am saying is if I want to calculate heat flux here the distance between this point and this point is delta x by 2 if I calculate here this is delta x okay that half cell width will be needed when I will calculate qx at the boundary here and here so here i is 1 here it is i max minus 1 so in the code you can see if i is equals to 1 this bar is or syntax is for or i is equals to i max minus 1 then in the denominator it is delta x by 2 it is forward difference for the left wall backward difference for the right wall this is loop to calculate the heat flux in the y direction note here it is 1 to j max minus 1 1 to 6 and 2 to 6 once you have calculate qx q by what we do we calculate the total heat gain by conduction here and then the temperature so you can see this code is exactly what you see in the slide implementation detail solution algorithm then rms error is calculated to give it a more literal meaning I am calling this rms error as unsteadiness then finally this are the here basically I think he is taking transpose of the temperature because when you want to plot it the plotting software wants the data structure in a particular way otherwise what will happen your bottom wall become top wall or it may become left wall you want bottom to be bottom in your when you are looking into the plot for that you may have to understand that a plotting software what is the data structure it wants to plot it appropriately so in this case he has taken a transpose of it and then finally he is using this spray plot plot for contour for plotting the contour of temperature and then he is doing all these are called as post processing what is the post processing in this case heat loss from the heat wall basically what he is doing is summing up qx from the bottom wall and top wall to calculate the total heat transfer on the left right bottom top heat generation if it is there okay and then printing it out so if this print will come to your screen you just need to note this value in the table and this is for you can also do one thing actually this is once you have got run into steady state then this plot is coming actually what you can do is that when you are doing a transient simulation sometimes if you want to create a movie actually this plot he has put inside the time loop and what is what he has done here is after every 25 time marching a screen will come what when you run the code it will start time marching from one time step two time step three time step it will come continue the time marching so let us suppose it takes thousand time steps thousand time marching to reach to the steady state after every 50 because you may feel both that you are looking into the screen it is only showing convergence criteria going from 100 200 300 so after 50 it will show you some picture so you will make you happy okay so at least you can see that you are getting some result because this computations will take some more time as compared to the grid generation okay so you have to be little patient okay any question on this code specifically do you think this programming language is difficult you need to know zeros actually what happens is that if I want to create a matrix of let us say 10 by 10 and if I want to have all the element as zero if you would see your photon then you have to write may be five line six line program for loop and then here you have single line command so zeros let us say 10 by 10 you create some matrix of size 10 by 10 with all the elements zero it is like Matlab also you have commands like zeros ones that command here actually in this programming this software the good thing is that it has lot lot more inbuilt library functions like to take maximum if you are writing in C and photon you have to write function for that here there is an inbuilt library you just write maximum so if it is a vector you write maximum of let us suppose x is a vector column vector or a row vector so if you write maximum of x it will give one value if it is a two-dimensional matrix you have to use maximum of maximum of x to get one this is the command which use in Matlab and the same commands are work here also there is lot of inbuilt function the debugging is easy so that way this code is this and why we chose this is that this is anyway open source software and it has in inbuilt so inbuilt graphics it has inbuilt lot of libraries so that way this is a good one specially for undergraduate teaching although if you want to solve complex CFD problem as compared to C or photon programs this takes slightly more time but for a beginner I think this is very good software so for a basic CFD course I think this is a good one to start here okay so how you how you will run this program you know how by this time how to run it you should run click execute and then you get here I think I had discussed this in earlier also that although I had given in my problem some density some specific it but I use some other value also steady state result will not vary let me put some value because I am not remembering it so this is the left wall boundary condition okay so let us put it 100 for no first I will to decide which boundary condition one means constant wall temperature bottom boundary one means constant wall temperature again right wall top wall this is a steady state criteria let me put it 0.001 this is the way after every 50 iteration temperature is varying this is like an animation this is the convergence which is occurring it will stop when it reaches 1 into 10 to power minus 4 this is the steady state temperature distribution actually you may feel that this is not matching with my slide you are right because your convergence criteria needs to be much smaller what I had given in my problem convergence criteria will be 1e minus 6 correct I had done what 1e minus 3 that's why it has not reached to complete steady state okay any question before we get started note that once you run the program it gives you heat loss from the left wall right wall bottom wall top wall heat generation total heat gain total heat loss and energy balance any question okay we will stop here and you can get started with the lab