from numpy import *
from scipy import linalg
from scipy.linalg import norm
from matplotlib.pyplot import *
from prettytable import PrettyTable
from timeit import default_timer as timer
import sys
sys.path.append('fncbook/')
import fncbook as FNC
# This (optional) block is for improving the display of plots.
# from IPython.display import set_matplotlib_formats
# set_matplotlib_formats("svg","pdf")
# %config InlineBackend.figure_format = 'svg'
rcParams["figure.figsize"] = [7, 4]
rcParams["lines.linewidth"] = 2
rcParams["lines.markersize"] = 4
rcParams['animation.html'] = "jshtml" # or try "html5"
The CFL criterion gives a necessary condition for convergence. It suggests, but cannot confirm, that a step size of O(h) may be adequate in the advection equation. More details emerge when we adopt the semidiscretization point of view.
be posed for x∈[0,1] and subjected to periodic end conditions. If we use the central-difference matrix Dx defined in (12.1.9) to discretize the space derivative, we get the ODE system
To apply an IVP solver, we need to compare the stability region of the solver with the eigenvalues of −cDx, as in Absolute stability. You can verify (see Exercise 12.3.1) that for m points in [0,1), these are
Two things stand out about these eigenvalues: they are purely imaginary, which is consistent with conservation of magnitude, and they extend no farther than O(m)=O(h−1) away from the origin. These characteristics suggest how to analyze the use of different time-stepping methods by referring to stability regions.
Many PDEs that conserve quantities will have imaginary eigenvalues, causing Euler and some other IVP methods to fail regardless of step size. Diffusion problems, in which the eigenvalues are negative and real, are compatible with a wider range of integrators, though possibly with onerous step size requirements due to stiffness.
The location of eigenvalues near ±ic/h also confirms what the CFL condition was suggesting. In order to use RK4, for example, whose stability region intersects the imaginary axis at around ±2.8i, the time step stability restriction is τc/h≤2.8, or τ=O(h). This is much more favorable than for diffusion, whose eigenvalues were as large as O(h−2).
The traffic flow equation (12.1.5) combines a nonlinear advection with a diffusion term. The simplest linear problem with the same feature is the advection–diffusion equation
The parameter ϵ controls the relative strength between the two mechanisms, and the eigenvalues accordingly vary between the purely imaginary ones of advection and the negative real ones of diffusion.
In a nonlinear problem, the eigenvalues come from the linearization about an exact solution, as in Stiffness.
Boundary conditions can have a dramatic effect on the eigenvalues of the semidiscretization. For instance, Example 12.2.7 solves linear advection ut=ux on [0,1] with the homogeneous inflow condition u(1,t)=0. Exclusion of the boundary node from the semidiscretization u to get the interior vector v is equivalent to
As a result, we conclude that A=EDxET is the appropriate matrix for determining the eigenvalues of the semidiscretization. More simply, we can simply delete the last row and last column from Dx.