Open with one click!

This notebook demonstrates how IPython notebooks can be used to discuss the theory and implementation of numerical algorithms on one page.

With ipython nbconvert --to markdown name.ipynb a notebook like this one can be made into a blog post in one easy step. To display the graphics in your resultant blog post use, for instance, your Dropbox Public folder that you can activate here.

The Crank-Nicolson Method

The Crank-Nicolson method is a well-known finite difference method for the numerical integration of the heat equation and closely related partial differential equations.

We often resort to a Crank-Nicolson (CN) scheme when we integrate numerically reaction-diffusion systems in one space dimension

ut=D2ux2+f(u),\frac{\partial u}{\partial t} = D \frac{\partial^2 u}{\partial x^2} + f(u),

uxx=0,L=0,\frac{\partial u}{\partial x}\Bigg|_{x = 0, L} = 0,

where uu is our concentration variable, xx is the space variable, DD is the diffusion coefficient of uu, ff is the reaction term, and LL is the length of our one-dimensional space domain.

Note that we use Neumann boundary conditions and specify that the solution uu has zero space slope at the boundaries, effectively prohibiting entrance or exit of material at the boundaries (no-flux boundary conditions).

Finite Difference Methods

Many fantastic textbooks and tutorials have been written about finite difference methods, for instance a free textbook by Lloyd Trefethen.

Here we describe a few basic aspects of finite difference methods.

The above reaction-diffusion equation describes the time evolution of variable u(x,t)u(x,t) in one space dimension (uu is a line concentration). If we knew an analytic expression for u(x,t)u(x,t) then we could plot uu in a two-dimensional coordinate system with axes tt and xx.

To approximate u(x,t)u(x,t) numerically we discretize this two-dimensional coordinate system resulting, in the simplest case, in a two-dimensional regular grid. This picture is employed commonly when constructing finite differences methods, see for instance Figure 3.2.1 of Trefethen.

Let us discretize both time and space as follows:

tn=nΔt, n=0,,N1,t_n = n \Delta t,~ n = 0, \ldots, N-1,

xj=jΔx, j=0,,J1,x_j = j \Delta x,~ j = 0, \ldots, J-1,

where NN and JJ are the number of discrete time and space points in our grid respectively. Δt\Delta t and Δx\Delta x are the time step and space step respectively and defined as follows:

Δt=T/N,\Delta t = T / N,

Δx=L/J,\Delta x = L / J,

where TT is the point in time up to which we will integrate uu numerically.

Our ultimate goal is to construct a numerical method that allows us to approximate the unknonwn analytic solution u(x,t)u(x,t) reasonably well in these discrete grid points.

That is we want construct a method that computes values U(jΔx,nΔt)U(j \Delta x, n \Delta t) (note: capital UU) so that

U(jΔx,nΔt)u(jΔx,nΔt)U(j \Delta x, n \Delta t) \approx u(j \Delta x, n \Delta t)

As a shorthand we will write Ujn=U(jΔx,nΔt)U_j^n = U(j \Delta x, n \Delta t) and (j,n)(j,n) to refer to grid point (jΔx,nΔt)(j \Delta x, n \Delta t).

The Crank-Nicolson Stencil

Based on the two-dimensional grid we construct we then approximate the operators of our reaction-diffusion system.

For instance, to approximate the time derivative on the left-hand side in grid point (j,n)(j,n) we use the values of UU in two specific grid points:

utx=jΔx,t=nΔtUjn+1UjnΔt.\frac{\partial u}{\partial t}\Bigg|_{x = j \Delta x, t = n \Delta t} \approx \frac{U_j^{n+1} - U_j^n}{\Delta t}.

We can think of this scheme as a stencil that we superimpose on our (x,t)(x,t)-grid and this particular stencil is commonly referred to as forward difference.

The spatial part of the Crank-Nicolson stencil (or see Table 3.2.2 of Trefethen) for the heat equation (ut=uxxu_t = u_{xx}) approximates the Laplace operator of our equation and takes the following form

