Skip to main content

A small package including a one-dimensional well-balanced Shallow Water Equations solver.

Project description

Shallow Water Equations Solver

This package provides a well-balanced solver for the one-dimensional Saint-Venant equations, based on the principles outlined in this paper.

Usage

To utilize this package, you can call the `SWE_Plot`` function with the following parameters:

h, u = SWE_Plot(B, h0, u0, Nx, tEnd, times, g=1, method='C')

Parameters:

  • B (callable): Bottom topography function. This function defines the topographic profile and should take spatial coordinates as input and return the bottom elevation at those coordinates. In case of method 'A', should be an array of two callables, representing B and its derivative.
  • h0 (array): Initial water height profile. This should be an array of length Nx, representing the initial water height at different spatial locations.
  • u0 (array): Initial water velocity profile. Similar to h0, this should be an array of length Nx, representing the initial water velocity at different spatial locations.
  • Nx (int): Number of spatial grid points.
  • tEnd (float): End time of the simulation. The simulation starts at time t=0.
  • times (list): List of time points at which you want to visualize the results.
  • g (float, optional): Gravitational constant. Default is 1.
  • method (str, optional): Method selection ('A', 'B' or 'C'). Default is 'C'.

Returns:

  • h (array): Array containing the water height profile at the final time point.
  • u (array): Array containing the water velocity profile at the final time point.

Example:

B = lambda x: 1
f = lambda T: 1 + sqrt(3) / (1 - erf(-0.5 / 0.1)) * (erf((T - 0.5) / 0.1) - erf (-0.5 / 0.1))
h0 = [f(_/ (Nx-1)) for _ in range(Nx)]
u0 = [2.0 / h0[_] for _ in range(Nx)]
_ = SWE_Plot(B, h0, u0, Nx=100, tEnd=1.0, times=[0.0, 0.1, 0.5, 1.0])

In this example, we're using a spatial grid with 100 points, running the simulation up to t=1 seconds, with gravitational constant g=1 (default value), and visualizing the results at times 0.0, 0.1, 0.5 and 1.0 seconds using method 'C'.

This produces the result in the following figure.

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

SWE_Solver-0.0.3.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

SWE_Solver-0.0.3-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file SWE_Solver-0.0.3.tar.gz.

File metadata

  • Download URL: SWE_Solver-0.0.3.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SWE_Solver-0.0.3.tar.gz
Algorithm Hash digest
SHA256 84a9bdf279c2166272cc2f826400223f663e1925bb76a38ae05f0fbcb834f4ec
MD5 541d557c298678e91ae7604e2d4b70d5
BLAKE2b-256 eeee80dd21bf5ca2e94f0585b1a8c5cbf85b974b8b41b3dbafccddb4354a9abf

See more details on using hashes here.

File details

Details for the file SWE_Solver-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: SWE_Solver-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for SWE_Solver-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 125971f4f0febc9aa53e82c1b7a8e8548cf9a81ee24087779d5b97b2a9411a8f
MD5 96f8d33032c90a9338ca908fab620f6a
BLAKE2b-256 443427c9663901669d7ad05f8fe90e7f92b8c68c8819c1f5822f171d4007f974

See more details on using hashes here.

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