Sie sind auf Seite 1von 8

ECE 759: Mathematics 1

Workshop 1
Due on September 30, 2015

Amodei 2:30

Gonzalo

Contents
Introduction

Finite Difference Method


Spatial Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Temporal Discretization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
4
4

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Stability

Problem 1
(1.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
(2.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
(3.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

5
6
6
6

Problem 2
(1.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
(2.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
(3.) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

7
7
7
7

Page 2 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Introduction
The first workshops of the subject Mathematics 1 focuses on the numerical solution of the one dimensional
heat equation. The form of the heat equation is the following:
2u
u
(1)
= 2 + f (x, t)
t
x
Where u is the variable to solve, is the diffusion coefficient, f represents a source term, t is the time
variable and x is the spatial coordinate. For a 1D finite line of length L, the heat equation must be combined
with the following boundary and initial conditions

u(0, t) = ug (x, t)

(2)

u(L, t) = ud (x, t)

(3)

u(x, 0) = (x)

(4)
(5)

The heat equation is a well known equation in partial derivatives and is capable of modeling numerous
physical phenomena such as: heat transfer in stationary continuous mediums or specific laminar flows under
certain conditions.
The aim of this workshops is to solver this one dimensional heat equation using the finite difference method
using different schemes for the temporal discretization and using a centered approach for the diffusive terms.

Finite Difference Method


The finite difference approximations for derivatives are one of the simplest and of the oldest methods to solve
differential equations. It was already known by L. Euler (1707-1783) ca. 1768, in one dimension of space and
was probably extended to dimension two by C. Runge (1856-1927) ca. 1908. The advent of finite difference
techniques in numerical applications began in the early 1950s and their development was stimulated by the
emergence of computers that offered a convenient framework for dealing with complex problems of science
and technology. Theoretical results have been obtained during the last five decades regarding the accuracy,
stability and convergence of the finite difference method for partial differential equations.
The principle of finite difference methods is close to the numerical schemes used to solve ordinary differential equations (cf. Appendix C). It consists in approximating the differential operator by replacing the
derivatives in the equation using differential quotients. The domain is partitioned in space and in time and
approximations of the solution are computed at the space or time points. The error between the numerical
solution and the exact solution is determined by the error that is commited by going from a differential
operator to a difference operator. This error is called the discretization error or truncation error. The term
truncation error reflects the fact that a finite part of a Taylor series is used in the approximation.
Generally one can write an EDP in the following form:
u
= F (u, x, t)
t
Where F is an spatial operator. For the example, for the heat equation F is from the form:
2u
+ f (x, t)
x2
For a fixed xj the general form of the EDP can be written as follow:
F (u, x, t) =

(6)

(7)

Page 3 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

du
= F (u, xj , t)
dt

(8)

Spatial Discretization
Temporal Discretization
The temporal derivative of the variable u is usually aproximated as:
unj
u un+1
j

t
t
Introducing this approximation in the equation 8 yields:
un+1
unj
j
= F (u, xj , t)
t

(9)

(10)

And thus we can solve the equation for un+1


:
j
un+1
j

unj

tn+1

F (u, xj , t)dt

(11)

tn

The different time schemes, modify the way the integral of the operator F (defined in 6) is defined.
For the Euler explicit schemes, the integral is evaluated using data from the previous timestep F (u, xj , t) =
F (un , xj , tn )
un+1
unj = F (un , xj , tn )t + o(t)
j

(12)

This explicit schemes allow to obtain ujn+1 without having to solve a linear system of equations, although
they have same stability limits.
For the Euler implicit scheme, the integral is evaluated using the variable to be obtained F (u, xj , t) =
F (un+1 , xj , tn+1 )
un+1
unj = F (un+1 , xj , tn+1 )t + o(t)
j

(13)

The implicit schemes generally need of a bigger computational cost because they generate a linear system
of equation which must be solve in order to obtain the variable un+1
. Usually, the implicit schemes present
j
more stability than the explicit schemes

Stability
In this section a study of the stability of the homogeneous one dimensional heat equation will be presented.
A scheme is stable if roundoff errors are not amplified in the calculations. The Fourier method can be used
to check if a scheme is stable, using the following approximation:
unj = an eiwjx

(14)

The Von Neumann stability condition states that the following condition for the amplification factor
G(w) must be fulfilled in order to ensure the stability of a discretized EDP:


an+1


(15)
|G(w)| = n <= 1
a

Page 4 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Introducing the Fourier approach (Equation 14) into the discretized equation and operating the expression
yields:




t


(16)
|G(w)| = 1 + 2
(cos(wx)

1)
<= 1


x2
Which gives a relation between the three parameters of the problem (t, x and ) in order to maintain
the stability of the solution:
t
1
<=
x2
2

(17)

And thus we can reach the Courant-Friedrichs-Lewy (CFL) condition for the heat equation using Euler
explicit scheme and central differential scheme:
2t
<= 1
(18)
x2
In cause of using an Euler implicit scheme for the temporal integration, the amplification function is of
the form:








1

<= 1
|G(w)| =
(19)

t


1 +
(2 cos(wx))
x2
CF L =

t
This condition is fulfilled for every value of the parameter
and there is no CFL condition, the
x2
solution is stable for all the combinations of t, x and . Although, one must take into account that the
bigger the temporal and spatial increments are, the bigger the error in the solution.

Problem 1
Listing ?? shows a MATLAB script that was used to generate Figure ??.
Listing 1: MATLAB Function Used to Generate Figure ??

10

function homework_example
%HOMEWORK_EXAMPLE Example MATLAB function for LaTeX homework templates.
% This function produces a figure by using a number of MATLAB commands. It
% should help generate the power of the \matlabscript macro for including
% MATLAB functions and scripts within code.
%
% The figure generated by this function will be used to demonstrate how to
% use \scalefig.
% Generate 100 random data points with a normal distribution
X = randn(1, 100);
% Generate a histogram in N at 100 centers specified at Xcenters
[N, Xcenters] = hist(X, length(X)/10);

15

% Plot the sample CDF of the data


clf;
subplot(211);

Problem 1 continued on next page. . .

Page 5 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Problem 1 (continued)

cdf_datafig = s t a i r s ( sort(X), linspace(0,1,length(X)) );


20

25

30

35

40

45

50

% Plot an expected CDF on top of it


hold on;
xlims = xlim;
expX = linspace(xlims(1), xlims(2), 1000);
cdf_expfig = plot( expX, normcdf(expX), r-- );
% Label the figure
legend( [cdf_datafig, cdf_expfig], Data Distribution, ...
Expected Distribution, 4 );
xlabel(x);
ylabel(F(x) = P(X \leq x));
t i t l e (Normal Cummulative Distribution Function);
%%% Notice the use of TeX in the above ylabel. In MATLAB 7.0, LaTeX can
%%% also be used if the interpreter on the text object is changed from
%%% tex" to latex.
% Plot the sample pdf of the data
subplot(212);
pdf_datafig = bar( Xcenters, N/length(X)/(Xcenters(2)-Xcenters(1)) );
xlim( xlims );
% Plot an expected pdf on top of it
hold on;
pdf_expfig = plot( expX, normpdf(expX), r-- );
% Label the figure
legend( [pdf_datafig, pdf_expfig], Data Density, ...
Expected Density, 1 );
xlabel(x);
ylabel(dF(x)/dx);
t i t l e (Normal Probability Density Function);

(1.)
Still no Latin.

(2.)
It can be demonstrated that the heat equation ( is of the form
#
"
n=
X
n
2
u(x, t) = A0 +
An cos(n/L) + Bn sin( ) e(nL) t
L
n=1

(20)

And thus when t the solution tends tou(x, t) = A0

(3.)
As seen in the section and the equation , the explicit scheme used in this problem needs a value of
CF L <= 1 in order to ensure the stability of the solution. Using a value of CF L = 1.1 makes the
solution blow up in a few number of iterations.
Page 6 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Problem 1

Problem 2
You were expecting lorem ipsum here, werent you?

(1.)
Still no Latin.

(2.)
It can be demonstrated that the heat equation ( is of the form
#
"
n=
X
n
2
u(x, t) = A0 +
An cos(n/L) + Bn sin( ) e(nL) t
L
n=1

(21)

And thus when t the solution tends to

(3.)
In this section, we will investigate the influence of the CFL number in the time discretization error, and also the influence of the mesh spacing x in the spatial discretization error, comparing
our numerical solution u with the analytical solution uex , using an Euler explicit temporal scheme
combined with a second order central scheme for the diffusive terms. As previously stated we expect
a temporal discretization error of order O(T ) and an spatial discretization error of order O(x2 ).
We will define the error for a given mesh as a function of the CFL number for a given time with
the following expression:
q

Pi=t
(unj uex (xj , tn ))2
i=0 max
E(t, CF L) =
(22)

Where t is the time where the error is evaluated and is the number of iterations needed to reach
up to time t with a given CFL. The figure represents the error previously defined as a function of
the CFL number for a given time of t = 1, using logaritmic scale for both axes, as one might expect
that the error is proportional to the CFL (or timestep) E = k CF L. As we can observe in the
figure, the error obtained is practically proportional to the CFL, or in other words, the temporal
discretization error is of order O(t). This result coincides with the theoretical value of the temporal
discretization error.
Time Discretization Error
104

Data
Slope O (t )

Slope O (t 2 )

105

106
102

100

101

101

CF L

Problem 2 [(3.)] continued on next page. . .

Page 7 of 8

Gonzalo

ECE 759 (Amodei 2:30): Mathematics 1

Problem 2

We will define the error for a given mesh as a function of the mesh spacing x for a given value
of CF L = 0.1 with the following expression:

q
Pi=t
n u (x , tn ))2
max
(u
ex
j
j
i=0
E(t, x) =
(23)

Where t is the time where the error is evaluated and is the number of iterations needed to reach
up to time t with a given CFL. The figure represents the error previously defined as a function of
the mesh spacing x number for a given time of t = 1. In this case, the error obtained is practically
proportional to the square of the mesh spacing , or in other words, the spatial discretization error is
of order O(x2 ). This result coincides with the theoretical value of the spatial discretization error.
Mesh Discretization Error
103

104
105
Data
Slope O (x )

106

Slope O (x 2 )

107
103

102

101

Page 8 of 8

Das könnte Ihnen auch gefallen