Edge, corner and vertex: Discretizing boundary conditions

Tianhao Zhao

Notation

In economic applications, we often deal with the following boundary problem of a nonlinear parabolic equation:

(1)ρv(x)=k=1Dμk(x,v)vk(x)+i,jD,Dσij2(x,v)vij(x)=:Lv(x)(2)vk(x)=gk(x),k=1,,D(3)xXX:=[xk,x¯k]DR

where L is the infinitesimal generator operator; X represents the interior of the hyper-rectangular domain; X denotes the boundary of the domain; gk(x)R are evaluable functions; and Neumann boundary conditions are assumed, which align with the majority of our economic applications. In the previous blog post, we discussed the monotonicity of the numerical scheme, with a focus on the interior points of the domain. However, special attention must be paid when handling boundary points to ensure monotonicity, consistency and stability in the numerical solution.

Conventionally, we denote the discretized node space of finite points as X^NX, where N is the number of supporting nodes, and thus the boundary of such node space as X^NX. Usually, there are two strategies to handle the boundary X in the finite difference framework by discretizing the nodes in X^N:

  1. True boundary: Assuming all xX^N are exactly on the boudary such that boundary conditions vk(x)=gk(x) hold for all these x nodes.

  2. Ghost boundary: Assuming all xX^N are slightly inward away from the boundary. Assuming there exist a "thin" suface X^Ng just outside X^N where the boundary conditions hold on points in X^Ng rather than on points in X^N.

We discuss each of them while considering the quasi-implicit scheme on uniform/dense grid.

True boundary

Let x[i]X^N be a node that we are about to discretize, where i is a multi-index of D dimensions. We use xk[i] to denote the value of the k-th dimension of x[i]. Before moving to the "corner" (intersection of two boundaries) or "vertex" (intersection of three or more boundaries), let's first discuss the "edge" case. Suppose x[i] is on the boundary of only one dimension, say m. For all km, xk[i] are interior.

Edge

In the case of true boundary, if the boundary condition is Dirichlet, then we simply evaluate v(x[i]). However, for Neumann boundary conditions, we still need to discretize the boundary condition at x[i]. Recall the boundary condition along dimension m:

(4)vm(x)=gm(x)

The quasi-implicit method requires discretizing Eq (4) on the layer of t+Δt. In this case, if x[i] is the left boundary along dimension m i.e. xm[i]=xm, then we do forward difference and rearrange the terms to make all coefficients positive:

1Δm[v(x[i+emΔm])v(x[i])]=gm(x)(5)v(x[i])=v(x[i+emΔm])Δmgm(x)

where the prime mark denotes the time layer of t+Δt. This scheme is unconditional monotonic. Similarly, in the case of right boundary, there is:

(6)v(x[i])=v(x[iemΔm])+Δmgm(x)

Equation (5,6) are the equations for updating the guess of v(x[i]). One should NOT use the parabolic equation (1) which holds on interior points.

Corner and vertex

In the case of the intersection of two boundaries, say m,q=1,,D and mq, let x[i] lie on the boundary along dimensions m and q simultaneously. A node like this is often referred to as a corner node. If three or more dimensions intersect simultaneously, we call such a node a vertex node. Note that the literature often does not distinguish between the two, which is fine.

The challenge in discretization here is to ensure that v(x[i]) simultaneously satisfies both boundary conditions. If we use Dirichlet conditions for both m and q, we can always assign a consistent value to v(x[i]). However, if two Neumann conditions meet, a problem arises: we have two equations but only one unknown, v(x[i]). This indeterminacy persists even if there is no mixed partial derivative vmq(x[i]) involved.

One possible solution is to average the two Neumann conditions such that (assuming both boundaries are left boundaries):

(7)2v(x[i])=v(x[i+emΔm])+v(x[i+eqΔq])[Δmgm(x)+Δqgq(x)]

The monotonicity still holds. This can trivially extends to three-dimension vertex nodes even nodes of higher dimensionality. However, one issue here is that the case of simultaneous-holding is certainly a solution to Eq. (7), but it is obviously not the unique solution. Numerical non-monotonicity, instability and other violations may still exist. Therefore, it is critical to ensure that the implied value function v(x[i]) derived from the two Neumann boundary conditions is continuous at the corner node. In the context of a household problem, for example, consider the reflection boundary condition (Neumann) for liquid assets, which implies consuming all flow income, alongside the reflection boundary condition for illiquid housing wealth, which implies purchasing as much housing wealth as possible. These two conditions must determine an allocation at the “lowest consumption and lowest housing wealth” point: how should the flow income be allocated between consumption and housing wealth investment? Furthermore, is the manually assigned allocation consistent with the policy functions for consumption and housing wealth investment? Answering these questions requires a deep understanding of the behavior of the quantitative model before attempting computational implementation. In such cases, solving a discrete-time version of the problem on a coarse grid can provide valuable intuition. The discrete-time version and its continuous-time counterpart must exhibit consistency, while the discrete-time model typically does not require explicitly specified boundary conditions, instead relying on numerical optimization to determine solutions.

