LINEAR INTERPOLATION SHAPE FUNCTIONS In the finite element method for one-dimensional problems, the region of interest is divided into elements connecting nodes. The elements and nodes are identified by a numbering system. The elements are numbered 1, 2, …, Ne. The nodes of an element are identified by 1 and 2 in the local node numbering system. A connectivity table relates the local node numbers to the global numbers. Element Element numbers 1 2 1 2 3 3 4 4 5 Global numbering 1 Local numbering Node e 1 2 1 1 2 2 2 3 3 3 4 4 4 5 local global 2 +X Fig. 1. Element and node numbering for a 4 element model. Assume that the solution to a problem is the unknown function u(x). The aim of the finite element method is to find an approximate solution v(x) by calculating its values at the nodes from an interpolation function ve(x) defined between two nodes. u v ve(x) ve2 ve1 e +X 1 Unknown solution u(x) 2 +X Approximate solution v(x) = ve(x) Fig. 2. Linear interpolation ve(x) used within each element to give the approximate solution v(x). ve1 and ve2 are the nodal values of the approximation function in local coordinates. To specify the location along the X-axis of a point, both global and local coordinate systems are used, as shown in figure 3. The global coordinates of the nodes are xi (i = 1, 2, … , Ne+1. The local coordinate system is often referred to as a natural or instrinsic coordinate system, denoted by where a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 1 2( x xi ) 2( x xi ) 1 1, xi 1 xi hi (1) for the ith element of length hi = xi+1 – xi. At node 1 of an element, = -1 and at node 2, = +1. ith element 1 2 x=0 xi x +X xi+1 = -1 = +1 hi Fig. 3. Coordinate systems for a typical element. From equation (1), we have the relationship d 2 dx hi and dx hi d 2 (2) The natural coordinate system is used to define the linear interpolation shape functions, N1 and N2 used for the interpolation within the ith element vi() = N1() ve1 + N2() ve2 (3) where ve1 and ve2 are the local nodal values of the function v(x) and N1 ( ) 1 2 (4a) N 2 ( ) 1 2 (4b) The interpolation functions are straight lines, with N1(-1) = 1, N1(+1) = 0, N2(-1) = 0 and N2(+1) = 1 as shown in figure 4. a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 2 v N 1 N2 N1 ve2 ve1 0 2 1 =0 = -1 Fig. 4. = +1 1 = -1 2 = +1 Linear interpolation shape functions and linear interpolation using N1 and N2. The derivates of the element interpolation function vi and the shape functions N1 and N2 with respect to and x are dN1 1 d 2 dN 2 1 d 2 dN1 dN1 d 1 2 1 dx d dx 2 hi hi (5a) dN 2 1 dx hi (5b) dvi 1 1 ve1 ve 2 d 2 2 (6a) dvi dvi d 1 1 1 ve1 ve 2 ve1 ve 2 dx d dx hi hi hi (6b) The interpolation function and its first derivative can be written in matrix form as vi [N]{v e } dvi 1 1 [ ]{v e } d 2 2 (7) dvi 1 1 [ ]{v e } dx hi hi (8) where ve1 [N] = [N1 N2] and {v e } ve 2 a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 (9) 5:12:35 AM 3 The coordinate transformation in equation (1) can also be written in matrix form using the shape functions x x = [N] {xe} = [N1 N2] e1 xe 2 (10) where xe1 and xe2 are the local nodal X coordinates. When both the approximation function v and coordinate x are interpolated using the same shape functions, the formulation is called isoparametric. We can calculate the integrals of the shape function with respect to x over an element by calculating the area under the curves for N1 and N2, hi hi hi o hi N1 dx N 2 dx o hi 2 (11a) and 0 0 hi dN dN dN1 dN1 1 2 2 dx dx 0 dx dx dx dx hi (11b) hi dN dN dN1 dN 2 1 2 1 dx dx 0 dx dx dx dx hi (11c) ONE-DIMENSIONAL STEADY-STATE HEAT TRANSFER In the steady-state heat transfer in one direction, our goal is to find the temperature distribution. A heat flux occurs and a temperature gradient exists along only one coordinate axis and the temperature at each point is independent of time. Many actual situations involving heat transfer can be modeled based upon the one-dimensional steadystate transfer of heat. Heat transfer by conduction through a material occurs when a temperature difference occurs within the material or between the material and surroundings. The onedimensional conduction process along the X-axis is described by Fourier’s law and is the heat flux equation is given by q( x ) ( x ) dT ( x ) dx a05/fem/doc/shape_functions_1d.doc (12) Saturday, February 06, 2016 5:12:35 AM 4 where T(x) is the temperature field in the material (K or C), q(x) is the heat flux (W.m2 ), (x) is the thermal conductivity (W.m-1.K-1) which is a property of the material and dT/dx is the temperature gradient (K.m-1). The minus sign indicates the direction of heat transfer is in the direction of decreasing temperature. There is convective transfer of heat between a fluid and a solid surface as a result of a temperature difference. The equation for heat transfer by convection is q hc Ts T (13) Where q is the convective heat flux (W.m-2), hc is the convection heat transfer coefficient (W.m-2.K-1), Ts is the surface temperature of the material and T is the fluid temperature. Heat transfer can also occur by radiation where the heat flux is proportional to the fourth power of the absolute temperature. This method of heat heat transfer will not be considered in our models. Consider the heat conduction through a wall as shown in figure ? The cross section area of the wall is A and assume a uniform internal generation of heat per unit volume QV (W.m-3), for example, a wire of resistance R with a current I (QV = I2R/V). QV is usually called a source when QV > 0 and a sink when QV < 0. For a steady-state situation, the heat flux and the internal heat generation for a volume element must equal the heat flux leaving an element for the temperature to remain independent of time, therefore, dq q A QV Adx q A (14) dx Using Fourier’s law and rearranging the equations gives a simple differential equation governing the one-dimensional steady state conduction of heat through the material d dT ( x ) ( x) QV 0 dx dx (15) where T(x) is the temperature along the material which can be determined by solving equation (15) given the boundary conditions. The boundary conditions are mainly of three types: 1. Dirichlet condition: the nodal values are specified by the boundary conditions. For example, the temperatures at the ends of the material are specified x=0 T(0) = To a05/fem/doc/shape_functions_1d.doc and x=L T(L) = TL Saturday, February 06, 2016 (16a) 5:12:35 AM 5 2. Neumann condition: the heat fluxes are specified at the boundaries. For example, where the inside surface is insulated and the flux is zero and the outside surface is a convection surface q(0) = 0 3. and q( L) hc Ts T (16b) Cauchy or mixed condition: Both field values and the field gradients are specified by the boundary conditions. For example, the inside wall is maintained at a constant temperature and convective occurs at the outside surface T(0) = and q( L) hc Ts T (16c) FINITE ELEMENT METHOD Galerkin’s approach To find the approximate temperature distribution (T v) along the material using the finite element method, we first define for each element, as in equation (7) vi [N]{v e } (17) The thermal conductivity within each element i is assumed to be constant. In the Galerkin approach, to find the unknown nodal temperatures we solve the equation L 0 d dv dx dx QV [N] dx 0 (18) Apply integration by parts to the left hand side of equation (18) to give L L L d [ N ] dv dv dx QV N dx 0 N 0 o dx dx dx 0 (19) The first term is determined by the boundary conditions at the ends of the material and can be assigned the values Q1 and QNe+1 which corresponds to the heat flux into the first element and the heat flux out of the last element. We can use the isoparametric representation with equation (19), so that for the ith element we can write hi 0 hi hi d [ N ] dvi dv i dx i N QVi N dx o dx dx dx 0 a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 (20) 5:12:35 AM 6 Using equations (5) and (6), the right hand side of equation (20) can be expressed as i N1 dvi dx hi hi QV i N1 dx qe1 hi dv i N2 i dx (21a) 0 o hi QV i N 2 dx qe 2 (21b) 0 o and we can define the column vector {qe}for an element as qe1 e2 q q e (22) The left hand side of equation (20) can be expressed as hi o i hi dN j dN1 dN 2 ve1 d [N] dvi dx i dx 0 dx dx dx dx dx ve 2 (23) where the column vector {ve} gives the local nodal values of the unknown function ve1 ve 2 v e (24) Let the thermal coefficient matrix for an element be [k e ] i hi 0 dN j dN1 dN 2 dx dx dx dx (25a) and using equation (11) hi ke11 i ke21 i [ke ] 0 hi 0 dN1 dN1 dx i dx dx hi ke12 i dN 2 dN1 i dx dx dx hi ke 22 i hi 0 hi 0 dN1 dN 2 i dx dx dx hi k dN 2 dN 2 dx i dx dx hi i 1 1 hi 1 (25b) (25c) (25d) 1 Therefore, the matrix equation for an element is a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 7 ke ve qe (26) Assembly Procedure We need to assemble the global matrices [K], [V] and [Q] from the element matrices [ke],{ve} and {qe}. For a three element model, the assembly process involves: 1. Construction of the global column matrix for the unknown nodal temperatures {V} V1 v11 V v1 v 2 1 V 2 2 V3 v 22 v31 V4 v32 (27) where terms such as v21 is the unknown value for element 2 and local node 1. The values of V1 and V4 may be determined by the boundary conditions at the external nodes. 2. Construction of the global column matrix {Q} Q1 q11 Q q1 q2 1 Q 2 2 Q3 q22 q31 Q4 q32 (28) where terms such as q32 is the heat flux across the local node 2 for element 3. If all quantities are measured in their S.I. unit, then the Qs are measured in watts in this problem on heat conduction. The Qs represent the rate of heat transfer or heat flux across each node and the values Q1 and Q4 represent the heat fluxes at the external boundaries, into and out of the material respectively. 3. Construction of the global thermal coefficient matrix [K] of (Ne +1) rows and (Ne+1) columns k111 k1 K 21 0 0 k112 0 k122 k 211 k 212 k 221 0 k 222 k 311 0 0 k 312 k 322 0 k 321 (29) Each term in the matrix [K] has the S.I. units of W.K-1 (W.C-1). The thermal coefficient matrix [K] is a banded and sparse matrix because the nonzero terms are a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 8 clustered about its main diagonal, and outside this band all the terms are zero. The banded and spare matrix results from the connectivity of a finite element mesh and for area and volume elements, efficient numbering of the nodes, the width of the band can be minimized. Usually the [K] matrix is symmetric. The integration by parts of equation (18) has two important implications: (1) it gives information of the boundary values and (2) it lowered the order of the highest order derivative appearing in the integrals of the thermal coefficient matrix [K]. The generality of this assembly process for the finite element method is very advantageous, since a computer code developed for the solution of one class of problem can be applied to other classes of problems. The complete system of equations solved by the finite element method is always of the form [K ] {V} = {Q} (30) where {V} is the column matrix of nodal values for the assemblage. Introducing the boundary conditions Regardless of the type of problem, the system of equation to be solved after the assembly process will have the form [K ] {V} = {Q} (31) The physics of the problem determines the boundary conditions that apply. We require at every node that we know either the Vi or Qi. There are a variety of ways to apply the boundary conditions. Method 1: Modification of [K] and {Q} matrices One way is to modify the matrices [K] and [Q]. For the three element model, equation (27) expands to the form K11 K12 K13 K14 V1 Q1 K K 22 K 23 K 24 V2 Q2 21 K31 K32 K33 K34 V3 Q3 K 41 K 42 K 43 K 44 V4 Q4 (32) Suppose that the values V1 and V3 were specified in the problem as V1 = 1 and V3 = 2 Then applying the boundary conditions, equation (28) becomes a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 9 0 0 V1 1 1 0 0 K 0 K 24 V2 Q2 K 211 K 233 22 (33) 0 0 1 0 V3 3 0 K 0 K V Q K K 42 44 4 4 41 1 43 3 This set of equations with unaltered dimensions can be solved to find all the unknown nodal values. Method 2: Penalty approach Another way in which the boundary conditions can be introduced and preserves the sparse, banded and usually symmetric properties of the [K] matrix is to modify the diagonal terms of [K] associated with the known nodal by multiplying them by a large number, say 1015, while the corresponding terms in {Q} are multiplied by the product of the large number and the corresponding diagonal term. With this procedure we obtain 15 K11 1015 K12 K13 K14 V1 1 K11 10 K K K K V Q 22 23 24 2 2 21 K K32 K 33 1015 K 34 V3 Q3 K 33 1015 31 K 42 K 43 K 44 V4 Q K 41 4 Again, the system of simultaneous equations can be solved to find the unknown nodal values. Example: Conduction through a composite slab with Dirichlet Boundary conditions Consider a composite slab with a uniform cross-sectional area A consisting of two materials having thicknesses L1 and L2 and thermal conductivities 1 and 2. The temperatures at the outer surfaces of the materials are T1 and T2. We can calculate for the steady-state case, the temperature Tx at the interface between the two materials and the rate of heat transfer (heat flux) through the slab H. Parameters L1 = 0.100 m T1 = 100 C L2 = 0.050 m T2 = 0C 1 = 20 W.m-1.C-1 2 = 50 W.m-1.C-1 Solution: analytic (exact) calculation The heat flux equation for conduction is a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 10 q( x ) dT ( x ) dx In the steady-state, the heat flux through both materials must be the same. Therefore, q1 = q2 and we can write Tx T1 T2 Tx 2 L1 L2 And rearranging 1 Tx 2 / L2 T2 1 / L1 T1 2 / L2 1 / L1 Results of calculation Tx = 16.6667 C q = 1.66667×104 W.m-2 Matlab Code % example_xxx.m clear clc % Input parameters ****************************** % Lengths L(1) = 0.1; L(2) = 0.05; % Thermal conductivities s(1) = 20; s(2) = 50; % Temperatures at outer surfaces T(1) = 100; T(2) = 0; % Calculations *********************************** c = s./L; % Temperature at interface Tx = T(3) T(3) = (c(1)*T(1) + c(2)*T(2))/(c(1)+c(2)); % Heat flux density I = H/A I(1) = -c(1)*(T(3)-T(1)); I(2) = -c(2)*(T(2)-T(3)); a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 11 % Output parameters fprintf('Temp at interface Tx = %0.5g deg C \n',T(3)) disp(' ') fprintf('Heat flux density I = %0.4e W.m^-2 \n',I(1)) Solution: fem Results of calculation Nodal positions x= 0 0.0500 0.1000 0.1250 0.1500 Nodal temperatures - Method 1: Modification of [K] and {Q} matrices V1 = 100.0000 58.3333 16.6667 8.3333 0 Nodal temperatures - Method 2: Penalty approach V2 = 100.0000 58.3333 16.6667 8.3334 0.0000 Temp at interface Tx = 16.6667 deg C Heat flux density q = 1.6667e+004 W.m^-2 The results are identical to the exact solution, because the temperature gradient within each material is a linear function and a linear interpolation function is used. a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 12 100 90 70 o Temperature T ( C) 80 60 50 40 30 20 10 0 0 0.02 0.04 0.06 0.08 0.1 Position x (m) 0.12 0.14 0.16 Matlab Code % example_xxx1.m clear clc % Input parameters ****************************** Ne = 4; % number of elements % Lengths L(1) = 0.1; L(2) = 0.05; % Thermal conductivities s(1) = 20; s(2) = 50; % Temperatures at outer surfaces T(1) = 100; T(2) = 0; % Setup ***************************************** % Coefficients c = sigma/h h = zeros(1,Ne); c = zeros(1,Ne); h(1:Ne/2) = L(1)/2; h(Ne/2+1:Ne) = L(2)/2; sigma(1:Ne/2) = s(1); a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 13 sigma(Ne/2+1:Ne) = s(2); c = sigma ./ h; Ke = [1 -1;-1 1]; x = zeros(Ne+1,1); for cc = 2 : Ne+1 x(cc) = x(cc-1) + h(cc-1); end % Assembly thermal coefficient matrix K = zeros(Ne+1,Ne+1); for c1 = 1 : Ne K(c1:c1+1,c1:c1+1) = K(c1:c1+1,c1:c1+1) + c(c1) * Ke; end % Matrix for unknown nodal values V = zeros(Ne+1,1); % Q matrix Q = zeros(Ne+1,1); % INTRODUCING THE BOUNDARY CONDITIONS *********** % Method 1: Modification of [K] and {Q} matricies V1 = zeros(Ne+1,1); Q1 = zeros(Ne+1,1); K1 = K; Q1(1) = T(1); Q1(5) = T(2); Q1(2) = Q(2) - K(2,1)*T(1) - K(2,5)*T(2); Q1(3) = Q(3) - K(3,1)*T(1) - K(3,5)*T(2); Q1(4) = Q(4) - K(4,1)*T(1) - K(4,5)*T(2); % Modify [K] matrix K1(1,:) = 0; K1(:,1) = 0; K1(1,1) = 1; K1(5,:) = 0; K1(:,5) = 0; K1(5,5) = 1; V1 = K1\Q1; % Method 2: Penalty approach V2 = zeros(Ne+1,1); Q2 = Q; K2 = K; Kmax = max(max(K))*1e5; a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 14 Q2(1) = Q(1) + Kmax * T(1); Q2(5) = Q(5) + Kmax * T(2); % Modify [K] matrix K2(1,1) = K(1,1) + Kmax; K2(5,5) = K(5,5) + Kmax; V2 = K2\Q2; % GRAPHICS ************************************** figure(1) plot(x,V1,'o-','LineWidth',2) xlabel('Position x (m)'); ylabel('Temperature T ( {^o} C)'); % OUTPUTS *************************************** % Heat Flux density I = - s(1)*(V1(2)-V1(1))/h(1); disp(' ') disp('Nodal positions') x disp(' ') disp('Nodal temperatures - Method 1: Modification of [K] and {Q} matrices') V1 disp('Nodal temperatures - Method 2: Penalty approach') V2 fprintf('Temp at interface Tx = %0.6g deg C \n',V1(3)) disp(' ') fprintf('Heat flux density I = %0.4e W.m^-2 \n',I) a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 15 Example: Conduction through a composite slab with Cauchy Boundary conditions A composite wall consists of three materials. The outer temperature at T(L) = 20 C. Convection heat transfer takes place on the inner surface of the wall with T = 800 C and hc = 25 W.m-2.C-1 Determine the temperature field T(x) within the wall. The thickness and thermal conductivities of the three materials are L1 = 0.3 m L2 = 0.15 m 1 = 20 W.m-2.K-1 L3 = 0.15 m 2 = 30 W.m-1.K-1 3 = 50 W.m-2.K-1 Solution: fem The matrix equation to solve is [K] {V} = {Q} which has to be modified by the boundary conditions x = 0 q(0) hc T (0) T where T(0) is the unknown temperature V1, hc = 25 W.m-2.C-1 and T = 800 C x = L T(L) = V4 = 20 C Consider a 3 element model with 4 nodes. The matrix equation can be written as K11 K12 K13 K14 V1 Q1 K K 22 K 23 K 24 V2 Q2 21 K31 K32 K33 K34 V3 Q3 K 41 K 42 K 43 K 44 V4 Q4 Applying the boundary condition at x = 0, Q1 hc V1 T means that we have to rearrange the matrix equation to give K11 hc K12 K13 K14 V1 hc T K K 22 K 23 K 24 V2 Q2 21 K31 K32 K33 K34 V3 Q3 K 42 K 43 K 44 V4 Q4 K 41 Applying the boundary condition at x = L, the matrix equation is modified to give a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 16 K11 hc K12 K13 0 V1 hc T K K 22 K 23 0 V2 K 25 21 K31 K32 K33 0 V3 K35 0 0 1 V4 T4 0 We can solve this set of simultaneous equations to find the unknown temperatures. are shown in figure 4. Tstraight lines functions a . ) defines nConsider a typical element e with local nodes 1 and 2. a05/fem/doc/shape_functions_1d.doc Saturday, February 06, 2016 5:12:35 AM 17