Skip to content
master
demos/first-order-wave-equation/
demos/first-order-wave-equation/

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

first-order-wave-equation

Simulating the first order wave equation

Nothing too interesting here. Just wasting time trying to figure out what it means to carry things all the way through and actually use scijs. So this repo implements a simple simulation of the first-order wave equation,

\frac{\partial f}{\partial t} = -c \, \frac{\partial f}{\partial x}

The equation permits a very simple solution,

f = f(x - c t).

That is, any smooth function simply translates ("is advected") to the right. The Courant-Friedrichs-Lewy (CFL) number is defined by

CFL = \frac{c \Delta t}{\Delta x}

and measures how far the solution moves in a single time step relative to the grid spacing. CFL = 1 indicates the solution moves a full grid step in each time step and defines a baseline limit of stability, though the individual methods differ.

Demos

The demos below should show a wave traveling uniformly to the right. The extent to which the high-frequency waves move more slowly than the low-frequency waves is error calledd dispersion. The tendency for the high-frequency waves to get damped out is error called dissipation. The most accurate method is RK4 + Spectral.

Methods

This repo implements solutions using the following methods in time:

and in space:

As a brief aside, compact schemes are similar to more common explicit finite differences, except they achieve a higher order of accuracy for a smaller stencil by solving for all derivatives simultaneously. The general form is [1]

\alpha f'_{i-1} + f'_i + \alpha f'_{i + 1} = c\frac{f_{i + 3} - f_{i - 3}}{6\Delta x} + b\frac{f_{i + 2} - f_{i - 2}}{4\Delta x} + a\frac{f_{i + 1} - f_{i - 1}}{2\Delta x}

This is a tridiagonal system that can be solved periodically to avoid dealing with boundary conditions.

References

Lele, S. K. (1992). Compact Finite Difference Schemes with Spectral-like Resolution. Journal of Computational Physics, 103, 16-42.

License

© 2016 Ricky Reusser. MIT License.

You can’t perform that action at this time.