2ux2x=jΔx,t=nΔt12Δx2(Uj+1n2Ujn+Uj1n+Uj+1n+12Ujn+1+Uj1n+1).\frac{\partial^2 u}{\partial x^2}\Bigg|_{x = j \Delta x, t = n \Delta t} \approx \frac{1}{2 \Delta x^2} \left( U_{j+1}^n - 2 U_j^n + U_{j-1}^n + U_{j+1}^{n+1} - 2 U_j^{n+1} + U_{j-1}^{n+1}\right).

To approximate f(u(jΔx,nΔt))f(u(j \Delta x, n \Delta t)) we write simply f(Ujn)f(U_j^n).

These approximations define the stencil for our numerical method as pictured on Wikipedia.

SVG

Applying this stencil to grid point (j,n)(j,n) gives us the following approximation of our reaction-diffusion equation:

Ujn+1UjnΔt=D2Δx2(Uj+1n2Ujn+Uj1n+Uj+1n+12Ujn+1+Uj1n+1)+f(Ujn).\frac{U_j^{n+1} - U_j^n}{\Delta t} = \frac{D}{2 \Delta x^2} \left( U_{j+1}^n - 2 U_j^n + U_{j-1}^n + U_{j+1}^{n+1} - 2 U_j^{n+1} + U_{j-1}^{n+1}\right) + f(U_j^n).

Reordering Stencil into Linear System

Let us define σ=DΔt2Δx2\sigma = \frac{D \Delta t}{2 \Delta x^2} and reorder the above approximation of our reaction-diffusion equation:

σUj1n+1+(1+2σ)Ujn+1σUj+1n+1=σUj1n+(12σ)Ujn+σUj+1n+Δtf(Ujn).-\sigma U_{j-1}^{n+1} + (1+2\sigma) U_j^{n+1} -\sigma U_{j+1}^{n+1} = \sigma U_{j-1}^n + (1-2\sigma) U_j^n + \sigma U_{j+1}^n + \Delta t f(U_j^n).

This equation makes sense for space indices j=1,,J2j = 1,\ldots,J-2 but it does not make sense for indices j=0j=0 and j=J1j=J-1 (on the boundaries):

j=0: σU1n+1+(1+2σ)U0n+1σU1n+1=σU1n+(12σ)U0n+σU1n+Δtf(U0n),j=0:~-\sigma U_{-1}^{n+1} + (1+2\sigma) U_0^{n+1} -\sigma U_{1}^{n+1} = \sigma U_{-1}^n + (1-2\sigma) U_0^n + \sigma U_{1}^n + \Delta t f(U_0^n),

j=J1: σUJ2n+1+(1+2σ)UJ1n+1σUJn+1=σUJ2n+(12σ)UJ1n+σUJn+Δtf(UJ1n).j=J-1:~-\sigma U_{J-2}^{n+1} + (1+2\sigma) U_{J-1}^{n+1} -\sigma U_{J}^{n+1} = \sigma U_{J-2}^n + (1-2\sigma) U_{J-1}^n + \sigma U_{J}^n + \Delta t f(U_{J-1}^n).

The problem here is that the values U1nU_{-1}^n and UJnU_J^n lie outside our grid.

However, we can work out what these values should equal by considering our Neumann boundary condition. Let us discretize our boundary condition at j=0j=0 with the backward difference and at j=J1j=J-1 with the forward difference:

U1nU0nΔx=0,\frac{U_1^n - U_0^n}{\Delta x} = 0,

UJnUJ1nΔx=0.\frac{U_J^n - U_{J-1}^n}{\Delta x} = 0.

These two equations make it clear that we need to amend our above numerical approximation for j=0j=0 with the identities U0n=U1nU_0^n = U_1^n and U0n+1=U1n+1U_0^{n+1} = U_1^{n+1}, and for j=J1j=J-1 with the identities UJ1n=UJnU_{J-1}^n = U_J^n and UJ1n+1=UJn+1U_{J-1}^{n+1} = U_J^{n+1}.

