1D stationary nonlinear differential equations

The section Linearization at the differential equation level presented methods for linearizing time-discrete PDEs directly prior to discretization in space. We can alternatively carry out the discretization in space of the time-discrete nonlinear PDE problem and get a system of nonlinear algebraic equations, which can be solved by Picard iteration or Newton’s method as presented in the section Systems of nonlinear algebraic equations. This latter approach will now be described in detail.

We shall work with the 1D problem

(α(u)u)+au=f(u),x(0,L),α(u(0))u(0)=C, u(L)=D.

The problem (569) arises from the stationary limit of a diffusion equation,

ut=x(α(u)ux)au+f(u),

as t and u/t0. Alternatively, the problem (569) arises at each time level from implicit time discretization of (570). For example, a Backward Euler scheme for (570) leads to

unun1Δt=ddx(α(un)dundx)aun+f(un).

Introducing u(x) for un(x), u(1) for un1, and defining f(u) in (569) to be f(u) in (571) plus un1/Δt, gives (569) with a=1/Δt.

Finite difference discretization

The nonlinearity in the differential equation (569) poses no more difficulty than a variable coefficient, as in the term (α(x)u). We can therefore use a standard finite difference approach to discretizing the Laplace term with a variable coefficient:

[DxαDxu+au=f]i.

Writing this out for a uniform mesh with points xi=iΔx, i=0,,Nx, leads to

1Δx2(αi+12(ui+1ui)αi12(uiui1))+aui=f(ui).

This equation is valid at all the mesh points i=0,1,,Nx1. At i=Nx we have the Dirichlet condition ui=0. The only difference from the case with (α(x)u) and f(x) is that now α and f are functions of u and not only of x: (α(u(x))u) and f(u(x)).

The quantity αi+12, evaluated between two mesh points, needs a comment. Since α depends on u and u is only known at the mesh points, we need to express αi+12 in terms of ui and ui+1. For this purpose we use an arithmetic mean, although a harmonic mean is also common in this context if α features large jumps. There are two choices of arithmetic means:

