Sei sulla pagina 1di 13

Numerical Solving of 1-D Advection-

Diffusion Equation

Abstract

The study aims at solving one-dimensional advection-diffusion equation, by means of explicit


and implicit numerical techniques of solving difference equations. The equation describes the
evolution of a passive element in a mass of water, circulating at a constant speed, U, in the
whole domain. Results for different values of the CFL number are obtained.

The case of no-diffusion is also taken into consideration, in order to verify the derived
conclusions for the diffusive case.

The results show that the implicit method yields stable solution with time, while the explicit
method depends on the CFL condition and becomes unstable for CFL  1 .

1. NUMERICAL METHODS OF SOLVING DIFFERENTIAL EQUATIONS

Two numerical methods, implicit and explicit, are used in the present study, in order to solve
the given differential equation. The partial derivatives in the equations are substituted by
appropriate finite difference expressions. The solution is obtained by marching in time. The
difference equation in the explicit approach is reduced to equation for one unknown, which is
obtained straightforwardly from the information in the previous time step. The implicit
approach involves system of equations that have to be solved simultaneously for the
unknowns in all grid points at the current time level.

The two methods are known to have their advantages and disadvantages, given as follows.
The explicit method is easy for programming, but the pursued solution becomes unstable with
time, if certain stability criterions for the time increment t are not satisfied. It is required to
be small enough, in order to maintain stable conditions. On the other hand, it is desirable that

1
the CFL number, which involves t , is less than, but also close to unity, in order to reach
higher accuracy of the solution.

The implicit method is more complicated to set in a program, but the solution remains stable,
no matter how large the time increment is. This allows using less number of steps in time for a
given time interval which reduces the total computational time. Disadvantage of the method is
that it operates with matrices, so the time spent to solve the equations at each time level
increases. Moreover, the larger time steps produce larger truncation errors, so the method is
not as accurate in predicting the timewise variations of the flow field variables as the explicit
method.

The present study aims at solving 1-D advection-diffusion equation of the form

C C  2C
U D 2
t x x
(1)

where C is the concentration of an element P, [kg/m3];

U is the flow velocity in the x-direction, [m/s];

D is the diffusion coefficient, [m2/s];

x is the distance from the source, [m].

Eq. (1) refers to the class of parabolic partial differential equations, thus it lends itself to a
marching solution. The marching variable is the time, t .

In order to solve the equation, the following initial conditions are assumed. The concentration
of the passive element at the inflow point is 75kg/m3. The flow velocity is deduced from the
mass flow, Q, where Q=75m3/s. The diffusive coefficient, D, is set at 15m2/s, although, the
case of no diffusion is also taken as an option for the solution of Eq. (1). The total length of
the computational domain is 25000m. The area of the river is 150m 2. For the pure diffusion
case, the space increment, x , is 100m and the time increment is 100s, which corresponds to
a grid of 250 by 250 points in space and time.

2
The first boundary condition requires that the concentration at the inflow point keeps constant

with time, namely, if n denotes the current time level, this condition reads C11  ...  C1n ,
where n=1,…,250. The second boundary condition refers to the equality of the concentration

in the last two spatial points at each time level, i.e. at time level n, C mn  C mn 1 , where m
denotes the total number of grid points in space, m=250.

The results obtained from the two numerical approaches are given in Section 2. The derived
conclusions are presented in Section 3.

2. RESULTS

2.1. Explicit method

Second order central difference for the partial derivative in the diffusive term and first order
backward differences for the derivatives in the other terms are used. The reason for choosing
backward difference in space is that it is impossible to know in advance the characteristics of
the physical process. Substituting the difference expressions in Eq. (1), it is transformed into

C in 1  C in C n  C in1 C n  2C in  C in1
U i  D i 1 (2)
t x  x  2

where the subscript i is the running index in the x - direction and the superscript n is the
running index in time.

The unknown quantity at time level (n+1), C in 1 , is expressed directly from the known

quantities at level n, C in1 , C in and C in1 (Eq. 3)

 t t   t t  t
C in 1  C in1  D U   C in 1  U
   2D   C in1 D
 (3)
  x  x  x  x  2  x  2
2
 

The boundary conditions for solving Eq. (1) state that the inlet concentration is constant with

time, C11  ...  C1n , with n the marching time levels, and at the outlet the concentrations in the

