Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

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,0xL,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),0xL.

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=DXT,

which we rewrite by separating the x and t dependence to opposite sides of the equation:

XX=1DTT.

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 XX=1DTT=λ,

and we obtain the two ordinary differential equations X+λX=0,T+λDT=0.

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

to be X(x)=Acosμx+Bsinμx.

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,

which is an equation for μ. The solutions are μ=nπ/L,
where n is an integer. We have thus determined the eigenvalues λ=μ2>0 to be λn=(nπ/L)2,n=1,2,3,,
with corresponding eigenfunctions Xn=sin(nπx/L).

For λ<0, we write λ=μ2 and determine the general solution of Xμ2X=0

to be X(x)=Acoshμx+Bsinhμx,
where we have previously introduced the hyperbolic sine and cosine functions in §4.4. Applying the boundary condition at x=0, we find A=0. The boundary condition at x=L then yields BsinhμL=0,
which for μ0 has only the solution B=0. Therefore, there is no nontrivial solution for u with λ<0. Finally, for λ=0, we have X=0,
with general solution X(x)=A+Bx.

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,

which has solution proportional to Tn=en2π2Dt/L2.

Therefore, multiplying the solutions given by (???) and (???), we conclude that the functions un(x,t)=sin(nπx/L)en2π2Dt/L2

satisfy the pde given by (???) and the boundary conditions given by (???) for every positive integer n.

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)en2π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 0xL, 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=2LL0f(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 (???).

Example 9.5.1

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δ(xL/2). Therefore, from (???), bn=2LL0M0δ(xL2)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)=2M0Ln=0(1)nsin((2n+1)πxL)e(2n+1)2π2Dt/L2.

When tL2/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,

and since L0sin(πx/L)dx=2Lπ,
we have for large times M(t)=4M0πeπ2Dt/L2.

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;

so that X(0)=C1/T(t).
However, our separation of variables ansatz assumes X(x) to be independent of t! We therefore say that inhomogeneous boundary conditions are not separable.

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,0xL,

with general solution v(x)=A+Bx.

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=(C2C1)/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))=D2x2(v(x)+w(x,t))

or
wt=Dwxx,
since vt=0 and vxx=0. The boundary conditions satisfied by w are w(0,t)=u(0,t)v(0)=0,w(L,t)=u(L,t)v(L)=0,
so that w is observed to satisfy homogeneous boundary conditions. If the initial conditions are given by u(x,0)=f(x), then the initial conditions for w are w(x,0)=u(x,0)v(x)=f(x)v(x).

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,

which are known as homogeneous Neumann boundary conditions. Again, we apply the method of separation of variables and as before, we obtain the two ordinary differential equations given by (???). Considering first the equation for X(x), the appropriate boundary conditions are now on the first derivative of X(x), and we must solve X+λX=0,X(0)=X(L)=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,

so that taking the derivative X(x)=μAsinμx+μBcosμ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,

with solutions μ=nπ/L,
where n is an integer. We have thus determined the eigenvalues λ=μ2>0 to be λn=(nπ/L)2,n=1,2,4,,
with corresponding eigenfunctions Xn=cos(nπx/L).

For λ<0, we write λ=μ2 and determine the general solution of (???) to be X(x)+Acoshμx+Bsinhμx,

so that taking the derivative X(x)=μAsinhμx+μBcoshμx.

Applying the boundary condition X(0)=0 yields B=0. The boundary condition X(L)=0 then yields μAsinhμL=0,

which for μ0 has only the solution A=0. Therefore, there is no nontrivial solution for u with λ<0. Finally, for λ=0, the general solution of (???) is X(x)=A+Bx,
so that taking the derivative X(x)=B.

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,

which can be seen as extending the formula obtained for eigenvalues and eigenvectors for positive λ given by (???) and (???) to n=0.

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,

which has solution proportional to Tn=en2π2Dt/L2,
valid for n=0,1,2,. Therefore, multiplying the solutions given by (???) and (???), we conclude that the functions un(x,t)=cos(nπx/L)en2π2Dt/L2
satisfy the pde given by (???) and the boundary conditions given by (???) for every nonnegative integer n.

The principle of linear superposition then yields the general solution as u(x,t)=n=0cnun(x,t)=a02+n=1ancos(nπx/L)en2π2Dt/L2,

where we have redefined the constants so that c0=a0/2 and cn=an, n=1,2,3,. The final solution step is to satisfy the initial conditions given by (???). At t=0, we have f(x)=a02+n=1ancos(nπx/L),
which we recognize as a Fourier cosine series (9.4.2) for an even function f(x) with period 2L. We have obtained a cosine series for the periodic extension of f(x) because of the boundary condition f(0)=0, which is satisfied by an even function with continuous first derivative. From our solution (9.4.1) for the coefficients of a Fourier cosine series, we determine an=2LL0f(x)cosnπxLdx.

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 (???).

Example 9.5.2

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=2LL0M0δ(xL2)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[12cos(2πx/L)e4π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.


This page titled 9.5: Solution of the Diffusion Equation is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Jeffrey R. Chasnov via source content that was edited to the style and standards of the LibreTexts platform.

Support Center

How can we help?