problem 1 - web.ics.purdue.edu

23
MAE 4700/5700 (Spring 2014) Homework 5 1DBVP Finite Element Analysis for Mechanical & Aerospace Design Page 1 of 23 Due Monday March 3 nd , 12:00 midnight This homework is considering the analysis of one dimensional boundary value problems (1DBVP). A list of MatLab programs is provided together with an example problem. Problem 1 – Properties of shape functions, finite element interpolation and interpolation error (MatLab) 1. Modify the function FiniteElement_1D.m to include quadratic and cubic shape functions in one-dimension. 2. Write a short MatLab program that uses the above function and for several values of ξ , 1 1 ξ −≤ returns the following two values (for N e =2,3,4, N e =number of shape functions per element e) 1 1 () ( ), e e e N N e i i i i dN a N b d ξ ξ ξ = = = = Verify that a=1 and b=0. These tests are necessary (but not sufficient) to ensure correct calculation of the shape functions in FiniteElement_1D.m 3. Write a short MatLab program utilizing the function FiniteElement_1D.m to calculate values of the finite element interpolant of the function () sin ,0 1. gx x x π = Use two elements with linear shape functions. Evaluate () h g x and () gx at 10 equally spaced points in each element. Print the values of , ( ), () h xg x gx and | () ( )| h g x gx at each point. Note that since the shape functions () e i N ξ are written as functions of ξ , where 1 1 ξ −≤ , the program must select the value of ξ at which calculations are to be made and then calculate the corresponding value of x from ( ) () () () 1 [ ]{ } e N e e e e i i i x N x N x ξ = = = . Repeat the calculations for quadratic and cubic elements. 4. Using function ErrorAnalysis.m, extend the program in part 3 above to calculate the mean-square norm of the interpolation error. Calculate and print the value [ ] 1/2 1 2 0 || || () () h h g g gx g x dx = for linear, quadratic and cubic elements. Use Gaussian integration of order 4.

Upload: others

Post on 01-Dec-2021

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 1 of 23

Due Monday March 3nd, 12:00 midnight

This homework is considering the analysis of one dimensional boundary value problems (1DBVP). A list of MatLab programs is provided together with an example problem. Problem 1 – Properties of shape functions, finite element interpolation and interpolation error (MatLab)

1. Modify the function FiniteElement_1D.m to include quadratic and cubic shape functions in one-dimension.

2. Write a short MatLab program that uses the above function and for several values ofξ , 1 1ξ− ≤ ≤ returns the following two values (for Ne=2,3,4, Ne=number of shape functions per element e)

1 1

( )( ),e e eN N

e ii

i i

dNa N bd

ξξξ= =

= =∑ ∑

Verify that a=1 and b=0. These tests are necessary (but not sufficient) to ensure correct calculation of the shape functions in FiniteElement_1D.m

3. Write a short MatLab program utilizing the function FiniteElement_1D.m to calculate values of the finite element interpolant of the function

( ) sin , 0 1.g x x xπ= ≤ ≤ Use two elements with linear shape functions. Evaluate ( )hg x and ( )g x at 10 equally spaced points in each element. Print the values of

, ( ), ( )hx g x g x and | ( ) ( ) |hg x g x− at each point. Note that since the shape functions ( )e

iN ξ are written as functions of ξ , where 1 1ξ− ≤ ≤ , the program must select the value of ξ at which calculations are to be made and then calculate the

corresponding value of x from ( )( ) ( ) ( )

1[ ]

eNe e e e

i ii

x N x N xξ=

= =∑ . Repeat the

calculations for quadratic and cubic elements.

4. Using function ErrorAnalysis.m, extend the program in part 3 above to calculate the mean-square norm of the interpolation error. Calculate and print the value

[ ]1/21

2

0

|| || ( ) ( )h hg g g x g x dx

− = − ∫

for linear, quadratic and cubic elements. Use Gaussian integration of order 4.

Page 2: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 2 of 23

Solution:

1) Shape Functions: The general expression for (Lagrange polynomial) shape function is

𝑁𝑖 =(𝜉 − 𝜉1)(𝜉 − 𝜉2) … (𝜉 − 𝜉𝑖−1)(𝜉 − 𝜉𝑖+1) … (𝜉 − 𝜉𝑛)

(𝜉𝑖 − 𝜉1)(𝜉𝑖 − 𝜉2) … (𝜉𝑖 − 𝜉𝑖−1)(𝜉𝑖 − 𝜉𝑖+1) … (𝜉𝑖 − 𝜉𝑛)

Therefore, Linear Element:

N1 =12

(1−ξ)

