Mod-01 Lec-11 Newton-Raphson method for multiple variables

So, we will continue with our discussion on system simulation when we have multiple unknowns; that means more than one component is present To, we will revisit the truck problem. So, we will solve the same problem using the Newton-Rapson method for multiple unknowns. It is going to be problem number. So, for the sake of completeness, we will go through the problem again So, a truck is climbing up a hill, hill, road very slowly. So, given below the characteristics, that is the torque speed characteristics of the engine and the torque speed characteristics of the load. The truck continues to drive uphill at the same transmission setting. So, it is going at the same either is the second gear or third gear or whatever. So, using Newton-Rapson method, determine the operating condition of the truck. So, its water down version of the earlier problem where we, where we, as we draw the information flow diagram, two information flow diagrams using successive substitutions solve using both information flow diagram examine the stability and all that Having done all that, now there is no need to go through all that. Now, you solve it using the Newton-Rapson method for two unknowns Rewrite the characteristics in terms of f 1 and f 2; f 1 and f 2 are functions of t and omega. You have to open out a very wide tabular column and then it is going to take some time. It is going to take at least half hour. So, I will help, I will help you the iteration, but after five minutes, I will take this slide off and then we will use the, I need to use the full board. So, all of you first write down f 1 f 2. Take duo f 1 by duo t, duo f 1 by duo omega, duo f 2 by duo t and duo f 2 by duo omega. Many of them will be constant. One of the four will keep on changing with iteration, and then, you can use any technique for solving a 2 by 2, 2 by 2 system So, in this case, I intentionally, I intentionally made a small error. Minus? Minus f 1 minus f 2 That is it. Correct? We are expanding the solution around x of I, x 1 of I x 2 of I x 3 of I at I plus 1 and then we are cancelling that x I plus 1 equal to 0. You remember, that is have we get this. Deepak, yeah, no, no, without minus, it will go in the other direction. How? No, no, no, no, you need a minus I somewhere. You will give the wrong correction. So, this is a, the initial guess Let us all start with the, I worked out the

number. So, I will tell you initial guess – 400 and 40, yeah, you note it down t i omega i t i plus 1, yeah. So, it is got well columns as of know the number of rows is unknown So, this is the kind of problem which you can expect next Monday. Not next Monday, subsequent Monday. I will not ask this is one, one, component system. So, you need patience Hopefully I do not give you problem in which there is log and other things. It possible to give. I can give a heat exchanger where m c p delta t is equal to u a l m t d and I can make you round, round, round, round, round. I have done that before. So, so, let us start with this 400. So, you have to evaluate Let us start with the iteration 1. So, please tell me what is f 1 minus 145; f 2 we have to get the components of the matrix this fellow because three guys in this will be will behave properly. All it, they will remains remain the same in all the iterations. So, duo f 1 by 1, good, all of us are happy. What about this fellow? He is also 1. What about this guy? Guy no, no, no, no ah I wrote, i wrote, it out in a deliberate sequence such that all the three are invariant with respect to iterations, but the fourth fellow is not is going to give trouble. I mean he will keep on changing 0.6 omega minus 30 So, now, you have to say t is 400. You have to evaluate this 1 minus 40. Any problem?

Good, yeah, yeah, yeah. There is a minus already So, good, so, minus of minus. Rajesh, you got it? Already doing? So, what about the fourth fellow minus 6 Parameswar, what is the problem? You are not able to see. The trouble is every iteration you have to solve a two by two. Suppose give a three component system, if you give a three component system, one problem will be a three hour exam because one shot you will not get it, because iterative. That will be a three hour exam, but it will become a test on whether you do algebraic manipulations properly or not so, but I have to test you One component system is very trivial. Three component system is very tough. So, I will test you two components system. That is a fair game, yeah. So, f 1 we can put minus 145 minus 40 duo f 1 duo f 2 by duo t, correct, duo f 1 by duo omega minus 6. Error is of course, so, it is good to do in the class because it becomes the lecture cum tutorial So, if you, because once you go through one or two iterations, you know how to do; it becomes very fast There is only one component in the two by two matrix which has to be evaluated. Three things have to be evaluated each time f 1 f 2 and this thing. See, the, you can stop the iteration either when this is not changing or we can stop the iterations either when t and omega are not changing or all f 1 and f 2 becomes close to 0 0, yeah, eventually when f 1 and f 2 are close to 0, this fellow also will become stationary; these two fellows So, what you get delta t and so, delta t is 61, 271, too much, plus both are plus. So, it is 671 and 61. This is too much. What is the error? What is the error? 73 82, 73,900 73,900, look at this. It look hopeless, but this Newton-Rapson. It will work; it has quadratic convergence. So, let us start with the iteration number 2 671 f 1 and f 2 fourth and fifth, fifth iteration. It converges. Do not worry, I have done it. Yesterday, I have done it and I have this. So, I want you to do it f

