Finite Difference Diagonalization to Simulate ... - Wiley Online Library

1 downloads 0 Views 692KB Size Report
problem when directly solving the problem in the time domain. Furthermore, many NMR experiments have sudden drastic changes in the magnetic field strength.
Finite Difference Diagonalization to Simulate Nuclear Magnetic Resonance Diffusion Experiments in Porous Media DENYS GROMBACHER, MATIAS NORDIN Department of Geophysics, Stanford University, 397 Panama Mall, Mitchell Building 101, Stanford, CA 94305

ABSTRACT: A finite difference approach for computing Laplacian eigenvalues and eigenvectors in discrete porous media is derived and used to approximately solve the Bloch–Torrey equations. Neumann, Dirichlet, and Robin boundary conditions are considered and applications to simulate nuclear magnetic resonance diffusion experiments are shown. The method is illustrated with MATLAB examples and computational tests in one C 2015 Wiley V and two dimensions and the extension to three dimensions is outlined. Periodicals, Inc.

KEY WORDS:

Concepts Magn Reson Part A 44A: 160–180, 2015.

diffusion; finite difference; porous media; Laplace operator

INTRODUCTION

pore-filling fluids (1–6). This approach has also become a routine diagnostic tool in medicine to differentiate between tissue types; e.g., between cancerous and healthy tissue or gray and white matter in the brain (7,8). The method is indirect, in the sense that it is measuring the content, diffusion, flow, and/or relaxation of a pore-filling fluid rather than the porous media itself and has the advantage of being completely noninvasive. The underlying physics describing a fluid NMR experiment is governed by the Bloch–Torrey equations (9), which describe a spin undergoing diffusion and flow in a magnetic field. Despite their simple form, these equations quickly become difficult to solve for

Nuclear magnetic resonance is commonly used to analyze the pore space geometry of porous media such as rock, sand, and sediments by measuring properties of Received 2 July 2015; revised 21 September 2015; accepted 1 October 2015 Correspondence to: Denys Grombacher; E-mail: denysg@stanford. edu Concepts in Magnetic Resonance Part A, Vol. 44A(3) 160–180 (2015) Published online in Wiley Online Library (wileyonlinelibrary. com). DOI: 10.1002/cmr.a.21349 Ó 2015 Wiley Periodicals, Inc.

160

FINITE DIFFERENCE DIAGONALIZATION

Figure 1 Schematic overview of common NMR problems. (a) A spin is diffusing in a pore X subject to boundary conditions at C. The pulsed gradient spin-echo experiment with mixing time (b) and without mixing time (c) and a general magnetic field rise and decay in the time domain (d).

conditions representative of real porous media. Factors that make these equations difficult to solve include inhomogeneities in the magnetic field, complicated experimental sequences, and flow of the pore-filling fluid. The main complication, however, arises from the fact that naturally occurring porous media often cannot be adequately described by simple geometries as it is a heterogeneous multiscale entity. Such geometries are impossible to solve analytically, while the experimental outcome is often interpreted using idealized models such as slabs, spheres, or cylinders where analytic solutions are known (10–12). To understand the validity of this commonly used geometrical approximation it is important to understand the signal behavior in nonideal geometries. Numerical methods therefore enter naturally in the analysis of the Bloch–Torrey equations in porous media. The majority of time-dependent problems are most conveniently solved numerically by direct methods using an appropriate time-stepping scheme. NMR in porous media is not an exception: A diffusing spin is confined geometrically to a (complicated) pore space void and subject to a magnetic field varying in both time and space (see Fig. 1). Such a complicated problem may be solved using Random Walk Monte Carlo approaches, which have been the most widely used method of choice [see e.g., (13–18)]. Alternative direct methods include finite difference schemes (19–21) and Markov Chain Monte Carlo approaches (22). These methods are reliable, easy to implement, and may be used to produce an NMR signal for a given geometry with experimental parameters. However, it can be difficult to gain insight into the geometrical impacts on the problem when directly solving the problem in the time domain. Furthermore, many NMR experiments have sudden drastic changes in the magnetic field strength

161

over timescales that can be several magnitudes smaller than the total experimental time. This makes random walks a very time consuming approach, as many realizations must be used in order to accurately resolve the behavior at such sudden changes (the whole trajectory must be simulated for each particle). This common time-scale separation suggests that more efficient approaches could be used, where the time-scale separations of the problems are appropriately addressed. One avenue to overcome these problems is to separate the time and spatial dependence of the Bloch–Torrey equation and solve the resulting spatial equation on its own. This is done by assuming that the magnetic field can be considered to be constant during some (short) time [see e.g. (23,24)]. The spatial problem then reduces to eigenvalue-like problems centered around the Laplace operator acting in the pore space void. The complicated experimental NMR sequence results in a set of coupled equations, each describing the evolution of the system during a time when the magnetic field is unchanging. The task is still delicate as the resulting operators are not Hermitian (12), but several successful methods have sprung from this approach (12, (23–28)). However, for these methods the Laplace eigenvalues and eigenfunctions for the particular porous geometry must be known. Alternative methods well worth mentioning in this context are the Lattice path count method (22), the mixed basis (29,30), and finite element methods (31). In this article we aim to discuss a finite-difference method for simulating NMR diffusion experiments by numerical diagonalization of the Laplace operator. This method has the flexibility of treating arbitrary discrete geometries for flexible NMR experiments (e.g., the time-varying gradient experiments illustrated Fig. 1). We aim to give the reader the necessary tools to set up and analyze NMR signals in arbitrary discrete geometries, and arbitrary NMR sequences. We also provide MATLAB code and examples for one- (1D) and twodimensional (2D) problems. The direct extension to three-dimensional problems is outlined.

OUTLINE The outline of the article is as follows. In The Continuum Formulation section, we introduce the Bloch–Torrey equations and illustrate the connection to the Laplace eigenvalue problem. In A Discrete Formulation section, we transform the continuous Laplace eigenvalue problem to a discrete finite difference equivalent. We also discuss the implementation of different boundary conditions. In Simulating NMR Restricted Diffusion Experiments section we illustrate

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

162

GROMBACHER AND NORDIN

how the finite difference method may be applied to the problem of simulating NMR experiments. Throughout the article, we provide MATLAB code that may be used to implement the techniques presented in the article to improve the accessibility of the described methods. The provided code is written with clarity rather than efficiency in mind. We encourage the reader to copy/paste the codes given throughout the article to build their own finite difference code to simulate NMR experiments. The algorithms and examples presented are available at http://sourceforge.net/projects/fdnmr/where a program based on the presented material called FDNMR is also available.

THE CONTINUUM FORMULATION To better understand the discrete finite difference approach we will begin by introducing the continuum problem.

