Power Point - University of Nevada, Reno
Download
Report
Transcript Power Point - University of Nevada, Reno
Numerical Methods
in Diffusion
J.C. LaCombe
University of Nevada, Reno
Reno, NV, USA
[email protected]
These lecture notes complement an online learning module and diffusion simulation
software that can be found at:
http://unr.edu/homepage/lacomj/Diffusion/index.htm
MSE 430 © 2006, J.C.LaCombe
Portions of this lecture were adapted from
Elements of Heat and Mass Transfer, 3rd ed.,
F.P. Incropera, and D.P. De Witt
John Wiley & Sons, NY, 1990
1
Introduction
Numerical Methods
In many real-world problems, the details of the system may not
correspond to a known solution to the diffusion equation. In these cases,
it is usually possible to produce a solution where the equation is solved
through iterative techniques. This is generally a lot of work to do by
hand. However, with the aid of a computer, this becomes possible. The
techniques used to reach such solutions are known as numerical methods.
Situations that often require numerical methods include
• Multi-dimensional problems (not simply 1-D)
• Complex Problems
•Complex Geometry/Shape
•Complex boundary conditions
•Complex initial conditions
MSE 430 © 2006, J.C.LaCombe
2
Discretization of the
Problem
Elements and Nodes
The numerical methods we will use in this course solve complex diffusion
problems by breaking up the system into manageable parts and solving the
diffusion equations for each part simultaneously with all the other parts.
To do this, we discretize the problem mathematically by dividing up space
into little elements or nodes and treating time as moving forward in small
steps.
Element
Component divided into elements
Node
MSE 430 © 2006, J.C.LaCombe
3
Discretization of the
Problem
Discretization of the Problem
Each element is identified using subscripts, and has a finite dimensions.
x
y
y
2
Nodem,n
x
2
MSE 430 © 2006, J.C.LaCombe
4
The Finite-Difference
Approach
Fick’s Laws in 2-D
Recall: Fick’s 1st law simply tells us how solute will flow if there is a
concentration gradient.
Recall: Fick’s 2nd law is simply a combination of Conservation of Mass
with Fick’s 1st law.
C
t
Fick’s 2nd Law in 2-D
Cartesian Coordinates.
D C
1 C
D t
2
C
2
x
2
C
2
y
2
(1)
Before we solve this, we need to re-write the equation into a discretized
form. The approach presented here is known as a finite-difference
solution approach.
MSE 430 © 2006, J.C.LaCombe
5
The Diffusion Equation Discretizing the Spatial Derivatives
1 C
D t
C
2
x
2
C
2
y
2
(1)
Consider first, the spatial 2nd derivatives on the RHS of Equation (1).
The 2nd derivatives can be thought of more simply as the slope of the 1st
derivatives. This is written (approximated) in the x-direction as
Gradient at
RHS of CV
C
2
Slope of the 1st derivative
x
2
m ,n
C
x m 1 , n
2
Gradient at
LHS of CV
x
C
x m 1 , n
2
(2)
Note that the 1st derivatives here are simply the concentration gradients.
We can use the central difference approximation to determine these…
MSE 430 © 2006, J.C.LaCombe
6
The Diffusion Equation Discretizing the Spatial Derivatives
C
2
x
2
C
x m 1 , n
2
m ,n
C
x m 1 , n
2
x
(2)
m-1,n+1
m,n+1
m+1,n+1
Eq. (2) further simplifies if we can determine
the concentration gradient at the midpoint
between nodes.
The gradient can be estimated using the
concentration values at the neighboring nodes
and the distance between the nodes.
m-1,n
m,n
m+1,n
Evaluate
gradient here
Thus,
C
x
m 12 , n
C
x
x
m
(3)
C m , n C m 1 , n
x
(4)
m-1
1
2
m
x
MSE 430 © 2006, J.C.LaCombe
m
1
2
C(x)
m 12 , n
C m 1, n C m , n
m+1
x
7
The Diffusion Equation Discretizing the Spatial Derivatives
Equations (3) and (4) can now be substituted into (2) to produce the
discretized form of the 2nd spatial derivative in the x direction.
C
2
x
2
m ,n
C m 1 , n C m 1 , n 2 C m , n
x
(5a)
2
The 1st and 2nd derivatives in the y (and z) directions can also be evaluated
in a similar manner…
C
2
y
2
m ,n
C m , n 1 C m , n 1 2 C m , n
y
(5b)
2
These make up the RHS
of Fick’s 2nd Law (Eq. 1)
MSE 430 © 2006, J.C.LaCombe
8
The Diffusion Equation Discretizing the Time Derivative
Now that we have discretized Fick’s 2nd law in space (1), we must
discretize it in time as well. To do this, we will introduce a new variable,
p, that is an integer that represents the time step. The duration of each step
is t. Thus, the total time, t, is written…
t pt
(6)
The finite-difference approximation to the time derivative (the LHS of
Fick’s 2nd law) is then expressed as…
This is the LHS of Fick’s
2nd Law (Eq. 1)
C
t
p 1
C m ,n C m ,n
p
t
(7)
The superscript, p, denotes the time dependence. The time derivative is
expressed in terms as the difference in concentrations between the new
time (step p+1) and the previous time (step p).
MSE 430 © 2006, J.C.LaCombe
9
Fick’s 2nd Law in
Discretized Form
The 2-D Diffusion Equation
We present here a solution approach known as the explicit method. In this
finite-difference scheme, the concentration at any node m,n at time t+t is
calculated from knowledge of the concentration at the same and
neighboring nodes for the preceding time t.
We now can combine (5a,b) and (7) to produce the discretized form of the
diffusion equation, (1).
Fick’s 2nd Law in discretized form...
p 1
1 C m ,n C m ,n
D
p
t
C m 1 , n C m 1 , n 2 C m , n
p
p
x 2
p
C m , n 1 C m , n 1 2 C m , n
p
p
y 2
p
(8)
Note:
Other approaches, such as the implicit method, are more efficient with
a computer, but require more complex algorithms. Nonetheless, the
fundamental principles are the same as we are applying here. We will
not be covering these other methods in this course.
MSE 430 © 2006, J.C.LaCombe
10
The Fourier Number
The Diffusion Equation
Equation (8) is the general form of our solution. We can simplify the
notation a bit if we use square elements, so that x = y. Additionally, we
can form the following group of parameters, which is commonly known
as the dimensionless Fourier Number, Fo.
Fo
Dt
x 2
(9)
Now, we can re-arrange (8) to solve for the concentration in node m,n at
the new time step, p+1. This equation applies to any element/node on the
interior of a component. The expression simplifies to…
2-D Interior
Node
C m , n Fo C m 1 , n C m 1 , n C m , n 1 C m , n 1 1 4 Fo C m , n
p 1
p
p
p
p
p
(10)
The NEW composition in an element is calculated using the PREVIOUS
compositions in the element and its neighbors.
MSE 430 © 2006, J.C.LaCombe
11
Explicit Method &
Solution Stability
The 1-D Diffusion Equation
For the case of 1-D transport, Equation (8) would instead develop into the
form of
1-D Interior
Node
p 1
Cm
Fo C m 1 C m 1 1 2 Fo C m
p
p
p
(11)
The accuracy of finite-difference solutions may be improved by
decreasing the values of x and t (I.e., finer discretization). On the other
hand, making these values larger will allow the calculation to proceed
more quickly.
One additional limitation of the explicit method is that it is not always a
stable solution. If the values of x and t are not small enough, it can
cause the solution to oscillate (even when this is physically impossible).
MSE 430 © 2006, J.C.LaCombe
12
Stability Criteria
Critical Values of Fo
To prevent such erroneous results when the solution is “unstable”, the
values of x and t must meet certain criteria (details omitted). For
interior nodes, these are,
Fo
Fo
1
2
1
4
1-D Stability
Criteria
2-D Stability
Criteria
Recalling,
Fo
Dt
x 2
So, once you pick a value of either x or t , the other value must be
chosen so that the stability criteria is met. Simply re-arrange the equation
for Fo to calculate the acceptable value.
MSE 430 © 2006, J.C.LaCombe
13
Other Element Configurations
The equations presented so far (10, 11) are for
interior nodes. I.e., each element’s surroundings are
geometrically the same in all directions.
We can develop similar equations for different element
types, but we need to be clever, or it gets messy.
A surface node (with no flux flowing through the
surface), can be modeled using the same equation as an
interior node. All we need to do is include an imaginary
node just outside the surface and set its composition to the
same as the node just inside the surface. This has the effect
of producing a zero net gradient through the surface.
m-1,n+1 m,n+1
m-1,n
m,n
External Surface
(zero-flux plane)
Zero-Flux Elements
and Surfaces
m-1,n-1 m,n-1
m
m-1
1
2
m
m+1
Imaginary
node
I.e., if the surface node is C mp then the no-flux condition is modeled by
adding an imaginary node at m+1 and setting Cmp1 Cmp1 to achieve a state
of no-flux at node m (no gradient means no net flux).
MSE 430 © 2006, J.C.LaCombe
14
Zero-Flux Elements
and Surfaces
Other Element Configurations
So, we can model a surface node by modifying the equation for an interior
node. Recalling Equation (10) for 2-D,
2-D Interior
Node
C m , n Fo C m 1 , n C m 1 , n C m , n 1 C m , n 1 1 4 Fo C m , n
p 1
p
p
p
p
p
(10)
We then incorporate the imaginary node…
C m 1 C m 1
p
p
And are left with the equation for a surface node…
2-D Surface
Node
C m , n Fo 2 C m 1 , n C m , n 1 C m , n 1 1 4 Fo C m , n
p 1
p
p
p
p
(12)
In 1-D, this would work out to…
1-D Surface
Node
MSE 430 © 2006, J.C.LaCombe
p 1
Cm
Fo 2 C m 1 1 2 Fo C m
p
p
(13)
15
Other Solution
Approaches
Developing Expressions for Other
Element Types
The method used on the previous slides to discretize the problem is not the
only way to produce equations such as Equations (10)-(13).
Another method can be used to provide even greater flexibility with
boundary conditions. It is simply based on conservation of mass (Recall
that Fick’s 2nd law is also essentially this as well).
Let us consider the element surrounding each node to be subject to
conservation of mass. This would be written as…
Solid State
Diffusive Flux
+
Solute
“Generated”
=
Stored
Mass
In practice, this can be
something like solute
entering an element at
external surface
MSE 430 © 2006, J.C.LaCombe
16
Other Solution
Approaches
Other Ways to Discretize
the Problem
Writing this for a generic interior node, we account for all possible
influences. As before, minor changes can be made for an external node.
Note that here, flux into the node is considered “positive”.
J n 1
J m 1 A J m 1 A J n 1 A J n 1 A M
gen
C stored A x
M
gen
J m 1
(14)
J m 1
Where,
p 1
C stored
C stored
C m ,n C m ,n
J n 1
p
t
C m , n C m 1, n
p
J m 1 D
MSE 430 © 2006, J.C.LaCombe
gen
Mass "Created"
per unit time
x
C m , n C m 1, n
J n 1 D
p
x
C m , n C n 1 , n
p
p
p
J m 1 D
M
p
y
C m , n C n 1, n
p
J n 1 D
p
y
17
Diffusion with “Mass
Generation”
Other Ways to Discretize
the Problem
When massaged, Equation (14) evolves into the same form as the earlier
equations (10)-(13), except now, we have added in the solute generation
term.
p 1
p
p
p
p
C m , n Fo C m 1 , n C m 1 , n C m , n 1 C m , n 1 M
gen
1 4 Fo C
p
m ,n
(15)
And in 1-D, this is
p 1
Cm
p
p
Fo C m 1 , n C m 1 , n M
gen
1 2 Fo C
p
m ,n
(16)
Thus, there are a variety of approaches to produce the discretized diffusion
equations for a variety of different element types.
MSE 430 © 2006, J.C.LaCombe
18
Example
1-D Thick Diffusion Couple
An earlier topic presented the analytical solution to the case of a binary
diffusion couple. Let’s analyze this using a finite-difference model.
Assume D = 110-9 cm2/s, and the initial compositions are Cl = 0.75, and
CR = 0.25.
1
C l 0 . 75
2
3
4
5
6
C R 0 . 25
x
110-3 cm
First, the stability criteria for this 1-D arrangement is that Fo ½.
Fo
Dt
x
2
1
2
t
1 1 10
2 1 10
3
cm
9 cm
s
2
2
t 500 s
MSE 430 © 2006, J.C.LaCombe
Thus the maximum time step for a stable
solution of this problem is 500 seconds.
19
Example
1-D Thick Diffusion Couple
(1-D Interior Node)
p 1
p
p
p
Equation (11) is the suitable solution form: C m , n Fo C m 1 C m 1 1 2 Fo C m
To handle the “infinite” ends, we treat them as having no-flux conditions
(I.e., the concentration gradient is zero at the ends) using Equation (13).
This will be ok, provided that the concentration field never reaches the end
during our simulation. The equations are written for each of the 6
elements…
p 1
C1
p 1
C2
p 1
C3
p 1
C4
p 1
C5
p 1
C6
Fo C C 1 2 Fo C
Fo C C 1 2 Fo C
Fo C C 1 2 Fo C
Fo C C 1 2 Fo C
Fo 2 C 1 2 Fo C
Fo 2 C 2 1 2 Fo C 1
MSE 430 © 2006, J.C.LaCombe
p
p
p
3
p
1
p
2
p
4
p
2
p
3
p
5
p
3
p
4
p
6
p
4
p
5
p
5
p
6
These 6 equations must be
solved at each time step, p.
There will be one equation
for each node. Models with
lots of elements involve
solving lots of equations.
20
Example
1-D Thick Diffusion Couple
This is expressed more concisely in matrix form.
1 2 Fo
Fo
0
0
0
0
2 Fo
0
0
0
1 2 Fo
Fo
0
0
Fo
1 2 Fo
Fo
0
0
Fo
1 2 Fo
Fo
0
0
Fo
1 2 Fo
0
0
0
2 Fo
p
p 1
C1 C1
p p 1
0
C
C
2 2
C 3p C 3p 1
0
p p 1
0
C 4 C 4
Fo C 5p C 5p 1
1 2 Fo C 6p C 6p 1
0
The new concentrations at each node are calculated by solving this matrix at each
time step. At each step, you use the resulting concentrations from the previous
step, Cp+1, as the new values of Cp. Likewise, to get it all started, you just use the
initial concentrations at each node.
You can use whatever methods or software you want to solve the matrix.
Even a spreadsheet will work…
MSE 430 © 2006, J.C.LaCombe
21
Example
1-D Thick Diffusion Couple
MS Excel Worksheet…
Fo= 0.05
p=1
Node
1
0.9
2
0.05
3
4
5
6
0.1
0.9
0.05
dt
50
Old C New C
0.75
0.750
0.05
0.75
0.750
0.9 0.05
0.75
0.725
0.05 0.9 0.05
0.25
0.275
0.05 0.9 0.05 0.25
0.250
0.1 0.9
0.25
0.250
0.8
p=1
p=2
0.7
p=3
p=4
p=3
p=4
1
2
3
4
5
6
0.9
0.05
1
2
3
4
5
6
0.9
0.05
1
2
3
4
5
6
0.9
0.05
0.1
0.9
0.05
0.1
0.9
0.05
0.1
0.9
0.05
0.75
0.75
0.725
0.275
0.25
0.25
0.750
0.749
0.704
0.296
0.251
0.250
0.75
0.05
0.7488
0.9 0.05
0.7038
0.05 0.9 0.05
0.2963
0.05 0.9 0.05 0.2513
0.1 0.9
0.25
0.750
0.747
0.686
0.314
0.253
0.250
0.7499
0.05
0.7466
0.9 0.05
0.6856
0.05 0.9 0.05
0.3144
0.05 0.9 0.05 0.2534
0.1 0.9 0.2501
0.750
0.744
0.670
0.330
0.256
0.250
0.05
0.9 0.05
0.05 0.9 0.05
0.05 0.9 0.05
0.1 0.9
Double-click above (ppt only) to
open the actual spreadsheet!
MSE 430 © 2006, J.C.LaCombe
C
0.6
p=2
Initial
Exact 200s
0.5
0.4
Fo = 0.05
0.3
0.2
1
2
3
4
5
6
Node
Recalling
the Analytical
Solution,
x
C CR
C ( x, t ) l
CR
erfc
2
2 Dt
22
2-D Equation
Summary
m,n+1
2-D Explicit Finite Difference
Equations (x=y)
m,n+1
Interior Node
m,n
m,n
m-1,n
Stability
m+1,n
Fo
Criterion
p
p
p
p
p 1
m,n+1
Stability
m-1,n
m+1,n
Exterior Corner
Fo
Stability
Criterion
m-1,n
1
4
p
m 1, n
2C
1 4 Fo C
MSE 430 © 2006, J.C.LaCombe
m+1,n
Fo
Criterion
1
4
m,n-1
m,n-1
Fo C
p
m,n
m,n
p
p
Interior Corner
m,n+1
p
1 4 Fo C m , n
p
C
1
4
C m , n Fo 2 C m 1, n C m , n 1 C m , n 1
1 4 Fo C m , n
2
3
Fo
m+1,n
Criterion
m,n-1
C m , n Fo C m 1, n C m 1, n C m , n 1 C m , n 1
p 1
m ,n
Stability
m-1,n
1
4
m,n-1
p 1
Plane Surface
p
m ,n
p
m 1 , n
2C
p
m , n 1
C
p
m , n 1
p 1
C m , n 2 Fo C m 1, n C m , n 1
p
p
1 4 Fo C m , n
p
23