N2 =12

(1+ ξ)

Quadratic Element:

N1 =12

ξ(ξ −1)

N2 =1−ξ 2

N3 =12

(1+ ξ)ξ

Cubic Element:

N1 =1

16(1−ξ)(3ξ +1)(3ξ −1)

N2 =9

16(1+ ξ)(ξ −1)(3ξ −1)

N3 =9

16(1+ ξ)(1−ξ)(3ξ +1)

N4 =1

16(1+ ξ)(3ξ +1)(3ξ −1)

We modified FiniteElement_1D.m to include the quadratic and cubic element shape functions and their derivatives. 2)

a = Nie

i=1

N e

∑ (ξ)

b =dNi

e (ξ)dξi=1

N e

We call the modified FiniteElement_1D.m and depending on the number of elements, add up the required number of terms.

Page 3: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 3 of 23

For several values of 𝜉, we could get the values of a and b as below:

For 𝜉 = −√32

, ElementType1 ElementType2 ElementType3 a 1 1 1 b 0 0 5.5511e-17

For 𝜉 = −√32

, ElementType1 ElementType2 ElementType3 a 1 1 1 b 0 1.1102e-16 7.2858e-17

For 𝜉 = 0.2, ElementType1 ElementType2 ElementType3 a 1 1 1 b 0 0 2.7756e-17

For 𝜉 = 0.7, ElementType1 ElementType2 ElementType3 a 1 1 1 b 0 0 2.2204e-16

From the obtained results, we could see that a is 1 and b is closed to 0, which demonstrates that our formulation of shape function is correct.

3) The value of the interpolant can be calculated by [N][u]u = , where [u] are the nodal values of the exact function provided. MATLAB Code: function Problem1_3and1_4.m % In order to make use of the global variables, include_variables; % include global variables % Get the user to set the element type: ElementType= 1; % Set element type: 1= linear, 2=quadratic, 3=cubic % For each element, specify the exact values of the function at each node, calculated from the exact function: for e= 1:2 if ElementType==1 d= [sin(pi*((e-1)*1/2+0));sin(pi*((e-1)*1/2+1/2))]; %d vector is just the value of the function at all nodes for every element. For example, d1=sin(0)=sin((e-1)*1/2+0) elseif ElementType==2 d= [sin(pi*((e-1)*1/2+0)) sin(pi*((e-1)*1/2+1/4)) sin(pi*((e-1)*1/2+1/2))]'; elseif ElementType==3 d= [sin(pi*((e-1)*1/2+0)) sin(pi*((e-1)*1/2+1/6)) sin(pi*((e-1)*1/2+1/3)) sin(pi*((e-1)*1/2+1/2))]'; end % Evaluate functions at 10 equally spaced points in each element using linspace:

Page 4: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 4 of 23

i=0; for xi= linspace(-1,1,10) % do calculations on 10 values of xi 0<xi<1 % Calculate the global nodal coordinates for the element, and interpolate to calculate the global x coordinate for that point. Run the FiniteElement_1D code to obtain the N and B matrices. i=i+1; x1= (e-1)*.5; % calculate the global x nodal coordinates (x1, x2) for the element x2= e*0.5; x(i)= x1 + 1/2*(1+xi)*(x2-x1); % interpolate to calculate the global x coordinate at that point [n,dndxi] = FiniteElement_1D(xi); % run the FiniteElement_1D code to obtain the N and B matrices % Interpolate to obtain the FE solution, and calculate the exact solution at that point: gh(i)= n*d; % interpolate to obtain the solution g(i)= sin(pi*x(i)); % get exact solution end figure(1) hold on plot(x,gh, x,g, x, abs(gh-g)) title('Comparison of FE Interpolant with Exact Solution') legend('gh', 'g', 'error') end % Print the values of x, gh(x), g(x) and |gh(x)-g(x)|, and plot it in a graph for easy comparison: % display the values in a table for k=1:i fprintf('%f \t\t %f \t\t %f \t\t %f\n', x(k), gh(k), g(k), abs(gh(k)-g(k))); end Results: Using Linear Shape Functions:

Element 1 Element 2 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)| 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)|

0 0 0 0 0.5 1 1 0 0.06 0.11 0.17 0.06 0.56 0.89 0.98 0.1 0.11 0.22 0.34 0.12 0.61 0.78 0.94 0.16 0.17 0.33 0.5 0.17 0.67 0.67 0.87 0.2 0.22 0.44 0.64 0.2 0.72 0.56 0.77 0.21 0.28 0.56 0.77 0.21 0.78 0.44 0.64 0.2 0.33 0.67 0.87 0.2 0.83 0.33 0.5 0.17 0.39 0.78 0.94 0.16 0.89 0.22 0.34 0.12 0.44 0.89 0.98 0.1 0.94 0.11 0.17 0.06 0.5 1 1 0 1 0 0 0

