Skip to main content

Shenfun -- Automated Spectral-Galerkin framework

Project description

https://app.codacy.com/project/badge/Grade/bd772b3ca7134651a9225d8051db8c41 https://dev.azure.com/spectralDNS/shenfun/_apis/build/status/spectralDNS.shenfun?branchName=master https://github.com/spectralDNS/shenfun/workflows/github-CI/badge.svg?branch=master https://codecov.io/gh/spectralDNS/shenfun/branch/master/graph/badge.svg https://anaconda.org/conda-forge/shenfun/badges/platforms.svg

Description

Shenfun is a high performance computing platform for solving partial differential equations (PDEs) by the spectral Galerkin method. The user interface to shenfun is very similar to FEniCS, but applications are limited to multidimensional tensor product grids, using either Cartesian or curvilinear grids (e.g., but not limited to, polar, cylindrical, spherical or parabolic). The code is parallelized with MPI through the mpi4py-fft package.

Shenfun enables fast development of efficient and accurate PDE solvers (spectral order and accuracy), in the comfortable high-level Python language. The spectral accuracy is ensured by using high-order global orthogonal basis functions (Fourier, Legendre, Chebyshev first and second kind, Ultraspherical, Jacobi, Laguerre and Hermite), as opposed to finite element codes that are using low-order local basis functions. Efficiency is ensured through vectorization (Numpy), parallelization (mpi4py) and by moving critical routines to Cython or Numba. Shenfun has been used to run turbulence simulations (Direct Numerical Simulations) on thousands of processors on high-performance supercomputers, see the spectralDNS repository.

The demo folder contains several examples for the Poisson, Helmholtz and Biharmonic equations. For extended documentation and installation instructions see ReadTheDocs. For interactive demos, see the jupyter book. Note that shenfun currently comes with the possibility to use two non-periodic directions (see biharmonic demo), and equations may be solved coupled and implicit (see MixedPoisson.py).

Note that shenfun works with curvilinear coordinates. For example, it is possible to solve equations on a sphere (using spherical coordinates), on the surface of a torus, on a Möbius strip or along any curved line in 2D/3D. Actually, any new coordinates may be defined by the user as long as the coordinates lead to a system of equations with separable coefficients. After defining new coordinates, operators like div, grad and curl work automatically with the new curvilinear coordinates. See also this notebook on the sphere or an illustration of the vector Laplacian.

The eigenvector of the 8'th smallest eigvalue on a Möbius strip Solution of Poisson's equation on a Coil Solution of Poisson's equation on a spherical shell Solution of Poisson's equation on the surface of a torus

For a more psychedelic experience, have a look at the simulation of the Ginzburg-Landau equation on the sphere (click for Youtube-video):

Ginzburg-Landau spherical coordinates

Shenfun can also be used to approximate analytical functions with global spectral basis functions, and to integrate over highly complex domains, like the seashell below, see this demo.

The surface of a seashell

Installation

Shenfun can be installed using either pip or conda, see installation chapter on readthedocs.

Dependencies

Try it in a codespace

The easiest way to try out shenfun is to create your own codespace. Press the green codespace button on this page and wait for a couple of minutes while everything in environment.yml gets installed. Then write in the terminal of the codespace editor:

source activate ./venv
python setup.py build_ext -i
echo -e "PYTHONPATH=/workspaces/shenfun" > .env

and you are set to run any of the demo programs, or for example try to follow the detailed instructions in the documentation. We assume that you know how to run a Python program. Please note that if you want to use for example IPython or Jupyter in the codespace, then these need to be installed into the venv environment.

Contact

For comments, issues, bug-reports and requests, please use the issue tracker of the current repository, or see How to contribute? at readthedocs. Otherwise the principal author can be reached at:

Mikael Mortensen
mikaem at math.uio.no
https://mikaem.github.io/
Department of Mathematics
University of Oslo
Norway

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

shenfun-4.2.1.tar.gz (1.8 MB view details)

Uploaded Source

File details

Details for the file shenfun-4.2.1.tar.gz.

File metadata

  • Download URL: shenfun-4.2.1.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for shenfun-4.2.1.tar.gz
Algorithm Hash digest
SHA256 e5f9d2223e66689718d82676ee1fb73d0cbd59487bc148daf7807fff98d1c122
MD5 65d0dedbf8069f093ff307f4459c7e00
BLAKE2b-256 4e980e84083d38855a9303d6d9b00a62363511a4be74924ba58c3ab467bc81d8

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