Plot for Prob 1 (Matlab code in next page)
u(0.6, 0.2) = 1.6929
Matlab code for Prob 1
clear
x = [0:0.01:1];
ntotal = 55;
%
for i = 1:length(x)
if (x(i) <= 0.5)
u0(i) = 3-4*x(i);
else
u0(i) = 1;
end
usteady(i) = 3-2*x(i);
end
%
for n = 1:ntotal
if (mod(n,
A quick note on orthogonality relation
In Eq. (14) in Slides #4, we have
a n sin n x = F x
,
n=1
where F(x) = 4sin(3x) + 7sin(8x). How do we determine the coefficients, an, using the
given information? In this simple example, a quick observation suffice
u
u
=c
t
x , describes the constant movement of an initial
distribution of u with a "speed" of c along the x-axis. The distribution moves while preserving its shape.
Linear advection equation:
A typical solution: u(x, t) = F() , x+ct ; F can be any funct
u
2 u
=
Some properties of heat (or "diffusion") equation ,
t
x2
Solution is "diffusive"; The sharper the temperature gradient is, the faster it is
damped => Temperature profile becomes smoother as time increases
Example from Slides #4: Heat equation fo
Using Matlab on ASU's application server
(For those who have never used it before)
(Prepared by HPH, Aug 2009; revised Jan 2011)
1. Log on to My Apps (or https:/apps.asu.edu) using ASURITE password
2. Select "Matlab R2009b" or later versions
R2009
b
You m
An example for the method of characteristics
Example 1
For u(x,t) defined on the infinite domain, - < x < and t 0,
solve the PDE
u
u
2u
=0
t
x
with the boundary condition,
u(x,0) = P(x) ,
where
P(x) = 1
, if x < 0
2
= 1 + x , if 0 x 1
=2
, if x > 1
Solut
Another example for the method of cheracteristics
For u(x,t) defined on the infinite interval, < x < , solve the PDE
u
u
+u
=0 ,
t
x
with the boundary condition,
u(x, 0) = P(x) sin(x).
Solution:
Applying the method of characteristics, we have
dx/dt = u
(t
Summary of Chapter 5
(When do we have orthogonal eigenfunctions for our boundary value problem?)
Key: A Sturm-Lioville problem has orthogonal eigenfunctions
Sturm-Liouville (eigenvalue) problem:
[
]
d
du
P x
Q x u R x u=0 ,
dx
dx
(1)
for u(x) defined on
Example 1: Find Fourier Sine series representation of f(x), defined as
f(x) = 1 , 0 x 1/2
= 0 , 1/2 < x 1
Step 1: Obtain the odd extension of f(x), for the domain of 1 x 1, as
F(x) = 1 , 0 x 1/2
= 0 , 1/2 < x 1
= 1 , 1/2 x < 0
= 0 , 1 x < 1/2
Step 2: Repr
A quick note on orthogonality relation
In Eq. (14) in Slides #4, we have
a n sin n x = F x
,
n=1
where F(x) = 4sin(3x) + 7sin(8x). How do we determine the coefficients, an, using the
given information? In this simple example, a quick observation suffice
Example of an end-to-end solution to Laplace equation
2 u
2 u
Example 1: Solve Laplace equation,
2
2 = 0 , with the boundary conditions:
x
y
(I) u(x, 0) = 0 (II) u(x,1) = 0 (III) u(0,y) = F(y) (IV) u(1,y) = 0 .
See illustration below. This describes the
Application of Fourier Transform to PDE (II)
Fourier Transform (application to PDEs defined on an infinite domain)
The Fourier Transform pair are
F. T. :
U =1/ 2 u x expi xdx
, denoted as U = F[u]
Inverse F.T. :
u x= U expi x d
, denoted as u = F-1 [U]
50
Basic Examples for Matlab
v. 2012.3 by HP Huang (typos corrected, 10/2/2012)
Supplementary material for MAE384, 471, 502, 561, 578
1
Part 1. Write your first Matlab program
Ex. 1 Write your first Matlab program
a = 3;
b = 5;
c = a+b
Output:
8
Remarks:
Separation of variables
Idea: Transform a PDE of 2 variables into a pair of ODEs (more precisely, 2 families of
ODEs)
u
u
=0
x y
Example 1: Find the general solution of
Step 1. Assume that u(x,y) = G(x)H(y), i.e., u can be written as the product of two fu
Solve the eigenvalue problem
G'(x) = c G(x) , with b.c. : (I) G(0) = 0,
(II) G(1) = 0
Observation: In the ODE, the second derivative of G is proportional to G itself. Two
types of functions possess this property:
(i) cfw_sin(x), cos(x)
[sin(x)]' = cos(x)
General remarks
1. General strategy for solving a complicated mathematical equation:
Transform it to a set of simpler equations that we already know how to solve
PDE ODE Algebraic equation
d2u
du
3
2 u=0
Example 1: Solve the ODE,
2
dx
dx
Assume that u exp
(continued)
Matlab code for Prob 1
clear
x = [0:0.01:1];
ue = 6 - 3*x;
u0 = 3*x.*x;
p = u0-ue;
%
% prepare eigenvalues/eigenfunctions and normalize eigenfunctions
% the n-th eigenvalue, C(n), is related to evl(n) by C(n) = -evl(n)^2
%
for ieig = 1:10
x1 =
Prob 1 Part (a) & (d), plot & code
F o u rie r S in e
1
N=5
N = 10
N = 30
0 .9
0 .8
0 .7
F S (x )
0 .6
0 .5
0 .4
0 .3
0 .2
0 .1
0
0
0 .1
0 .2
0 .3
0 .4
0 .5
x
0 .6
0 .7
0 .8
0 .9
1
F o u rie r C o s in e
1
N=5
N = 10
N = 30
0 .9
0 .8
0 .7
F C (x )
0 .6
0
Plot for Prob 1 (Matlab code in next page)
u(0.6, 0.2) = 1.6929
Matlab code for Prob 1
clear
x = [0:0.01:1];
ntotal = 55;
%
for i = 1:length(x)
if (x(i) <= 0.5)
u0(i) = 3-4*x(i);
else
u0(i) = 1;
end
usteady(i) = 3-2*x(i);
end
%
for n = 1:ntotal
if (mod(n,
(continued)
Matlab code for Prob 1
clear
x = [0:0.01:1];
ue = 6 - 3*x;
u0 = 3*x.*x;
p = u0-ue;
%
% prepare eigenvalues/eigenfunctions and normalize eigenfunctions
% the n-th eigenvalue, C(n), is related to evl(n) by C(n) = -evl(n)^2
%
for ieig = 1:10
x1 =
Prob 1 Part (a) & (d), plot & code
F o u rie r S in e
1
N=5
N = 10
N = 30
0 .9
0 .8
0 .7
F S (x )
0 .6
0 .5
0 .4
0 .3
0 .2
0 .1
0
0
0 .1
0 .2
0 .3
0 .4
0 .5
x
0 .6
0 .7
0 .8
0 .9
1
F o u rie r C o s in e
1
N=5
N = 10
N = 30
0 .9
0 .8
0 .7
F C (x )
0 .6
0
Plot for Prob 1 (Matlab code in next page)
u(0.6, 0.2) = 1.6929
Matlab code for Prob 1
clear
x = [0:0.01:1];
ntotal = 55;
%
for i = 1:length(x)
if (x(i) <= 0.5)
u0(i) = 3-4*x(i);
else
u0(i) = 1;
end
usteady(i) = 3-2*x(i);
end
%
for n = 1:ntotal
if (mod(n,
(continued)
Matlab code for Prob 1
clear
x = [0:0.01:1];
ue = 6 - 3*x;
u0 = 3*x.*x;
p = u0-ue;
%
% prepare eigenvalues/eigenfunctions and normalize eigenfunctions
% the n-th eigenvalue, C(n), is related to evl(n) by C(n) = -evl(n)^2
%
for ieig = 1:10
x1 =