Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 1.31 KB

README.md

File metadata and controls

43 lines (26 loc) · 1.31 KB

Synopsis

pysws is a simple python script for solving the shallow water equations in a doubly-periodic geometry. The method is based on the Fourier pseudospectral method (see Spectral Methods in Matlab by L.N. Trefethen).

Code Example

pysws illustrates how simple it is to do Matlab-type computations with numpy. Here is an example from the code where a gradient is calculated with Discrete Fourier transforms.

# Declare background depth profile.
background_depth = CONST_DEPTH - 3.0*np.exp(-np.square((x - 0.5*LX)/(LX/5.0)))

# Compute bed slopes.
background_depth_xderiv = np.real(ifft(1.j*k*fft(background_depth, axis=1), axis=1))
background_depth_yderiv = np.real(ifft(1.j*l*fft(background_depth, axis=0), axis=0))

Motivation

This project exists a spin-off from my Ph.D. thesis, that involved a lot of work with Shallow Water-type equations in two dimenions.

Installation and Running

  1. Install dependencies (python2.7, numpy, matplotlib).
  2. Download the source.
  3. Run with python pysws.py.
  4. Start playing with the source code!

Tests

The code's current architecture doesn't support automated unit testing, but I'm hoping to contribute a second implementation soon.

Screenshot

Screenshot

Contributors

Derek Steinmoeller

License

Licensed under the MIT license.