Page 5: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 5 of 23

Figure 1: Linear Element

Using Quadratic Shape Functions:

element 1 element 2 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)| 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)|

0 0 0 0 0.5 1 1 0 0.06 0.19 0.17 0.02 0.56 0.97 0.98 0.01 0.11 0.37 0.34 0.02 0.61 0.92 0.94 0.02 0.17 0.52 0.5 0.02 0.67 0.85 0.87 0.02 0.22 0.65 0.64 0.01 0.72 0.76 0.77 0.01 0.28 0.76 0.77 0.01 0.78 0.65 0.64 0.01 0.33 0.85 0.87 0.02 0.83 0.52 0.5 0.02 0.39 0.92 0.94 0.02 0.89 0.37 0.34 0.02 0.44 0.97 0.98 0.01 0.94 0.19 0.17 0.02 0.5 1 1 0 1 0 0 0

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Comparison of FE Interpolant with Exact Solution

ghgerror

Page 6: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 6 of 23

Figure 2: Quadratic Element

Using Cubic Shape Functions:

element 1 element 2 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)| 𝑥 𝑔ℎ(𝑥) 𝑔(𝑥) |𝑔ℎ(𝑥) − 𝑔(𝑥)|

0 0 0 0 0.5 1 1 0.00 0.06 0.18 0.17 0.01 0.56 0.99 0.98 0.01 0.11 0.34 0.34 0.00 0.61 0.94 0.94 0.00 0.17 0.5 0.5 0.00 0.67 0.87 0.87 0.00 0.22 0.64 0.64 0.00 0.72 0.76 0.77 0.01 0.28 0.76 0.77 0.01 0.78 0.64 0.64 0.00 0.33 0.87 0.87 0.00 0.83 0.5 0.5 0.00 0.39 0.94 0.94 0.00 0.89 0.34 0.34 0.00 0.44 0.99 0.98 0.01 0.94 0.18 0.17 0.01 0.5 1 1 0.00 1 0 0 0.00

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Comparison of FE Interpolant with Exact Solution

ghgerror

Page 7: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 7 of 23

Figure 3: Cubic Element

From the tables and graphs, it can be seen that the FE interpolation using 2 elements is least accurate using linear shape functions, and is the most accurate using the cubic shape functions. The solution curves match the exact solution better, and the error values are smaller. This is useful as with few elements (and subsequently less computing power) a more accurate interpolation can be obtained by using cubic shape functions. 4) In this problem, we basically need to evaluate the integral

[ ]1/21

2

0

|| || ( ) ( )h hg g g x g x dx

− = − ∫

which can be done by using Gauss Quadrature. In fact, the value of this integration is also known as the normalized L2 error. Since this has been coded in the function ErrorAnalysis.m, the FEinterpolant.m function from part 3 was simply extended to input the parameters needed; then ErrorAnalysis was called. MATLAB Code: Input parameters that are called within ErrorAnalysis. Use a Gaussian quadrature integration of order 4. For each element type, specify the exact nodal function values and connectivity matrices. Finally, call the error analysis function. % input the parameters required in the ErrorAnalysis function nel=2; % 2 elements ngp= 4; % use 4 gauss points nno= nel*ElementType + 1; % number of nodes Nodes = linspace(0,1,nno); % x coordinates of nodal points

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1Comparison of FE Interpolant with Exact Solution

ghgerror

Page 8: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 8 of 23

% for each element type, specify the exact nodal function values and element % connectivity matrix over the whole domain if ElementType == 1 d= [0 1 0]'; Elems= [1:(nno-1); 2:nno]; elseif ElementType== 2 d= [0 sin(pi/4) 1 sin(pi/4) 0]'; Elems= [1, 3; 2, 4; 3, 5]; elseif ElementType== 3 d= [0 sin(pi/6) sin(pi/3) 1 sin(pi/3) sin(pi/6) 0]'; Elems= [1, 4; 2, 5; 3, 6; 4, 7]; end % call the ErrorAnalysis function ErrorAnalysis Modify the exact.m to account for the exact solution of our problem: u = sin ( pi * x ); du = pi*cos(pi * x ); MATLAB Results: (after normalization)

linear 2.133717E-01 quadratic 2.154594E-02 cubic 1.480859E-03

