A time-dependent scalar field \(c({\bf x, t})\) with \({\bf x}\in \mathbb{R}^d\), \(t \in (0, \infty)\) in \(d\)-dimensional space, can be approximated by a discretized scalar field of the form
where \(C_{i}\) is the value of the scalar field at the \(i\) th point, \(N = \prod_{i=1}^{d} n_i\), \(\,n_i\) is the number of lattice points in the \(i\) th dimension, \(d\) is the dimension of the space, and \(\psi_i\) are interpolation functions. We assume that the node points are uniformly spaced with grid-step \(h\) the same in all dimensions, and use the notation \({\bf x^{(n)}}=(x_{1}^{(n)},x_{2}^{(n)},\ldots, x_{d}^{(n)})\) to designate the \(n\) th lattice point.
We will make use of the Taylor expansion for functions with three-dimensional spatial dependence
We will also make use of the notation \({\bf h}_i \equiv ( \delta_{i1}, \delta_{i2}, \delta_{i3})h\), where \(\delta_{ij}\) is the Kronecker delta
To approximate first derivative in the \(x_1\)-direction at the lattice points, we use \({\bf h}=(\pm h,0,0)\) with the Taylor expansions (2). Then
Subtracting the two equations above gives the \(x_1\)-derivative to first order at the \(n\text{th}\) lattice point
Generalizing to other dimensions and using (5) and (3), the gradient operator to first order (in a rectilinear coordinate-system) is
where \({\bf\hat{x}_i}\) is the unit vector in the \(i\text{th}\) dimension.
We only consider boundary surfaces whose unit normal are coincident with the rectilinear axes of the space.
The central differences in (6) cannot be evaluated at the boundaries. To approximate the gradient at the boundary, we use a polynomial approximation of the function to get a first order estimate of the derivative in the direction perpendicular to the boundary surface. For example, in the vicinity of the boundary point \((x_1=0, x_2, x_3)\), we approximate the function as \(f(x_1,x_2,x_3) \approx c_0 + c_1 x_1 + c_2 x_1^2\). Then,
Solving for the coefficients \(c_0\) and \(c_1\) gives
Differentiating the polynomial and evaluating at \(x=0\) gives
which approximates the derivative in the direction perpendicular to the boundary in terms of the values at the boundary node and neighbor nodes.
Similarly, in the vicinity of the boundary point \((x_1=L, x_2, x_3)\) we approximate the function as \(f(x_1,x_2,x_3) \approx c_0 + c_1 x_1 + c_2 x_1^2\). Then,
From the first equation we obtain \(c_0 = f(L,x_2,x_3) - c_1 L - c_2 L^2\). Multiplying the second equation by 4, subtracting the third equation and using the above result, gives
Differentiating the polynomial at \(x=L\) and using the result above gives
Approximation of the derivatives at other boundaries follow in a similar manner.
To approximate second derivatives, we add the two equations in (4). This gives the second derivative in the \(x_1\)-direction (to first order)
where again we are using the notation \({\bf h}_i \equiv ( \delta_{i1}, \delta_{i2}, \delta_{i3})h\).
Generalizing to other dimensions and using (5) and (3), the Laplacian operator to first order (in a rectilinear coordinate-system) is
Consider a scalar field \(f({\bf x},t)\) describing the time-dependent concentration of molecules in volume \(V\) with surface \(S\). The time evolution of \(f({\bf x},t)\) due to diffusion is given by
subject to boundary conditions
where \(\zeta\) is the diffusion coefficient, \(\phi({\bf x})\) is the flux (amount of material per unit area per time) through a surface element at position \({\bf x}_s\) on \(S\), and \({\bf \hat{n}}\) is the unit normal to the surface, which points out of the volume.
Using (14), the Laplacian applied to lattice points on the interior is, to first order, given by
where again \({\bf h}_i \equiv ( \delta_{i1}, \delta_{i2}, \delta_{i3}) h\) and \(\delta_{ij}\) is the Kronecker delta.
When we impose flux boundary conditions, we specify the flux \({\bf \phi}({\bf x}_s)\) at the surface point \({\bf x}_s\). Then from (17), this imposes a gradient at the surface
Flux at natural boundaries
In general, the discretized points of the volume may not be coincident with the discretized points of the surface. Such cases will occur for curved surfaces or for surfaces moving with respect to the volume, such as with cells. We define natural boundaries to be those boundaries for which the lattice points of the surface are coincident with lattice points of the volume.
Consider a lattice point \({\bf x_s}^{(n)}\) on the surface of a volume. Using (17) and (6), the flux condition on the gradient at \({\bf x_s}^{(n)}\) can be written as
where again \({\bf h}_i \equiv ( \delta_{i1}, \delta_{i2}, \delta_{i3}) h\). For \({\bf x_s}^{(n)}\) on the surface, 1 to 3 of the evaluation points \({\bf x}_s^{(n)} \pm {\bf h}_i\) lie outside the volume. We impose the flux by calculating the value of the field at these {it virtual (image)} lattice points as function of the applied flux (using (19)), then substitute these resulting expressions for the virtual points in the application of the Laplacian at the surface point (14).
Let us illustrate with some simple cases.
Consider the scalar field \(f({\bf x}, t)\) defined in the volume \(V\), which is a rectangular prism with extents \(0 \le x_1 \le L_1\), \(0 \le x_2 \le L_2\), and \(0 \le x_3 \le L_3\), with flux \(\phi\) specified at the natural boundaries.
Example 1: Consider the point \(x_1=L_1\) on the boundary , with \({\bf x_{1L}} \equiv (L_1,x_2,x_3)\) and \({\bf \hat{n}} = (1, 0,0)\). Then using (19), we can compute the value of the virtual lattice point \(f(L_1+h_1,x_2,x_3)\)
Substituting this in the equation for the Laplacian (14) gives the second derivative in the \(x_1\) direction at the boundary point as a function of the applied flux
Example 2: Consider the point on the boundary \(x_1=0\), with \({\bf x_{10}} \equiv (0,x_2,x_3)\) and \({\bf \hat{n}} = (-1, 0,0)\). Using (19), we can compute the value of the virtual lattice point \(f(-h_1,x_2,x_3)\)
Substituting this in the equation for the Laplacian (14) gives the second derivative in the \(x_1\) direction at the boundary point as a function of the applied flux
Consider a spherical surface \(S\) with flux \(\phi\) at an arbitrary location \({\bf x_s}\) in the volume \(V\). (In this case, the surface is not a natural boundary.) If the radius \(\rho\) of the sphere is much less than the distance \(h\) between lattice points \(\rho \ll h\), then the flux acts like a point source and the rate of change of the concentration at \({\bf x}_s\) is give by
We use interpolation to distribute the change in concentration to the lattice points of the voxel that contains the point:math:{bf x}_s.
A Dirichlet boundary conditions specifies a fixed value \(\psi({\bf x}_s)\) for the function at the boundary point \({\bf x}_s\). Therefore, the value of the function at the boundary does not change in time and
Essentially, there are no boundaries for the toroidal case; material that diffuses through one face enters through the opposite face.
Consider the scalar field \(f({\bf x}, t)\) defined in the volume \(V\), which is a rectangular prism with extents \(0 \le x_1 \le L_1\), \(0 \le x_2 \le L_2\), and \(0 \le x_3 \le L_3\) and toroidal boundary conditions.
Example 1: Consider the point \(x_1=L_1\) on the boundary, with \({\bf x_{1L}} \equiv (L_1,x_2,x_3)\). Applying the toroidal boundary condition \(f(0,x_2,x_3) = f(L_1,x_2,x_3)\) to the second derivative in the \(x_1\)-direction (13) gives
Example 2: Consider the point \(x_1=0\) on the boundary, with \({\bf x_{10}} \equiv (0,x_2,x_3)\). Applying the toroidal boundary condition \(f(0,x_2,x_3) = f(L_1,x_2,x_3)\) to the second derivative in the \(x_1\)-direction (13) gives
We will use the following notation in this section.
Figure 1: Node designations for interpolation.
Point \(f^0\) lies in the pixel with surrounding nodes: \(f^1\), \(f^2\), \(f^3\), and \(f^4\) (Figure 1). We use a 2D Taylor expansions about point \(f^0\) to approximate the function at the surrounding nodes
Combining the first two and last two equations in (28) gives
Combining the equations in (29) gives
Finally,
where \(\Delta \equiv \frac{\delta}{h}\).
Equation (31) can be easily generalized to the 3D case.
Applying the bilinear interpolation equation (31) to the \(x\)-derivative \(f_x^0\) at point \(x^0\) gives
Using the first-order approximations for the derivatives at the node points (5)
in (32) gives
The derivatives calculated with (34) are continuous across nodes.
Base node \((i,j)\).
Equation (34) can easily be generalized to derivatives in other dimensions and to the 3D case.
Figure 2: Node designations for interpolation.
Case 1: Consider the case of gradient interpolation at point \(f^0\), which lies in the pixel with surrounding nodes 1,2, 3, an 4, with associated function values \(f^1\), \(f^2\), \(f^3\), and \(f^4\) (Figure 2 (a)), where nodes 1 and 2 lie on the boundary.
Applying the bilinear interpolation equation (31) to the \(x\)-derivative \(f_x^0\) at point \(x^0\) gives
Using the first-order approximations for the derivatives at the node points (5) and (12)
in (36) gives
Case 2: Consider the case of gradient interpolation at point \(f^0\), which lies in the pixel with surrounding nodes 1,2, 3, an 4, with associated function values \(f^1\), \(f^2\), \(f^3\), and \(f^4\) (Figure 2 (b)), where nodes 3 and 4 lie on the boundary.
Applying the bilinear interpolation equation (31) to the \(x\)-derivative \(f_x^0\) at point \(x^0\) gives
Using the first-order approximations for the derivatives at the node points (5) and (12)
in (39) gives