last two points at a given time level n are equal, C mn  C mn 1 , given the number of spatial grid
points, m, is 250 for the present initial conditions, described in Section 1.

3
Equation (3) is solved for diffusion coefficient D  15 corresponding to different values of
the Courant-Friedrichs-Lewy (CFL) number given by

t
CFL  U (4)
x

4
a) D = 15; CFL = 0.25 b) D = 15; CFL = 0.5
80 80
70 70
60 60
50 50
C, [kg/ m ]

C, [kg/ m ]
3

3
40 40
30 30

20 20
10 10

0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
24
x10 c) D = 15; CFL = 0.75 42
x10 d) D = 15; CFL = 1
2 4
1.5 3

1 2
0.5 1
C, [kg/ m ]

C, [kg/ m ]
3

0 0
-0.5 -1

-1 -2

-1.5 -3
-2 -4
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
47
x10 e) D = 15; CFL = 1.25 47
x10 f) D = 15; CFL = 1.5
3 6

2 4

1 2
C, [kg/ m ]

C, [kg/ m ]
3

0 0

-1 -2

-2 -4

-3 -6
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]

Fig. 1. Explicit method solution for the case of D  15 and changing CFL values

5
Varying the CFL number, it is the time step, t , that is changed, since the other terms in
Eq. (4) are constant. It should be small enough, in order to guarantee stable solution with
time. The results are shown in Fig. 1.

a) D = 0; CFL = 0.25 b) D = 0; CFL = 0.5


80 80
70 70

60 60
50 50
C, [kg/ m ]

C, [kg/ m ]
3

3
40 40
30 30

20 20
10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
c) D = 0; CFL = 0.75 d) D = 0; CFL = 1
80 80
70 70

60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40
30 30
20 20

10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
18
x10 e) D = 0; CFL = 1.25 25
x10 f) D = 0; CFL = 1.5
1.5 2
1.5
1
1
0.5
0.5
C, [kg/ m ]

C, [kg/ m ]
3

0 0
-0.5
-0.5
-1
-1
-1.5
-1.5 -2
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]

Fig. 2. Explicit method solution for the case of D  0 and changing CFL values

6
The advancing in space is shown on the x-axis and the concentrations are plot on the y-axis.
The plots represent the time marching solution of Eq. (3) for chosen moments in time, namely
1000:3000:25000s. It is seen that for very small values of t , where the CFL number is
almost zero, Fig. 1a, there is negligible propagation of mass with time and space. The process
of transfer of the passive element with time is clearly seen in Fig. 1b. The solution reaches the
steady state, which is expressed by reaching the concentration at the inlet. However, it is
impossible to obtain good results for values of CFL larger than 0.5. If the diffusive term in Eq.
(1) is neglected, D=0, the solution is stable until CFL reaches 1 (Fig. 2). In case CFL  0 , no
advection, there is negligible transfer of mass with time when D  15 (Fig. 3b), or, no
transfer when D  0 (Fig. 3a).

a) D = 0; CFL = 0 b) D = 15; CFL = 0


80 80

70 70

60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40

30 30

20 20

10 10

0 0
0 100 200 300 0 100 200 300
x, [m] x, [m]

Fig. 3. Explicit method solution for the case of CFL=0

2.1. Implicit method

The finite difference representation used for the explicit method is also applied for the
implicit method, namely, second order central difference for the diffusive term and first order
backward differences for the other terms. The finite difference equation is given by Eq. (5).
However, the finite differences in the advective and diffusive term this time refer to time level
 n  1 . The unknowns are the concentrations in all grid points at time level  n  1 .

7
C in1  C in C n 1  C in11
U i 
D

C in11  2C in 1  C in11  (5)
t x  x  2

Eq. (5) can be represented in a form where all unknowns are stored on the right-hand side and
n
all known quantities at time level n, C i - on the left-hand side (Eq. (6))

 t t   t t   t 
C in  C in11   U D   C in 1 1  U
   2D   C in11   D
 

 (6)
 x  x  2   x  x  2    x  2 

Designating the quantities in the brackets by K1, K2 and K3, Eq. (6) is rewritten as

C in  C in11 K1  Cin 1 K 2  C in11 K 3 (7)

where

t t
K1  U D (8)
x  x  2

t t
K2  1U  2D (9)
x  x  2

t
K 3  D (10)
 x  2