As expected, the L2 norm error decreases from linear to cubic elements. Problem 2 – Axisymmetric radial heat flow through a circular cylinder (MatLab) Consider the axisymmetric radial heat flow by conduction through a homogeneous hollow cylinder of inside radius ir and outside radius 0r . If the cylinder is sufficiently long, the end effects can be neglected. The governing equation for the temperature is given as

0( ) , id dTkA AQ r r rdr dr

− = < <

Page 9: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 9 of 23

where k is the thermal conductivity, 2A rlπ= the surface area, l is the length of the cylinder, Q the heat generation per unit area, r the radial coordinate and T the temperature. The heat flux is given as

dTq kAdr

= −

Use the data 0r =3.25 in, ir =1.75 in, l =10 ft, Q = 0, k = 0.04Btu/(h.ft.0F), iT = 400oF, 0T = 800F, where iT and 0T are the specified temperatures at the inner and outer walls, respectively. Modify the given MATLAB programs to compute the temperature and flux in the cylinder (use 10 linear elements). Comment on the accuracy of the temperature/flux results. Compare your results with the analytical solution

00

ln( )( ) ( )

ln( )i

i i

i

rrT r T T T rr

= − −

Solution: This problem follows the differential equation below:

−ddr

(kA dTdr

) = AQ , ri < r < ro

q = −kA dTdr

The parameters are specified as Q=0, k=0.04 Btu/(h.ft.F) and A=2πrl where l=10 ft. And boundary condition:

Ti =400 F,

ri =1.75 in To=80 F,

ro=3.25 in The problem has the following analytical solution:

T (r ) = Ti − (Ti − To )ln( r

ri)

ln(rori

)

The weak form of the governing differential equation can be written as:

0o o

i i

r r

r r

dw dTkA dr QAwdrdr dr

+ =∫ ∫ Discretize the problem and use the same interpolation function for both w and T

(w=[N][w] and T=[N][T]). We get:

Page 10: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 10 of 23

[T] [N]o o

i i

r r

r r

dN dNkA dr QA drdr dr

= −∫ ∫ Therefore,

[N]

o

i

o

i

r

r

r

r

dN dNK kA drdr dr

f QA dr

=

= −

∫ Nodal value of temperature can be solved by [K][T]=[f]. Most of the process above has already been implemented in the program, the main modifications of the program are listed as below: InputData.m was modified to use the appropriate boundary conditions. At the first node, a temperature of 400° F is applied while at the last node, a temperature of 80° is applied. InputGrid.m is where we input the coordinates of the leftmost and rightmost nodes (at the inner and outer radius). We used ten linear elements to approximate the solutions. In exact.m, we input the analytical solution given for T(r) and the heat flux solution based on the equation given. ff.m, qq.m, and pp.m were modified to reflect the parameters of the boundary value problem. Postprocessor.m was also changed so that it plots the FE solution of the heat flux, not just dT/dr. The plot titles in ErrorAnalysis.m were also modified for that reason. The analytical and FE solutions given by MATLAB are as follows:

Page 11: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 11 of 23

Figure 4: Temperature

Figure 5: Heat Flux

From the plots, it is apparent that the FE solution for T is very accurate, but the FE solution for heat flux is not. Analytically, the heat flux is constant. It is given by

𝑞 = −𝑘(2𝜋𝑟𝑙)𝑑𝑇𝑑𝑟

1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.650

100

150

200

250

300

350

400

u

x

u: FE versus analytical solution

FEExact Solution

1.6 1.8 2 2.2 2.4 2.6 2.8 3 3.2 3.4 3.61240

1260

1280

1300

1320

1340

1360

kA*d

u/dx

x

kA*(du/dx): FE versus analytical solution

FEExact Solution

Page 12: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 12 of 23

Note that the gradient of the temperature is of the form ~1/r (this r is cancelled when multiplying with the area but the FEM code does not supposed to know that!). It is not easy to use linear or even quadratic shape functions to represent that correctly with moderate number of elements. Because we are using linear elements, dT/dr is constant. In order to make the FE solution more accurate for heat flux, we could either increase the number of linear elements or use higher order elements. Problem 3 – Boundary value problems (BVPs) with non-smooth solutions – Error analysis and higher order (quadratic and cubic) elements (MatLab) Consider the following BVP

( ( ) ) ( ), 0 1d duk x f x xdx dx

− = ≤ ≤

where 20

1( ) ( )k x a x xa

= + − and

0 0 0( ) 21 ( )[arctan[ ( )] arctan( )]f x a x x a x x ax= + − − + . The analytical solution to this problem (check it out!) is:

0 0( ) (1 )[arctan ( ) arctan( )]exu x x a x x ax= − − +