Bloch–Torrey: Diffusion/Relaxation The Bloch–Torrey equations (9) [see e.g., (32) for a complete derivation] describing the magnetization mðr; tÞ at point r at time t in a pore space X with isotropic diffusion in the presence of a constant magnetic field and an additional spatially and temporally varying magnetic field Bðr; tÞ are given by 8 < o mðr; tÞ5ðDD1igBðr; tÞÞmðr; tÞ r 2 X ot [1] : ðD^ n ðrÞ  r1qðrÞÞmðr; tÞ50 r2C where D denotes the self-diffusion coefficient of the pore-filling fluid. The pore space is confined by a boundary described by C, where the boundary conditions are defined. The term qðrÞ denotes the surface relaxivity, a parameter controlling the ability of the boundary to promote relaxation (33). When qðrÞ50 the problem reduces to a Neumann boundary condition (no flux boundary) and as qðrÞ ! 1 the problem tends toward a Dirichlet boundary condition (perfectly absorbing boundary). The intermediate case (0 < qðrÞ  1Þ is called a Robin boundary condition. Analytic solutions of this equation are available for simple geometries, e.g., slabs, cylinders, and spheres subject to particular experimental conditions (12).

Laplace Eigenvalue Equation A general solution to Eq. [1] is sought by considering the problem in the absence of Bðr; tÞ; i.e. the situation when only the constant magnetic field is present. Equation [1] then reduces to the diffusion equation

8 < o mðr; tÞ5DDmðr; tÞ r2X ot : ðD^ n ðrÞ  r1qðrÞÞmðr; tÞ50 r 2 C

[2]

By assuming that the problem is separable in time and space i.e. mðr; tÞ5uðrÞf ðtÞ the formal solution is obtained (34) mðr; tÞ5

1 X

An un ðrÞe2tkn :

[3]

n50

The separation of the time and spatial dependence is possible because the left and right hand sides of Eq. [2] depend only on the temporal and spatial derivatives, respectively. The beauty of this expression (Eq. [3]) lies in the fact that the spatial functions un ðrÞ are constant in time. Hence the time-evolution of the magnetization mðr; tÞ is controlled by the weights contained in the exponents. The An’s are scalars and obtained by the initial condition mðr; t50Þ and describe the initial amount of magnetization for each spatial function un ðrÞ ð [4] An 5 un ðrÞmðr; t50Þdr: X

The functions un ðrÞ and the scalars kn are the eigenfunctions and eigenvalues of the Laplace operator, meaning that they satisfy the eigenvalue equation (

Dun ðrÞ5kn un ðrÞ

r2X

ðD^ n ðrÞ  r1qðrÞÞun ðrÞ50 r 2 C:

[5]

This equation is a direct consequence of applying the separation criteria mðr; tÞ5uðrÞf ðtÞ to Eq. [2]. The theory for the Laplace eigenvalue problem is rich [see e.g., (11,35) for relations to NMR theory]. For our purposes it will be sufficient to mention the following properties: The functions un ðrÞ form an orthonormal basis in pore void space X, meaning that ð un ðrÞum ðrÞdr5dnm [6] X

where dnm denote the Kronecker delta function. Furthermore, they form a complete set in the domain X; i.e. a linear combination of fun ðrÞg1 n can be used to describe any square integrable function. Therefore, if one assumes that the solution to the problem described in Eq. [1] is a square integrable function in the domain X (a safe and sound assumption), a solution may be sought as a linear combination of the eigenfunctions un ðrÞ. In this way, the ill-defined non Hermitian character of the operator in Eq. [1] can be circumvented. This procedure will be shown below in Simulating

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

163

NMR Restricted Diffusion Experiments section. Before that however, we focus our attention on how Eq. [5] can be solved numerically using finite differences.

A DISCRETE FORMULATION In this section we derive a procedure to solve the Laplace eigenvalue problem (Eq. [5]) numerically by representing it as a matrix eigenvalue problem DuðrÞ5kuðrÞ ) LuðrÞ5kuðrÞ:

[7]

Note here the abuse of notation. We keep intentionally the same notation for the continuous eigenfunctions and the discrete vectors. It should be clear from context what uðrÞ is referred to. The matrix L will be constructed as L5

LP 2S h2

[8]

where LP is a circulant matrix representing a Laplace operator in a discrete periodic domain and S is a matrix representing the difference between the periodic problem and the problem defined by the boundary conditions in Eq. [5]. The term h is a scaling parameter related to the problem size and will be defined below. We refer to L and LP as the Laplacian and the periodic Laplacian, respectively. The matrix LP is therefore by construction independent of the boundary conditions in Eq. [5] and explicitly known. In this way all information regarding the pore geometry and type of the boundary conditions is contained in S. The task at hand is to form LP, S, and numerically diagonalize the resulting matrix L. First we will derive an expression for the geometry independent LP in one and two dimensions. The implementations are made using a cell-centered approach on a square grid, meaning that the boundaries occur at the midpoint between two grid points. This choice is not unique, in some circumstances alternative implementations may be easier i.e., triangular or hexagonal grids. The Laplacian may also be formulated in other coordinate systems such as cylindrical coordinates (36) or spherical coordinates (37). For details we refer the reader to a textbook in finite difference methods such as (38) or similar.

The Discrete Periodic Laplace Operator LP One Dimension. Given a one-dimensional domain X defined by x 2 ½xL ; xR , the first step is to discretize the domain into N points separated by a distance h5ðxL 2xR Þ=N. The discretization of the domain is illustrated in Fig. 2. The grid points contained within the domain [x1, xN] are shown by filled black circles. The points marked by

Figure 2 Schematic illustration of a cell-centered discretization of a one-dimensional problem defined between xL and xR.

empty circles (labeled x0 and xN11) are not part of the domain. Their role will be explained below in Boundary Conditions—Forming the S-matrix section. The finite difference approximation of the continuous Laplacian operator in one dimension at a point xi within the domain X is described by, o2 uðxÞjx5xi  ox2 2uðxi Þ2uðxi11 Þ2uðxi-1 Þ : h2 Duðxi Þ5

[9]

At the edges of the domain, a slight modification will be introduced in order to give periodic boundary conditions. Given the leftmost point x1 we expect 2uðx1 Þ2uðx2 Þ2uðxN Þ ; h2

[10]

in order to account for the periodicity. Likewise at the rightmost point xN we expect 2uðxN Þ2uðx1 Þ2uðxN-1 Þ : h2

[11]

The periodic Laplacian matrix LP has the following structure 2

21

6 6 6 6 6 6 6 6 6 LP 56 6 6 6 6 6 6 6 4

..

.

..

.

..

.

21

21 21 .. .. . 21 . .. . 2

3 7 7 7 7 7 7 7 7 7 7: [12] 7 7 7 7 7 7 7 5

21

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

164

GROMBACHER AND NORDIN

2

Figure 3 Schematic illustration of the transform from a matrix representation of the 2D domain to a column vector representation.

All other elements are zero. Each ith grid point corresponds to the ith diagonal element in LP and the off-diagonal elements in the ith row and ith column correspond to the points connected to the ith grid point. The size of LP is therefore N 3 N. The two corner elements (bottom left and top right) give the periodicity. Two Dimensions. The two-dimensional case is very similar to the one-dimensional case described above. We again discretize the, now two-dimensional, domain into a structured grid of size N 3 N; in this case with equal spacing between grid points along the x- and ydirections. The Laplacian is now of size N2 3N2 as there are N2 grid points in total. The Laplacian operates on vectors, as such we must transform our domain from cartesian coordinates (an N 3 N domain) to a vector of size N2 31. This requires a map between the two representations N3N ! N 2 31. This allows the effect of applying the Laplacian to be represented by matrixvector products. In MATLAB such a mapping is easily accomplished using the command (:) after the name of the matrix representing the system in an N 3 N domain resulting in a column-wise ordering of the grid representation. Figure 3 illustrates this transform schematically. The 1D and 2D Laplacians differ because of the increased number of neighboring grid points in 2D (four neighbors) compared with 1D (two neighbors). As such, when the Laplacian operates at a point xi within the domain (not at a boundary) the result is described by

. 6 6 6 21 6 6 6 .. 6 . ⯗ 6 6. .. .. 6 . 6 . . . 21 6 6 LP 56 21 .. . 21 4 6 6 .. 6 . 21 6 6 6 . .. ⯗ 6 6 6 6 21 6 4

..

.

21 .. . .. . ..

7 7 7 7 7 7 7 7 7 .. 7 7 . 7 7 7 . .. 21 7 .. 7 .. 7 .7 . 7 7 7 7 7 7 7 5

. [14]

Equation 14 illustrates the ith row and ith column of LP, which correspond to the xi position. The diagonal value of 4 indicates the number of connected neighbors, while the 21 values occur at positions in the ith row and ith column corresponding to the neighbors of xi. The row vector describing the ith row of LP has values of 21 in the i – N, i – 1, i 1 1, and i 1 N elements. Similarly the column vector describing the the ith column of LP has values of 21 in the i – N, i – 1, i 1 1, and i 1 N elements. The elements accounting for periodicity have been omitted. Algorithm 1 illustrates how to implement a one-dimensional Laplacian in MATLAB.

Boundary Conditions—Forming the S-matrix Apart from the circulant matrix LP representing a Laplace operator with periodic boundary conditions, a matrix S is needed in order to approximate the Laplace eigenvalue equation in a restricted domain. In this article we consider three types of boundary conditions: 1. Neumann conditions n^DuðrÞ50 r 2 C

[15]

2. Dirichlet conditions uðrÞ50 r 2 C

Duðxi Þ ! Luðxi Þ5 4uðxi Þ2uðxi-1 Þ2uðxi11 Þ2uðxi-N Þ2uðxi1N Þ : h2

3

..

[16]

[13]

The uðxi21 Þ; uðxi11 Þ; uðxi2N Þ, and u(xi1N) terms are the values of the function at grid points above, below, to the left, and to the right of the grid point xi. That is, our two-dimensional Laplacian has a crossshaped stencil. In matrix form the Laplacian become

3. Robin conditions D^ n DuðrÞ1quðrÞ50 r 2 C:

[17]

The implementation of these different boundary conditions will be derived below for a few simple examples

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

165

Algorithm 1 MATLAB code to produce the one-dimensional LP-matrix and the implementation of Neumann, Dirichlet, and Robin conditions at the edges.

N 5 100; bc 5 ‘N’; % ‘N’, ‘D,’ ‘P,’ or ‘R’ h 5 20e-8; % grid spacing [m] % Form the unrestricted (periodic) one dimensional Laplacian. LU 5 spdiags([-ones(N,1),2*ones(N,1),-ones(N,1)],[-1,0,1],N,N); LU(N,1) 5 21; % Periodic BC between x_1 and x_N. LU(1,N) 5 21; % Periodic BC between x_1 and x_N. switch(bc) case ‘P’ S 5 sparse(N); case ‘N’ % Apply Neumann boundary conditions at the edges. S 5 sparse(N); S(1,1) 5 1; S(1,N) 5 21; S(N,N) 5 1; S(N,1) 5 21; case ‘D’ % Apply Dirichlet boundary conditions at the edges. S 5 sparse(N); S(1,1) 5 21; S(1,N) 5 21; S(N,N) 5 21; S(N,1) 5 21; case ‘R’ % Apply Robin boundary conditions at the edges D 5 2.5e–9; % [m/s^2] Diffusion coefficient rho 5 10e-6; % surface relaxivity [m/s] S 5 sparse(N); S(1,1) 5 (D-rho*h/2)/(D1rho*h/2); S(1,N) 5 21; S(N,N) 5 (D-rho*h/2)/(D1rho*h/2); S(N,1) 5 21; end L 5 LU - S; and then a general approach is presented where arbitrary geometries can be described. In Fig. 2 where the one-dimensional discretization was shown, two additional points x0 and xN11 are shown, outside the domain defined by [xL, xR]. These points, called ghost points, only serve a temporary role when deriving the boundary conditions at xL and xR. The placement of the boundaries between the grid points is called a cell-centered discretization. This allows a convenient representation of the domain where all grid points fall within the domain. In two dimensions

the grid points near a boundary fall into two scenarios: 1) they lie along an edge or 2) they lie in a corner. Each of these scenarios requires a different modification to the Laplacian to account for the boundary condition. Figure 4 illustrates the two cases. The solid lines indicate the boundaries and filled and empty circles indicate grid points within the domain and ghost points, respectively. For the edge scenario (left image), the boundary is applied at the position xe that occurs at the midpoint between x0 and x1. For the corner scenario (right image),

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