αi+12α(12(ui+ui+1)=[α(¯ux)]i+12,
αi+1212(α(ui)+α(ui+1))=[¯α(u)x]i+12

Equation (572) with the latter approximation then looks like

12Δx2((α(ui)+α(ui+1))(ui+1ui)(α(ui1)+α(ui))(uiui1))
+aui=f(ui),

or written more compactly,

[Dx¯αxDxu+au=f]i.

At mesh point i=0 we have the boundary condition α(u)u=C, which is discretized by

[α(u)D2xu=C]0,

meaning

α(u0)u1u12Δx=C.

The fictitious value u1 can be eliminated with the aid of (575) for i=0. Formally, (575) should be solved with respect to ui1 and that value (for i=0) should be inserted in (576), but it is algebraically much easier to do it the other way around. Alternatively, one can use a ghost cell [Δx,0] and update the u1 value in the ghost cell according to (576) after every Picard or Newton iteration. Such an approach means that we use a known u1 value in (575) from the previous iteration.

Solution of algebraic equations

The structure of the equation system

The nonlinear algebraic equations (575) are of the form A(u)u=b(u) with

Ai,i=12Δx2(α(ui1)+2α(ui)α(ui+1))+a,Ai,i1=12Δx2(α(ui1)+α(ui)),Ai,i+1=12Δx2(α(ui)+α(ui+1)),bi=f(ui).

The matrix A(u) is tridiagonal: Ai,j=0 for j>i+1 and j<i1.

The above expressions are valid for internal mesh points 1iNx1. For i=0 we need to express ui1=u1 in terms of u1 using (576):

u1=u12Δxα(u0)C.

This value must be inserted in A0,0. The expression for Ai,i+1 applies for i=0, and Ai,i1 does not enter the system when i=0.

Regarding the last equation, its form depends on whether we include the Dirichlet condition u(L)=D, meaning uNx=D, in the nonlinear algebraic equation system or not. Suppose we choose (u0,u1,,uNx1) as unknowns, later referred to as systems without Dirichlet conditions. The last equation corresponds to i=Nx1. It involves the boundary value uNx, which is substituted by D. If the unknown vector includes the boundary value, (u0,u1,,uNx), later referred to as system including Dirichlet conditions, the equation for i=Nx1 just involves the unknown uNx, and the final equation becomes uNx=D, corresponding to Ai,i=1 and bi=D for i=Nx.

Picard iteration

The obvious Picard iteration scheme is to use previously computed values of ui in A(u) and b(u), as described more in detail in the section Systems of nonlinear algebraic equations. With the notation u for the most recently computed value of u, we have the system F(u)ˆF(u)=A(u)ub(u), with F=(F0,F1,,Fm), u=(u0,u1,,um). The index m is Nx if the system includes the Dirichlet condition as a separate equation and Nx1 otherwise. The matrix A(u) is tridiagonal, so the solution procedure is to fill a tridiagonal matrix data structure and the right-hand side vector with the right numbers and call a Gaussian elimination routine for tridiagonal linear systems.

Mesh with two cells

It helps on the understanding of the details to write out all the mathematics in a specific case with a small mesh, say just two cells (Nx=2). We use ui for the i-th component in u.

The starting point is the basic expressions for the nonlinear equations at mesh point i=0 and i=1 are

A0,1u1+A0,0u0+A0,1u1=b0,
A1,0u0+A1,1u1+A1,2u2=b1.

Equation (578) written out reads

12Δx2((α(u1)+α(u0))u1+(α(u1)+2α(u0)+α(u1))u0(α(u0)+α(u1)))u1+au0=f(u0).

We must then replace u1 by (577). With Picard iteration we get

12Δx2((α(u1)+2α(u0+α(u1))u1+(α(u1)+2α(u0)+α(u1))u0+au0=f(u0)1α(u0)Δx(α(u1)+α(u0))C,

where

u1=u12Δxα(u0)C.

Equation (579) contains the unknown u2 for which we have a Dirichlet condition. In case we omit the condition as a separate equation, (579) with Picard iteration becomes

12Δx2((α(u0)+α(u1))u0+(α(u0)+2α(u1)+α(u2))u1(α(u1)+α(u2)))u2+au1=f(u1).

We must now move the u2 term to the right-hand side and replace all occurrences of u2 by D:

12Δx2((α(u0)+α(u1))u0+(α(u0)+2α(u1)+α(D))u1+au1=f(u1)+12Δx2(α(u1)+α(D))D.

The two equations can be written as a 2×2 system:

(B0,0B0,1B1,0B1,1)(u0u1)=(d0d1),

where

B0,0=12Δx2(α(u1)+2α(u0)+α(u1))+a
B0,1=12Δx2(α(u1)+2α(u0)+α(u1)),
B1,0=12Δx2(α(u0)+α(u1)),
B1,1=12Δx2(α(u0)+2α(u1)+α(D))+a,
d0=f(u0)1α(u0)Δx(α(u1)+α(u0))C,
d1=f(u1)+12Δx2(α(u1)+α(D))D.

The system with the Dirichlet condition becomes

(B0,0B0,10B1,0B1,1B1,2001)(u0u1u2)=(d0d1D),

with

B1,1=12Δx2(α(u0)+2α(u1)+α(u2))+a,
B1,2=12Δx2(α(u1)+α(u2))),
d1=f(u1).

Other entries are as in the 2×2 system.

Newton’s method

The Jacobian must be derived in order to use Newton’s method. Here it means that we need to differentiate F(u)=A(u)ub(u) with respect to the unknown parameters u0,u1,,um (m=Nx or m=Nx1, depending on whether the Dirichlet condition is included in the nonlinear system F(u)=0 or not). Nonlinear equation number i has the structure

Fi=Ai,i1(ui1,ui)ui1+Ai,i(ui1,ui,ui+1)ui+Ai,i+1(ui,ui+1)ui+1bi(ui).

Computing the Jacobian requires careful differentiation. For example,

ui(Ai,i(ui1,ui,ui+1)ui)=Ai,iuiui+Ai,iuiui=ui(12Δx2(α(ui1)+2α(ui)+α(ui+1))+a)ui+12Δx2(α(ui1)+2α(ui)+α(ui+1))+a=12Δx2(2α(ui)ui+α(ui1)+2α(ui)+α(ui+1))+a.

The complete Jacobian becomes

Ji,i=Fiui=Ai,i1uiui1+Ai,iuiui+Ai,i+Ai,i+1uiui+1biui=12Δx2(α(ui)ui1+2α(ui)ui+α(ui1)+2α(ui)+α(ui+1))+a12Δx2α(ui)ui+1b(ui),Ji,i1=Fiui1=Ai,i1ui1ui1+Ai1,i+Ai,iui1uibiui1=12Δx2(α(ui1)ui1(α(ui1)+α(ui))+α(ui1)ui),Ji,i+1=Ai,i+1ui1ui+1+Ai+1,i+Ai,iui+1uibiui+1=12Δx2(α(ui+1)ui+1(α(ui)+α(ui+1))+α(ui+1)ui).

The explicit expression for nonlinear equation number i, Fi(u0,u1,), arises from moving the f(ui) term in (575) to the left-hand side:

Fi=12Δx2((α(ui)+α(ui+1))(ui+1ui)(α(ui1)+α(ui))(uiui1))
+auif(ui)=0.

At the boundary point i=0, u1 must be replaced using the formula (577). When the Dirichlet condition at i=Nx is not a part of the equation system, the last equation Fm=0 for m=Nx1 involves the quantity uNx1 which must be replaced by D. If uNx is treated as an unknown in the system, the last equation Fm=0 has m=Nx and reads

FNx(u0,,uNx)=uNxD=0.

Similar replacement of u1 and uNx must be done in the Jacobian for the first and last row. When uNx is included as an unknown, the last row in the Jacobian must help implement the condition δuNx=0, since we assume that u contains the right Dirichlet value at the beginning of the iteration (uNx=D), and then the Newton update should be zero for i=0, i.e., δuNx=0. This also forces the right-hand side to be bi=0, i=Nx.

We have seen, and can see from the present example, that the linear system in Newton’s method contains all the terms present in the system that arises in the Picard iteration method. The extra terms in Newton’s method can be multiplied by a factor such that it is easy to program one linear system and set this factor to 0 or 1 to generate the Picard or Newton system.