Skip to main content

a symbolic finite element definition library

Project description

Symfem

Documentation status Style checks Run tests Coverage Status PyPI conda status

Symfem is a symbolic finite element definition library, that can be used to symbolically evaluate the basis functions of a finite element space. Symfem can:

  • Symbolically compute the basis functions of a wide range of finite element spaces
  • Symbolically compute derivatives and vector products and substitute values into functions
  • Allow the user to define their own element using the Ciarlet definition of a finite element
  • Be used to verify that the basis functions of a given space have some desired properties

Installing Symfem

Installing from sourde

Symfem can be installed by downloading the GitHub repo and running:

python3 setup.py install

Installing using pip

The latest release of Symfem can be installed by running:

pip3 install symfem

Installing using conda

The latest release of Symfem can be installed by running:

conda install symfem

Testing Symfem

To run the Symfem unit tests, clone the repository and run:

python3 -m pytest test/

You may instead like to run the following, as this will skip the slowest tests.

python3 -m pytest test/ --speed fast

Using Symfem

Finite elements can be created in Symfem using the symfem.create_element() function. For example, some elements are created in the following snippet:

import symfem

lagrange = symfem.create_element("triangle", "Lagrange", 1)
rt = symfem.create_element("tetrahedron", "Raviart-Thomas", 2)
nedelec = symfem.create_element("triangle", "N2curl", 1)
qcurl = symfem.create_element("quadrilateral", "Qcurl", 2)

The polynomial basis of an element can be obtained by calling get_polynomial_basis():

import symfem

lagrange = symfem.create_element("triangle", "Lagrange", 1)
print(lagrange.get_basis_functions())
[-x - y + 1, x, y]

Each basis function will be a Sympy symbolic expression.

Derivative of these basis functions can be computed using the functions in symfem.calculus. Vector-valued basis functions can be manipulated using the functions in symfem.vector.

The function map_to_cell can be used to map the basis functions of a finite element to a non-default cell:

import symfem

lagrange = symfem.create_element("triangle", "Lagrange", 1)
print(lagrange.get_basis_functions())
print(lagrange.map_to_cell([(0,0), (2, 0), (2, 1)]))
[-x - y + 1, x, y]
[1 - x/2, x/2 - y, y]

Further documentation

More detailed documentation of the latest release version of Symfem can be found on Read the Docs. A series of example uses of Symfem can be found in the demo folder or viewed on Read the Docs.

Details of the definition of each element can be found on DefElement alongside Symfem snippets for creating the element.

Getting help

You can ask questions about using Symfem by opening an issue with the support label. You can view previously answered questions here.

Contributing to Symfem

You can find information about how to contribute to Symfem here.

List of supported elements

Interval

  • Bernstein
  • bubble
  • discontinuous Lagrange
  • Hermite
  • Lagrange
  • Morley-Wang-Xu
  • serendipity
  • Taylor
  • vector discontinuous Lagrange
  • vector Lagrange
  • Wu-Xu

Triangle

  • Argyris
  • Arnold-Winther
  • Bell
  • Bernardi-Raugel
  • Bernstein
  • Brezzi-Douglas-Fortin-Marini
  • Brezzi-Douglas-Marini
  • bubble
  • bubble enriched Lagrange
  • bubble enriched vector Lagrange
  • conforming Crouzeix-Raviart
  • Crouzeix-Raviart
  • discontinuous Lagrange
  • Fortin-Soulie
  • Guzman-Neilan
  • Hellan-Herrmann-Johnson
  • Hermite
  • Hsieh-Clough-Tocher
  • Kong-Mulder-Veldhuizen
  • Lagrange
  • Mardal-Tai-Winther
  • matrix discontinuous Lagrange
  • Morley
  • Morley-Wang-Xu
  • Nedelec
  • Nedelec2
  • nonconforming Arnold-Winther
  • Raviart-Thomas
  • reduced Hsieh-Clough-Tocher
  • Regge
  • symmetric matrix discontinuous Lagrange
  • Taylor
  • transition
  • vector discontinuous Lagrange
  • vector Lagrange
  • Wu-Xu

Quadrilateral

  • Bogner-Fox-Schmit
  • Brezzi-Douglas-Fortin-Marini
  • bubble
  • direct serendipity
  • discontinuous Lagrange
  • dQ
  • matrix discontinuous Lagrange
  • NCE
  • NCF
  • Q
  • serendipity
  • serendipity Hcurl
  • serendipity Hdiv
  • symmetric matrix discontinuous Lagrange
  • vector discontinuous Lagrange
  • vector Q

Tetrahedron

  • Bernardi-Raugel
  • Bernstein
  • Brezzi-Douglas-Fortin-Marini
  • Brezzi-Douglas-Marini
  • bubble
  • Crouzeix-Raviart
  • discontinuous Lagrange
  • Guzman-Neilan
  • Hermite
  • Kong-Mulder-Veldhuizen
  • Lagrange
  • Mardal-Tai-Winther
  • matrix discontinuous Lagrange
  • Morley-Wang-Xu
  • Nedelec
  • Nedelec2
  • Raviart-Thomas
  • Regge
  • symmetric matrix discontinuous Lagrange
  • Taylor
  • transition
  • vector discontinuous Lagrange
  • vector Lagrange
  • Wu-Xu

Hexahedron

  • Brezzi-Douglas-Duran-Fortin
  • Brezzi-Douglas-Fortin-Marini
  • bubble
  • discontinuous Lagrange
  • dQ
  • matrix discontinuous Lagrange
  • NCE
  • NCF
  • Q
  • serendipity
  • serendipity Hcurl
  • serendipity Hdiv
  • symmetric matrix discontinuous Lagrange
  • vector discontinuous Lagrange
  • vector Q

Prism

  • Lagrange
  • Nedelec

Pyramid

  • Lagrange

Dual polygon

  • Buffa-Christiansen
  • dual
  • rotated Buffa-Christiansen

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

symfem-2021.8.1.tar.gz (51.2 kB view hashes)

Uploaded Source

Built Distribution

symfem-2021.8.1-py3-none-any.whl (72.1 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