166

GROMBACHER AND NORDIN

ilarly applying a Neumann condition at the right side (xR in Fig. 2) results in two additional non-zero components of S SN;N 51 SN;1 521:

[21]

boundary conditions are applied at the xc1 and xc2 positions which occur at the midpoint between x0 and x1 (for xc1) and between x1 and x3 (for xc2). Below we discuss how to implement Neumann, Dirichlet, and Robin conditions in each scenario for first one-dimension and subsequently for twodimensions.

Therefore, by forming L5ðLP 2SÞ=h2 we have a matrix that represents the slab geometry with Neumann boundary conditions. For the discrete Neumann boundary condition, the corresponding diagonals of the Laplacian matrix represent the number of neighbors for each grid point. Points within the domain have two neighbors (left and right in 1D) and therefore have a 2 in the corresponding diagonal position. Grid points at the boundary (edge in 1D) have 1’s along the diagonal. Furthermore, each column sums to zero for a Neumann boundary condition. Note that since Lp is periodic, the application of Eqs. [20 and 21] may be viewed as a single operation: The application of a boundary condition at x1 and its (left) neighbor xN.

1D: Neumann Conditions. The Neumann boundary condition (Eq. [15]) can be approximated by a firstorder difference using neighboring points. For example, the boundary at xL in Fig. 2 the equation for the boundary condition becomes

1D: Dirichlet Conditions. To derive a Dirichlet boundary condition (Eq. [16]), using a cell-centered implementation, the value of the function at the boundary xL needs to be interpolated. A linear interpolation using the neighboring points yields

Figure 4 Schematic illustration of the relevant grid points when calculating the Laplacian at an edge or corner boundary in 2D.

n^  ruðxL Þ50 !

uðx1 Þ2uðx0 Þ 50; h

[18]

where the gradient of u(x) at xL has been approximated as the difference between the values of u(x) at x1 and the temporary ghost point x0. Equation [18] gives us u(x1) 5 u(x0); combining this with Eq. [9] gives us the following relation to hold at x1 2uðx1 Þ2uðx2 Þ2uðx0 Þ 5 h2 2uðx1 Þ2uðx2 Þ2uðx1 Þ 5 h2 uðx1 Þ2uðx2 Þ : h2

[19]

Note that the temporary ghost-point has been eliminated. Comparing with LP (Eq. [9]) and the expression for S (Eq. [8]) we note that the only non-zero components of S are the two following elements S1;1 51 S1;N 521:

[20]

The subscripts of S corresponds the row and column, respectively. It can be seen that LP– S reproduces the Neumann boundary condition at xL (Eq. [15]). Sim-

uðxL Þ50 !

uðx1 Þ1uðx0 Þ 50; 2

[22]

Equation [22] gives us uðx1 Þ52uðx0 Þ; combining this with the expression for the one dimensional Laplacian (Eq. [9]) gives the following relation to hold at x1 2uðx1 Þ2uðx2 Þ2uðx0 Þ 5 h2 3uðx1 Þ2uðx2 Þ : h2

[23]

Comparing this to the original expression for the Laplacian (Eq. [9]) gives the non-zero elements of the matrix S as S1;1 521

[24]

S1;N 521:

[25]

Adding a Dirichlet condition also at xR (following the outline depicted by Eq. [22 and 23]) gives us SN;N 521

[26]

SN;1 521:

[27]

In the Dirichlet condition, the columns no longer sum to zero, but the points that are no longer connected

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

have the off-diagonal elements removed from the appropriate columns. The diagonal element in this case represents the original number of connected grid points plus the number of grid points no longer connected.

1D: Robin Boundary Conditions in 1D. The Robin boundary condition (Eq. [17]), which describes a balance between the Neumann and Dirichlet conditions, can be approximated by uðx1 Þ2uðx0 Þ h uðx1 Þ1uðx0 Þ 50; 1q 2

D^ n  ruðxL Þ1quðxL Þ50 ! D

[28]

where the gradient of u(x) at xL has been approximated as the difference between the values of u(x) at x1 and the ghost point x0 and the value of u(x) at xL has been approximated as the linear interpolation of the values of u(x) at x1 and the ghost point x0. Equation [28] gives us the following relation between the ghost point x0 and x1.   D2 hq 2  uðx0 Þ [29] uðx1 Þ5  D1 hq 2

167

Algorithm 1 illustrates how the Neumann, Dirichlet, and Robin boundary conditions are implemented for a 1D slab geometry using MATLAB.

2D: Neumann Boundary Conditions. For Neumann boundary conditions in 2D we must satisfy Eq. [15] at xe for an edge boundary and at both xc1 and xc2 for a corner boundary. For the edge boundary, the situation is exactly the same as the 1D case where DnDuðxe Þ50 !

uðx1 Þ2uðx0 Þ 50: h

[35]

The gradient of u(x) at xe has been approximated as the difference between the values of u(x) at x1 and the temporary ghost point x0. From Eq. [35] we have u(x1) 5 u(x0) and therefore when the Laplacian operates at a Neumann edge boundary the result is described by 4uðx1 Þ2uðx2 Þ2uðx0 Þ2uðx3 Þ2uðx4 Þ h2 [36] 3uðx1 Þ2uðx2 Þ2uðx3 Þ2uðx4 Þ 5 : h2

Luðx1 Þ5

Comparing with LP we note that the only non-zero elements of S are then