The idea of re-introducing some numerical optimization reminds us that, instead of manually specifying the allocation at such corner nodes, one can solve the optimization problem at x[i] numerically. This approach preserves the convenience of analytical policy solutions for continuous-time models, as the number of corner/vertex nodes is very small relative to the total number of nodes. An example of such an optimization step looks like:

(8)v(x[i])=maxcHamiltonian(x[i],c,v)(9)s.t.|vm(x[i])gm(x[i])|ϵm(10)|vq(x[i])gq(x[i])|ϵp(11)Other constraints such as monotonicity

where c is a vector of control variables. Here, we are searching for a control that satisfies the maximum principle while respecting the multiple boundary conditions as much as possible.

It is important to note that, in economic applications, we typically do not impose "hard" boundary conditions that require strict equalities. Instead, we often work with "soft" boundary conditions, which are expressed as inequalities. The nature of the free boundary problem we are addressing validates the optimization framework outlined above without compromising adherence to the boundary conditions.

Example: optimization at corner nodes

Let's consider a simple human capital problem which has two states: k physical capital, and h human capital.

(12)ρv(k,h)=maxc,slog(c)+vk{rk+wh(1s)c}+vh{θ(sh)αδh}(13)s.t. k0,h0(14)c0,s[0,1](15)(k,h)[k,k¯]×[h,h¯]

in which households choose consumption and the time allocation between working and education. We use soft reflection boundaries for k such that k˙(k,h)0 for k=k, k˙(k,h)0 for k=k¯, h˙(k,h)0 for h=h, and h˙(k,h)0 for h=h¯. Readers may notice that we use all "soft" boundary conditions rather than standard Neumann conditions because, by definition, this is a free-boundary problem.

Now, let's define the optimization problem. We define the generalized Hamiltonian H, which is discounted to the current moment rather than to t=0 as in the standard statement of maximum principle.

(16)H(c,s;k,h;vk(k,h),vh(k,h)):=log(c)+vk{rk+wh(1s)c}+vh{θ(sh)αδh}

Notes: The solved policy function of c and s, which are denoted as functions of partial derivetives of v, are:

(17)c=vk1(18)s=(vhvkθαw)11α1h

They will be discretized in Eq (24,25). We list them here for reference.

For the "bottom-left" corner x[i] in which k=k and h=h, we discretize the Hamiltonian using forward difference along both dimensions (recall that we are handling the case of true boundary). Assume the values of neighbor nodes are known such that they become parameters of the Hamiltonian. The function value v(x[i]) becomes a control that we want to solve:

(19)H^(c,s,u|k,h;uk,uh):=log(c)+ukuΔk{rk+wh(1s)c}+uhuΔh{θ(sh)αδh}

where u:=v(x[i]) for convenience; uk:=v[i+Δkek] and uh:=v[i+Δheh] are the two neighbor nodes used in the finite difference approximation. This discretized Hamiltonian, which serves as the objective function, is subject to:

