Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATH 212 NE 217 Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada Copyright © 2011.

Similar presentations


Presentation on theme: "MATH 212 NE 217 Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada Copyright © 2011."— Presentation transcript:

1 MATH 212 NE 217 Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada Copyright © 2011 by Douglas Wilhelm Harder. All rights reserved. Advanced Calculus 2 for Electrical Engineering Advanced Calculus 2 for Nanotechnology Engineering 1-D Finite-Element Methods with Tent Test Functions

2 1-D Finite-element Methods with Tent Test Functions 2 Outline This topic discusses an introduction to finite-element methods –Background –Define tent-shaped test functions –Perform integration-by-parts to get the linear equation Approximate the solution by a linear solution Find the system of equations

3 1-D Finite-element Methods with Tent Test Functions 3 Outcomes Based Learning Objectives By the end of this laboratory, you will: –Understand the use of test functions in one dimension –Understand how to create a system of linear equations using these test functions in one dimenion

4 1-D Finite-element Methods with Tent Test Functions 4 The Target Equation At this point, we have generalized the finite-difference method to allow arbitrarily spaced points in one dimension The ultimate goal is to do this in 2 and 3 dimensions –In order to achieve this, we need one further idea

5 1-D Finite-element Methods with Tent Test Functions 5 Test Functions Up to this point, we have used uniform test functions:

6 1-D Finite-element Methods with Tent Test Functions 6 Test Functions Two problems: –The impulse function appears in the integrals, and –This will not generalize to two and three dimensions!

7 1-D Finite-element Methods with Tent Test Functions 7 Test Functions Solution: –Use a tent function

8 1-D Finite-element Methods with Tent Test Functions 8 Test Functions Defining such functions is straight-forward: If x = x 2, both, if x = x 1,, and if x = x 3,

9 1-D Finite-element Methods with Tent Test Functions 9 Integration by Parts Now, substitute this test function into the integral: which yields

10 1-D Finite-element Methods with Tent Test Functions 10 Integration by Parts The tent function disappears at x 1 at x 3 : thus, this simplifies to: 0

11 1-D Finite-element Methods with Tent Test Functions 11 Integration by Parts The tent function disappears at x 1 at x 3 : thus, this simplifies to: 0 A similar property will be used in 2 and 3 dimensions – remember this fact!

12 1-D Finite-element Methods with Tent Test Functions 12 Integration by Parts Recall that both the test function  2 (x) and are defined on :

13 1-D Finite-element Methods with Tent Test Functions 13 Integration by Parts On the intervals, the derivatives are defined:

14 1-D Finite-element Methods with Tent Test Functions 14 Integration by Parts Thus:

15 1-D Finite-element Methods with Tent Test Functions 15 Integration by Parts In general:

16 1-D Finite-element Methods with Tent Test Functions 16 Integration by Parts Substituting this back into our equation, we get: or, expanding the left-hand side:

17 1-D Finite-element Methods with Tent Test Functions 17 Integration by Parts In the special case that is a constant, this simplifies further:

18 1-D Finite-element Methods with Tent Test Functions 18 The Test Functions The function to find the approximations is straight-forward: function [ v ] = uniform1d( x, uab, rho ) n = length( x ) - 2; idx = 1./diff(x); M = diag( -(idx( 1:end - 1 ) + idx( 2: end )) ) +... diag( idx( 2:end - 1 ), -1 ) +... diag( idx( 2:end - 1 ), +1 ); b = zeros ( n, 1 ); for k = 1:n b(k) = int( rho, x(k), x(k + 1), x(k + 2) ); end b(1) = b(1) - idx(1)*uab(1); b(end) = b(end) - idx(end)*uab(end); v = [uab(1); M \ b; uab(2)]; end int( rho, a, b ) approximates

19 1-D Finite-element Methods with Tent Test Functions 19 The Test Functions In Matlab, recall that we may evaluate functions at a vector of points: –Let a, b, c be the points x = linspace( a, c, n ); rhox = rho( x ).*((x = b).*(x – c)/(b – c));

20 1-D Finite-element Methods with Tent Test Functions 20 The Test Functions For example, we get the following graph with this Matlab code: >> a = 1; b = 2; c = 5; >> x = linspace( a, c, 100 ); >> tentx = (x = b).*(x - c)/(b – c); >> cosx = cos(x).*tentx; >> hold on >> plot( x, cosx, 'b' ); >> plot( x, cos(x), 'r' ); >> plot( x, tentx, 'm' );

21 1-D Finite-element Methods with Tent Test Functions 21 The Test Functions Using the exact same example from the last uniform case: >> x_uneq = [0 0.16 0.25 0.33 0.41 0.5 0.59 0.67 0.75 0.84 1]'; >> u_uniform = uniform1d( x_uneq, [0, 0], @rho ); >> u_tent = tent1d( x_uneq, [0, 0], @rho ); >> plot( x_uneq, u_uniform, 'b+' ); >> hold on >> plot( x_uneq, u_tent, 'rx' );

22 1-D Finite-element Methods with Tent Test Functions 22 The Test Functions To demonstrate that this is better than the previous approximation: >> plot( x_uneq, u_uniform - u(x_uneq), 'b+' ); >> plot( x_uneq, u_tent - u(x_uneq), 'rx' ); >> norm( u_uniform - u(x_uneq) ) ans = 0.0012 >> norm( u_tent - u(x_uneq) ) ans = 4.7368e-011 Recall that the function u(x) is the exact solution 8 × 10 –4 –1.8 × 10 –11

23 1-D Finite-element Methods with Tent Test Functions 23 Summary In this topic, we have used tent-shaped test functions as opposed to uniform test functions –The integration-by-parts was simpler We avoided the end points as they were zero No impulse functions… –More work is required for the code –Better solution for our example

24 1-D Finite-element Methods with Tent Test Functions 24 What’s Next? We will next look at how we can extend this to two dimensions –Use triangles to divide up the region instead of intervals Tessellations –Approximate the solution using interpolating polynomials Intervals Tessellation

25 1-D Finite-element Methods with Tent Test Functions 25 References [1]Glyn James, Advanced Modern Engineering Mathematics, 4 th Ed., Prentice Hall, 2011, §§9.2-3.

26 1-D Finite-element Methods with Tent Test Functions 26 Usage Notes These slides are made publicly available on the web for anyone to use If you choose to use them, or a part thereof, for a course at another institution, I ask only three things: –that you inform me that you are using the slides, –that you acknowledge my work, and –that you alert me of any mistakes which I made or changes which you make, and allow me the option of incorporating such changes (with an acknowledgment) in my set of slides Sincerely, Douglas Wilhelm Harder, MMath dwharder@alumni.uwaterloo.ca


Download ppt "MATH 212 NE 217 Douglas Wilhelm Harder Department of Electrical and Computer Engineering University of Waterloo Waterloo, Ontario, Canada Copyright © 2011."

Similar presentations


Ads by Google