Combining Eq. [29] with Eq. [9] gives the following relation at x1

S1;1 51

[37]

2uðx1 Þ2uðx2 Þ2uðx0 Þ Luðx1 Þ5 5 h2   0 1 hq D2 B 2 C B22  Cuðx Þ2uðx2 Þ @ hq A 1 D1 2 : h2

S1;0 521:

[38]

[30]

By comparing this expression with the unrestricted Laplacian (Eq. [9]) we see that   D2 hq 2  [31] S1;1 5  D1 hq 2 S1;N 521:

[32]

Similarly we get  SN;N 5 

D2 hq 2 D1 hq 2

SN;1 521

 

[33] [34]

at the right boundary xR. In the Robin condition, the diagonal entries of L depend on the strength of the surface relaxivity.

For a corner boundary we effectively have two edge conditions, each giving 8 uðx1 Þ2uðx0 Þ > > 50 < DnDuðxc1 Þ50 ! h [39] > > : DnDuðxc2 Þ50 ! uðx1 Þ2uðx3 Þ 50 h Therefore, in addition to u(x1) 5 u(x0) we also have u(x1) 5 u(x3). As a result when the Laplacian operates in a corner the result is described by Luðx1 Þ5

4uðx1 Þ2uðx2 Þ2uðx0 Þ2uðx3 Þ2uðx4 Þ 5 h2 2uðx1 Þ2uðx2 Þ2uðx4 Þ h2 [40]

Comparing again with LP we get the following nonzero elements of S S1;1 52

[41]

S1;0 521

[42]

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

168

GROMBACHER AND NORDIN

Algorithm 2 MATLAB code to produce the two-dimensional LP-matrix and creating S representing a single boundary element with Neumann, Dirichlet or Robin boundary conditions (on both sides of the boundary). The example is easily extended to form more complicated geometries. The length scales of D and rho are given in the natural Laplacian units.

% Form the one-dimensional circulant Laplacian LP N 5 100; h 5 20e-8; % grid spacing [m] LP1D 5 spdiags([-ones(N,1),2*ones(N,1),-ones(N,1)],[-1,0,1],N,N); LP1D(N,1) 5 21; % Periodic BC between x_1 and x_N. LP1D(1,N) 5 21; % Periodic BC between x_1 and x_N. LP 5 kron(LP1D, speye(size(LP1D))) 1 kron(speye(size(LP1D)), LP1D); % Define the type of boundary conditions bc 5 ‘N’; % Set up a single boundary between (10,10) and (10,11); x1 5 10; y1 5 10; x2 5 10; y2 5 11; % Find the diagonal elements of S i1 5 sub2ind([N,N],x1,y1); i2 5 sub2ind([N,N],x2,y2); % Define the diagonal elements switch(bc) case ‘N’ % Apply Neumann boundary conditions at the edges. el 5 1; case ‘D’ % Apply Dirichlet boundary conditions at the edges. el 5 21; case ‘R’ % Apply Robin boundary conditions at the edges D 5 2.5e-9; % [m/s^2] Diffusion coefficient rho 5 10e-6; % surface relaxivity [m/s] el 5 (D-rho*h/2)/(D1rho*h/2); end % Form S (two diagonal elements and two off-diagonal elements) S 5 sparse([i1 i1 i2 i2],[i1 i2 i2 i1],[el,-1,el,-1],N^2,N^2); % Form L L 5 LP - S;

S1;3 521:

[43]

In both cases the modification necessary to the Laplacian to account for the Neumann condition at a boundary grid point is same as the 1D case. The diagonal element in the ith column of L describes the number

of neighbor points connected to position xi, while values of 21 are placed in the elements of the ith row and ith column of L corresponding to xi’s connected neighbors. Again the sum of both the ith row and ith column is equal to zero.

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

2D: Dirichlet Boundary Conditions. The Dirichlet conditions are derived in a similar fashion as for the 2D Neumann conditions and the 1D Dirichlet conditions. In case of the edge boundary we get the following nonzero elements of S S1;1 521 [44]

169

placed in the elements of the ith row and ith column of L corresponding to xi’s connected neighbors.

S1;1 522

[46]

2D: Robin Boundary Conditions. The Robin conditions are derived in a similar fashion as for the 2D Neumann conditions and the 1D Robin conditions. In case of the edge boundary the non-zero elements of S are   D2 hq 2  [49] S1;1 5  D1 hq 2

S1;0 521

[47]

S1;0 521:

S1;3 521:

[48]

S1;0 521;

[45]

where the S1,0 element corresponds to the grid point that is no longer connected. For the corner condition we get

where the S1,0 and S1,3 elements correspond to the grid points that are no longer connected. Again the modification necessary to the Laplacian to account for the Dirichlet condition at a boundary grid point is same as the 1D case. The diagonal element in the ith column of L describes the number of original connected neighbors (4) plus the number of neighbors no longer connected (1 for edges, 2 for corners), while values of 21 are

Whereas for the corner we get   2 D2 hq 2  S1;1 5  D1 hq 2

[50]

[51]

S1;0 521

[52]

S1;3 521:

[53]

The modification necessary to the Laplacian to account for the Robin condition in 2D is same as the

Algorithm 3

MATLAB code to calculate numerically and analytically the eigenvectors and eigenvalues of the one- or two-dimensional Laplacian. num_eigs 5 20; % # eigenvalues to find h 5 20e-8; % grid spacing [m] n 5 2; % index of eigenvector to plot x 5 linspace(h/2,1-h/2,N); % Calculate the eigenvectors and eigenvalues [V,A] 5 eigs(L,[],num_eigs,1e-12); [lambda,inds] 5 sort(diag(A)/h^2); % Sort and scale. A 5 diag(lambda); V 5 V(:,inds); % Sort and scale. figure; subplot 121 if length(V(:,n)) 55 N % 1D plot(((1:N)20.5)*h,V(:,n)); else % 2D T 5 zeros(N); T(:) 5 V(:,n); surf(((1:N)20.5)*h,((1:N)20.5)*h,T); end title(sprintf(’Eigenvector %i’,n)); subplot 122 plot(lambda,’x’); title(’Eigenvalues’); Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

170

GROMBACHER AND NORDIN

Figure 5 Comparison of the lowest three non-trivial eigenvalues and eigenvectors, for a 1D Laplacian with Neumann boundary conditions, Dirichlet boundary conditions and Robin boundary conditions computed analytically (solid lines) and numerically (empty squares). The domain was discretized using N 5 100. In the Robin condition qðrÞ510 m/s and D51 m2 =s. The relative error of the first non-trivial eigenvalue as a function of N demonstrates the convergence as the resolution increases.

1D case. The diagonal element in the ith column of L is modified by a ratio controlled by the strength of the surface relaxivity and diffusion coefficients, while values of 21 are placed in the elements of the ith row and ith column of L corresponding to xi’s connected neighbors.

account for arbitrary discrete geometry of the boundary with arbitrary boundary conditions by forming a loop over all boundary elements and calculating the corresponding S-matrix. The only information needed is a set of boundary points, the type of boundary condition(s) and the knowledge of which points in LP are the neighboring points. The following example illustrates how to implement this approach. If we are given a twodimensional Laplacian describing a periodic rectangular grid of size N 3 N and we are interested in implementing a Neumann boundary condition between two neighboring points x1 and x2 that correspond to the ith

Identifying Boundaries and Implementing Boundary Conditions for Arbitrary 2D Geometries. To account for boundary conditions, all that is required is to populate the S matrix, which only has nonzero elements at locations corresponding to boundary points and points adjacent to boundaries. Therefore, we can Table 1 Approximative Eigenvalues for the 1D Pore. q 10 10 10 1 1 1 0.1 0.1 0.1

N k0 k1 k2 k0 k1 k2 k0 k1 k2

(6.9048. . .) (28.1674. . .) (65.0781. . .) (1.7069. . .) (13.4924. . .) (43.3570. . .) (0.1967. . .) (10.2656. . .) (39.8780. . .)

10

50

100

500

1,000

5.7301 22.7553 50.4083 1.5068 11.0587 34.0664 0.1767 8.2759 31.2637

6.6713 27.1669 62.6084 1.6676 13.0147 41.6479 0.1927 9.8632 38.2546