1 f 2 132.3, 132, 0, but do not be too happy, only one of the two fellows is 0. So then, good, 6.6 588 Senthil, keep it up. Deepak, yeah, Mirthla, what is the error? 6,900 6,900? Not bad, right? Error is becoming decent So, it is not decent enough, but still quadratic Let us see 588.31. So, actually if you see, it is not so difficult, but it requires patience and perseverance; I mean, so, you should not even if you make a mistake in one iteration, if your basic algorithm is right, it will get corrected. You may take five minutes You may take two more iterations, but it eventually convert. So, long as you have not made any mistake in writing this out. Suppose one of the derivates you make a mistake or somewhere f 1 f 2 you make a mistake, it goes to some other orbit value. It will correct itself after some time So, 5 88, but all the good work you have done in the previous iteration will simply vanish If you make a mistake then, again the solution will go somewhere. f 1 is now 0.03, 2.09 So, look at how f 1 is falling; f 2 is more or less will be a. f 2 is a linear equation; t is equal to eleven omega. It would not miss behave. There, this fellow is because he has quadratic terms minus plus 175 is there, 1 minus 30 omega is there plus 0.3 omega So, you can go up down, but already I think we are able to see some tasting, some success because f 1 is going down. I know for a fact that it converges because already done. The next two iteration, it will converge. So, what you get now? T I plus 1 574. The, try, how many of you have completed three iterations? Two, two iterations? Yeah, you please check out your speed. I would expect you to finish this problem in thirty minutes in the exam So, if I give this question, I will give one or may be two more questions which will take 10 10 minutes. This probably will carry 60 percent of the marks or something like that and I except you to finish it in half hour Of course, I know that if duo f 1 by duo t and duo f 1 by duo f 1 and by duo x 1 duo f 2 by duo x 2 are more involved, then it takes a longer time. Here, it is simple function It will be more involve. The calculation of derivatives will take a long time. Vishwas, did you get it? You got it? What is the error now? Yeah, yeah, then we check. I made out. I made a mistake. Is it correct raga? Correct sir This correct? Then tell me, report the error 217 217 205 So, we will go to the fourth iteration 574.127 What is this now? f 1 0.5, Sambath, 0.5. So,

we already we, there almost there; f 2 is slightly going on 0.08 f 2, yeah, derivative 1.308 1.? 308 1.31, Deepak, Snthil, did you get it? Vaibhav, doing? Aruu, what happen Deepak? Which one? Yes, yeah, it is alright? May depends on how many decimal places which, which, close to that. Vikram, did you get it? What? You are not getting 5 74 and 51? F2 I got 3.75 It is not 0.08 It is not 0.08. I think so I got 3.75. What are you getting Paramaswer, Sambath? I am getting 0.02 0.02? Yes Minus? 0.2 Minus 0.2 2 or 02? For these values, what you get now? 574.152 For 574.3 and 51.85? Its 52.2 You want to change this? Fifty, this is correct? And this is 52.? 18 18. This is 2 naught 5 or… We will stay with that this 0.5 f 1. So, what is f 1 with this? You got it Miruthala? 0.53 plus both are plus. This one is 1.31. Now, you get the next one. I think we will stop with this. Got it? No, you are not doing I think it should be calculator; otherwise, you will miss the, I want to you to make mistakes in the class; it is better to make mistakes in the class and learn instead of making mistakes in the day of quiz. Akshay, what is up? Yeah, now complete this. What are you getting? 5, 573. 6; error? 0.20. We will just go for one more iteration. Still not, 573.6, yeah, just go for one more iteration five minutes and we will… So, since it is already reached this level, it is not a very acceptable for go down further because it is the sum of two, two, things It should go down little bit, it will, yeah What are f 1 and f 2 for this? 0.05, yeah; that means already we have, already we have reached. So, we have reached our destination We can stop with this, but if you want, you can. Suppose I give you a condition. Usually I will say decide an appropriate stopping criterion. You can decide a stopping criterion based on f i f 1 i plus 1 minus f 1 i divided by f 5 or divided by f 5 modulus must be less then something and f 2 i plus one minus f 2 i divided by f 2 I modulus into 100 must

