 So, welcome to lecture 32. In this lecture, now we will see how to derive FEM formulation for permanent magnets. We start with this governing equation which we have seen in the previous lecture. So, J is basically due to free current and this is representing the source corresponding to permanent magnet. And now, henceforth, subscript R will be dropped. So, these actually you have to always remember these all m, henceforth actually is m R. So, subscript R for m is dropped for simplicity. So, now what we will do is we will apply wetted residual metal to above formulation. So, in wetted residual method, what we do? We you know integrate wet into residue over the domain and equate it to 0, is it not? And here and why there is residue because we generally we substitute approximate solution. So, there will be residue and we minimize the residue in wetted integral sense. Now, as compared to earlier approach that we saw wetted residual, there is one difference here. Now, here we there it was a purely scalar formulation because we had seen two dimensional formulation with A in current in z direction. So, A in z direction. So, it was only you know direction was fixed only magnitude was to be determined. But here now in general because m is vector. So, we have to work in vector notation. So, that is why this wet also becomes vector because residue is residue will be vector. So, so will be the you know wet has to be vector. What does it mean? We will see as we go along. So, now we have here again Galerkin's approach. There also we took wetting function as shape function, only difference being here it is now vector is capital bold w and bold ni. So, now this is this term we are first taking. So, this term we are actually you know we are using this vector identity v is this term and c is right. So, using this vector identity, this expression is split into 2 right you can verify it comes very well this. So, now we consider this second term first. This actually we apply divergence theorem. We have seen this earlier right actually here divergence theorem divergence of vector dv is it not integral is equal to that vector dot ds. But now since it is 2D approximation dv becomes dx dy and ds becomes A in dl same thing we had done earlier right. And now this actually this whole thing is a vector because this is going to be vector that vector multiplied with the normal vector to that surface because this is actually surface is it not. But in 2 dimension it becomes A and dl counter ok. So, this say this multiplied with An will result in normal component to that surface and if there is homogeneous Neumann condition then this whole thing will become 0 is it not. If it is not then of course this will result into some term and then our final FEM matrix equation will have additional term. It is not that always you know you have to have this condition and it is not like that. If it is homogeneous Neumann condition is there that means derivative of field with respect to the normal direction if it is 0 then it simply if this simplifies to 0 is it not because this results into normal derivative. If there is no this condition getting satisfied this will not be 0 and there will be additional term in our final matrix equation that is the only thing. And remember this is if we are at the element level if you remember this all at all elements is internal contribution common contributions will get cancelled because An vectors will be opposite. So, remember that and only on the outside boundary this will get executed when you when we assemble all the elements. So, that is why when I say homogeneous Neumann condition this is on the outermost boundary because inner you know inter element segment the An's are being opposite and that is why those contributions will get cancelled. So, same theory as we have seen earlier these applicable only the boundary condition on the outermost boundary. So, now then one term goes to 0. So, this term goes to 0 if there is a homogeneous Neumann condition on the outermost boundary everywhere. So, now we are left with this term and in this term is it not because we had split this term into 2 and out of this 1 is made to is made 0. So, then we are left with this term and this term that is what is being written here 2 term. Now, we will go further now this expression is split into 2 now del cross A dot this and then this term dot again del cross N i. So, this is split into 2 and this as it is now we know del cross A with you know 2 dimensional formulation with A being only in A z direction right it becomes this is you have seen earlier. Similarly, del cross N i N i been in again z direction. So, this is actually N i z N i subscript z because if A is in z direction N i also will be in z direction because finally, what is N i because A magnetic vector potential for any element is A is equal to N 1 A 1 plus N 2 A 2 plus N 3 A 3. So, in this vector formulation the direction to A will be given by direction of N's because A 1 A 2 A 3 are just scalars at the nodes 3 nodes. I am getting what I am saying A for A is equal to N 1 A 1 plus N 2 A 2 plus N 3 A 3 is it not. Now, A on this left hand side is vector. So, on the right hand side also there has to be a vector, but A 1 A 2 A 3 they are just the scalar magnitude. So, here A being vector it gets reflected by N 1 N 2 N 3 being vector right and if A is in z direction N 1 N 2 N 3 also will be in z direction is it not A has only z component N 1 N 2 N 3 also will be a z component only right. So, that is the reason that here so again that is why N i actually here it is N i z, but I have dropped that subscript z for simplicity right. So, it is N i z then again like del cross A is this del cross N i also will be this is it not same thing only just replaced A z by N i remember it is N i z. Now, what we want here is del cross A dot del cross N i. So, del cross A is this del cross N i is this and then this gets simplified to this right. So, just a dot product and that is why then you get now this A is when it is replaced by this is it not then this A j will come out and then this A you will have N i here is it not when A is replaced by this summation N i A i j goes from 1 to 3 is it clear when this now A z A is replaced by this you will get A j A j out and summation is it not and then you will get this is just the product of this and product of this thing at node 1 for example, N 2 and N 3 are 0 right. Then N 1 has to be because this is now A equal to A is in z direction N 1 has to be in z direction in fact this N is our standard N right. So, earlier also this N this was in z direction because A was in z direction is it not it was a 2 D formulation A was in z direction is it not. So, N i there also was in z. So, they there also it was a function of x and y and it was in z direction because A is in z direction there also, but here we are doing vectorial because n generally will be in 2 because m will have 2 components x and y as we will see. No, because that question arises because we have here m will m is generally in say x and y direction generally you know this permanent magnet m we know this is in this direction is it not this is the x y plane m is in it can be you know either this is x y plane. So, it can have in general x and y depending upon the orientation of this permanent magnet suppose the permanent magnet is like this vertical it will have only y components if it is you know at an angle it will have both x and y components is it not and earlier in our 2 D formulation everything you know current as well as A they were in z direction and there was no other vector there. So, you know we were always solving in terms of A this scalar formulation and then there was no other vector wherein we had to take cross product or whatever okay then this gets simplified to now we are in position to write because now we have this n del cross n i we have this is it not. So, this m is nothing but with x and y component and del cross n i is this del cross n i right same del cross n i here and then we just sort of simplify this dot product. So, you get this term this into this and this into this with a minus sign here. Now, we take you know these derivatives right we take derivatives and then we get where n i is this right. So, then we get standard derivative with respect to y will result only in q i derivative with respect to x will result into p i only that that is our standard thing. So, that is why here finally at the element level now remember this is q i and p i this we are doing weighted residual. So, this this statement that we have got this will be for one node similarly there will be you will get two equations for other two nodes right. So, that is why you will get three equations that is why you know I was telling here this is you know n i. So, this also really is n i because we are talking weighted residual statement is for each node right. So, that that is the reason when you write weighted residual statement for other two nodes also suppose this we have done for i suppose there is j and k then we will get additional two such statements and that is the reason your final matrix equation at the element level will be q 1 q 2 q 3 because here you will get q 1 and if this is say node 1 you would have got q 1 and p 1 q 2 p 2 q 3 p 3 right. So, this whole thing is leading to only this this matrix this anyway is going to come from this this is going to give you the your c matrix is it not. So, this is going to give you c matrix this is that individual matrix is it not this will give you three by three matrix for the element right and then into a j is them coming here this B e is our standard matrix which will come out of the source condition if there is a j also then this will be like j delta by 3 and then the corresponding B matrix will get formed and when you combine all this at the end if there is a non-zero non-homogeneous condition then that term also will come on the on account of boundary or if there is a outermost boundary with a equal to 0 or some derelict condition then that has to be imposed at the final global system of equation ok. So, what was what was new in this permanent magnet FEM formulation only this term and that is what we have seen the complete derivation of that yeah it was there in our previous formulation also it was there because no it is not new it is only m x into this m x and m y have come now and then this term also this multiplicand that was all not there this in fact whole term itself was not there because now there are m x and m y this whole term has have come. So, if suppose now you see if there is no permanent magnet m x and m y are 0 this whole term become 0 and you get only the Poisson's equation without permanent magnet which will be you know del square A equal to minus mu j that is our this at the element level that will be the equation is it not. So, this actually term is coming at the element level only on account of presence of permanent magnet ok. Now quickly we will see the Sylab code if suppose you were to develop and what will be the change will be only to the extent of this term only is it not that is all everything is same. So, here you know again wherever permanent magnet is there we have to basically note that. So, go from 1 to number of elements and here that permanent magnet is subdomen number 5 because t first you know entry of the t matrix is the subdomen number. So, we are assuming here that permanent magnet is subdomen number 5 right and then the corresponding let us we have assume that m is only in y direction. So, it is a vertical vertically placed magnet. So, m y and m value is this right 1.14 into 10 raised to 6. Now, this you know is quite high as compared to non magnetic material this is very high right. So, that that is why it is a permanent magnet. So, m y is high. So, remember for ferromagnetic material also this will be high m will be high that capital M. Now, this is m r actually are you getting this is actually m r then then go going further then this element level coefficient matrix is the exactly identical equation 1 1 2 c 3 3 is the same expression the change only is in this b. Now, it is minus 0.5 m y p 1 p 2 p 3 because this is our that additional term here m x is equal to 0, m x is 0 because magnet is in vertical direction. So, this reduces to only y component right and that is what is minus 0.5 m y p 1 p 2 p 3 because it is element level it will be 3 entries will be there right and here m x is 0 anyway and I am assuming mu r for that permanent magnet as being equal to 1 right that is why mu is actually mu is a electivity is 1 over mu which is equal to mu 0 times mu r, but mu r I am assuming equal to 1 that means chi m I am assuming as equal to 0 right and that is the reason that this becomes just 1 over mu 0 and then that gets cancelled with this. So, that is why only minus 0.5 m and then that is the when you get this ok. So, that is the only change here let us all the code remains there.