Lec 4
Lec 4
Lec 4
Lecture – 04
Converting PDE to algebraic equation using FD approximation
In the last lecture, we have seen how to convert a partial differential equation into a set of
algebraic equations using finite difference approximations. We have done that in theory,
we have not done it completely. So now, we will do a tutorial on this so that we can
understand the steps very clearly and convert the same equation into a system of
equations and check for ourselves that we have a complete system, which when solved
will give us the required solution. We are going to do a tutorial on fully developed flow
through a rectangular duct in which we sub divide the domain into 16 tiles; 4 by 4 grid
rather than 5 by 5 that we had earlier.
So, we are looking at a rectangular domain with walls on all the 4 sides, which is divided
into 1, 2, 3, 4 cells in along the x-direction and 4 cells along the y-direction. So, we have
i equal to 1, 2, 3, 4, 5 and j equal to 1, 2, 3, 4, 5 and we would like to solve the equation
dou square w dou x square plus dou square w by dou y square equal to constant c, where
c is minus 1000, delta x is 0.1 and delta y is 0.05. Here, when we consider the domain
here there are all this points on the boundary, where velocity is equal to 0.
So, in all the positions where you have crosses, the velocity is known and it is 0 and it is
at interior points marked by circles is where we would like to get the velocity which will
satisfy this equation. So, we need to get velocity at 9 interior points. So, the tutorial
problem is what is w at the 9 interior points? Specifically what is w 22, w 23, w 32, w 42
and then w 23, w 33, w 43 and then w 24, w 34, w 44. So, these are the 9 velocities that
we need to determine and all the other velocities are equal to 0 and how do we do this,
we have said that we convert this equation we make a template for this using second
order accurate finite different approximations for the second derivative in x and second
derivative in y, and our template was w i plus 1 j minus 2 w i j plus w i minus 1 j divided
by delta x square plus w i j plus 1 minus 2 w i j plus w i j minus 1 divided by delta y
square equal to c.
Let us go on and write down the same thing for 32, 42 and all this things I would like
you do it on your own, but we will also do it here 0.32.
(Refer Slide Time: 07:53)
So, that is this point here. So, will have 100 of this, 100 w 22 and will have minus 400
minus 200 coming from this and minus 800 coming from this. So, we have, then will
have this point here that is w 42 and that comes with 100 and then we have this point
which is 33 and that comes with a coefficient of 400. So, we are essentially following
this lead here for this point variations in the x-direction that is why we have this w 32
and that gives us a multiplying factor of 100 because this delta x is 0.1 and 0.1 square is
0.01. So, 1 by 01 will give you 100 here and a variation in the y-direction. So, that is w
23 example here is divided by delta y square and delta y is 0.05. So, that gives us the
multiplicative factor 400. So, we get minus 2 divided by 0.05 whole square plus minus 2
divided by 0.01 whole square. So, that gives us 1000; 200 here and 800 there. So, that is
what that is how we written for this.
Now, we got 42, 42 is this. So, we get this one with 100 this one is 0 and this one with
400 and this will have 1000. So, we will have 100 of 32 minus 1000 of 42 plus 400 of 43
equal to this. So, we have done this, this, this is over. So, let me tick them here we come
to w 23. So, that is this point here. So, we get nothing from here and we get 100 of this
400 of this 400 of this and then we have, 100 of w 33. So, this is minus 1000 of w 23
plus 400 of 24 plus 400 of 22 equal to minus 1000 and, w 33 is this point here. So, we
have 100 of this, 100 of this, 400 of this, 400 of this, 1000 minus 1000 here. So, we have
100 of 23 plus 100 of 43 minus 1000 of 33 plus 400 of 32 plus 400 of w 34 will give us
minus 1000.
We can also write for 43, 43 is this point here. So, we have 100 of 33, 400 of 44, 400 of
42 and 1000 of this. So, that is 100 of w 33 minus 1000 of w 43 plus 400 of w 44 plus
400 of w 42 equal to minus 1000. You now have w 24 here, we have nothing here 100 of
this plus 400 of this minus 1000 of this and this is 0. So, you have 1000 of w 34. So, this
is 24 100 of 34 minus 1000 of 24 plus 400 of w 23 that is this point here equal to minus
1000 and we come to w 34 so that is this point here, this point will have 100 of 24, 100
of 44, 400 of 33 and the last point is w 44 here so that will have 100 of this 34 and 100 of
this 43. So, we have finished for all this things.
Here, we do not need anything because there the values are already given and we do not
need to write down anything there. So that means that we now have 9 equations. So, this
is 1, 2, 3, 4, 5, 6, 7, 8, 9 equations and these 9 equations need to be solved together. So,
let us see what kind of equations these are. Firstly, we can see that these are all algebraic
equations because all the w are just some real values also, which will be the velocities
and the coefficients are numerical coefficients, constant coefficients here and we like to
put this in, in the form a matrix and we and we see what kind of metrics we get. So, what
we try to do is we try to make a lexicographic ordering.
So, essentially if you have some f, i, j, k you can and there, i takes values from 1 to 10
and j takes from 1 10 and k takes from 1 to 10 like that. So, you can order them in a
sequential way in which for example, i has a value j has a value and then k keeps
changing from 1 to 10 and then once you get up to k equal to 10 and then j changes and
then with the fixed value of j then k changes like that. So, that is one possibility or you
can also do it in other way, i changes first j and k is fixed and then once i is exhausted
only then j changes and then again i keeps changing like that.
So, let us try to see what we have, we have two indices here and let us put them, let us
define a variable metrics w. So, we would like to put the all these equations in the form
of a w equal to b, where w contains all the velocities which are unknown and we would
to order them in a certain way in the lexicographic. So, we can say that w consists of w
22, w 32, w 42 and then w 23, w 33, w 43 and then we have w 24, w 34, w 44 this is all
the transpose because here w is a column matrix and there are 9 elements in this
representing 9 nodes. So, there are 9 elements. So, this is a vertical column matrix here
and this is 9 by 9 coefficient matrix and b is a corresponding right hand side value for
each of these equations. So, let us try to fit this in this and try to find out what the
coefficients of a can be. So, for this we will just copy down these things here.
So, we have w 22, 32, 33. So, these are; this just mnemonic for us to just understand our
coefficient matrix is this and when we look at the first equation, we see that it has 100 of
w 32 and for w 22, we have minus 1000. So, we put minus 1000 and w 23 it has 400 here
and all the others are 0. Now, you come to this equation here and w 32 is minus 1000, w
22 is 100, w 42 is 100, w 33 is 400 and all the others are 0 now we take this 1 here w 42
is minus 1000, w 32 is 100, w 43 is 400 and all the others are 0. So, 0 here 0 here 0, 0, 0,
0 and we come to this one here, w 23 is minus 1000, 33 is 100, 24 is 400 and 22 is 400
and the others are 0, 0, 0, 0, 0, 0.
So, now we come to this one here. So, w 33 is minus 1000. So, we can put the major
value here minus 1000 and then we have 23 is 100 and 43 is 100, 32 is 400 and 34 is 400
and others are 0. So, we come to the 43 equation. So, here 43 is minus 1000, 33 is 100,
44 is 400, 42 is 400, others are 0. Now, 24 is minus 1000, 34 is 100, 23 is 400 and all the
others are 0 and here we have 34 as minus 1000, we have 24 as 100, 44 as 100, 33 as
400, we have 0 and then we come to the last equation, which is 44 is minus 1000, 34 is
100 and 43 is 400.
So, this is our coefficient matrix. We have the variable matrix w, which is a column
vector and then b happens to be the same minus 1000 minus 1000 1, 2, 3, 4, 5, 6, 7, 8.
(Refer Slide Time: 26:56)
And similarly we can write w, in the way that we ordered we have to maintain the same
order here. So, w 22, w 32, w 42, w 23, w 33, w 43 and then w 24, w 34, w 44. So, we
have converted this partial differential equation into a w equal to b.
So, this is the end of this tutorial. In the next lecture, we will see how we can solve this.