be less than something or as he says f f 2 i plus 1 minus f 1 I whole square plus f 1 i plus 1 minus f 1 I whole square that should be less than something. So, if somebody has, somebody has its iterates, please let me know 573 what is this? 1. 2, 573.62, then the minus, minus, 6. So, we have reached. I can show it on excel, but you can see the quadratic converges here 73,900 6,900, 200.2 10 the minus 6. If you plot, you can see that will go rapidly. Santhosh, yes F 2 I, f 2 and f 1 should be Yeah So, this itself is the error That is what I am saying – error you can, error you can decide on the basis of several criteria. Normally in problems, you have to choose the error criteria. I told you choose an appropriate error stopping criteria. Which function No, no, what is saying simultaneously see, if here f 2 become zero, but f 1 was very bad, but no both are, when they are, see when this is approaching, this also we go to a low value. So, this is only an additional check. For example, when you solve, when you use fluent and solve system of equation, Navier-Strokes equation, energy equation, you can beautifully converge to a totally wrong answer, that is, your momentum equation, 10 to the power of minus, continue the equation 10 to the power of minus 4 residuals energy, 10 to the power of minus 8. It, it, is converged, but you converge to a highly inaccurate solution So, we need additional checks. What you do now normally has heat transfer. When you solving heat transform problem, I will ask my students check whether energy balance is satisfied If it is steady state, energy in the some of energy whether it is equal to energy out If it involves mass flow mass out, mass in minus or mass out divided by mass in modulus into 100. There are additional checks. When you are solving a transient problem, this, this, alone may not be may not suffice, because if we have an extremely small time step, your simply not allowing the variables to change, and then if 10 to the power of minus 6, then meaningless. When you have micro second or nan0 second as your time step, you are not just allowing the variables to change If you are having that such a kind of time step, you should allowing to run it for million time steps. Once you start solving problems, once you do your project whether its b tech or m tech or p h d or, then when you get into this business of computing, then you will realize that is its not straight forward to decide on the stopping criteria and all that multiple checks have to be there and so on That is why we have grid independent study You have validation. There are so many things which your solution has to satisfy So, this gives an idea of how to use Newton- Rapson method for multiple unknowns. So, we will go to system of linear equations where several variables are involved. Any doubts up to this? People are excited about this can solve the fan and deck problem. I have the solution. It converges within three iterations, three or four. So, this is what a semolina of mat lab is doing. How many of you are aware

of this semolina tool in mat lab? You can put various components and modulate together Of course, it is the class room environment and I can demonstrate only for two component, but if you write out the equation for each of these components and put together, something some solver like this may be running in the background. This is what semolina is doing So, if you write a code, so many engineers develop this and this, then you make it a product and make people buy this. Of course, as a user, we want to solve some engineering problems. So, whether it is in fluid mechanics or basically lot of these things will come in ventilation design systems. You want to design an air conditioning system for this third floor of ICSR. Fan like characteristics will come. Then the chilling load, I mean the chiller performance with the load Suppose Balaji takes a class with eighty students; next class somebody takes with forty students, what is the load for ten o clock, eleven o clock, eleven o clock, twelve o clock, have to calculate all that. How is the ambient temperature changing diagonal variation? How is the ambient temperature changing which is an all. So, we get messier and messier, but this is essentially what, this is the engine of semolina. The engine of semolina is something like this. The fund semolina is this. This also European something called modalica. That is also available on d c plus plus. Modalica is a very powerful tool I think there must be an equivalent of semolina in open source. What is that spelling? Yes High lab is it like mat labs. I will write it for the benefit of other students. Spelling, somebody should stand up and spell it out, S C? So, please make a note of this. If you are doing your projects, if you are of open source, you can use this; otherwise, you will use illegal version of So, please be reminded that you are still doing simulation. We are not come to optimization Simulation itself we have so many right multiple system. There are, you have to learn methods to do simulation; optimization comes later You are, by solving all these, you are getting only the operating point. We have not come to the point where we where we able to say whether it is a best or whether it is a most desirable or not; it is taken so much time for us to get the operating point itself system of linear equations. In thermal engineering, where do we encounter examples? Fluid flow circuits From a source, it comes through one pipe Then it branches out, it goes in to various branches. You are trying to find out the mask low rate is going through various components and then pressure drop characteristics. So, fluid flow circuits, then chemical reactors, these are all linear system. For example, in a fractionating column, the total amount of petroleum product must be equal to whatever is come; whatever is sent in plus whatever minus, whatever is left out must be equal to some of plus diesel plus kerosene plus blah blah blah You set system of equation and try to find it. You may eventually try to solve an optimization problem. What should be the optimal product mix was to maximize my profits. That is eventual problem. So, it will, will, pose the, it will be mathematically pose system of linear equation Then conduction heat transfer. What you get in conduction heat transfer? I have a, I have a composite in solution. I have material a