and 0 0 2 20

(1 )[arctan ( )] [arctan( )]1 ( )

exdu x aa x x axdx a x x

−= − − + +

+ −

The boundary conditions are taken as (0) (1) 0u u= = . a) Plot the analytical solution for different values of a and 0 0.5x = to realize that

the function ( )exu x exhibits behavior which ranges from very smooth to almost

discontinuous near 0x x= . b) Before we study this problem in more detail, modify the provided MATLAB code

for 1D BVP to allow the use of quadratic and cubic elements. c) For both a `smooth’ problem (small a , e.g. 5a = ) and a `rough’ problem (large

a , e.g. 50a = ), study the convergence rate of linear, quadratic and cubic

elements. Use uniform meshes of 2, 4, 8 and 16 elements (1 1 1 1, , ,2 4 8 16

h = ).

Study the convergence in both the 2L and energy norms discussed in lecture. Plot

log log || ||hE u u≡ − versus log h and determine the experimental convergence rates for the different element types. Compare these with the theoretical values shown in class, e.g for the 2L norm

Page 13: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 13 of 23

( )2

1/21 2 110

|| || ( ( )) ,kLE E x dx C h += ≤∫

1C being a constant independent of h , and for finite elements employing complete polynomials of degree k . Similarly, we have the following result for the energy norm:

1/221

20

1|| || ( ) ,2

kenergy

dEE k x dx C hdx

= ≤ ∫

2C being a constant independent of h , and for finite elements employing complete polynomials of degree k . In your results, please normalize these computed errors with the corresponding norms of the exact solution, i.e. use the following:

( )( )

2

1/21 2

01/21 2

0

( ( ) ( ))

( ( ))

hex

L

ex

u x u x dxe

u x dx

−=

and

1/2

1 2

0

1/21 2

0

( )1 ( )( )( )2

( )1 ( )( )2

hex

energy

ex

du x du xk x dxdx dx

edu xk x dx

dx

=

The above theoretical error estimates are called asymptotic since they exhibit increasing accuracy as 0h → . How small does h needs to be in your error plots to achieve asymptotic convergence? Note that the theoretical error estimates assume smooth solutions so your approximations may get worst as the smoothness of the solution deteriorates.

Solution: (a) Just plot the function 0 0( ) (1 )[arctan ( ) arctan( )]exu x x a x x ax= − − + :

Page 14: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 14 of 23

So it is obvious that the function exhibits behavior which ranges from very smooth to almost discontinuous near middle point with increase of a.

(b) Modify the function FiniteElement_1D.m to include quadratic and cubic shape functions in one-dimension.

𝑁𝑖 =(𝜉 − 𝜉1)(𝜉 − 𝜉2) … (𝜉 − 𝜉𝑖−1)(𝜉 − 𝜉𝑖+1) … (𝜉 − 𝜉𝑛)

(𝜉𝑖 − 𝜉1)(𝜉𝑖 − 𝜉2) … (𝜉𝑖 − 𝜉𝑖−1)(𝜉𝑖 − 𝜉𝑖+1) … (𝜉𝑖 − 𝜉𝑛)

So, for quadratic shape functions,

𝑁 = 𝜉(𝜉 − 1)

2, (𝜉 + 1)(1 − 𝜉),

𝜉(1 + 𝜉)2

For cubic shape functions,

𝑁 = [−9

16𝜉 +

1

3 𝜉 −

1

3 (𝜉 − 1),

27

16(𝜉 + 1) 𝜉 −

1

3 (𝜉 − 1),

−2716

𝜉+ 1 𝜉+13 𝜉 − 1,

916 (𝜉+ 1)(𝜉+

13)(𝜉 − 1

3)]

For 𝑑𝑁𝑑𝜉

, it can be realized by hand calculation. The results are in the file FiniteElement_1D.m. Also, as the number of nodes in each element is 3 and 4 for quadratic and cubic element respectively, the MeshGenerator and the PlotGrid file need to be changed a little bit as well. (c) The theoretic result for 2L norm can be expressed as

( ) ( ) ( )2 1log || || log ( 1) log ,LE C k h= + +

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.2

0.4

0.6

0.8

1

1.2

1.4

x

u(x)

u(x) vs a

a = 5a = 15a = 25a = 35a = 45a = 55a = 65a = 75

Page 15: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 15 of 23

So if we plot the log error vs log h, the plot is a straight line, where the slop ( )1k + is the rate of convergence of the element. Therefore, for linear elements, the slop is 2. The slope is 3 for quadratic elements and 4 for cubic elements if the asymptotic convergence is achieved. The energy norm can also be expressed as

