Finite differencing

The first step in our numerical implementation of the solver is to discretize the spatial coordinates into grid points (or nodes). The one-dimensional case is shown in the figure below, where the x coordinate is discretized into Ngrid grid points:

Finite differencing

If the distance between the grid points Δ x is constant, it can easily be seen that it is given by L/(Ngrid – 1). With this arrangement, the second order derivative of ϕ at x = x0 can then be approximated by an algebraic equation:

Finite differencing

(6.9)

where i is then the grid point located at x0. This ...

Get GNU Octave now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.