Let us reinterpret our numerical approximation of the line concentration of uu in a fixed point in time as a vector Un\mathbf{U}^n:

Un=[U0nUJ1n].\mathbf{U}^n = \begin{bmatrix} U_0^n \\ \vdots \\ U_{J-1}^n \end{bmatrix}.

Using this notation we can now write our above approximation for a fixed point in time, t=nΔtt = n \Delta t, compactly as a linear system:

[1+σσ0000000σ1+2σσ0000000σ1+2σσ000000000000000000σ1+2σσ00000000σ1+σ][U0n+1U1n+1U2n+1UJ2n+1UJ1n+1]=[1σσ0000000σ12σσ0000000σ12σσ000000000000000000σ12σσ00000000σ1σ][U0nU1nU2nUJ2nUJ1n]+[Δtf(U0n)Δtf(U1n)Δtf(U2n)Δtf(UJ2n)Δtf(UJ1n)]. \begin{bmatrix} 1+\sigma & -\sigma & 0 & 0 & 0 & \cdots & 0 & 0 & 0 & 0\\ -\sigma & 1+2\sigma & -\sigma & 0 & 0 & \cdots & 0 & 0 & 0 & 0 \\ 0 & -\sigma & 1+2\sigma & -\sigma & \cdots & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & \ddots & \ddots & \ddots & \ddots & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\sigma & 1+2\sigma & -\sigma \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & -\sigma & 1+\sigma \end{bmatrix} \begin{bmatrix} U_0^{n+1} \\ U_1^{n+1} \\ U_2^{n+1} \\ \vdots \\ U_{J-2}^{n+1} \\ U_{J-1}^{n+1} \end{bmatrix} = \begin{bmatrix} 1-\sigma & \sigma & 0 & 0 & 0 & \cdots & 0 & 0 & 0 & 0\\ \sigma & 1-2\sigma & \sigma & 0 & 0 & \cdots & 0 & 0 & 0 & 0 \\ 0 & \sigma & 1-2\sigma & \sigma & \cdots & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & \ddots & \ddots & \ddots & \ddots & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & \sigma & 1-2\sigma & \sigma \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & \sigma & 1-\sigma \end{bmatrix} \begin{bmatrix} U_0^{n} \\ U_1^{n} \\ U_2^{n} \\ \vdots \\ U_{J-2}^{n} \\ U_{J-1}^{n} \end{bmatrix} + \begin{bmatrix} \Delta t f(U_0^n) \\ \Delta t f(U_1^n) \\ \Delta t f(U_2^n) \\ \vdots \\ \Delta t f(U_{J-2}^n) \\ \Delta t f(U_{J-1}^n) \end{bmatrix}.

Note that since our numerical integration starts with a well-defined initial condition at n=0n=0, U0\mathbf{U}^0, the vector Un+1\mathbf{U}^{n+1} on the left-hand side is the only unknown in this system of linear equations.

Thus, to integrate numerically our reaction-diffusion system from time point nn to n+1n+1 we need to solve numerically for vector Un+1\mathbf{U}^{n+1}.

Let us call the matrix on the left-hand side AA, the one on the right-hand side BB, and the vector on the right-hand side fn\mathbf{f}^n. Using this notation we can write the above system as

AUn+1=BUn+fn.A \mathbf{U}^{n+1} = B \mathbf{U}^n + f^n.

In this linear equation, matrices AA and BB are defined by our problem: we need to specify these matrices once for our problem and incorporate our boundary conditions in them. Vector fn\mathbf{f}^n is a function of Un\mathbf{U}^n and so needs to be reevaluated in every time point nn. We also need to carry out one matrix-vector multiplication every time point, BUnB \mathbf{U}^n, and one vector-vector addition, BUn+fnB \mathbf{U}^n + f^n.

The most expensive numerical operation is inversion of matrix AA to solve for Un+1\mathbf{U}^{n+1}, however we may get away with doing this only once and store the inverse of AA as A1A^{-1}:

Un+1=A1(BUn+fn).\mathbf{U}^{n+1} = A^{-1} \left( B \mathbf{U}^n + f^n \right).