6.7882 27.6737 63.8799 1.6874 13.2544 42.5147 0.1947 10.0643 39.0746

6.8814 28.0700 64.845 1.7031 13.4449 43.1908 0.1963 10.2253 39.7183

6.893 28.1189 64.9622 1.7051 13.4686 43.2741 0.1965 10.2454 39.7979

The analytic eigenvalues are given within the parenthesis. The lowest three eigenvalues are shown for the Robin BC’s with varying strengths of the surface relaxivity q.

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

171

Figure 6 Approximative eigenvector, analytic eigenfunction, residual and norm of residual as a function of N for the 2D box example given a Robin boundary condition where qðrÞ510 m/s and D51 m2 =s.

and jth indices in the Laplacian, respectively. We then construct LP as described above and form S using the indices of the neighboring points Si;i 51

[54]

Sj;i 521

[55]

Sj;j 51

[56]

Si;j 521:

[57]

The first two lines denote the Neumann condition at x1. The last two lines denote the same condition at the other side of the boundary (x2). The extension to several boundary elements is extended using a loop. Algorithm 2 illustrates how the Neumann, Dirichlet, and Robin boundary conditions are implemented at an arbitrary position within a 2D domain using MATLAB.

Table 2 Approximative Eigenvalues for the 2D Box Example (of size 1 3 1) q 10 10 10 1 1 1 0.1 0.1 0.1

N k0 k1 k2 k0 k1 k2 k0 k1 k2

(13.8094. . .) (35.0724. . .) (56.3354. . .) (3.4141. . .) (15.1994. . .) (26.9847. . .) (0.3934. . .) (10.4623. . .) (20.5312. . .)

200

400

600

800

1,000

1,200

13.6929 34.7688 55.8447 3.3945 15.0708 26.7471 0.3914 10.3606 20.3298

13.7512 34.9210 56.0909 3.4043 15.1352 26.8660 0.3924 10.4114 20.4305

13.7706 34.9716 56.1726 3.4076 15.1566 26.9056 0.3928 10.4284 20.4640

13.7803 34.9968 56.2134 3.4092 15.1673 26.9254 0.3929 10.4369 20.4808

13.7861 35.0119 56.2378 3.4102 15.1737 26.9373 0.3930 10.4420 20.4909

13.7900 35.0220 56.2541 3.4108 15.1780 26.9452 0.3931 10.4453 20.4976

The analytic eigenvalues are given within the parenthesis. Eigenvalue k1 is degenerate, only one of the obtained values is shown.

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

172

GROMBACHER AND NORDIN

Figure 7 The first eigenfunction for a cylinder-like geometry calculated numerically using the finite-difference approach compared to the first analytic eigenfunction for a cylinder. Despite the two functions looking very similar, the residual reveal that the numerically obtained function behaves poorly when the cylinder boundary approaches the maximum deviance from the finite difference grid (at 45 from the x/y-plane). The reason for this discrepancy becomes clear when one compares the cylinder geometry with the finite difference cylinder-like geometry. In the schematic image of the grid the cell-centered boundary is defined along the interface between the white and the gray shaded area. This geometry differs from the true cylinder (the bold line). See Cell-centered vs. Curved Geometries section for a discussion of this effect. In the calculations the radius was set to r 5 1 m, D 5 1 m2 =s, q 5 30 m=s, and N 5 400 in each direction for the numerical calculation.

Three Dimensions The extension of the finite difference method to three dimensions is very similar to the extension from 1D to 2D. To apply the Laplace operator at any particular location in 3D we must now consider the points above and below, left and right, and front and back. To implement the Neumann, Dirichlet, and Robin boundary conditions for each boundary type the same approach is used as that illustrated for the 2D cases.

ization of a Laplacian matrix L produced by the previous algorithms is given in algorithm 3. To illustrate the accuracy of the finite difference method consider the comparison between the analytical and numerically determined eigenvectors and eigenvalues for the 1D slab problem in the domain x 2 ½xL ; xR  with Neumann, Dirichlet, and Robin boundary conditions. For this simple geometry the analytic eigenfunctions and eigenvalues are given by [see e.g., (12)]: Neumann

Diagonalizing the Laplacian L When the Laplacian L has been constructed, it is straight forward to numerically diagonalize it. A sparse Lanczos eigenvalue solver is recommended as L is a banded sparse matrix—most elements are zero. Furthermore, only a subset of the eigenvalues and eigenvectors are needed for the NMR calculations below. A MATLAB implementation of the numerical diagonal-

kn 5 un ðxÞ5

p2 n2 ðxR 2xL Þ2

pffiffiffiffiffiffiffiffiffiffiffiffiffiffi 22d0N cosðnpðx2xL Þ=ðxR 2xL ÞÞ;

[58] [59]

Dirichlet kn 5

p2 n2 ðxR 2xL Þ2

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

; n>0

[60]

FINITE DIFFERENCE DIAGONALIZATION

173

Algorithm 4

MATLAB code to perform a PGSE-sequence and calculate the resulting echo attenuation using numerically obtained eigenvectors/eigenvalues. This code assumes that a set of eigenvalues and eigenvectors of a 2D Laplacian matrix have been calculated, e.g. using algorithm 2–3. Note that the matrix M3 is the complex conjugate of M1 i.e., an immediate optimization would be to only calculate M1 and use its complex conjugate to form the final magnetization profile. % Initialize parameters D 5 2.5e-9; % [m/s^2] Diffusion coefficient gamma 5 267.513e6; % Hydrogen gyromagnetic ratio tau 5 500e-3; % [s] Mixing time delta 5 10e-3; % [s] Gradient pulse duration g 5 0.1; % [T/m] Gradient amplitude % Form initial magnetization m0 5 ones(N^2,1); % homogeneous initial distribution m0_proj 5 V.’*m0/N; % project to Laplace basis % Form gradient x 5 1:N; [X,] 5 meshgrid(x,x); Grad 5 repmat(X(:),1,length(diag(A))); % Calculate the B-matrix B 5 V’*(Grad.*V)*h; % Perform experiment M1 5 expm(-delta*(D*A 1 1i*g*gamma*B)); % Simulate first gradient pulse M2 5 expm(-tau*D*A); % Simulate mixing time M3 5 expm(-delta*(D*A - 1i*g*gamma*B)); % Simulate second gradient pulse m 5 M3*M2*M1*m0_proj; %the final magnetization profile % Calculate (un-normalized) Echo attenuation E 5 m0_proj.’*(M3*M2*M1)*m0_proj; % Calculate the corresponding q-value q 5 gamma*delta*g/(2*pi); % calculate the corresponding b-value b 5 q^2*(tau-delta/3);

pffiffiffi un ðxÞ5 2sinðnpðx2xL Þ=ðxR 2xL ÞÞn2 ;

[61]

tanðan Þ 2ðxR 2xL Þ 5 : 2 an an 2ðxR 2xL Þ2

and Robin conditions kn 5 pffiffiffi un 5 2

a2n

[62]

ðxR 2xL Þ2 !

kn kn 12ðxR 2xL Þ1ðxR 2xL Þ2

 cosðan ðx2xL Þ=ðxR 2xL ÞÞ1   ðxR 2xL Þ ðx2xL Þ ; sin an an ðxR 2xL Þ

where an is found by solving

3 [63]

[64]

In Fig. 5 the first three non-trivial approximate eigenvectors for these three boundary conditions are plotted using N 5 100 together with the corresponding analytic solutions. These results were obtained by using algorithm 1 followed by algorithm 3. The numerical solutions are shown by open squares, while the analytic solutions are given by the solid lines. The numerical eigenvectors closely reproduce the corresponding analytic solution. The convergence rate for the accuracy of the first non-trivial eigenvalue for the Neuman,

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

174

GROMBACHER AND NORDIN

