Partial Differential Equation Symbols & Discretization

CS 493 Lecture, Dr. Lawlor


Discrete
Continuous
Model:
Values change instantly, at clock ticks.
Values change smoothly.
Material:
Atoms
Metal
Light:
Photons
Electromagnetic waves
Written:
Computer program
System of equations
Unit:
Expression
Partial differential equation (PDE)
Domain:
Computer Science
Applied Mathematics
Benefits:
Easy to compute.  Solutions are well-posed.
Easy to vary in space and time.  Equations always stable.
Drawbacks:
Roundoff.  Stability.  Conservation. The code!
Ill-posed problems (singularities).  The math!

One very common trick is "discretization": converting continuous equations to a discrete computer program.  In theory this is always possible due to the limit definition of continuity, although it can be a lot of work in practice.  Much less common is "continuization", recovering the continuous equations represented by a discrete program--this isn't always even possible.  For example, the discrete logistic equation oscillates in a chaotic fashion that does not match any PDE.

The key trick in discretization or continuization is to use either the definition of the derivative df/dx as a limit:
 
limx0xf(x+x)f(x)

Or you can even use a finite difference, ∆f / ∆x.  I usually use finite differences.

Here are some typical conversions.  B and C are some arbitrary quantity.

Discrete
Finite
Continous
B = (right.z - left.z) / grid_size_x;
B=∆z/∆x B = dz/dx  (or  ∂z/∂x)
C = (new.z - old.z) / dt;
C=∆z/∆t C = dz/dt
new.z = old.z + C*dt;
∆z=C*∆t C = dz/dt
P += V*dt; ∆P=V*∆t dP/dt = V

So far, so good--one dimensional quantities have simple derivatives. 

Discretizing the Shallow Water Wave Equations

Wikipedia lists the simplified velocity-based shallow water wave equations as:
 \begin{align} \frac{\partial
            u}{\partial t} - f v& = -g \frac{\partial h}{\partial x}
            - b u,\\[3pt] \frac{\partial v}{\partial t} + f u& = -g
            \frac{\partial h}{\partial y} - b v,\\[3pt] \frac{\partial
            h}{\partial t}& = - H \Bigl( \frac{\partial u}{\partial
            x} + \frac{\partial v}{\partial y} \Bigr) \end{align}
Here:
Using finite differences, it's actually not terribly hard to derive these equations from first principles.  Consider a 1D layer of thickness L meters, divided into cells of width x meters. 

Velocity to height: assume the cell to your right has a velocity difference, of ∆v meters/second.
Height to velocity: assume the cell to your right has a height difference, of ∆h meters.  You can similarly derive the official PDE by equating the pressure at the different cells.