Feb 4, 2010 Lecture 8 FEM in 2D: Fin with Derivative BC (Lecture notes taken by Zhibin Deng and Xiaoyin Ji) ๐ถฬ ๏ท Steady state problem: -KΔu + Cu =f(x,y)= Cusur on Ω with ๐ถ = 2๐๐ ๐ข๐ ๐ป ๐ = 2โ ( ๐ ๐ข๐ ), ๐ป where ๐๐บ = ๐๐บ1 ∪ ๐๐บ2 ∪ ๐๐บ3. ๐ข|๐๐บ1 = ๐(๐ฅ, ๐ฆ) ๐๐ข | = ๐๐ ๐ข๐ ( ๐ข๐ ๐ข๐ − ๐ข) ๐๐ ๐๐บ2 ๐๐ข ๐พ | =0 ๐๐ ๐๐บ3 For a fin cooling problem, parameter ๐ป is usually small. ๐พ ๏ท Weak equation and element matrices. In order to find the weak equation, multiply the differential equation by ๐ where ๐|๐๐บ1 = 0 and apply the divergence form of Green’s theorem โฌ ∇ โ ๐นโ = โฎ ๐นโ โ ๐โโ ๐๐ ๐นโ = ๐∇๐ข ∇ โ ๐นโ = ๐โ๐ข + ∇๐ข โ ∇๐ This gives โฌ ๐โ๐ข + โฌ ∇๐ข โ ∇๐ = โฎ โ (∇๐ข โ ๐โโ) ๐๐๐ ๐๐ข ๐๐ −๐พ โฌ Δ๐ข๐ + ๐ถ โฌ ๐ข๐ = โฌ ๐ถ๐ข๐ ๐ข๐ ๐ โฌ ๐โ๐ข = 1 [− โฌ ๐ถ๐ข๐ ๐ข๐ ๐ + ๐ถ โฌ ๐ข๐] ๐พ 1 Feb 4, 2010 ๐๐ข 1 ๐๐๐ − โฌ ∇๐ข โ ∇๐ = [− โฌ ๐ถ๐ข๐ ๐ข๐ ๐ + ๐ถ โฌ ๐ข๐] ๐พ ๐Ω ๐๐ โฎ ๐๐ข ๐๐๐ + โฌ ๐ถ๐ข๐ ๐ข๐ ๐ ๐Ω ๐๐ ๐พ โฌ ∇๐ข โ ∇๐ + โฌ ๐ถ๐ข๐ = ๐พ โฎ โฌ(๐พ๐ป๐ข โ ๐ป๐ + ๐ถ๐ข๐) = โฌ ๐ถ๐ข๐ ๐ข๐ ๐ + โฎ ๐พ ๐๐บ1 โ ๐๐บ2 ∪๐๐บ3 ๐๐ข ๐๐๐ ๐๐ Next apply the boundary conditions to the line integral โฎ๐พ ๐๐ข ๐๐ข ๐๐ข ๐๐๐ = ∫ ๐พ ๐ โ ๐๐ + ∫ ๐๐ ๐ข๐ (๐ข๐ ๐ข๐ − ๐ข)๐๐๐ + ∫ ๐พ โ ๐๐๐ ๐๐ ๐๐ ๐๐ ๐๐บ1 ๐๐บ2 ๐๐บ3 0 0 โฌ(๐พ๐ป๐ข โ ๐ป๐ + ๐ถ๐ข๐) = โฌ ๐ถ๐ข๐ ๐ข๐ ๐ + ∫ ๐๐ ๐ข๐ (๐ข๐ ๐ข๐ − ๐ข)๐๐๐ ๐๐บ2 This gives the weak equation, which are used to find the element matrices, โฌ(๐ฒ๐ต๐ โ ๐ต๐ + ๐ช๐๐) + ∫ ๐๐๐๐ ๐๐๐ ๐ = โฌ ๐ช๐๐๐๐ ๐ + ∫ ๐๐๐๐ ๐๐๐๐ ๐๐ ๐ ๐๐ด๐ ๐๐ด๐ โ โ ๐(๐,๐) ๐(๐) The domain Ω is approximated by a union of triangular elements. This induces the approximation of the boundary by a union of edges of selected triangular elements. ๐Ω โ 1 1 3 2 2 ๐2 ๐3 ๐1 2 3 3 1 ๐ข๐ = ๐ข1๐ ๐1๐ + ๐ข2๐ ๐2๐ + ๐ข3๐ ๐3๐ โ = √(๐๐ฅ)2 + (๐๐ฆ)2 Instead of integrating along the boundary ∂Ω2 , we integrate ๐ข๐ along edges close to the boundary ๐๐บ2 , such as the edge 1-2 in element ๐1 , edge 3-1 in element ๐2 and edge 2-3 in element ๐3 in above 2 Feb 4, 2010 figure. The length of the edge is โ = √(๐๐ฅ)2 + (๐๐ฆ)2 and can be calculated if the corresponding system node numbers and their coordinates are known. ๏ท Insertion of the derivative boundary conditions and genbc2fin.m. npt2(edge,1) npt2(edge,2) edge In order to insert derivative boundary condition on the boundary ๐๐บ2 , we need to compute following two items (These two items appeared in weak equation) ∫ ๐๐ ๐ข๐ ๐ข๐ ← ∫ ๐Ω2 ∫ ๐Ω2 ๐๐ ๐ข๐ ๐ข๐ ๐ข๐ ๐ ← ∫ ๐Ω2 ๐Ω2 ๐๐ ๐ข๐ ๐ข๐ ๐๐๐ (๐๐ ๐ข๐ ๐ข๐ ๐ข๐ )๐๐๐ There are two ways to insert the boundary condition. One is to insert the above items in element matrices before we assemble the system matrix; the other one is to adjust the system matrix by above items after we assemble the system matrix by elements. The MATLAB code fem2d_fin.m used the latter one. ๐๐๐๐๐ = total # of edges on the boundary ๐๐บ2 , ๐๐บ3 ๐๐๐ก2(๐๐๐๐, 1 ๐๐ 2) = system # nodes lies on the boundary ๐๐บ2 , ๐๐บ3 HOT MASS ∂Ω1 ∂Ω3 ∂Ω3 ∂Ω2 3 Feb 4, 2010 ๏ท Matlab code fem2d_fin.m and required files: genxyfin.m : generates nodes coordinates (๐ฅ, ๐ฆ). gennod.m: generates system node numbers for each element, nod(e,1 or 2 or 3). The array nod is an ๐๐ × 3 matrix, where ๐๐ is the number of elements. Each row ๐ corresponds to element ๐. genbc1fin.m: output the system number of nodes that lies on the boundary ๐๐บ1 genbc2fin.m: output the system number of nodes that lies on the boundary ๐๐บ2 and ๐๐บ3 . This generates the array npt2(edge,1 or 2) whose values are system node numbers on the on a particular line segment approximating the second and third parts of the boundary. Assume the first row is ๐๐๐ก2(3,1) = 7 ๐๐๐ ๐๐๐ก2(3,1) = 8. This means the system number of number 7 is one node of the third edge = 3 and the system node number 8 is the other node of the third edge = 3. csur = 10; usur = 23.0; for edge = 1:nedge if edge < nx npt2(edge,1) npt2(edge,2) elseif edge < nx + npt2(edge,1) npt2(edge,2) else npt2(edge,1) npt2(edge,2) end end % Nodes lies on the = edge; = edge + 1; (ny - 1) % Nodes lies on the = (edge - nx )*nx + 1; = (edge - nx )*nx + 1 + nx; % Nodes lies on the = (edge - (nx + (ny - 1)) )*nx + = (edge - (nx + (ny - 1)) )*nx + bottom left side right side nx; nx + nx; ffem2d.m: the right hand side ๐ in heat equation. fem2d_fin.m: the critical difference from fem2d.m in this code is the insertion of derivative boundary conditions as following: for edge = 1:nedge % Insert derivative boundary conditions % Get the system number of two nodes on the edge i = npt2(edge,1); j = npt2(edge,2); dx = x(j) - x(i); dy = y(j) - y(i); h = sqrt(dx^2 + dy^2); % Calculate the length of the edge % Adjust the system matrix sm(i,i) = sm(i,i) + csur*2*h/6; sm(i,j) = sm(i,j) + csur*h/6; sm(j,i) = sm(j,i) + csur*h/6; sm(j,j) = sm(j,j) + csur*2*h/6; % Adjust the right hand side vector rhs(i) = rhs(i) + usur*csur*2*h/6 + csur*usur*h/6; rhs(j) = rhs(j) + usur*csur*h/6 + csur*usur*2*h/6; end 4 Feb 4, 2010 ๏ท Variations of the problem and fem2d_fin.m ๐Ω1 ๐ข = 100 ๐Ω3 ๐Ω3 ๐ข๐ฅ = 0 −๐ข๐ฅ = 0 −๐ข๐ฆ = ๐๐ ๐ข๐ (๐ข๐ ๐ข๐ − ๐ข) ๐Ω2 Given ๐ข๐ ๐ข๐ = 23, ๐๐ ๐ข๐ = 10, ๐ป = 0.0001, ๐พ = 237, ๐ถ = 2๐๐ ๐ข๐ /๐ป and ๐ข|๐๐บ1 = 100. Test Case: −๐ข๐ฆ๐ฆ = 0 (1) ๐ข(. 1) = 100 (2) ๐ข๐ฆ (0) = 10(23 − ๐ข(0)) From (1) and (2), the solution ๐ข(๐ฆ) has the form ๐ข(๐ฆ) = ๐(. 1 − ๐ฆ) + 100 Then, ๐ข๐ฆ = −๐, combing with (3), we have −๐ = 10(23 − (๐(. 1 − 0) + 100)) This should be used to help debug the proposed code fem2d_fin.m 5 (3) Feb 4, 2010 Run the MATLAB code in fem2d_fin.m gives the following results: 0.1 0.09 0.08 100 0.07 80 0.06 0.05 60 0.04 40 0.03 20 0.02 0.1 0.01 0 0 0.1 0 0.02 0.04 0.06 0.08 0.08 0.1 0.05 0.06 0.04 0.02 0 0 The test problem is actually one dimensional fin problem. This can also be seen from the above right figure. Increasing H has the effect of decreasing the heat transfer coefficient of the top and bottom of the fin while leaving it the same on the three boundary edges. Thus less heat is allowed to leave the fin as is indicated by the following calculation with H = 2.0: 0.1 0.09 100 0.08 0.07 99.8 0.06 99.6 0.05 0.04 99.4 0.03 99.2 0.1 0.02 0.1 0.01 0.08 0.05 0.06 0.04 0.02 0 0 0.02 0.04 0.06 0.08 0 0.1 6 0