Dirichlet, and Robin conditions are illustrated in Fig. 5. The residual between the analytic and numerically calculated eigenvalues is observed to decrease linearly with increasing N. In Table 1 the accuracy of the eigenvalues predicted for the 1D slab problem for Robin boundary conditions are shown for varying strengths of the surface relaxivity. A similar convergence rate is observed with increasing number of grid points. To illustrate the accuracy of the numerical determination of the eigenvectors and eigenvalues for a two dimensional case a square pore geometry (box pore) of N points in each direction was used. In Fig. 6 the first eigenvector of L is compared with the analytical eigenfunction for N 5 1,000. The residual (i.e., difference between the numerical and analytical solution) is also shown together with the norm of the residual for increasing the resolution with N. The norm of the residual is observed to decrease linearly the number of grid points squared (N2). Table 2 shows the first three eigenvalues obtained for different N and surface relaxivity compared to analytically obtained values for the two dimensional box. The convergence of the lowest eigenvalue displays a similar trend as the 1D case; increasing N improves the accuracy of the numerical eigenvalue.

Cell-centered vs. Curved Geometries The current implementation is a cell-centered approach, meaning that the boundaries will always, at some resolution, be of a staircase-like type where each boundary element lies perpendicular to the grid. However, such geometries are inherently different from curved geometries. This means that one cannot directly compare results obtained from a cell-centered approach with results from curved geometries. The discrepancy between the cell-centered implementation and truly curved geometries is not a major concern when Neumann boundary conditions are used but the discrepancy becomes notable when Robin and Dirichlet conditions are present. The reason for this is that the adsorbing nature of such boundary conditions will reflect the exposed boundary and a staircase-like surface is quite different from a curved one. In Fig. 7 this effect and its consequence is demonstrated for a Robin condition by comparing the lowest eigenmode calculated for a cell-centered approximation of a cylinder against the analytical solution. Although this comparison is rather ill defined (since the geometries are inherently different) it serves as a good reminder of the scope and limitations of the cell-centered approach. It is possible to expand the presented material to a finite difference implementation that circumvents this

limitation and thus gives a numerical approach for describing curved geometries, but a more sophisticated implementation is needed. One approach would be to interpolate the boundary points on the grid with respect to the underlying curved boundary. This would lead to a change in the S-matrix where boundary elements are weighted with respect to their distance (and normal) to the underlying boundary. Such an implementation lies beyond the scope of this article.

SIMULATING NMR RESTRICTED DIFFUSION EXPERIMENTS Armed with the ability to approximately solve the Laplacian eigenvalue problem for the Bloch–Torrey equation, the original problem (Eq. [1]) is restated 8 < o mðr; tÞ5ðDD1igBðr; tÞÞmðr; tÞÞ r 2 X ot : [65] : ðD^ n ðrÞ  r1qðrÞÞmðr; tÞÞ50 r2C If the spatially varying magnetic field Bðr; tÞ can be considered to be constant for some time, say from t0 to t we can formally express the evolution of the magnetization in the following integral form (23) ðt t0

ðt o mðr; tÞdt5 ðDD1igBðrÞÞmðr; tÞdt ot

[66]

t0

giving the following expression mðr; tÞ5e2tðDD1igBðrÞÞ mðr; t50Þ:

[67]

The Laplace operator may be represented by the outer product ð 1 X un ðrÞkn drun ðrÞf ðrÞ [68] Df ðrÞ ! n50

X

where f ðrÞ denotes a test function and likewise the magnetic field term containing BðrÞ may be (due to completeness of the eigenfunctions) expressed as ð 1 X 1 X un ðrÞ dXun ðrÞBum ðrÞ3 igBðrÞf ðrÞ ! ig n50 m50

ð

X

dXum ðrÞf ðrÞ:

X

[69] Combining Eq. [67] with Eqs. [68] and [69] and writing the magnetization in the Laplacian eigenbasis we get

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

m5e2tðDA1igBÞ m0

[70]

The A and B terms are two (infinite) matrices defined by Anm 5dnm kn

[71]

Bnm 5 drun ðrÞBðrÞum ðrÞ:

[72]

ð

2

2

BðrÞ5^ x  r;

[73]

X

The B matrix now serves to describe the phase shifts between different regions in the pore space due to the presence of the gradients. Multiplying B by a scalar g gives a gradient of magnitude g. Note that (as depicted in Eqs. [70–72]) the magnetization is represented in the Laplace eigenbasis. To represent the magnetization in this form we must determine the set of coefficients that represents the magnetization. The initial magnetization, for example, becomes m0 ðrÞ5

1 X

cn un ðrÞ

[75]

n

where the coefficients are determined from ð cn 5 drun ðrÞm0 ðrÞ:

[76]

X

In this way, the initial magnetization can be represented as a vector

3 [78]



which describes the final magnetization profile m in the Laplacian basis. The primes in Eq. [78] indicate that these coefficients now describe the state of the magnetization after multiplication with the matrix exponent. Given this vector of coefficients it is straight forward to construct the resulting magnetization profile mðrÞ X mðrÞ5 c0n un ðrÞ: [79] n

In many applications the magnitude of the resulting magnetization is of interest. This can be determined by solving the following integral ! ð ð X 0 drmðrÞ5 dr cn un ðrÞ 5 n X

X [74]

c00

6 07 7 m!6 4 c1 5

X

and the elements of the B-matrix become ð Bnm 5 drun ðrÞxum ðrÞ:

3

6 7 7 m0 ! 6 [77] 4 c1 5 : ⯗ By calculating the matrix exponent in Eq. [70] and multiplying this with the initial magnetization vector we form a vector of coefficients

X

The growing magnitude of the eigenvalues kn ensures that the matrices A and B can safely be truncated to finite size (23) and therefore, the matrices A and B can be expressed using the smallest eigenvalues of the Laplacian, their corresponding eigenfunctions, and information of the spatially varying magnetic field BðrÞ. Therefore, all that is needed to simulate an NMR experiment given a discrete pore is knowledge of the experimental parameters (i.e., pore size, the diffusion constant, experimental time) and the A and B matrices. The matrix A captures all surface relaxation and diffusion effects, while the matrix B captures the impact of the spatially varying magnetic field on the magnetization profile. The matrix B is formed using the eigenvectors of the Laplacian operator and the spatial distribution of the magnetic field. For example, a (linear) magnetic field gradient applied in the x-direction gives

c0

175

c0n

ð

[80] drun ðrÞ:

n X

Arbitrary experiments may be designed by realizing that the resulting magnetization m may be used as an initial state for a new matrix exponent with different time and B-matrix. As an example we demonstrate the implementation of a pulsed gradient spin echo experiment below.

The Pulsed Gradient Spin Echo Experiment The pulsed gradient spin echo (PGSE) sequence consists of two gradient pulses of duration d, separated by a mixing time s (see top row of Fig. 8). The two gradient pulses have opposite polarity; i.e. one has a gradient of 1 g and the other – g. The spin-echo is measured immediately following the second gradient pulse. To simulate a pulsed field gradient spin-echo experiment we must define five parameters: 1) the amplitude of the gradient pulse g, 2) the duration of the gradient pulse d, 3) the mixing time s, 4) the diffusion coefficient D and

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

176

GROMBACHER AND NORDIN

Figure 8 The magnetization profile at several time steps during a PGSE experiment. The upper schematic illustrates the PGSE experiment consisting of two opposite polarity gradient pulses. Each column illustrates the magnetization profile at times [0,d, d1s=2; d1s; 2d1s], respectively. The images describe an experiment where the gradient strength is g50:016 T=m, the gradient pulse duration is d 5 10 ms, and the mixing time is 500 ms. The diffusion coefficient equals D52:531029 m2 =s and the grid spacing h was adjusted so that the characteristic pore lengths resulted in a55031026 m. The pore geometry was formed in Adobe Illustrator and imported into FDNMR to simulate the pulsed gradient spin-echo experiment.

5) the grid spacing length h. The grid spacing length serves to scale the spatial dimensions of the eigenvalues and eigenfunctions to our NMR parameters. The two gradient pulses and the mixing time describing the PGSE experiment can now, when written in the Laplacian basis (following Eq. [70]), be represented as the following matrix operations m5M1 M2 M3 m0 :

[81]

The three matrices M1, M2, and M3 are given by M1 5e2dðDA2iggBÞ

[82]

M2 5e2sðDAÞ

[83]

M3 5e2dðDA1iggBÞ :

[84]

