 In the previous lecture what did we do? We actually did what is known as whole domain approximation. So this was the whole domain approximation. What was the pi we assume? C0 plus C1x plus C2x square like that. So you can then generalize this by you know just C1p1 plus C2p2 plus so on up to Cnpn. So effectively that C0 plus C1x plus C2x square can be you know I am just replacing C0 by C1 here just to make it you know uniform here in terms of you know formulation and also remember it was only C0 there and here you may be wondering it is C1 into some function of x but you know C it could be just that could be just written as C0x raise to 0 is it not. So just for maintaining uniformity for formulation we are generalizing the first this could be a constant also is this clear. So now this is the what we actually started with so each pi is polynomial function of x either x, x square, x cube like that and then if we now take Poisson's equation right pi double dash is equal to minus x right and then the corresponding functional for Poisson's equation now we know it is this pi dash half integral pi dash square minus twice pi h dx. So now if what is the this is the functional so now and this is this is pi now we will actually see we will generalize the whole formulation that we did for that one day problem. So what did we do there capital F is now you can actually substitute pi pi dash and pi here using this exclamation so pi dash will be simply C1 P1 dash C2 P2 dash and so on square dx minus now I am separating these two terms that is why these two does not appear two and two gets cancelled and then this is twice pi h so this is pi h dx right so this can be you know written in a elegant form using matrices like this so half C transpose AC minus C transpose B. So what are these A and B's? Aij is integral pi dash Pj dash dx and Bi is integral pi h dx. Now how did we get this in it is simple if we take just say for simplicity if you just take the two terms here and you know just forget about this integral without the integral so it will be half C1 P dash square plus C2 P dash square then that actually can be expanded to this form right and that can be written in a an elegant equation consisting of expression consist of matrices like this so basically this is a row vector column vector of C coefficients and this is a 2 by 2. So if you expand if you expand this you will get this same thing we are doing it here right. Now you have got this capital F which is functional of the energy and now this has to be minimized right so f by dc will be equal to simply AC minus B, derivative of this will be AC because it is like it is actually like C square so C square derivative is twice C so it is A into C will be the derivative of this and derivative of this will be simply B so it will be AC minus B equal to 0 so the final matrix equation linear system of equation will be simply AC is equal to B and what is unknown here C the coefficient so those can be easily evaluated because B is known to you depending on source conditions and A is actually A can be evaluated which we will see how to evaluate right and then we can you know further if it was a wave equation for example then you get one more term here instead of just these two terms here in F you will get one more term here C transpose dc why because for wave equation you have phi term is it not wave equation it was phi double dash plus phi plus x is equal to 0 that was the wave equation Poisson's equation is just simply phi dash plus x is equal to 0 where x stands for h there is it not wave equation is phi double dash plus phi plus x or h x is h so phi double dash plus phi plus h or x is equal to 0 so when you have phi in the equation I mentioned to you earlier phi will become phi square in the functional expression and which is simply minus phi dash square is minus of this is the phi that we have assumed square so this again can be written in an elegant matrix multiplication form as minus C transpose dc where d ij is simply integral p i p j d x now here remember p i and p j are the corresponding polynomial expression in x right and then again if you do minimization then daba F by daba C equal to 0 and then you will get this and then you will get one more instead of just ac equal to b you will get a minus d whole bracket into C is equal to b so again here b is known as a function of source condition and here a minus a and d matrices are also known they just depend on the material properties and geometrical you know dimensions as we see more of these what do they mean little later so now we will you know take the same example in one dimension and we will solve it for Poisson's equation and we will see how the this generalized formulation can be used to get the final set of equation and get the solution right now here what we did earlier was whole domain approximation right so it is difficult to choose the proper function for example it was C0 plus C1x plus C2x so R plus C3x cube like that so if it is a complicated potential distribution it will be difficult to find a proper you know polynomial expression which can you know fit closely the exact solution right so what we do instead of choosing a polynomial function over the entire domain we will approximate solution for each finite element now we are slowly getting into finite element formulation right so here what we will do we will divide that one dimensional domain suppose this is one dimensional domain so this one dimensional domain is divided here into number of segment which are called as finite element right and then over each element for example element number 1 between nodes 1 and 2 we can assume phi as A plus dx which is much simpler right so earlier also I probably must have mentioned you know one of the first lectures when we saw numerical and analytical techniques if suppose you have some solution like this actual solution is like this it is difficult to assume approximate solution which can closely match this over the entire domain rather than that what you could do is you could actually subdivide this right over number of segments so these are the segments is it not like that over each of these segments you can assume a plus bx as a solution because this segment is you know straight line then that can be represented by a plus bx remember this a and b will be different for different segments right so that means for each segment the unknowns are a and b but later on we will see we will not actually solve in terms of a and b we will eliminate a and b yeah as in fact done in this slide later we will inside eliminate a and b and then we will solve it in terms of nodal potentials phi 1 and phi 2 how do we do that we will see okay so going further so now if we agree that it is easier to approximate solution over each segment and here we are doing linear approximation right instead of complicated higher order approximation then now we can proceed then for first element for example phi 1 will be given by a plus bx 1 just you know substituting the values of x 1 and x 2 and corresponding phi 1 and phi 2 so phi 1 will be a plus bx 1 and phi 2 will be a plus bx 2 phi 1 will be a plus bx 1 phi 2 will be a plus bx 2 for the first and second node right so that will give phi 1 phi 2 in matrix form you can write it this state of equation like this is it not because this phi 1 will be simply a plus bx 1 and phi 2 will be 1 into a that is a plus bx 2 right now what you do you eliminate this a b you basically you know by just rearranging this matrix equation a a b will be simply be equal to 1 1 x 1 x 2 into phi 1 phi 2 and then if you expand this inverse which is this and x 2 minus x 1 be in L right that will substitute it later so you get you know this this expression a and b so then phi 1 x that means potential phi in element 1 as a function of x this we are writing it as 1 x a b is it not and that a b now we are replacing by this this column vector of a and b we are replacing by here and x 2 minus x 1 being 1 by L so then we get 1 by L this if you expand this you will get this so effectively what we have done is a very important step left the the phi potential in the element 1 is now expressed in terms of potential of only node later on we will see why we are doing this is because finally what we want to do we want to minimize the energy now energy for one element for example is function of potential at every every point in that element is it not potential at every point but that would be cumbersome to handle and we are expressing now the energy of an element in terms of its potentials of its end nodes and eventually now you can imagine that we will get the total energy expression as function of only the nodal potential values if we can do it for one element we can do it for each element this same procedure so that means the eventual total energy will be function of only the nodal potential values and that can be you know minimized by taking derivative of f capital F with respect to each of those potentials and equating it to be equal to 0 and then we will get set of equation which can be solved so in nutshell this is what finite element method is we will see more of this you know and we will consolidate this learning as we go ahead so now it matter of details now what we are doing is we are phi 1 we are calling this as n1 now and this we are calling is as n2 so phi of 1 phi potential in at any x in element 1 can be expressed as n1 phi 1 plus n2 phi 2 where n1 is this n2 is this okay now what are these n1 and n2 n1 and n2 are the same functions of nodes 1 and 2 right so what are their properties you can see n1 is equal to 1 at node number 1 and it is 0 at node number 2 you can verify that if you put n1 n1 corresponds to node number 1 at node number 1 x will be x1 so this will be x2 minus x1 upon L L is again x2 minus x1 so this becomes 1 but same x1 at node number 2 will be x will be equal to x2 is it not at node number 2 x will be x2 so n1 will be 0 so similarly n2 n2 will be 1 at node number 2 right and 0 at node number 1 this has to be there because see this expression phi if you now substitute phi at node number 1 now remember this bracket means it is element 1 okay so phi of bracket 1 means this is element now if I actually calculate phi of 1 right phi at node number 1 it will be equal to n1 phi 1 plus n2 phi 2 but for this phi 1 to be equal to phi 1 here n1 has to be 1 n2 has to be 0 is it not similarly phi of 2 phi of x of 2 will be n1 phi 1 n2 phi 2 so here it is phi 2 so for this and 2 these 2 side 2 be equal n2 has to be 1 n1 has to be 0 at node 2 is it not so this is what this is logical this is logical from or this is obvious from these 2 expressions as well as it has to be like that from this equation clear now similarly phi of 2 in element 2 phi in element 2 as a function of x will be n2 phi 2 plus n3 phi 3 because element number 2 is actually between nodes 2 and 3 so it will be phi x for element 2 will be n2 phi 2 plus n3 phi 3 and then n2 will be x3 minus x by l and n3 will be x minus x2 by l and then same set of conditions will apply for n2 and n3 here I have just written it for n2 similar things will be for n3 will be equal to 1 at node number 3 and n3 will be 0 at node number 2 similarly for elementary will be this now effectively what we have done here this is again now we are taking a 3 element example we are taking a 3 element example so the total length each length is l so the total length of your domain is 3 times l and it is 3 elements and 4 nodes now here n1 it is shape function of 1 will actually be 1 at node number 1 0 at node number 2 that is what we have seen here n2 has now 2 you know sets of expressions n2 is in this element also in this element also n2 is 1 at node number 2 in both element right and n2 goes to 0 at node number 0 at node number 1 and at node number 3 so that is why n2 has 2 expressions n2 for first element is this n2 expression for the second element is this element right so we have to remember this n2 expression for the first element is not valid for the second element although you can always put some value and you will get answer so it is not valid this expression of n2 is valid only in first element this expression of n2 is valid only in this second element right so now here it is written node in element number 1 only n1 and n2 exist n1 and n2 exist in node number 2 n2 and n3 exist in node number 3 or in element number 3 n3 and n4 exist now here n2 is equal to 0 here on this because n2 is 0 since it is undefined or invalid expression is there if you put some x value you will get some value but it is not valid right so that is what is explained here this is called as you know roof top function is like a roof that is why it is called in some type of roof it is called as roof top function so n2 this is node number 2 n2 is 1 at node number 2 it is 0 at all in fact all nodes all other nodes 1, 3 and 4 is it not? and here for the entire this element n2 is not defined at all so going further now so I have explained here n2 has 2 expressions 1 valid for between x1 and x2 other valid between x2 and x3 and remember at actually node 2 whether you use this expression or this expression both will give you a value equal to 1 clear that is why it is equal less than or equal to because that is the so now we can generalize if we have understood this the phi at any x in the entire domain phi at any x in entire domain of this three elements can be written as n151 plus n252 plus n353 plus n454 but we have to remember that in no in element number 1 n3 and n4 are 0 so it will be simply in element number 1 it will be just n151 plus n252 because you know these 2 n3 and n4 are 0 similarly for element 2 it will be only n252 plus n353 right so we are generalizing this now let us solve Poisson's equation and see the procedure in 1D so first we are seeing in 1D and then we will see later on after may be 2 lectures for 2D so again we are solving Poisson's equation phi double dash is equal to minus h it is representing the source and we have seen this the functional energy functional to be minimized is this right so the functional is this phi dash square minus 2 phi h the same thing we are taking here phi dash square now what is our general expression for phi phi is this so phi dash square will be and remember here important thing phi dash is equal to square the derivative does not appear on this phi dash phi 1 dash phi 2 dash and all that what is variable here with x and y x n1 n2 here with variable is with x is only n1 because shape function and you know going back if you remember the infinite element formulation what we said in the variation formulation what we are doing is the potential at every point we are just varying right is it not we are varying so phi is not function of x phi at every point is not function of x in this variational procedure is it clear we are actually changing the potential values at every x and we are seeing which combination of potentials at various nodes is going to give you the minimum energy right so phi i that is potentials at various point they are not they are not being made to vary with x in our energy minimization procedure is this point clear so your shape functions are all this shape functions are functions of x right so we are only that is why we are when we are talking phi dash we are actually only so phi 1 phi 2 phi 3 they are not they are not varying with x is it not yeah in the variational formulation right so that then this is phi dash square minus again 0 to 3l this is the total our domain and then this phi into hdx and phi is this hdx so now again this can be written in matrix form as half phi transpose a phi minus phi transpose b we have seen this earlier is it not aij will be ni dash nz dash dx bi will be integral 0 to 3l ni hdx and then when you actually f by f by phi equal to 0 you will get a a a phi a phi minus b equal to 0 that will give you a phi equal to b now see the difference earlier it was a c equal to b the previous case when we had done whole domain approximation in terms of no c 0 plus c 1 x plus c 2 x square is it not so there are the unknown where the coefficient c and that was whole domain approximation for over the entire domain we have approximated or we assume some potential distribution right here we have not done that we have done potential approximation over each segment or element is it not and what are we and then we eliminated those a and b and we made the potential as a function of only the nodal potential values right and that is the reason now our variables become phi the nodal potentials at all these 1 2 3 4 is it not so from those coefficients being unknown that case we have come to the case where potentials at node they become variable you understood this distinction earlier those coefficients were variables unknown c c 0 c 1 c 2 c 3 now here phi 1 phi 2 phi 3 phi 4 become unknown and then we when we minimize the energy with respect to those phi i's we will finally get potentials at various nodes and of course there will be some boundary conditions some potentials will be known so then we will you know use those and only some potentials will be unknown so that we will see later right now again little bit to understand here finally now we have got after the FEM applying the FEM procedure so what is the FEM procedure we discretize the whole domain into segments so we have discretized so this is the discretization procedure after doing that we got this a phi equal to b now phi of course earlier it was a continuous variable earlier when it was a whole domain approximation or if you suppose if it was some analytical solution if we are trying to attempt right any phi would be a continuous variable here phi is not continuous variable because now phi is only at the nodes of this discretized domain so from continuous domain we have come to discretized domain a i j we got it here as this so now this how do we evaluate this so when it is like a i j when i is equal to j and two case there are two cases here one is for nodes two and three now you can see a i j will be integral 0 to 3 l ni dash ni dash because i is equal to j here i i and j are there but since i equal to j it will be ni dash ni dash and if you do it for calculate for a 2 2 for example right then ni n 2 dash what will be n 2 dash for first now see this is the entire 0 to 3 l domain so now that we are split into 3 0 to l l to 2 l 2 l to 3 l so we are calculating this n 2 dash so n 2 dash here in the first 0 to l will be simply 1 over l is it not because this is 1 divided by x and x is l so the basically it is defining the slope in the second element l to 2 l that is this n 2 dash the slope is minus 1 by l is it not and here n 2 n to itself is 0 in the third element so this is 0 so if you evaluate this will be 2 by l right similarly i when i is equal to j and this same thing will be true for 3 3 only thing what will happen here in this element this will be 0 because n 3 will be 0 here here it will be plus 1 by l here it will be minus 1 by l square right but the answer will still come 2 by l but 1 and 4 is different from 2 entry that is diagonal element because you know there is no connectivity on this side for 1 and 4 that is why it is different because 2 is 2 entry they are common to 2 elements whereas 1 and 4 they are only appearing only in 1 1 element is it not that is why the diagonal elements of 1 4 are different than the diagonal elements for 2 3 right so now we will see that this is again you know now if it is for example a 1 1 will be n dash 1 square so it will be minus 1 by l because see n 1 is reducing so it is reducing slope so it will be minus 1 by l square and n 1 is 0 in this other 2 so 0 and 0 n 1 is 0 here n 1 is 0 here n 1 appears only here in the first element right so here it is 0 and 0 right so here this you get only as 1 by l and now let us consider off diagonal element that means i not equal to 0 now you will get here ni dash nz dash so now you consider again first case a 2 3 let us consider 2 3 so this will be 1 by l into 0 because 1 of the because n 3 n 3 dash is 0 here is it not in first element n 3 dash is 0 in the fourth element n 2 dash is 0 because n 2 is 0 so and i said n 2 is 0 because n 2 is not valid expression is not valid it is not it is not defined there is it not so only segment where in both n 2 and n 3 are non-zero and that is why n 2 dash and n 3 dash exist is this middle segment right and in one case the you know the slope is this slope is positive n 3 slope is positive so 1 by l n 2 dash n 2 slope is negative so minus 1 by l clear and then that is why you get if you simplify this will lead to minus 1 by l and this will be valid for other phi of diagonal element also where there is connectivity 1 2 2 1 3 2 2 3 and 3 4 4 3 so where there is a direct connectivity between node you will get minus 1 by l where if there is no connectivity you will get 0 so no connectivity there are 6 of diagonal element there is no connectivity between 1 and 4 because either n 1 is 0 or n 4 is equal to 0 in that you know integral evaluation is it not see when there is no connectivity one of them will be 0 is it not in the for example here if you know if you are calculating 1 and 4 right you will find that in every segment either n 1 is 0 or n 4 is 0 or both are 0 right for example in this segment 2 3 both n 1 and n 4 are 0 here n 4 is 0 here n 1 is 0 is it not okay so then these are the then you get then if you understood this so effectively what we have done we have evaluated all these you know matrix we can evaluate similarly b matrix b matrix is again 0 to 2 l ni h dx so b matrix is representing the source and then you know n i h so n for example for if you evaluate for b b 1 it will be only form 0 to l because n 1 anyway 0 in the letter 2 segment so only 0 to l will come is it not instead of 0 to 3 l because in the second and third segment n i is 0 n 1 is 0 only first segment and then you substitute n 1 as x 2 minus x by l expression that we already seen and x 2 is nothing but l first element x 1 x 2 so x 2 will be equal to l right and then you can evaluate this integral you will get b 1 as h l by 2 same thing will be for b 4 now b 2 and b 3 now b 2 and b 3 now b 2 and node number 2 entry they are common to 2 segments is it not that is why you got you here you get 2 terms because they are non 0 into an entry are non 0 for over 2 segments so that is why you get 2 terms here and the corresponding expression if you substitute for that you will get b 2 as h into l here it is it was h l by 2 here it will be h l so effectively what is happening nodes 2 and 3 are contributing to both the elements effectively is it not because they are common so then here that is why here h l into 0.5 1 1 0.5 I have substitute b 1 b 2 b 3 b 4 so these are our final a 5 equal to b expression equation is it not and then you know this can be solved by after putting the boundary condition right and then you know you can solve unknown this because this is known this matrix is entirely known this is known h is known because those condition will be given to you so h will be known so then you can calculate the unknown vector which is 5 1 5 2 5 3 5 4 and in this unknown vector some voltages would be known right. Now one question may arise why non 0 half diagonal entries are negative now intuitively you can understand is like this finally what we are doing our basic thing is we are calculating the energy so half our basic thing is electrostatic energy is half epsilon e square so energy for each element is proportional to the corresponding electric field intensity magnitude square right so now here there are 3 elements so the e will be and let us assume in this example we are later we are going to take this 5 1 we are taking at 0 and 5 4 we are taking it as 1 boundary condition so if this is 0 and this is 1 the electric field intensity will be directed from 5 5 4 to 4 to 1 is it not so you know then that means electric field intensity magnitude here will be proportional to 5 2 minus 5 1 e square is for element number 1 will be simply proportional to 5 2 minus 5 1 square if you expand this you see these 2 represent the diagonal term which will be positive those are the ones which are represent this diagonal term and is minus twice 5 1 5 2 half diagonal term this is just you know logical explanation of why we are getting negative as half diagonal entries. So now F5 equal to b this was the equation that we got is it not now what we do we impose the boundary conditions so boundary conditions are in terms of 5 1 and 5 4 now here boundary conditions are this 5 1 is equal to 0 and 5 4 is equal to 1 volt right now actually what we are doing we are just expanding this second row and third row of this matrix equation so that will be actually this the second row is this is it not when we expand and then you what you do is this known things you transfer on the right hand side because the right hand side in any you know linear system of equations like x is equal to b the right hand side is known is it not so what you do right hand side you transfer this 5 1 and 5 2 now 5 4 anyway 0 so this term does not come at explicitly appear here the term corresponding to 5 4 it is 0 it is getting multiplied by 0 so that is why it is 0 into 5 4 whereas here in third row 0 gets multiplied by 5 1 so that is why here 0 into 5 1 right and then we transfer the known potentials in both these equations on the right hand side and then we get this so right hand side is completely known h is known l is known 5 1 and 5 2 5 4 are known right so then what we do we impose effectively we you know the matrix equation from 4 by 4 matrix equation we get 2 by 2 the main matrix is just 2 by 2 now and this is this you know these 2 equations are written in matrix form here right and then if you solve this you will immediately get you know the answer so for example if h is equal to 0 that is Laplace equation then it will be you know h will be 0 here so it will be simply 5 1 and 5 4 on the right hand side and that is 0 and 1 if you solve this you will get you can just try 5 2 you will get as 1 by 3 and 5 3 as 2 by 3 which is obvious because the whole domain is between 0 and 1 and they are at the best point so the second node will have 1 by 3 volt third node will have 2 by 3 volt right if h is equal to 1 that is Poisson's equation then you will get 5 2 as 4 by 3 and 5 3 as 5 by 3 because the presence of some charge throughout the region will basically change the potentials as compared to the Laplace equation okay so we will stop here and continue next time thank you.