Eq. (7) represents a system of equations that have to be solved simultaneously for all grid
points at the current time level, which is n+1. The system can be rewritten in a matrix form
given by Eq. (11) where the quantities in Eqs. (8) to (10) form the elements of the coefficient
matrix in Eq. (11).

8
a) D = 15; CFL = 0.25 b) D = 15; CFL = 0.5
80 80
70 70
60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

3
40 40
30 30
20 20

10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
c) D = 15; CFL = 0.75 d) D = 15; CFL = 1
80 80
70 70
60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40
30 30

20 20
10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
e) D = 15; CFL = 1.25 f) D = 15; CFL = 1.5
80 80
70 70

60 60
50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40
30 30
20 20

10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]

Fig. 4. Implicit method solution for the case of D  15 and changing CFL values

9
a) D = 0; CFL = 0.25 b) D = 0; CFL = 0.5
80 80
70 70
60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

3
40 40
30 30
20 20
10 10

0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
c) D = 0; CFL = 0.75 d) D = 0; CFL = 1
80 80
70 70

60 60
50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40
30 30

20 20

10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]
e) D = 0; CFL = 1.25 f) D = 0; CFL = 1.5
80 80
70 70

60 60
50 50
C, [kg/ m ]

C, [kg/ m ]
3

40 40
30 30
20 20

10 10
0 0
0 50 100 150 200 250 0 50 100 150 200 250
x, [m] x, [m]

Fig. 5. Implicit method solution for the case of D  0 and changing CFL values

10
n1 n
K 2  K 3 0 0   0 0 0 C C 1 1
n1 n
K1 K 2 K3 0   0 0 0 C2 C2
n1 n
0 K1 K 2 K3   0 0 0 C3 C3
         (11)

         
n1 n
0 0 0 0   K1 K 2 K3 C C m1 m1
0 0 0 0   0 K1 K 2 C n1 C n
m m

Subsequently, Thomas algorithm is applied, to solve the linear system of equations


represented by Eq. (7) and Eq. (11). The results are presented in Figs. 4 to 6. Fig. 4 shows the
results for the case of D  15 . It is seen that no matter what the value of CFL number is, the
solution is stable with time, although a decrease in the initial concentration is observed. It is
more pronounced with increase in the value of CFL number. Similar results are obtained
when the diffusion coefficient is set to zero (Fig. 5). In this case the decrease for each value of
CFL is smaller than in the previous case (Fig. 4). The results for no advection, U  0 (
CFL  0 ), are given in Fig. 6. It is observed that no mass is spread when there is neither
advection, nor diffusion (Fig. 6a), or, the spread is negligible when only diffusion is present
(Fig. 6b).

11
a) D = 0; CFL = 0 b) D = 15; CFL = 0
80 80

70 70

60 60

50 50
C, [kg/ m ]

C, [kg/ m ]
3

3
40 40

30 30

20 20

10 10

0 0
0 100 200 300 0 100 200 300
x, [m] x, [m]

Fig. 6. Implicit method solution for the case of CFL=0

3. CONCLUSIONS

1-D advection-diffusion equation has been solved, by means of explicit and implicit
numerical methods. The two approaches use the same finite difference representations.
Second order central difference is applied to the second order derivative in the diffusive term
of Eq. (1). First order backward differences are used for the time derivative term and for the
spatial derivative in the advective term. However, the finite differences in the advective and
diffusive terms in the implicit method refer to time level n+1, while in the explicit method
they refer to time level n. From physical point of view, the choice of backward differences is
due to the fact, that it is impossible to know in advance the characteristics of the physical
process.

The solution is found for various values of the CFL number, i.e. for various time steps, t . It
is observed that the explicit method does not work well for large values of CFL. For the case
of D  15 , the solution deteriorates for CFL  0.5 , and for D  0 it becomes unstable for
CFL  0.75 .

12
On the other hand, the implicit method shows no dependence on the choice of time step. The
steady state is reached with marching in time. A drop of the concentration is observed, which
is bigger for larger values of CFL.

The methods are applied also to the case of no advection, U  0 . If additionally no diffusion
is considered, no spread of mass is observed. Otherwise, only small transfer with time is seen,
due to the diffusion.

4. REFERENCES

Anderson, J.D. Jr., 1995. Computational fluid dynamics: the basics with applications,
McGraw-Hill, Inc.

13

Potrebbero piacerti anche