( ) ( ) ( )2log || || log log ,energyE C k h= +

Thus the convergence rate for energy norm is one order less than the L2 norm. Note that this asymptotic behavior can be only achieved when h is small enough (That is actually the definition of the word asymptotic). If we plot our data in log-log plot, as h is not small enough, the slope would not be a constant. Therefore, the slope at each point (corresponding to each mesh size) is calculated to be compared to theoretical value. For example, the experimental

convergence rate for h=1/4 is calculated as 2 2log(E (1/ 4)) log(E (1/ 2))log(1/ 4) log(1/ 2)L L−

−. Our results of

calculation are listed below: For L2 norm and a=50, the results are:

Linear Elements Quadratic Elements Cubic Elements The results are listed below: Linear Elements Quadratic Elements Cubic Elements Slope at h=1/4 1.864066 2.766593 2.619586 Slope at h=1/8 2.200452 2.627636 3.72719 Slope at h=1/16 2.024013 2.936185 4.129902 For linear elements, the convergence rate should be p+1=2 for asymptotic convergence, this is approximately achieved when ℎ < 1

2. Similarly, for quadratic elements, the

convergence rate should be 3, so asymptotic convergence is achieved when ℎ < 18, and

for cubic elements, h needs to be ℎ < 1/8. For L2 norm and a=50, the results are:

-3 -2.5 -2 -1.5 -1 -0.5-6

-5.5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1log(EL2) versus log(h),a=5,linear elements

log(h)

log(

EL2

)

-3 -2.5 -2 -1.5 -1 -0.5-9

-8

-7

-6

-5

-4

-3log(EL2) versus log(h),a=5,quadratic elements

log(h)

log(

EL2

)

-3 -2.5 -2 -1.5 -1 -0.5-12

-11

-10

-9

-8

-7

-6

-5

-4log(EL2) versus log(h),a=5,cubic elements

log(h)

log(

EL2

)

Page 16: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 16 of 23

Linear Elements Quadratic Elements Cubic Elements The convergence rate results are listed below: Linear Elements Quadratic Elements Cubic Elements Slope at h=1/4 0.579389 0.887806 1.285372 Slope at h=1/8 0.844878 1.375918 2.125058 Slope at h=1/16 1.241226 2.222484 3.529285 Even when ℎ < 1/8, the asymptotic convergence has not be achieved, so at least h need to be less than 1/16. For Energy norm and a=5, the results are:

Linear Elements Quadratic Elements Cubic Elements The experimental convergence rates results are listed below: Linear Elements Quadratic Elements Cubic Elements Slope at h=1/4 1.05073662 2.01337678 1.503859351 Slope at h=1/8 1.061978141 1.587345539 2.791434772 Slope at h=1/16 1.001341151 1.937454759 3.103925654 As this is energy norm, the convergence rate should be p to match the asymptotic convergence results. So, For linear elements, ℎ < 1

2,

For quadratic elements, ℎ < 18

For cubic elements, ℎ < 1/4. For Energy norm and a=50, the results are:

-3 -2.5 -2 -1.5 -1 -0.5-2.5

-2

-1.5

-1

-0.5

0log(EL2) versus log(h),a=50,linear elements

log(h)

log(

EL2

)

-3 -2.5 -2 -1.5 -1 -0.5-4

-3.5

-3

-2.5

-2

-1.5

-1

-0.5log(EL2) versus log(h),a=50,quadratic elements

log(h)

log(

EL2

)

-3 -2.5 -2 -1.5 -1 -0.5-7

-6

-5

-4

-3

-2

-1log(EL2) versus log(h),a=50,cubic elements

log(h)

log(

EL2

)

-3 -2.5 -2 -1.5 -1 -0.5-3

-2.5

-2

-1.5

-1

-0.5log(EEnergy) versus log(h),a=5,linear elements

log(h)

log(

EEn

ergy

)

-3 -2.5 -2 -1.5 -1 -0.5-6

-5.5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5log(EEnergy) versus log(h),a=5,quadratic elements

log(h)

log(

EEn

ergy

)

-3 -2.5 -2 -1.5 -1 -0.5-9

-8

-7

-6

-5

-4

-3log(EEnergy) versus log(h),a=5,cubic elements

log(h)

log(

EEn

ergy

)

Page 17: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 17 of 23

Linear Elements Quadratic Elements Cubic Elements The computed convergence rates results are listed below: Linear Elements Quadratic Elements Cubic Elements Slope at h=1/4 0.700873758 0.704907974 0.756245873 Slope at h=1/8 0.681158425 0.802826542 1.231608947 Slope at h=1/16 0.754306761 1.396070397 3.295432535 For linear and quadratic elements, h needs to be at least less than 1/16 to achieve asymptotic convergence. For cubic elements, when ℎ < 1

