9.5: Solution of the Diffusion Equation
( \newcommand{\kernel}{\mathrm{null}\,}\)
Homogeneous Boundary Conditions
We consider one dimensional diffusion in a pipe of length L, and solve the diffusion equation for the concentration u(x,t), ut=Duxx,0≤x≤L,t>0.
Both initial and boundary conditions are required for a unique solution. That is, we assume the initial concentration distribution in the pipe is given by u(x,0)=f(x),0≤x≤L.
Furthermore, we assume that boundary conditions are given at the ends of the pipes. When the concentration value is specified at the boundaries, the boundary conditions are called Dirichlet boundary conditions. As the simplest example, we assume here homogeneous Dirichlet boundary conditions, that is zero concentration of dye at the ends of the pipe, which could occur if the ends of the pipe open up into large reservoirs of clear solution, u(0,t)=0,u(L,t)=0,t>0.
We will later also discuss inhomogeneous Dirichlet boundary conditions and homogeneous Neumann boundary conditions, for which the derivative of the concentration is specified to be zero at the boundaries. Note that if f(x) is identically zero, then the trivial solution u(x,t)=0 satisfies the differential equation and the initial and boundary conditions and is therefore the unique solution of the problem. In what follows, we will assume that f(x) is not identically zero so that we need to find a solution different than the trivial solution.
The solution method we use is called separation of variables. We assume that u(x,t) can be written as a product of two other functions, one dependent only on position x and the other dependent only on time t. That is, we make the ansatz u(x,t)=X(x)T(t).
Whether this ansatz will succeed depends on whether the solution indeed has this form. Substituting (???) into (???), we obtain XT′=DX″T,
X″X=1DT′T.
The left hand side of this equation is independent of t and the right hand side is independent of x. Both sides of this equation are therefore independent of both x and t and equal to a constant. Introducing −λ as the separation constant, we have X″X=1DT′T=−λ,
Because of the boundary conditions, we must first consider the equation for X(x). To solve, we need to determine the boundary conditions at x=0 and x=L. Now, from (???) and (???), u(0,t)=X(0)T(t)=0,t>0.
Since T(t) is not identically zero for all t (which would result in the trivial solution for u), we must have X(0)=0. Similarly, the boundary condition at x=L requires X(L)=0. We therefore consider the two-point boundary value problem X″+λX=0,X(0)=X(L)=0.
The equation given by (???) is called an ode eigenvalue problem. Clearly, the trivial solution X(x)=0 is a solution. Nontrivial solutions exist only for discrete values of λ. These discrete values of λ and the corresponding functions X(x) are called the eigenvalues and eigenfunctions of the differential equation.
Since the form of the general solution of the ode depends on the sign of λ, we consider in turn the cases λ>0, λ<0 and λ=0. For λ>0, we write λ=μ2 and determine the general solution of X″+μ2X=0
Applying the boundary condition at x=0, we find A=0. The boundary condition at x=L then yields BsinμL=0.
The solution B=0 results in the trivial solution for u and can be ruled out. Therefore, we must have sinμL=0,
For λ<0, we write λ=−μ2 and determine the general solution of X″−μ2X=0
The boundary condition at x=0 and x=L yields A=B=0 so again there is no nontrivial solution for u with λ=0.
We now turn to the equation for T(t). The equation corresponding to the eigenvalue λn, using (???), is given by T′+(n2π2D/L2)T=0,
Therefore, multiplying the solutions given by (???) and (???), we conclude that the functions un(x,t)=sin(nπx/L)e−n2π2Dt/L2
The principle of linear superposition for homogeneous linear differential equations then states that the general solution to (???) and (???) is given by u(x,t)=∞∑n=1bnun(x,t)=∞∑n=1bnsin(nπx/L)e−n2π2Dt/L2.
The final solution step is to satisfy the initial conditions given by (???). At t=0, we have f(x)=∞∑n=1bnsin(nπx/L).
We immediately recognize (???) as a Fourier sine series (9.4.4) for an odd function f(x) with period 2L. Equation (???) is a periodic extension of our original f(x) defined on 0≤x≤L, and is an odd function because of the boundary condition f(0)=0. From our solution for the coefficients of a Fourier sine series (9.4.3), we determine bn=2L∫L0f(x)sinnπxLdx.
Thus the solution to the diffusion equation with homogeneous Dirichlet boundary conditions defined by (???), (???) and (???) is given by (9.5.26) with the bn coefficients computed from (???).
Determine the concentration of a dye in a pipe of length L, where the dye has total initial mass M0 and is initially concentrated at the center of the pipe, and the ends of the pipe are held at zero concentration.
Solution
The governing equation for concentration is the diffusion equation. We model the initial concentration of the dye by a delta-function centered at x=L/2, that is, u(x,0)=f(x)=M0δ(x−L/2). Therefore, from (???), bn=2L∫L0M0δ(x−L2)sinnπxLdx=2M0Lsin(nπ/2)={2M0/Lif n=1,5,9,…;−2M0/Lif n=3,7,11,…;0if n=2,4,6,….
With bn determined, the solution for u(x,t) given by (9.5.26) can be written as u(x,t)=2M0L∞∑n=0(−1)nsin((2n+1)πxL)e−(2n+1)2π2Dt/L2.
When t≫L2/D, the leading-order term in the series is a good approximation and is given by u(x,t)≈2M0Lsin(πx/L)e−π2Dt/L2.
The mass of the dye in the pipe is decreasing in time, diffusing into the reservoirs located at both ends. The total mass in the pipe at time t can be found from M(t)=∫L0u(x,t)dx,
Inhomogeneous Boundary Conditions
Consider a diffusion problem where one end of the pipe has dye of concentration held constant at C1 and the other held constant at C2, which could occur if the ends of the pipe had large reservoirs of fluid with different concentrations of dye. With u(x,t) the concentration of dye, the boundary conditions are given by u(0,t)=C1,u(L,t)=C2,t>0.
The concentration u(x,t) satisfies the diffusion equation with diffusivity D:
ut=Duxx.
If we try to solve this problem directly using separation of variables, we will run into trouble. Applying the inhomogeneous boundary condition at x=0 directly to the ansatz u(x,t)=X(x)T(t) results in u(0,t)=X(0)T(t)=C1;
The proper way to solve a problem with inhomogeneous boundary conditions is to transform it into another problem with homogeneous boundary conditions. As t→∞, we assume that a stationary concentration distribution v(x) will attain, independent of t. Since v(x) must satisfy the diffusion equation, we have v″(x)=0,0≤x≤L,
Since v(x) must satisfy the same boundary conditions of u(x,t), we have v(0)=C1 and v(L)=C2, and we determine A=C1 and B=(C2−C1)/L.
We now express u(x,t) as the sum of the known asymptotic stationary concentration distribution v(x) and an unknown transient concentration distribution w(x,t):
u(x,t)=v(x)+w(x,t).
Substituting into the diffusion equation, we obtain ∂∂t(v(x)+w(x,t))=D∂2∂x2(v(x)+w(x,t))
The resulting equations may then be solved for w(x,t) using the technique for homogeneous boundary conditions, and u(x,t) subsequently determined.
Pipe with Closed Ends
There is no diffusion of dye through the ends of a sealed pipe. Accordingly, the mass flux of dye through the pipe ends, given by (9.1.1), is zero so that the boundary conditions on the dye concentration u(x,t) becomes ux(0,t)=0,ux(L,t)=0,t>0,
Again, we consider in turn the cases λ>0,λ<0 and λ=0. For λ>0, we write λ=μ2 and determine the general solution of (???) to be X(x)=Acosμx+Bsinμx,
Applying the boundary condition X′(0)=0, we find B=0. The boundary condition at x=L then yields −μAsinμL=0.
The solution A=0 results in the trivial solution for u and can be ruled out. Therefore, we must have sinμL=0,
For λ<0, we write λ=−μ2 and determine the general solution of (???) to be X(x)+Acoshμx+Bsinhμx,
Applying the boundary condition X′(0)=0 yields B=0. The boundary condition X′(L)=0 then yields μAsinhμL=0,
The boundary condition X′(0)=0 yields B=0; X′(L)=0 is then trivially satisfied. Therefore, we have an additional eigenvalue and eigenfunction given by λ0=0,X0(x)=1,
We now turn to the equation for T(t). The equation corresponding to eigenvalue λn, using (???), is given by T′+(n2π2D/L2)T=0,
The principle of linear superposition then yields the general solution as u(x,t)=∞∑n=0cnun(x,t)=a02+∞∑n=1ancos(nπx/L)e−n2π2Dt/L2,
Thus the solution to the diffusion equation with homogenous Neumann boundary conditions defined by (???), (???) and (???) is given by (9.5.66) with the coefficients computed from (???).
Determine the concentration of a dye in a pipe of length L, where the dye has total initial mass M0 and is initially concentrated at the center of the pipe, and the ends of the pipe are sealed
Solution
Again we model the initial concentration of the dye by a delta-function centered at x=L/2. From (???), an=2L∫L0M0δ(x−L2)cosnπxLdx=2M0Lcos(nπ/2)={2M0/Lif n=0,4,8,…;−2M0/Lif n=2,6,10,…;0if n=1,3,5….
The first two terms in the series for u(x,t) are given by u(x,t)=M0L[1−2cos(2πx/L)e−4π2Dt/L2+…].
Notice that as t→∞, u(x,t)→M0/L: the dye mass is conserved in the pipe (since the pipe ends are sealed) and eventually diffused uniformly throughout the pipe of length L.