b c d e f g. So, there are various materials of thickness of thermal conductivity So, I have a t 1 infinity here; I have a t 2 infinity here. I write it out as, write all this out as resistance in series in parallel will combine. So, this is one possibility So, like that there are various examples in which you can linearise and I have a system of linear equation. So, we need to know how to solve system of linear equation. So, this has been taught to you ever since you came to the nineth standard. So, solving a system of equation involving two components or two variables is very trivial So, let us consider a simple two variable problem. Let us go back to our high school days and I have some specific example 2 x plus, how many ways are there to solve the system? How many ways, how many ways are there to solve the system? We can do elimination, but you can use substitution. From the first equation, you can take 3 y is equal to 13 minus 2 x put into the next equation and solve. Method number 1, method number 2, matrix you can solve using matrix. Method number 3, you can solve graphically. So, there are, so, for a two variable problem, it is very trivial; we learnt it long back. If you want to solve it in a, the solution is 2 3, right? Correct? So, substitution these are all very elementary Let us look at this matrix inversion So, the whole system can be written as A X equal to B. So, the vector X, what you write for two variables can be extended to any number of variables? So, so, in our case, correct – where d is the determinant. Yeah, we can complete it. Hopefully it gives 2 3; Otherwise, it gives a major embracement. Let us see, 26, thank god. So, this is now we have this

So, if we have a system of linear equation for n number of variables, it can be used Crammer’s rule, you want be teach that or how many of you do not, do not know the crammer’s rule? Good So, you have to take the determinant and change the first row by the, to solve for x 1 change it by a 1 a 1 1 a 1 2 a 1 3 and some linear analysis, but matrix inversion is important So, up to hundred variables, you can invert; generally it will be stable, but if you have more than hundred variables, matrix inversion is not, sometimes, some time matrix could be singular. If a matrix is singular, the determinant is 0. The determinant 0, it cannot be inverted; it leads to lot of trouble. That is one or sometimes you have infinite number of solutions. In those cases, it is imperative where, and also in other cases where the number of variables is more than hundred, inversion is not a good idea. People have developed the other techniques like Gaussian elimination decomposition. So, let us be decomposition, Jacobean method, Gauss Seidel method So, there are so many methods. So, this could become a 45 hour course on linear some linear analysis and all that, but for this course, the Gauss Seidel method is extremely popular; it is eminently programmable. Therefore, we look at the Gauss Seidel method. Before that, we will see how this even a two variable problem can give trouble. What, that is, where are the situations where you can have singular and ill condition systems. So, I have taken a specific case for example – 2 x plus 3 y What about these two? No solution, why? They are parallel lines man; they never meet. What is D? D is equal to 0 is a singular system, this a So, a minus is our example which is well behaved Call that a; call this b, c whatever. B 2 X plus 3 y is equal to 12. They are same Therefore, infinite number of solutions d is equal to D equal to 0, this also a singular system. You can also third category is getting late. I want to show it on the excel, but still ok. You can have 2 X plus 3 y. The determinant is close to 0. This will give a hell a lot of trouble. The two lines will be very close to each other. You do not know exactly where the two lines intersect. This is called a ill conditioned system So, but how small, small, is a subjective

The certain type of system with small is alright This value of D which certain types of systems is value of D is not alright. So, D is small Therefore, two lines are very difficult to locate point of intersection. In tomorrow’s class, we will, first five minutes, we just plot this an excel and see why. So, this is basically ill condition system. If you have a, if you have several variables and the system is ill condition, round of errors will give lot of trouble; this round of errors will propagate because the D small, and it will preventing from getting the true solution So, in tomorrows class, we will just complete this and I will teach you the Gauss Seidelmethod It is a very powerful technique. We will solve a three variable system using the Gauss Seidelmethod