A Crank-Nicolson Example in Python

Let us apply the CN method to a two-variable reaction-diffusion system that was introduced by Mori et al.:

ut=Du2ux2+f(u,v),\frac{\partial u}{\partial t} = D_u \frac{\partial^2 u}{\partial x^2} + f(u,v),

vt=Dv2vx2f(u,v),\frac{\partial v}{\partial t} = D_v \frac{\partial^2 v}{\partial x^2} - f(u,v),

with Neumann boundary conditions

uxx=0,L=0,\frac{\partial u}{\partial x}\Bigg|_{x=0,L} = 0,

vxx=0,L=0.\frac{\partial v}{\partial x}\Bigg|_{x=0,L} = 0.

The variables of this system, uu and vv, represent the concetrations of the active form and its inactive form respectively. The reaction term f(u,v)f(u,v) describes the interchange (activation and inactivation) between these two states of the protein. A particular property of this system is that the inactive has much greater diffusivity that the active form, DvDuD_v \gg D_u.

Using the CN method to integrate this system numerically, we need to set up two separate approximations

AuUn+1=BuUn+fn,A_u \mathbf{U}^{n+1} = B_u \mathbf{U}^n + \mathbf{f}^n,

AvVn+1=BvVnfn,A_v \mathbf{V}^{n+1} = B_v \mathbf{V}^n - \mathbf{f}^n,

with two different σ\sigma terms, σu=DuΔt2Δx2\sigma_u = \frac{D_u \Delta t}{2 \Delta x^2} and σv=DvΔt2Δx2\sigma_v = \frac{D_v \Delta t}{2 \Delta x^2}.

Import Packages

For the matrix-vector multiplication, vector-vector addition, and matrix inversion that we will need to carry out we will use the Python library NumPy. To visualize our numerical solutions, we will use pyplot.

In [1]:
import numpy from matplotlib import pyplot

Numpy allows us to truncate the numerical values of matrices and vectors to improve their display with set_printoptions.

In [2]:
numpy.set_printoptions(precision=3)

Specify Grid

Our one-dimensional domain has unit length and we define J = 100 equally spaced grid points in this domain. This divides our domain into J-1 subintervals, each of length dx.

In [153]:
L = 1. J = 100 dx = float(L)/float(J-1) x_grid = numpy.array([j*dx for j in range(J)])

Equally, we define N = 1000 equally spaced grid points on our time domain of length T = 200 thus dividing our time domain into N-1 intervals of length dt.

In [154]:
T = 200 N = 1000 dt = float(T)/float(N-1) t_grid = numpy.array([n*dt for n in range(N)])

Specify System Parameters and the Reaction Term

We choose our parameter values based on the work by Mori et al..

In [155]:
D_v = float(10.)/float(100.) D_u = 0.01 * D_v k0 = 0.067 f = lambda u, v: dt*(v*(k0 + float(u*u)/float(1. + u*u)) - u) g = lambda u, v: -f(u,v) sigma_u = float(D_u*dt)/float((2.*dx*dx)) sigma_v = float(D_v*dt)/float((2.*dx*dx)) total_protein = 2.26

Specify the Initial Condition

As discussed by Mori et al., we can expect to observe interesting behaviour in the steady state of this system if we choose a heterogeneous initial condition for uu.

Here, we initialize uu with a step-like heterogeneity:

In [156]:
no_high = 10 U = numpy.array([0.1 for i in range(no_high,J)] + [2. for i in range(0,no_high)]) V = numpy.array([float(total_protein-dx*sum(u))/float(J*dx) for i in range(0,J)])

Note that we make certain that total protein amounts equal a certain value, total_protein. The importance of this was discussed by Walther et al..

Let us plot our initial condition for confirmation:

In [157]:
ylim((0., 2.1)) xlabel('x'); ylabel('concentration') pyplot.plot(x_grid, U) pyplot.plot(x_grid, V) pyplot.show()
{"metadata":{},"output_type":"display_data","png":"iVBORw0KGgoAAAANSUhEUgAAAYMAAAEECAYAAADK0VhyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFvlJREFUeJzt3XtwlOXZx/HfGkhCJRxUEmsSiKVqyebARlChAqFMQ4PD\nQZGBUGIJ4mRwRkrf2pGxY00cxpGeRpQXjFNAaCEcp1NajlPL2sIwiITKwda2NJQsQscwlEAgYZPc\n7x/0XYgh7CbZ3Sf38v3MZJLdfbL74x7Yi/u6nt11GWOMAAC3tTucDgAAcB7FAABAMQAAUAwAAKIY\nAABEMQAASOrhdIBbcblcTkcAACt19FUD3X5nYIzhyxi9+uqrjmfoLl+sBWvBWtz6qzO6fTEAAEQe\nxQAAQDGwRX5+vtMRug3W4jrW4jrWomtcprMNpihwuVyd7n8BwO2qM8+d7AwAAOEvBjU1NRo9erSy\ns7P10EMP6cc//vFNj5s/f77cbrfy8vJ0+PDhcMcAAHRA2F9nEB8fr2XLlikrK0uXLl1SXl6exo8f\nr9zc3MAxW7Zs0alTp3T8+HEdPnxYJSUl+vOf/xzuKACAEIW9GKSkpCglJUWS1Lt3b+Xk5Oiz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jx47pD3/4gy5fvqzH\nHntMI0aMkNvtjkLC6AllLV5//XUNHTpUXq9XJ06c0De/+U19/PHHgd307aYjz5uO7ww68rqE/9fe\n6xJsF8paSNKRI0c0d+5cbd269ZbbRFuFsg6HDh3SjBkzdP/992vLli16/vnntXXr1mhHjbhQ1mLg\nwIEqKChQr169dPfdd2vMmDE6cuRItKNGXChrsXfvXk2bNk2SNHjwYN1///36y1/+EtWc3UWHnzfD\nOtHohCtXrphBgwYZn89nrl69aoYNG2YOHTrU6pjNmzebKVOmGGOMOXTokMnJyXEiasSFshb/+te/\nzODBg83+/fsdShl5oazDjWbPnh2zZxOFshZVVVVm3LhxpqmpydTX15vMzExz+PBhhxJHTihr8fzz\nz5uysjJjjDFnz5419957b2CwHouqq6tvOUDuyPOm420iXpdwXShr8dprr+n8+fOBXnnPnj314Ycf\nOhk77EJZh9tFKGvh8Xj0rW99Szk5OfL7/Zo7d66GDh3qcPLwC2UtfvSjH2nWrFnKzMxUc3OzFi1a\nFBisx5qioiJ98MEHqq2tVXp6usrLy+X3+yV17nnTZUyMNlsBACFzfGYAAHAexQAAQDEAAFAMAACi\nGAAdcvDgQeXm5qqxsVH19fXKysrSJ5984nQsoMs4mwjooFdeeUUNDQ26cuWK0tPT9dJLLzkdCegy\nigHQQX6/X8OGDVOvXr20f//+mHxrFNx+aBMBHVRbW6v6+npdunRJV65ccToOEBbsDIAOmjRpkmbO\nnKl//vOfOnPmjN5++22nIwFd5vjbUQA2WbNmjRISEjRjxgy1tLRo5MiR8nq9ys/Pdzoa0CXsDAAA\nzAwAABQDAIAoBgAAUQwAAKIYAABEMQAASPo/3Ve16AM9CtoAAAAASUVORK5CYII=\n","text":["<matplotlib.figure.Figure at 0xd824a90>"]}

The blue curve is the initial condition for UU, stored in Python variable U, and the green curve is the initial condition for VV stored in V.

Create Matrices

The matrices that we need to construct are all tridiagonal so they are easy to construct with numpy.diagflat.