8, the solution exhibit asymptotic

convergence. From the comparison above, we can see that for smooth solution (a=5), it is much easier (h does not need to be very small) to achieve asymptotic convergence compared with the almost discontinuous solution (a=50). This is because near the discontinuous region, the derivative of the solution changes rapidly. Thus, more elements are needed in this region. A better idea is to use adaptive mesh where we place more elements around the region with sharp changes in the function value while placing less elements in the smooth region. Problem 4 – Boundary value problems (BVPs) with non-smooth solutions – Adaptive finite element method (It requires some MatLab programming – but you will enjoy your program in action!) From Problem 3, it is seen that when the solution exhibits non-smooth behavior, the convergence of the solution is significantly reduced. A possible remedy is to adaptively refine the finite element mesh around the singular region. Basic Ideas of Adaptive Finite Element Algorithms: Suppose we can compute the exact error Ke in element K . If the overall target error for the computation isγ , we want that KK

e γ≤∑ . Having a finite element mesh, we would like

to construct a new mesh, with the minimal number of nodes, such that KKe∑ meets the

target error. This is actually a constrained nonlinear optimization problem. To facilitate its solution, we can introduce an iterative process over successively finer grids. First, we need to estimate an upper bound the true error. The error bound in such estimates normally has the form 2

KKε ε= ∑ , where 2

Kε is the contribution from element K . The

estimates are only valid as the sum, but it is common to use the local components 2Kε of

-3 -2.5 -2 -1.5 -1 -0.5-2

-1.8

-1.6

-1.4

-1.2

-1

-0.8

-0.6

-0.4

-0.2log(EEnergy) versus log(h),a=50,linear elements

log(h)

log(

EEn

ergy

)

-3 -2.5 -2 -1.5 -1 -0.5-3.5

-3

-2.5

-2

-1.5

-1

-0.5log(EEnergy) versus log(h),a=50,quadratic elements

log(h)

log(

EEn

ergy

)

-3 -2.5 -2 -1.5 -1 -0.5-5.5

-5

-4.5

-4

-3.5

-3

-2.5

-2

-1.5

-1log(EEnergy) versus log(h),a=50,cubic elements

log(h)

log(

EEn

ergy

)

Page 18: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 18 of 23

the sum as indicators for the refinement of individual elements. That means that we locally employ an error bound of the form 2 2

K Ke ε≤ . Of course, Kε should be something that can be easily computed. We let jΤ be the mesh in the iteration j , that is, after j refinements of the initial mesh. Furthermore, let ( )jm Τ be the number of element in jΤ . We can then apply the values of

Kε computed in the current mesh jΤ to select the elements to be refined. Applying a mesh refinement algorithm yields a new mesh 1j+Τ . The selection of elements to be refined is often based on the principle that the error should be uniformly distributed throughout the mesh. Thus, we aim at having 2 2 /K optmε γ≤ , where optm is the number of element in the final (optimal) mesh. A natural consequence is that an element K is marked for refinement if 2 2 /K optmε γ> . The iteration process is stopped when the total estimated errorε is less than the target error γ , or when the number of refinements exceeds a prescribed maximum level. For practical computations, we often choose || ||h energyuγ η= , whereη is given tolerance for the relative error in the global energy norm, if the energy norm is used for the estimate. Here || ||h energyu is the energy norm of the solution and η can be seen as the tolerance in the normalized energy-norm error of the solution. Adaptive finite element algorithm: Choose initial mesh 0Τ Compute hu using the current mesh 0Τ .

1j = . While maxj j≤ 1j j= + Compute estimator Kε in each element

If the total error 2 || ||K h eKuε ε η= >∑ then

Split the elements K for which ( )|| || jK h eu m Tε η> equally into two smaller

(e.g. equal length) elements Compute hu using the new mesh 1j+Τ Endwhile Here the energy norm can be computed in the following way:

( ) ( )1 11 2 2

0|| || ( ) T

h e h h h hu k x dx= ∇ ∇ =∫ u u u Ku

where K is the stiffness matrix.

Page 19: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 19 of 23

In this problem, Kε is chosen to be the ZZ (Zienkiewicz-Zhu) estimator, which is a popular error indicator for low-order elements. It is defined as

( ) ( )( )12( )

kK h hk x dxε ∗ ∗

Ω= − −∫ q q q q

where hh

duqdx

