1+1-D Linear Advection Demo

MSSRC

1 The Problem

The linear advection equation is

$\displaystyle \bar{u}_{t}^{}$ + A$\displaystyle \bar{u}_{x}^{}$ = 0
where
$\displaystyle \bar{u}$ : $\displaystyle \mathbbm$R×R$\displaystyle \to$$\displaystyle \mathbbm$Rn
and A is an n×n matrix with real entries. The Cauchy problem asks for the solution $ \bar{u}$ given the initial function
$\displaystyle \bar{u}_{0}^{}$(x) = $\displaystyle \bar{u}$(x, 0).
It is well known that when n = 1, so that the matrix A has only one entry a, the unique solution u is
u(x, t) = u0(x - at).
It is possible to construct the solution for general n if it is assumed that A has real eigenvalues $ \lambda_{1}^{}$,...,$ \lambda_{n}^{}$ with corresponding eigenvalues v1,..., vn that are linearly independent. With this hypothesis, the matrix P whose ith column is vi is invertible and
P-1AP = D
where D is diagonal with entries $ \lambda_{1}^{}$,...,$ \lambda_{n}^{}$. Setting
$\displaystyle \bar{w}$ = P-1$\displaystyle \bar{u}$
so that $ \bar{u}$ = P$ \bar{w}$, we have
P-1$\displaystyle \bar{u}_{t}^{}$ + P-1A$\displaystyle \bar{u}_{x}^{}$ = 0
i.e.
$\displaystyle \bar{w}_{t}^{}$ + P-1AP$\displaystyle \bar{w}_{x}^{}$ = 0
or
$\displaystyle \bar{w}_{t}^{}$ + D$\displaystyle \bar{w}_{x}^{}$ = 0.
This completely decouples the equations into n one-dimensional advection equations and hence the solution is
$\displaystyle \bar{y}$(x, t) = $\displaystyle \left[\vphantom{\begin{array}{c} w^1_0(x-\lambda_1 t) \ \vdots \ w^n_0(x-\lambda_n t) \ \end{array}}\right.$ $\displaystyle \begin{array}{c} w^1_0(x-\lambda_1 t) \ \vdots \ w^n_0(x-\lambda_n t) \ \end{array}$ $\displaystyle \left.\vphantom{\begin{array}{c} w^1_0(x-\lambda_1 t) \ \vdots \ w^n_0(x-\lambda_n t) \ \end{array}}\right]$
where wi0(x) = P-1$ \bar{u}$(x, 0). The desired solution is therefore
$\displaystyle \bar{u}$ = P$\displaystyle \bar{y}$.

2 The Demo

ExprLib will be used to solve the linear advection equation given by the 2×2 matrix

A = $\displaystyle \left[\vphantom{\begin{array}{cc} a & b \ b & a \end{array}}\right.$ $\displaystyle \begin{array}{cc} a & b \ b & a \end{array}$ $\displaystyle \left.\vphantom{\begin{array}{cc} a & b \ b & a \end{array}}\right]$
and initial function
u10u20.
It is assumes that u10 and u20 are expressions in x (in the sense of ExprLib) and that a and b are expressions that do not contain the variables x or t, i.e. are constant in x and t. Thus we will be solving the system of PDEs
$\displaystyle {\frac{{\partial u^1}}{{\partial t}}}$ = a$\displaystyle {\frac{{\partial u^1}}{{\partial x}}}$ + b$\displaystyle {\frac{{\partial u^2}}{{\partial x}}}$  
     
$\displaystyle {\frac{{\partial u^2}}{{\partial t}}}$ = b$\displaystyle {\frac{{\partial u^1}}{{\partial x}}}$ + a$\displaystyle {\frac{{\partial u^2}}{{\partial x}}}$  

Make sure that u_0^1 and u_0^2 are functions of x only.

Make sure that a and b are free of x and t.