In [158]:
A_u = numpy.diagflat([-sigma_u for i in range(J-1)], -1) +\ numpy.diagflat([1.+sigma_u]+[1.+2.*sigma_u for i in range(J-2)]+[1.+sigma_u]) +\ numpy.diagflat([-sigma_u for i in range(J-1)], 1) B_u = numpy.diagflat([sigma_u for i in range(J-1)], -1) +\ numpy.diagflat([1.-sigma_u]+[1.-2.*sigma_u for i in range(J-2)]+[1.-sigma_u]) +\ numpy.diagflat([sigma_u for i in range(J-1)], 1) A_v = numpy.diagflat([-sigma_v for i in range(J-1)], -1) +\ numpy.diagflat([1.+sigma_v]+[1.+2.*sigma_v for i in range(J-2)]+[1.+sigma_v]) +\ numpy.diagflat([-sigma_v for i in range(J-1)], 1) B_v = numpy.diagflat([sigma_v for i in range(J-1)], -1) +\ numpy.diagflat([1.-sigma_v]+[1.-2.*sigma_v for i in range(J-2)]+[1.-sigma_v]) +\ numpy.diagflat([sigma_v for i in range(J-1)], 1)

To confirm, this is what A_u looks like:

In [159]:
print A_u
[[ 1.981 -0.981 0. ..., 0. 0. 0. ] [-0.981 2.962 -0.981 ..., 0. 0. 0. ] [ 0. -0.981 2.962 ..., 0. 0. 0. ] ..., [ 0. 0. 0. ..., 2.962 -0.981 0. ] [ 0. 0. 0. ..., -0.981 2.962 -0.981] [ 0. 0. 0. ..., 0. -0.981 1.981]]

Solve the System Iteratively

To advance our system by one time step, we need to do one matrix-vector multiplication followed by one vector-vector addition on the right hand side.

To facilitate this, we rewrite our reaction term so that it accepts concentration vectors Un\mathbf{U}^n and Vn\mathbf{V}^n as arguments and returns vector fn\mathbf{f}^n.

As a reminder, this is our non-vectorial definition of ff

f = lambda u, v: v*(k0 + float(u*u)/float(1. + u*u)) - u
In [160]:
f_vec = lambda U, V: numpy.multiply(dt, numpy.subtract(numpy.multiply(V, numpy.add(k0, numpy.divide(numpy.multiply(U,U), numpy.add(1., numpy.multiply(U,U))))), U))

Let us make certain that this produces the same values as our non-vectorial f:

In [161]:
print f(U[0], V[0])
0.00996135898275
In [162]:
print f(U[-1], V[-1])
-0.0623832232232
In [163]:
print f_vec(U, V)
[ 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 -0.062 -0.062 -0.062 -0.062 -0.062 -0.062 -0.062 -0.062 -0.062 -0.062]

Accounting for rounding of the displayed values due to the set_printoptions we set above, we can see that f and f_vec generate the same values for our initial condition at both ends of our domain.

We will use numpy.linalg.solve to solve our linear system each time step.

While we integrate our system over time we will record both U and V at each time step in U_record and V_record respectively so that we can plot our numerical solutions over time.

In [164]:
U_record = [] V_record = [] U_record.append(U) V_record.append(V) for ti in range(1,N): U_new = numpy.linalg.solve(A_u, B_u.dot(U) + f_vec(U,V)) V_new = numpy.linalg.solve(A_v, B_v.dot(V) - f_vec(U,V)) U = U_new V = V_new U_record.append(U) V_record.append(V)

Plot the Numerical Solution

Let us take a look at the numerical solution we attain after N time steps.