The final magnetization profile m is a column vector containing the coefficients that describe the final magnentization profile in terms of a basis formed of the eigenvectors of L (see Eqs. [77–79]). To determine the echo amplitude (i.e., total signal amplitude) we spatially integrate the final magnetization profile according to Eq. [80]. In the case of a homogeneously distributed initial magnetization we note that the expression can be simplified further since the final spatial integral and the determination of the initial coefficients coincide. The echo decay can then be obtained by the scalar product E5mT0 ðM1 M2 M3 Þm0 :

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

[85]

FINITE DIFFERENCE DIAGONALIZATION

177

To visualize the final magnetization profile we use Eq. [79] where the scalars c0n are obtained by 2 03 c0 6 07 6 c 75M1 M2 M3 m0 : [86] 4 15 ⯗

The echo decay E is commonly plotted against q5g dg=2p (q-space imaging) or the so-called b-value b5 q2 ðs2d=3Þ which is more commonly used in the medical community. Algorithm 4 describes the implementation of the PGSE sequence along these lines using the eigenvalues and eigenvectors of the Laplace operator L representing a two-dimensional problem. The eigenvectors un ðrÞ and eigenvalues kn are assumed to have been calculated using algorithm 2 and algorithm 3.

RESULTS The Pulsed Gradient Spin Echo Experiment Figure 8 illustrates the variation of the magnetization profile across a dumbbell shaped pore at several time slices during a PGSE experiment. The bottom two rows illustrate the magnetization profiles at different times during the PGSE. The arrows in the upper PGSE schematic illustrate the time during the PGSE corresponding to each column. The middle and bottom rows illustrate the real and imaginary components of the magnetization profile. At the beginning of the first gradient pulse the magnetization profile is real-valued (real(mðrÞ) 5 1 and imag(mðrÞÞ 5 0) and constant across the pore space (left column of Fig. 8). This describes the situation following a perfect p/2 excitation pulse that has rotated the magnetization to lie completely in the transverse plane with no phase variation across the pore space. After the first gradient pulse a banded structure can be observed in the magnetization profile in both the real and imaginary components (second column). This banded structure arises due to the presence of the gradient resulting in a spatially varying Larmor frequency that causes dephasing and a spatially varying phase across the pore. At the midway point of the mixing time (third column), the banded structure remains in the imaginary component (but has lower amplitude values) and is no longer present in the real component. Diffusion has smoothed out the banded structure in the real component resulting in an uniform real amplitude. At the end of the mixing time (fourth column) the banded structure is even more muted in the imaginary component; diffusion has continued to smooth the banded phase structure. Following the sec-

Figure 9 Echo decays for the dumbbell pore (shown in Fig. 8) plotted against qa. Fully drawn lines represent an experiment with a gradient directed across the dumbbell and the dashed lines correspond to a gradient directed along the dumbbell. Four mixing times s were used. The results are compared to analytic calculations for a cylinder of same size and parameters using the multiple correlation function approach (12) (shown as triangles). The two geometries are however inherently different due to the discrete nature of the cell-centered approach and the comparison should not be interpreted strictly (see Cell-centered vs. Curved Geometries section for a discussion on the topic).

ond gradient pulse the real component appears to have two bands, observed in the upper and lower regions of the pore space, and bands that are still present in the imaginary component. This remaining banded structure results in signal loss due to imperfect refocusing caused by the diffusion process giving rise to destructive interference. Figure 9 shows an echo decay calculated using Eq. [85] for the dumbbell pore (as in Fig. 8) for four different mixing times s and two different gradient directions: along the dumbbell (fully drawn lines) and across the dumbbell (dashed lines). The gradient duration was set to d 5 10 ms and the gradient wave number qa5dgga=2p formed by defining a 5 50 lm as the width of the dumbbell (see Fig. 8) was varied by increasing the gradient strength g. The echo is observed to reduce in amplitude as the gradient amplitude increases and characteristic diffraction peaks appear when s is increased. The peaks for the echo decays where the gradient is directed across the dumbbell coincide with the peaks expected for a cylinder (10) whereas additional peaks appear for the experiment where the gradient is directed along the pore. The reason for the additional peaks when the gradient is along the pore is due to the double pore size (qa 0.55) and the presence of an additional length scale due to the pore throat (qa 1.5,2.55).

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

178

GROMBACHER AND NORDIN

DISCUSSION The finite difference method provides a conceptually simple and efficient means of solving the Bloch–Torrey equations for arbitrary geometries and boundary conditions on a grid. This gives a tool to study NMR problems in geometries where analytic solutions are unavailable. All that is required is to determine the Smatrix, which describes the boundary conditions at all boundary elements in the domain and numerically diagonalize the resulting Laplacian matrix L. The process of determining the eigenvalues and eigenvectors represents the most computationally intensive part of the finite difference method. For Neumann and Dirichlet boundary conditions this calculation is only required once as long as the geometry and boundary conditions are not altered throughout the NMR experiment. As such, the finite difference method allows large suites of synthetic measurements to be conducted very efficiently; where many experimental parameters may be varied to conduct a wide range of experiments. This is because the eigenvectors and eigenvalues of the Laplacian in these cases are calculated prior to the specification of a length or time scale allowing both the pore size and diffusion coefficient to become experimental parameters that may also be varied without requiring a second calculation of the eigenvectors and eigenvalues. For Robin boundary conditions, the parameter h appears in the S matrix, meaning that the eigenvalues and eigenvectors must be recalculated if the spatial dimensions change. However, when simulating a PGSE experiment the gradient strength, gradient duration, and delay time between gradient pulses are all parameters that may be varied to produce echo attenuation curves for a broad range of experimental conditions; all without requiring a second calculation of the eigenvectors and eigenvalues, regardless of the type of boundary condition. The PGSE sequence was illustrated in this article given its common application, but the finite difference method may be adapted to simulate arbitrary NMR diffusion experiments. This is done by discretizing the experiment into time periods where the experimental parameters are approximately constant. The limiting factor is that the number of eigenvalues needed increases as the time periods where the experimental parameters are approximately constant are reduced. If too few eigenvectors and eigenvalues are included inaccurate results may be produced due to an inability to describe the spatial distribution of the magnetization density over time. In practice we recommend to ensure that the magnitude of expð2Dtkmax Þ  1 for a given experimental time t, where t denotes the duration of the

shortest time period in the experiment and kmax is the largest calculated eigenvalue. The method can also be adjusted to handle more complicated gradients, such as those produced by magnetic susceptibility contrasts between the rock grain and pore fluid, to investigate the impact of internal gradients on the NMR experiment. This will involve an alteration to the calculation of the matrix B or alternatively by calculating the linear gradient field and expressing more complicated features using matrix multiplications (39). In this study the boundary conditions are implemented using first order approximations. To improve the accuracy of the boundary conditions higher order interpolation schemes may be used. This involves including more neighboring points in the derivation of the boundary conditions, at the cost of reducing the sparsity of the Laplacian. The presented method uses a cell-centered approach, meaning that the boundary occurs at the midpoint between two grid points. This scheme has better convergence properties for the Neumann conditions as compared to Dirichlet and Robin (see Fig. 5), which contain an interpolation in order to express the value of the function in between two nodes. The cell-centered approach results in geometries where the boundaries lie exactly in between the grid points. As a result a curved boundary will always be represented in a staircase-like fashion. This effect is not a major concern when one compares geometries using pure Neumann boundary conditions (see Fig. 9) but such comparisons cannot be made when Dirichlet or Robin conditions are investigated since the geometries (discrete staircase-like versus truly curved boundary) are inherently different. The presented material can be extended to better represent curved geometries and situations where the boundary does not necessarily occur at the midpoint between two grid points (using e.g. an interpolation scheme between the grid points and the underlying curved boundary). This approach is not included in this article, but would result in an alteration to the S matrix. Alternatively one could expand the presented material to a finite volume method, where an arbitrary (curved) boundary is discretized into small line-segments and where the domain is divided into small volumes. Such schemes share many similarities with finite difference methods since the resulting matrices resemble a finite difference discretization using an irregular grid [see e.g., (40)]. The MATLAB codes and examples presented in this article are available at http://sourceforge.net/projects/fdnmr/. Included in the downloaded materials is a program based on the presented material called FDNMR. This program can used to import arbitrary

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

FINITE DIFFERENCE DIAGONALIZATION

pixelized geometries (eg.jpeg or.png image) and simulate NMR diffusion experiments.

CONCLUSIONS A cell-centered finite difference method for simulating NMR diffusion experiments in discrete geometries is presented. The method is tested in one- and two dimensions and is demonstrated to reproduce known results. Arbitrary boundary conditions and geometries may be included.

ACKNOWLEDGMENTS Denys Grombacher was supported by funding from the Stanford School of Earth, Energy, and Environmental Sciences. Matias Nordin thanks Wallenberg Foundation for financial support.

REFERENCES 1. Latour LL. 1995. “Pore-size distributions and tortuosity in heterogeneous porous media.” J Magn Reson A 112:83–91. 2. Mair RW, H€urlimann MD, Sen PN, Schwartz LM, Patz S, Walsworth RL. 2000. “Tortuosity measurement and the effects of finite pulse widths on xenon gas diffusion NMR studies of porous media.” Magn Reson Imaging 19:345–351. 3. Mair RW, Sen PN, H€urlimann MD, Patz S, Cory DG, Walsworth RL. 2002. “The narrow pulse approximation and long length scale determination in xenon gas diffusion NMR studies of model porous media.” J Magn Reson 156:202–212. 4. Mitra P, Sen P, Schwartz L, Doussal LP. 1992. “Diffusion propagator as a probe of the structure of porous media.” Phys Rev Lett 68:3555–3558. 5. Callaghan PT, Coy A, MacGowan D, Packer KJ, Zelaya FO. 1991. “Diffraction-like effects in NMR diffusion studies of fluids in porous solids.” Nature 351:467–469. 6. Tanner JE, Stejskal EO. 1968. “Restricted selfdiffusion of protons in colloidal systems by the pulsed-gradient, spin-echo method.” J Chem Phys 49: 1768–1778. 7. Horsfield MA, Jones DK. 2002. “Applications of diffusion-weighted and diffusion tensor MRI to white matter diseases—a review.” NMR Biomed 15:570–577. 8. Koh DM, Collins DJ. 2007. “Diffusion-weighted MRI in the body: applications and challenges in oncology.” Am J Roentgenol 188:1622–1635. 9. Torrey HC. 1956. “Bloch equations with diffusion terms.” Phys Rev 104:563–565.

179

10. Linse P, S€oderman O. 1995. “The validity of the short-gradient-pulse approximation in NMR studies of restricted diffusion simulations of molecules diffusing between planes, in cylinders and spheres.” J Magn Reson A 116:77–86. 11. Grebenkov D. 2008. “Laplacian eigenfunctions in NMR. I. A numerical tool.” Concepts Magn Reson Part A 32:277–301. 12. Grebenkov D. 2007. “NMR survey of reflected Brownian motion.” Rev Mod Phys 79:1077–1137. 13. Gudbjartsson H, Patz S. 1995. “NMR diffusion simulation based on conditional random walk.” Med Imaging IEEE Trans 14:636–642. 14. Vasenkov S, K€arger J, Freude D, Rakoczy R, Weitkamp J. 2000. “Percolation diffusion of guest molecules in nacaa zeolites: field gradient NMR studies and Monte Carlo simulations.” J Mol Catal A Chem 158:373–376. 15. Kvarnstr€om M, Westergard A, Loren N, Nyden M. 2009. “Brownian dynamics simulations in hydrogels using an adaptive time-stepping algorithm.” Phys Rev E 79, p. 016102. 16. Hall MG, Alexander DC. 2009. “Convergence and parameter choice for Monte-Carlo simulations of diffusion MRI.” IEEE Trans Med Imaging 28:1354–1364. 17. Laun FB, Huff S, Stieltjes B. 2009. “On the effects of dephasing due to local gradients in diffusion tensor imaging experiments: relevance for diffusion tensor imaging fiber phantoms.” Magn Reson Imaging 27: 541–548. 18. Waudby CA, Christodoulou J. 2011. “GPU accelerated Monte Carlo simulation of pulsed-field gradient NMR experiments.” J Magn Reson 211:67–73. 19. Hagsl€att H, Jonsson B, Nyden M, S€oderman O. 2003. “Predictions of pulsed field gradient NMR echodecays for molecules diffusing in various restrictive geometries. Simulations of diffusion propagators based on a finite element method.” J Magn Reson 161:138–147. 20. Mohnke O, Klitzsch N. 2010. “Microscale simulations of NMR relaxation in porous media considering internal field gradients.” Vadose Zone J 9:846–857. 21. Fichele S, Paley MNJ, Woodhouse N, Griffiths PD, van Beek EJR, Wild JM. 2004. “Investigating 3He diffusion NMR in the lungs using finite difference simulations and in vivo PGSE experiments.” J Magn Reson 167:1–11. 22. Momot KI, Powell SK, Tourell MC. 2015. “Further development of discrete computational techniques for calculation of restricted diffusion propagators in porous media.” Microporous Mesoporous Mater 205:24–30. 23. Barzykin AV. 1999. “Theory of spin echo in restricted geometries under a step-wise gradient pulse sequence.” J Magn Reson 139:342–353. 24. Callaghan PT. 1997. “A simple matrix formalism for spin echo analysis of restricted diffusion under generalized gradient waveforms.” J Magn Reson 129:74–84.

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

180

GROMBACHER AND NORDIN

25. Nordin M, Nilsson-Jacobi M, Nyden M. 2009. “Deriving time-dependent diffusion and relaxation rate in porous systems using eigenfunctions of the Laplace operator.” J Magn Reson 201:205–211. 26. Kenkre VM, Fukushima E, Sheltraw D. 1997. “Simple solutions of the Torrey-Bloch equations in the NMR study of molecular diffusion.” J Magn Reson 128:62–69. 27. Caprihan A. 1996. “A multiple-narrow-pulse approximation for restricted diffusion in a time-varying field gradient.” J Magn Reson A 118:94–102. 28. Laun FB, Kuder TA, Wetscherek A, Stieltjes B, Semmler W. 2012. “NMR-based diffusion pore imaging.” Phys Rev E Stat Nonlin Soft Matter Phys 86:021906. 29. Nordin M, Nilsson-Jacobi M, Nyden M. 2011. “A mixed basis approach in the SGP-limit.” J Magn Reson 212:274–279. 30. Nordin M, Grebenkov D, Jacobi MN, Nyden M. 2013. “An efficient eigenfunction approach to calculate spin-echo signals in heterogeneous porous media.” Microporous Mesoporous Mater 178:7–10. 31. Moroney BF, Stait-Gardner T, Ghadirian B, Yadav NN, Price WS. 2013. “Numerical analysis of NMR diffusion measurements in the short gradient pulse limit.” J Magn Reson 234:165–175. 32. Price WS. 2009. NMR Studies of Translational Motion. New York: Cambridge University Press. 393 p.

33. Brownstein KR, Tarr CE. 1979. “Importance of classical diffusion in NMR studies of water in biological cells.” Phys Rev A 19:2446–2453. 34. Arfken GB, Weber HJ. 1995. Mathematical Methods for Physicists, 4th ed. San Diego: Academic Press. 1029 p. 35. Grebenkov DS. 2009. “Laplacian eigenfunctions in NMR. II. Theoretical advances.” Concepts Magn Reson Part A 34A:264–296. 36. Ziener CH, Kurz FT, Kampf T. 2015. “Free induction decay caused by a dipole field.” Phys Rev E 91:032707. 37. Ziener CH, Kurz FT, Buschle LR, Kampf T. 2015. “Orthogonality, Lommel integrals and cross product zeros of linear combinations of Bessel functions.” SpingerPlus 4:390. 38. LeVeque R. 2007. Finite Difference Methods for Ordinary and Partial Differential Equations: SteadyState and Time-Dependent Problems. Philadelphia: Society for Industrial and Applied Mathematics. 341 p. 39. Laun F. 2012. “Restricted diffusion in NMR in arbitrary inhomogeneous magnetic fields and an application to circular layers.” J Chem Phys 137:044704. 40. Domelevo K, Pascal O. 2005. “A finite volume method for the Laplace equation on almost arbitrary two-dimensional grids.” ESAIM Mathematical Modeling and Numerical Analysis 39:1203–1249.

Concepts in Magnetic Resonance Part A (Bridging Education and Research) DOI 10.1002/cmr.a

Suggest Documents