Lecture Slides - Wayne State University

Derivative Boundary Value
Problems
Consider:
d2F
F
2  f ( x , F, F ' )  
4
dx
Derivative Boundary Value
Problems
Consider:
d2F
F
2  f ( x , F, F ' )  
4
dx
with B.C.’s: F (0)  F0  0 and F ( )  Fn  1
Derivative Boundary Value
Problems
Consider:
d2F
F
2  f ( x , F, F ' )  
4
dx
with B.C.’s: F (0)  F0  0 and F ( )  Fn  1
Note that in this case, we have derivative
boundary conditions.
Derivative Boundary Value
Problems
Let us solve this using finite differences.
Using the finite difference approximations:
Derivative Boundary Value
Problems
Let us solve this using finite differences.
Using the finite difference approximations:
Fi 1  2 Fi  Fi 1
Fi
d2F


2
2
4
dx x  x
h
i
Derivative Boundary Value
Problems
Let us solve this using finite differences.
Using the finite difference approximations:
Fi 1  2 Fi  Fi 1
Fi
d2F


2
2
4
dx x  x
h
i
Now if we attempt to set up the difference
equations we obtain:
Derivative Boundary Value
Problems
Our Finite Difference Analog is:
Derivative Boundary Value
Problems
Our Finite Difference Analog is:

h2 
Fi 1   2   Fi  Fi 1  0

4
Derivative Boundary Value
Problems
Our Finite Difference Analog is:

h2 
Fi 1   2   Fi  Fi 1  0

4
Evaluating this equation at i = 1 through 3,
we obtain:
Derivative Boundary Value
Problems
For i = 1:
1  2

F0  2   4  F1  F2  0


4
Derivative Boundary Value
Problems
For i = 1:
1  2

F0  2   4  F1  F2  0


4
For i = 2
1  2

F1  2   4  F2  F3  0


4
Derivative Boundary Value
Problems
For i = 1:
1  2

F0  2   4  F1  F2  0


4
For i = 2
1  2

F1  2   4  F2  F3  0


4
For i = 3
1  2

F2  2   4  F3  F4  0


4
Derivative Boundary Value
Problems
These equations become:
F0 -1.84579F1 + F2
= 0
F1 - 1.84579 F2 + F3
= 0
F2 - 1.84579 F3 + F4 = 0
Notice that we now have 3 equations with 5
unknowns!
But we also know:
Derivative Boundary Value
Problems
These equations become:
F0 -1.84579F1 + F2
= 0
F1 - 1.84579 F2 + F3
= 0
F2 - 1.84579 F3 + F4 = 0
Notice that we now have 3 equations with 5
unknowns!
But we also know:
Fn 1  Fn 1
Fn 
2h
Derivative Boundary Value
Problems
If we use our knowledge of the derivative at x0
and xn, i.e., F’0 = 0 and F’4 = 1:
Derivative Boundary Value
Problems
If we use our knowledge of the derivative at x0
and xn, i.e., F’0 = 0 and F’4 = 1:
F1  F1
F0  1 
2 / 4
Derivative Boundary Value
Problems
If we use our knowledge of the derivative at x0
and xn, i.e., F’0 = 0 and F’4 = 1:
F1  F1
F0  1 
2 / 4
F5  F3
F4  1 
2 / 4
Derivative Boundary Value
Problems
If we use our knowledge of the derivative at x0
and xn, i.e., F’0 = 0 and F’4 = 1:
F1  F1
F0  1 
2 / 4
F5  F3
F4  1 
2 / 4
Notice, now we have two new equations,
but we have also introduced two new
unknowns!
We need two more equations!
Derivative Boundary Value
Problems
Two that we can use are :
Derivative Boundary Value
Problems
Two that we can use are :
For i = 0
1  2

F1  2   4  F0  F1  0


4
Derivative Boundary Value
Problems
Two that we can use are :
For i = 0
1  2

F1  2   4  F0  F1  0


4
For i = 4
1  2

F3  2   4  F4  F5  0


4
Derivative Boundary Value
Problems
Two that we can use are :
For i = 0
1  2

F1  2   4  F0  F1  0


4
For i = 4
1  2

F3  2   4  F4  F5  0


4
This gives us two more equations, and we have
the same number of unknowns.
Derivative Boundary Value
Problems
So now our equations become:
F-1 + -1.84579F0 + F1
= 0
- F-1
+ F1
= 0
-1.84579F1 +
F2
= 0
F1 - 1.84579 F2 +
F3
= 0
F2 - 1.84579 F3 + F4 = 0
-F3
+ F5 = 1.5708
F3 - 1.84579 F4 + F5 = 0
Notice that we now have 7 eqns with 7 unkns!
Derivative Boundary Value
Problems
Or: [A][F] = [b]
where:
Derivative Boundary Value
Problems
A
1
0
1
0
0
0
0
1
a1
1
0
0
0
0
0
1
a1
1
0
0
0
0
0
1
a1
1
0
0
0
0
0
1
a1
1
0
0
0
0
0
1
0
1
0
0
0
0
1
a1 1
Derivative Boundary Value
Problems
where
-a1 = -1.84579
and :
Derivative Boundary Value
Problems
0
where
-a1 = -1.84579
and :
0
0
b
0
0

2
0
Derivative Boundary Value
Problems
where
-a1 = -1.84579
and :
0
1.88253
0
2.03981
0
b
0
0

1.88253
F=
1.43494
0.76606
2
0.02095
0
0.80474
Derivative Boundary Value
Problems
Comparing to exact solution of F = -2cos(x/2):
2
F
j
0
x
2. cos
j
2
2
4
2
0
2
x
j
4
Derivative Boundary Value
xj
Problems
2. cos
2
1.88253
Compared to
the exact
solution:
2.03981
1.88253
F=
1.43494
0.76606
0.02095
0.80474
1.414
2
1.848
1.414
0.765
0
0.765
Nonlinear Problems
2
Consider:
d F
dF
x
2  F dx  e  0
dx
Nonlinear Problems
2
Consider:
d F
dF
x
2  F dx  e  0
dx
with B.C.’s: F(0)  F0  1 and F(1)  Fn  1
Nonlinear Problems
2
Consider:
d F
dF
x
2  F dx  e  0
dx
with B.C.’s: F(0)  F0  1 and F(1)  Fn  1
Note that in this case, we have a nonlinear
D.E. (because of the second term)
Nonlinear Problems
Let us solve this using finite differences.
Using the finite difference approximations:
Nonlinear Problems
Let us solve this using finite differences.
Using the finite difference approximations:
d F
Fi 1  2 Fi  Fi 1

dx 2 x  x
h2
2
i
Nonlinear Problems
Let us solve this using finite differences.
Using the finite difference approximations:
d F
Fi 1  2 Fi  Fi 1

dx 2 x  x
h2
2
i
dF
Fi 1  Fi 1

dx x  xi
2h
Nonlinear Problems
Our Finite Difference Analog is:
Nonlinear Problems
Our Finite Difference Analog is:
h
2 xi
Fi 1  2 Fi  Fi 1  ( Fi Fi 1  Fi Fi 1 )  h e
2
Nonlinear Problems
Our Finite Difference Analog is:
h
2 xi
Fi 1  2 Fi  Fi 1  ( Fi Fi 1  Fi Fi 1 )  h e
2
Evaluating this equation with h = 0.2 and
thus at i = 1 through 4, we obtain:
Nonlinear Problems
For i = 1:
1  2 F1  F2  0.1( F1F2  F1F0 )  0.04e 0.2
Nonlinear Problems
For i = 1:
For i = 2
1  2 F1  F2  0.1( F1F2  F1F0 )  0.04e 0.2
F1  2 F2  F3  0.1( F2 F3  F2 F1 )  0.04e
0. 4
Nonlinear Problems
For i = 1:
For i = 2
1  2 F1  F2  0.1( F1F2  F1F0 )  0.04e 0.2
F1  2 F2  F3  0.1( F2 F3  F2 F1 )  0.04e
0. 4
For i = 3
F2  2 F3  F4  0.1( F3 F4  F3 F2 )  0.04e 0.6
Nonlinear Problems
For i = 1:
For i = 2
1  2 F1  F2  0.1( F1F2  F1F0 )  0.04e 0.2
F1  2 F2  F3  0.1( F2 F3  F2 F1 )  0.04e
0. 4
For i = 3
F2  2 F3  F4  0.1( F3 F4  F3 F2 )  0.04e 0.6
For i = 4
F3  2 F4  1  0.1(  F4  F4 F3 )  0.04e 0.8
Nonlinear Problems
Using MathCad to solve these four
simultaneous non-linear equations,
the results are :
Nonlinear Problems
Using MathCad to solve these four
simultaneous non-linear equations,
the results are :
[F] =
1.000
0.49454
-0.01211
-0.45794
-0.79503
-1.000
Nonlinear Problems
Graphically:
1
0.5
F
i
0
0.5
1
0
0.5
x
i
1
Two Dimensional Steady-State..
Consider:
T T


0
2
2
x
y
2
2
Laplace Equation
Two Dimensional Steady-State..
Analytical:
T 
4To

1
y
sin( 2n  1)

a
n 0 2n  1


b
sinh( b  1)( 2n  1)
cos ec ( 2n  1)
a
a
Two Dimensional Steady-State..
Consider: System of grid-points (i,j)
and its four immediate neighbors
i,j+1
i,j
I-1,j
Dy
i+1,j
Dx
i,j-1
Two Dimensional Steady-State..
T T

0
2
2
x
y
2
2
Difference equation:
Ti
Ti ,
 2Ti , j  Ti  1, j

2
Dx
 1  2Ti , j  Ti , j  1

0
2
Dy
 1, j
j
Two Dimensional Steady-State..
If Dx = Dy:
Ti , j 
Ti  1, j  Ti  1, j  Ti , j  1  Ti , j  1
4
Two Dimensional Steady-State..
Example:
What is the temperature at P
P= (100 + 0 + 0 + 0)/4
= 25
0
100
0
100
0
100
not very accurate…grid is too coarse!
0
0
Two Dimensional Steady-State..
Apply the equation to each interior node:
Ta = (Tb + 0 + 100 + Tc)/4
Tb = (0 + 0 + Ta + Td)/4
Tc = (Td + Ta + 0 + 100)/4
Td = (0 + Tb + Tc + 0)/4
0
100
100
100
0
a
b
c
d
0
0
100
0
Four equations --> four unknown!
0
0
0
Two Dimensional Steady-State..
Gauss-Seidel Iteration:
a. replace all “=“ by “<--”
b. make starting guesses
c. compute new approximations
for Ta, Tb, Tc, Td
d. repeat step c until converge.