In [165]:
ylim((0., 2.1)) xlabel('x'); ylabel('concentration') pyplot.plot(x_grid, U) pyplot.plot(x_grid, V) pyplot.show()
{"metadata":{},"output_type":"display_data","png":"iVBORw0KGgoAAAANSUhEUgAAAYMAAAEECAYAAADK0VhyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHgdJREFUeJzt3Xt4VPWdx/H3kJAEJQTEECUJcrWaK4kgQgWirKHAcnkE\nhCi4Bu2TwnrBp1117WNLdl0X2t1WEaEgrdUWogjFUuW2tQwWNwKSKBCttphohotr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ZFRcXX3YA\n2ZPtpu27iXReQgN32uLf/u3fOHXqVP2+8u7du7Nv3z47y/Y5d9qhq3CnLdLS0vjOd75DSkoKVVVV\nPPDAAwwfPtzmyn3Pnbb40Y9+xLx580hISKCmpoann366fmC9s8nKymL37t2UlZURHx9Pbm4uVVVV\ngHfbTYcxnXRnq4iIuM32MQMREbGfwkBERBQGIiKiMBARERQGIh7Zv38/qampXLhwgfLycpKSkvjo\no4/sLkuk3XQ0kYiHnnrqKSorK6moqCA+Pp7HH3/c7pJE2k1hIOKhqqoqRowYQY8ePcjPz++Ul0aR\nrke7iUQ8VFZWRnl5OefOnaOiosLuckR8Qj0DEQ9NmzaNu+++m88++4zjx4/z/PPP212SSLvZfjkK\nkY7klVdeITw8nLlz51JbW8uYMWNwOp1kZGTYXZpIu6hnICIiGjMQERGFgYiIoDAQEREUBiIigsJA\nRERQGIiICPD/nl62oEp/gH0AAAAASUVORK5CYII=\n","text":["<matplotlib.figure.Figure at 0x3a764d0>"]}

And here is a kymograph of the values of U. This plot shows concisely the behaviour of U over time and we can clear observe the wave-pinning behaviour described by Mori et al.. Furthermore, we observe that this wave pattern is stable for about 50 units of time and we therefore conclude that this wave pattern is a stable steady state of our system.

