Giter VIP home page Giter VIP logo

shallow-water-sim's Introduction

shallow-water-sim

A shallow water simulator in a rectangular tub that uses the Navier-Stokes Equations to create an animation of how the surface of the water will move over time when given the initial state of the surface of the water.

Outline

1 - Explanation of Inputs

The calculations for the simulation as well as the function that does the calculations is contained in the 'shallow_water_simulation.py' file. The function that performs the calculation is shallow_water_simulation. It takes in the parameters (Lx, Ly, T, eps, dx, dy, dt, init_cond, H), where

  • Lx: The width of the rectangular tub in meters.
  • Ly: The length of the rectangular tub in meters.
  • T: The total duration of the simulation in seconds (i.e. the simulation will show how the surface of the water behaves from t=0 to t=T).
  • eps: The smoothing parameter. This determines how smoothed out the waves are after every calculation. This makes it so that the waves in the animation look smooth rather than jagged. Note that eps is short for epsilon.
  • dx: Step size for the horizontal spatial dimension. Splits the grid into N = Lx/dx number of cells horizontally. Program calculates surface height at every grid point.
  • dy: Step size for the vertical spatial dimension. Splits the grid into M = Ly/dy number of cells vertically.
  • dt: Step size for the time dimension. Program calculates the state of the surface of the water after every time step from t=0 to t=T.
  • init_cond: A numpy array containing the initial state of the surface of the water. It is an array containing 3 arrays in the form init_cond = [u_0, v_0, eta_init]. Each of the following arrays has M rows and N columns so that there are N elements horizontally and M elements vertically:
    • u_0: Contains the horizontal component of the velocity of the water at each grid point.
    • v_0: Contains the vertical component of the velocity of the water at each grid point.
    • eta_init: Contains the height of the water at each grid point.
  • H: The bathymetry function. I.e., this is a function that returns the height (and thus the shape) of the surface of the bottom of the tub.

To input the initial state and create the animation, use the Animation code and results.py file.

2 - Animations

(i) Water droplet as an input

The output of the simulation with a still water droplet (i.e., Gaussian peak) at some position in the tub initially:

animation_part_b.mp4

The same output with a different surface colouring:

animation_part_b_ver2.mp4

(ii) Water wall as an input

The output of the simulation with a still water "wall" at some position in the tub initially:

animation_part_c.mp4

The same output with a different surface colouring:

animation_part_c_ver2.mp4

Improvements to Make

  • Work on animations (fill in under the plot, reduce height of initial water droplet/wall, and make waves easier to see).
  • Combine all plot and animation code into one "create_animation" function.
  • Create a user interface where changing the input of the simulation is a lot easier/more accesible to someone not familiar with programming OR offer a range of inputs to click on.
  • Add in math & physics section for more details on how or why the values are calculated the way they are and what to expect when testing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.