# 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:

lim x 0 xf(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:
• (u,v) is the fluid's 2D velocity (meters/second).  The key assumption in shallow-water work is the velocity is constant throughout the fluid column--that is, vertical velocities are small enough to ignore.
• h is the current vertical deviation in fluid height from the mean (meters).
• H is the mean fluid height above the bottom (meters).
• b is the viscous drag coefficient (1/seconds).  I prefer to stabilize the solution with artificial diffusion instead of using drag.
• f is the Coriolis coefficient (1/seconds); this is zero for a non-rotating frame of reference.
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.
• The interface between cells has surface area H L square meters.
• A flow rate of ∆v meters/second moves by ∆v ∆t meters in one timestep of size ∆t seconds.
• The volume flowing across the interface is thus ∆v ∆t H L cubic meters.
• This volume needs to go somewhere (conservation of volume), so your cell gets taller.
• The top of your cell has area ∆x L square meters.
• Adding a height of ∆h to your cell thus has a volume of ∆h ∆x L cubic meters.
• Since the volume flowing in equals the volume caused height change, ∆h ∆x L = - ∆v ∆t H L.
• L cancels out.
• ∆h / ∆t = - ∆v / ∆x H
• This is the bottom equation above.
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.