Skip to main content

A CFD python package for the shallow water equations

Project description

MattFlow

MattFlow is a CFD python package for the shallow water equations.
It simulates drops or stones falling on the surface of the water.


requirements os
python 3 GNU/Linux
numpy 1.16.4 Windows
matplotlib 3.1.1
ffmpeg (optional)

How to run MattFlow

  1. pip
$ mkdir mattflow
$ cd mattflow
$ pip install numpy matplotlib
$ pip install mattflow
$ mattflow
  1. venv (python>=3.3)
$ mkdir mattflow
$ cd mattflow
$ python3 -m venv mattflow_env
$ source mattflow_env/bin/activate
$ pip install numpy matplotlib
$ pip install mattflow
$ mattflow
  1. anaconda environment
    (this is prefered, because anaconda handles low level libs required from matplotib animation)
$ conda create --name mattflow pip numpy matplotlib
$ conda activate mattflow
$ mkdir mattflow
$ cd mattflow
$ pip install mattflow
$ mattflow

Swallow Water Equations

SWE is a simpified CFD problem which models the surface of the water, with the
assumption that the horizontal length scale is much greater than the vertical
length scale.

SWE is a coupled system of 3 hyperbolic partial deferential equations, that
derive from conservation of mass and conservation of linear momentum (Navier-
Stokes) equations, in case of a horizontal steam bed, with no Coriolis, frictional
or viscours forces (wiki).

{\displaystyle {\begin{aligned}{\frac {\partial (\rho \eta )}{\partial t}}&+{\frac {\partial (\rho \eta u)}{\partial x}}+{\frac {\partial (\rho \eta v)}{\partial y}}=0,\\[3pt]{\frac {\partial (\rho \eta u)}{\partial t}}&+{\frac {\partial }{\partial x}}\left(\rho \eta u^{2}+{\frac {1}{2}}\rho g\eta ^{2}\right)+{\frac {\partial (\rho \eta uv)}{\partial y}}=0,\\[3pt]{\frac {\partial (\rho \eta v)}{\partial t}}&+{\frac {\partial (\rho \eta uv)}{\partial x}}+{\frac {\partial }{\partial y}}\left(\rho \eta v^{2}+{\frac {1}{2}}\rho g\eta ^{2}\right)=0.\end{aligned}}}

where:
η : height
u : velocity along the x axis
υ : velocity along the y axis
ρ : density
g : gravity acceleration

MattFlow structure

  1. configuration of the simulation via a config file
  2. pre-process
    structured/cartesian mesh
  3. solution
    supported solvers:
    • Lax-Friedrichs Reiman    | O(Δt, Δx2, Δy2)
    • 2-stage Rugne-Kutta       | O(Δt2, Δx2, Δy2)  | default
    • MacCormack         | O(Δt2, Δx2, Δy2)  | experimental
  4. post-processing
    matplotlib animation

Additional configurations

  • mesh sizing
  • domain sizing
  • simulation mode (single drop, multiple drops, rain)
  • solver
  • boundary conditions (currently: reflective)
  • plotting style
  • animation options

Currently, you can configure the simulation at the config file

TODO

  1. mattflow_exceptions
  2. tests
  3. Simple API to configure the simulation
  4. Implementation of higher order schemes
  5. Addition of source terms
  6. Addition of viscous models
  7. Support moving objects inside the domain
  8. Unstructured mesh
  9. Extent to 3D CFD

Start the flow!

(C) 2019, Thanasis Mattas
atmattas@physics.auth.gr

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mattflow-1.0.3.tar.gz (16.0 kB view hashes)

Uploaded Source

Built Distribution

mattflow-1.0.3-py3-none-any.whl (33.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page