In [169]:
U_record = numpy.array(U_record) V_record = numpy.array(V_record) fig, ax = subplots() xlabel('x'); ylabel('t') heatmap = ax.pcolor(x_grid, t_grid, U_record, vmin=0., vmax=1.2)
{"metadata":{},"output_type":"display_data","png":"iVBORw0KGgoAAAANSUhEUgAAAYYAAAEICAYAAABbOlNNAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3X9sleX9//HXoS1FUH615Ye0KuOzj66l5YeM6IaTxQ8q\nNfFHdAEdZNO5Md1i3JLFxWUD/Owztv2xaMxmSBxLtmYRJiaTFRtNZt1Xp5YUIjIX8/0w9dtTFVoQ\nEVranvb+/sE857ouet/c5/Q+v5+P5IT7Ptd97l69yrne5/p5Yp7neQIA4N8m5TsDAIDCQmAAAFgI\nDAAAC4EBAGAhMAAALAQGAIAl8sDQ09OjL33pS2pubtbll1+uX/7yl5Kk48ePa82aNWppadENN9yg\nEydOJF+zbds2NTY2qrm5Wc8//3zUWQIApCEW9TqGI0eOqK+vT4sXL9apU6e0fPly/elPf9KTTz6p\nRYsW6cEHH9Sjjz6qd955R4899pi6u7v17W9/W6+99po+/PBDrVq1Sm+//bYmT54cZbYAACFF3mKY\nO3euFi9eLEm68MIL1dLSot7eXu3du1cbN26UJG3YsEHt7e2SpPb2dq1fv14VFRVasGCBmpqa1NXV\nFXW2AAAhZXWM4d1339W+ffu0atUq9fX1qaamRpJUW1uro0ePSpJ6e3tVX1+ffE19fb3i8Xg2swUA\nCFCZrRufOnVKd9xxhx577DFNnz59QveKxWIR5QoAyksmowVZCQwjIyO6/fbb9dWvflW33nqrJKmu\nrk79/f2qra1VX1+f5syZI+lsC6Gnpyf52ng8roaGhnNvWsuWTpKkgS3S1C35zkVhmEhZVGXwmqB3\nS1Bahc/PdV9jnk9x0qb4HE/7979vbZEat0gXGWkzfY4lqdY4nuekmef1ieThnEvety67WKnzBvVY\nafONtIV61/c689y83/wh+2dN6xlLndhJ9vlRactz0pa1ko441500jo85aR8bx6d9jt3zIeP4jHOd\nkTbopI2Mpo4TCeP5hH2dc5q6zuf58SxM41pT5F1JnufpG9/4hhobG/W9730v+Xxra6va2tokSW1t\nbWptbU0+v3PnTiUSCcXjcR06dEgrV66MOlsAgJAibzG88soramtrU0tLi5YtWybp7HTUrVu3at26\nddqxY4fmzZunXbt2SZKuvPJK3XbbbWppadGkSZO0fft2VVVl8nEOABCFyAPDqlWrNDY2Nm7aCy+8\nMO7zDz/8sB5++OGos1KaqlbnOweFg7JIqVud7xwUjNX/ke8cFD9WPhcbKsMUyiKFwJC0+rP5zkHx\nIzAAACwEBgCAhcAAALAQGAAAFgIDAMBCYAAAWAgMAAALgQEAYCEwAAAsBAYAgIXAAACwEBgAABYC\nAwDAQmAAAFgIDAAAC4E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GdzMh7mmFKT7e27fvl233HJLLrKWc2HK\nore3V3/+85913333SUpnCnRxCVMWb7/9tt5//31dffXVamlp0ZNPPpnrbOZEmLL45je/qX/84x+6\n+OKLtWTJEj322GO5zmZByKTezPvg86fCvpk9Z+pqKVYC6fxOnZ2d2rFjh1555ZUs5ih/wpTFgw8+\nqJ///OeKxWLyPK9kpzeHKYvR0VEdOnRIf/3rXzUwMKCrrrpKV199tZqams772mISpix+9rOfaenS\npers7NThw4e1Zs0avfHGG8mWdjlJt94smBZDmPUM7jXxeFz19fU5y2OuhCkLSTp48KDuvfdePfvs\ns4FNyWIWpiy6u7u1fv16LVy4ULt379b999+vZ599NtdZzbowZXHJJZfo+uuv1wUXXKCamhpde+21\nOnjwYK6zmnVhyuLll1/WV75ydqXyokWLtHDhQv3zn+6mRqUvo3ozshGQCRocHPQuvfRSLx6Pe8PD\nw96KFSu87u5u65qnn37au/XWWz3P87zu7m6vpaUlH1nNujBl8d5773mLFi3yXn311TzlMjfClIXp\n61//urd79+4c5jB3wpTF/v37veuuu85LJBLe6dOnvcbGRu/AgQN5ynH2hCmL+++/39uyZYvneZ73\n4YcfevPmzUsOypead955J3DwOd16s2C6kvzWM3w6xWzTpk26/fbb9eKLL6qpqUnV1dX63e9+l+dc\nZ0eYsnjkkUf00UcfJfvVq6qq1NXVFXTbohSmLMpFmLJYtmyZbrzxRrW0tGhkZET33nuvli5dmuec\nRy9MWfzkJz/Rhg0b1NjYqNHRUf30pz9NDsqXkjvvvFMvvfSS+vv71dDQoK1bt2pk5OyOipnWmzHP\nK9EOWQBARgpmjAEAUBgIDAAAC4EBAGAhMAAALAQGIAP79u3TkiVLNDQ0pNOnT2vx4sV666238p0t\nIBLMSgIy9OMf/1hnzpzR4OCgGhoa9NBDD+U7S0AkCAxAhkZGRrRixQpdcMEFevXVV0tyexaUJ7qS\ngAz19/fr9OnTOnXqlAYHB/OdHSAytBiADN18882666679K9//UsffPCBHn/88XxnCYhEwWyJARST\n3//+96qguAyGAAAAQUlEQVSurtb69es1NjamL3zhC+rs7NTq1avznTVgwmgxAAAsjDEAACwEBgCA\nhcAAALAQGAAAFgIDAMBCYAAAWP4/JxX2wzCh4jcAAAAASUVORK5CYII=\n","text":["<matplotlib.figure.Figure at 0x3aa01d0>"]}