7.3: Higher Dimensions
( \newcommand{\kernel}{\mathrm{null}\,}\)
We can work out the finite-difference equations for higher dimensions in a similar manner. In two dimensions, for example, the wavefunction ψ(x,y) is described with two indices:
ψmn≡ψ(xm,yn).
The discretization of the derivatives is carried out in the same way, using the mid-point rule for first partial derivatives in each direction, and the three-point rule for the second partial derivative in each direction. Let us suppose that the discretization spacing is equal in both directions:
h=xm+1−xm=yn+1−yn.
Then, for the second derivative, the Laplacian operator
∇2ψ(x,y)≡∂2ψ∂x2+∂2ψ∂y2
can be approximated by a five-point rule, which involves the value of the function at (m,n) and its four nearest neighbors:
∇2ψ(xm,yn)≈ψm+1,n+ψm,n+1−4ψmn+ψm−1,n+ψm,n−1h2+O(h2).
For instance, the finite-difference equations for the 2D Schrödinger wave equation is
−12h2[ψm+1,n+ψm,n+1−4ψmn+ψm−1,n+ψm,n−1]+Vmnψmn=Eψmn.
7.3.1 Matrix Reshaping
Higher-dimensional differential equations introduce one annoying complication: in order to convert between the finite-difference equation and the matrix equation, the indices have to be re-organized. For instance, the matrix form of the 2D Schrödinger wave equation should have the form
∑νHμνψν=Eψμ,
where the wavefunctions are organized into a 1D array labeled by a "point index" μ. Each point index corresponds to a pair of "grid indices", (m,n), representing spatial coordinates on a 2D grid. We have to be careful not to mix up the two types of indices.
We will adopt the following conversion scheme between point indices and grid indices:
μ(m,n)=mN+n,wherem∈{0,…,M−1},n∈{0,…,N−1}.
One good thing about this conversion scheme is that Scipy provides a reshape
function which can convert a 2D array with grid indices (m,n) into a 1D array with the point index μ:
>>> a = array([[0,1,2],[3,4,5],[6,7,8]]) >>> a array([[0, 1, 2], [3, 4, 5], [6, 7, 8]]) >>> b = reshape(a, (9)) # Reshape a into a 1D array of size 9 >>> b array([0, 1, 2, 3, 4, 5, 6, 7, 8])
The reshape
function can also convert a 1D back into the 2D array, in the right order:
>>> c = reshape(b, (3,3)) # Reshape b into a 2D array of size 3x3 >>> c array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
Under point indices, the discretized derivatives take the following forms:
∂ψ∂x(→rμ)≈12h(ψμ+N−ψμ−N)
∂ψ∂y(→rμ)≈12h(ψμ+1−ψμ−1)
∇2ψ(→rμ)≈1h2(ψμ+N+ψμ+1−4ψμ+ψμ−N+ψμ−1).
The role of boundary conditions is left as an exercise. There are now two sets of boundaries, at m∈{0,M−1} and n∈{0,N−1}. By examining the finite-difference equations along each boundary, we can (i) assign the right discretization coordinates and (ii) modify the finite-difference matrix elements to fit the boundary conditions. The details are slightly tedious to work out, but the logic is essentially the same as in the previously-discussed 1D cases.