= (note that differentiation of uh via the shape functions to compute the

flux qh is only accurate at the Gauss points). A very simply choice of ∗q is the smoothed version of hq at the nodal points, using Galerkin, least-squares, or 2L projection methods (in essence we compute it by extrapolating the accurate fluxes at the Gauss points to the nodes of the element. This extrapolation is posed as a least squares problem with the nodal values of q* being the main unknowns). A MatLab file makeGradient.m is provided to compute the ∗q given the solution vector u . More details can be found in the lecture notes. Implement the Adaptive finite element algorithm with linear finite elements by modifying the 1DBVP MatLab code. Resolve problem 3 with 50a = and three different

0 0.2, 0.5, 0.8x = . Give the final errors comparing with the analytical solution and plot the adaptive mesh (a movie presentation should be nice!). Verify that the obtained mesh is refined near 0x . Compare your solutions with that of uniform mesh with the same number of elements in the final mesh. Consider 5%η = and 1%η = for each case to check the convergence of the algorithm. The initial mesh consists of 2 elements and the maximum number of refinement iterations is set to 15. Hint : A basic structure of the code is provided in the folder 1DBVP_adaptive. You need to finish the function ErrorEstimator.m. Make sure you understand it before you start implementation. If you like, you could still modify your own code directly on the original 1DBVP code. Solution: In this problem, we can use Gauss Quadrature Integration to get an estimate of the error for each element and then compare this error with the required accuracy. If the error is bigger than required, split this element into two. Repeat the above process for each element, resolve the problem and reexamine the error until the required accuracy is achieved. Major modifications of program 1DBVP_adaptive are described below:

(1) ErrorEstimator: Use the Gauss Integration to get 𝜀𝑘, and change the mesh when 𝜀𝑘 > 𝜂‖𝑢ℎ‖/𝑚(𝑇𝑗). For different accuracy requirement, we need to change the value of 𝜂.

(2) InputData: Change 𝑥0 when required.

In the case that 𝒙𝟎 = 𝟎.𝟐, the final results are shown below: For 𝜂 = 5%, the adaptive mash:

Page 20: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 20 of 23

The final number of elements is 18

Adaptive mesh Uniform mesh L2 norm error 3.682771e-03 2.567537e-02 Energy norm error 3.074613e-02 5.507147e-02 For 𝜂 = 1%, the adaptive mesh is:

The final number of elements is 59

Adaptive mesh Uniform mesh L2 norm error 2.363276e-04 5.281221e-03 Energy norm error 8.275980e-03 2.789808e-02 In the case that 𝒙𝟎 = 𝟎.𝟓, the final results are shown below: For 𝜂 = 5%, the adaptive mash:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

Page 21: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 21 of 23

The final number of elements is 23

Adaptive mesh Uniform mesh L2 norm error 5.032291e-03 1.898417e-02 Energy norm error 3.546072e-02 5.523873e-02 For 𝜂 = 1%, the adaptive mesh is:

The final number of elements is 68

Adaptive mesh Uniform mesh L2 norm error 2.701961e-04 5.238377e-03 Energy norm error 9.680972e-03 3.041930e-02

In the case that 𝒙𝟎 = 𝟎.𝟖, the final results are shown below: For 𝜂 = 5%, the adaptive mash:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

Page 22: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 22 of 23

The final number of elements is 33

Adaptive mesh Uniform mesh L2 norm error 1.670972e-03 2.633095e-02 Energy norm error 3.101023e-02 8.878898e-02 For 𝜂 = 1%, the adaptive mesh is:

The final number of elements is 107

Adaptive mesh Uniform mesh L2 norm error 1.907058e-04 3.324034e-03 Energy norm error 8.820726e-03 3.107541e-02

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

11D Grid Plot

Page 23: Problem 1 - web.ics.purdue.edu

MAE 4700/5700 (Spring 2014) Homework 5 1DBVP

Finite Element Analysis for Mechanical & Aerospace Design Page 23 of 23

Conclusions: 1. Overall, the developed algorithm can effectively capture the discontinuity/non-

smooth parts in the solution and put more elements around that region. 2. For the same number of elements, the error with adaptive mesh is much smaller

than the error with uniform mesh. 3. Although going from 𝜂 = 5% to 𝜂 = 1% the accuracy does not improve a lot, the

number of elements to achieve that accuracy increases significantly. So, from the view of computational cost, 𝜂 = 5% might be better.

4. Although the boundary condition seems symmetric, the complexity at the regions 𝑥 = 0.2 𝑎𝑛𝑑 𝑥 = 0.8 is not same. To obtain the same accuracy, 𝑥 = 0.8 requires more elements.