(20)rk+wh(1s)c0(Boundary condition of k(21)θ(sh)αδh0(Boundary condition of h(22)uku(Monotonicity along k(23)uhu(Monotonicity along h(24)c=(ukuΔk)1(Policy function(25)s=(ΔkΔhuhuukuθαw)11α1h(Policy function

where the two monotonicity constraints are imposed by the non-negativity constraint of consumption and our domain knowledge, respectively. Meanwhile, we require policy functions of c and s still hold in order to smooth the policy function surface, while make the optimal u bounded.

In this way, by knowing the two neighboring nodes uk and uh, one can solve the above optimization problem efficiently using fmincon() or other nonlinear optimizer routines. This approach focuses solely on one point, v(x[i]), of the value function, allowing the problem to be modeled as a closure. Consequently, there is no need to interpolate the entire v(). Similarly, one can define such an optimization problem for all four corners in this human capital example. Furthermore, the problem can be trivially generalized to higher dimensions.

Remark: explicit? or implicit?

The optimization solution for corner/vertex nodes described above requires knowing the values of v(x[i±Δkek]) and v(x[i±Δheh]), i.e., the value function in the neighborhood of the corner nodes. This approach works perfectly with an explicit scheme as Eq (26) since these values are guesses from the previous iteration. However, with the implicit method, these neighboring node values are on the time layer t+Δt, meaning they are unknown when solving for v(x[i]). Equivalently, this results in nonlinear equation(s) that must be solved to update the corner nodes. Consequently, one needs to solve these nonlinear corner equations simultaneously with the interior equations. This process breaks the linearity of the quasi-implicit scheme that is commonly used.

(26)F(v(x[i]),v(x[i+Δkek]),v(x[i+Δheh]),)=0

However, one may have noticed that the above optimization problems are computationally very cheap to solve, making them suitable to be wrapped as a callable object. The corner/vertex equations can then be expressed as:

(27)F(v(x[i]),v(x[i+Δkek]),v(x[i+Δheh]),)=0

The monotonicity of this nonlinear scheme is always satisfied due to the monotonicity constraint embedded within the optimization routine. Meanwhile, the monotonicity of the scheme for interior nodes can be ensured by the regular quasi-implicit upwind scheme.

In general, either the implicit form as Eq (27) or the explicit form as Eq (26) works, regardless of which form is applied to interior nodes. Mixing implicit and explicit methods for different parts of the domain X is feasible and is often referred to as a locally defined difference scheme.

In practice, the explicit form is usually preferred due to its computational simplicity. However, if the implicit form is chosen, the entire numerical scheme (incorporating both interior and boundary nodes) remains implicit. To solve the entire system of updates, one may consider employing iterative algorithms such as the Newton method.

Hint: Always check CFL condition carefully when working with any explicit scheme.

Ghost boundary

The ghost boundary method is more frequently used due to its smoothness in the neighborhood of X, especially when we are not particularly interested in the boundary behavior of the PDE but merely use the boundary to pin down the solution.

Remark: In Benjamin Moll's illustrative examples, the partial derivatives from backward difference at a left boundary node are manually specified (e.g., using the reflection of zero savings). This approach effectively embeds a backward difference operation with a ghost outside node.

The idea of discretizing ghost boundaries is similar to the true boundary case. However, in this approach, we require the PDE to hold on x[i]X^N while the boundary conditions are enforced on ghost nodes, e.g., on x[iΔkek]X^Ng.

Edge

Let's illustrate this using an edge node x[i] which is the left boundary of dimension h. Let's consider Neumann boundary condition on ghost node vm(x[iΔmem])=gm(x[iΔmem]). Because it is a left boundary, we use forward difference to approximate vm(x[iΔmem]), rearrange terms and get the following formula for v(x[iΔmem]):

(28)v(x[i])v(x[iΔmem])Δm=gm(x[iΔmem])(29)v(x[iΔmem])=v(x[i])Δmgm(x[iΔmem])

Suppose the PDE for interior points bas the following simple form:

(30)ρv(x)=μm(x)vm(x)

Discretizing it and apply quasi-implcit upwind scheme:

v(x[i])v(x[i])Δt+ρv(x[i])=μm+(x)Δm[v(x[i+Δmem])v(x[i])](31)+μm(x)Δm[v(x[i])v(x[iΔmem])]v(x[i])v(x[i])Δt+ρv(x[i])=μm+(x)Δm[v(x[i+Δmem])v(x[i])](32)+μm(x)gm(x[iΔmem])

It is easy to realize Eq (32) is unconditionally monotonic.

Corner and vertex

When using ghost boundaries, a notable advantage is that we usually do not need to solve for the very corner ghost node unless we are approximating specific partial derivatives. To illustrate, consider x[i], a "bottom-left" corner node. The following table provides the spatial locations of x[i] and its neighboring ghost nodes:

yx
x[iΔxex], ghost x edgex[i], actual node
x[iΔxexΔyey], ghost cornerx[iΔyey], ghost y edge

The ghost corner, x[iΔxexΔyey], is only required when approximating the off-diagonal element of the Hessian matrix, such as vxy(x[i]), particularly using backward difference. This type of approximation typically arises, at least in the context of economic research, in portfolio selection models with systemic risks. The same concept can be trivially generalized to vertex nodes.

However, if someone really wants to solve v(x[iΔxexΔyey]), they may simply use the optimization idea introduced in the last section. Notably, this optimization does not contribute to updating the guess in this example.