Symfem

Symfem: a symbolic finite element definition library - Published in JOSS (2021)

https://github.com/mscroggs/symfem

Science Score: 100.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
    1 of 6 committers (16.7%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

finite-elements symbolic-algebra

Keywords from Contributors

standardization
Last synced: 4 months ago · JSON representation ·

Repository

A symbolic finite element definition library

Basic Info
  • Host: GitHub
  • Owner: mscroggs
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 2.59 MB
Statistics
  • Stars: 64
  • Watchers: 4
  • Forks: 12
  • Open Issues: 18
  • Releases: 53
Topics
finite-elements symbolic-algebra
Created about 5 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security Codemeta

README.md

Symfem

| | Badges | | --- | :---: | | Documentation | Documentation status | | Testing & coverage | Style checks Run tests Coverage Status DefElement: used as verification baseline | | Packages | PyPI conda | | Paper | DOI |

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

You can find details of recent changes to Symfem in the changelog.

Installing Symfem

Installing from source using pip

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

bash pip3 install .

You may also use -e to install in editable mode:

bash pip3 install -e .

Installing from PyPI using pip

The latest release of Symfem can be installed by running:

bash pip3 install symfem

Installing using conda

The latest release of Symfem can be installed by running:

bash conda install -c conda-forge symfem

Testing Symfem

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

bash python3 -m pytest test/

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

bash 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:

```python import symfem

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

The basis functions of an element can be obtained by calling get_basis_functions():

```python

lagrange = symfem.createelement("triangle", "Lagrange", 1) print(lagrange.getbasis_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.functions.

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

```python

lagrange = symfem.createelement("triangle", "Lagrange", 1) print(lagrange.getbasisfunctions()) print(lagrange.mapto_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 using GitHub Discussions. Bugs can be reported using the GitHub issue tracker.

Contributing to Symfem

Reporting bugs

If you find a bug in Symfem, please report it on the issue tracker.

Suggesting enhancements

If you want to suggest a new feature or an improvement of a current feature, you can submit this on the issue tracker.

Adding a new element

If you want to add a new element to Symfem, take a look at the Adding an element guide.

Submitting a pull request

If you want to directly submit code to Symfem, you can do this by forking the Symfem repo, then submitting a pull request. If you want to contribute, but are unsure where to start, have a look at the issues labelled "good first issue".

On opening a pull request, unit tests and flake8 style checks will run. You can click on these in the pull request to see where (if anywhere) there are errors in your code.

Code of conduct

We expect all our contributors to follow the Contributor Covenant. Any unacceptable behaviour can be reported to Matthew (symfem@mscroggs.co.uk).

Available cells and elements

Interval

The reference interval has vertices (0,) and (1,). Its sub-entities are numbered as follows.

The numbering of a reference interval

List of supported elements

  • Bernstein (alternative names: Bernstein-Bezier)
  • bubble
  • dPc
  • enriched Galerkin (alternative names: EG)
  • Hermite
  • Lagrange (alternative names: P)
  • Morley-Wang-Xu (alternative names: MWX)
  • P1-iso-P2 (alternative names: P2-iso-P1, iso-P2 P1)
  • serendipity (alternative names: S)
  • Taylor (alternative names: discontinuous Taylor)
  • vector Lagrange (alternative names: vP)
  • Wu-Xu

Triangle

The reference triangle has vertices (0, 0), (1, 0), and (0, 1). Its sub-entities are numbered as follows.

The numbering of a reference triangle

List of supported elements

  • Alfeld-Sorokina (alternative names: AS)
  • Argyris
  • Arnold-Winther (alternative names: AW, conforming Arnold-Winther)
  • Bell
  • Bernardi-Raugel
  • Bernstein (alternative names: Bernstein-Bezier)
  • Brezzi-Douglas-Fortin-Marini (alternative names: BDFM)
  • Brezzi-Douglas-Marini (alternative names: BDM, N2div)
  • bubble
  • bubble enriched Lagrange
  • bubble enriched vector Lagrange
  • conforming Crouzeix-Raviart (alternative names: conforming CR)
  • Crouzeix-Raviart (alternative names: CR, Crouzeix-Falk, CF)
  • enriched Galerkin (alternative names: EG)
  • enriched vector Galerkin (alternative names: locking-free enriched Galerkin, LFEG)
  • Fortin-Soulie (alternative names: FS)
  • Gopalakrishnan-Lederer-Schoberl (alternative names: GLS)
  • Guzman-Neilan first kind (alternative names: Guzman-Neilan)
  • Guzman-Neilan second kind
  • Hellan-Herrmann-Johnson (alternative names: HHJ)
  • Hermite
  • Hsieh-Clough-Tocher (alternative names: Clough-Tocher, HCT, CT)
  • Kong-Mulder-Veldhuizen (alternative names: KMV)
  • Lagrange (alternative names: P)
  • Mardal-Tai-Winther (alternative names: MTW)
  • matrix Lagrange
  • Morley
  • Morley-Wang-Xu (alternative names: MWX)
  • Nedelec (alternative names: Nedelec1, N1curl)
  • Nedelec2 (alternative names: N2curl)
  • nonconforming Arnold-Winther (alternative names: nonconforming AW)
  • P1 macro
  • P1-iso-P2 (alternative names: P2-iso-P1, iso-P2 P1)
  • Raviart-Thomas (alternative names: RT, N1div)
  • reduced Hsieh-Clough-Tocher (alternative names: rHCT)
  • Regge
  • symmetric matrix Lagrange
  • Taylor (alternative names: discontinuous Taylor)
  • transition
  • vector Lagrange (alternative names: vP)
  • Wu-Xu

Quadrilateral

The reference quadrilateral has vertices (0, 0), (1, 0), (0, 1), and (1, 1). Its sub-entities are numbered as follows.

The numbering of a reference quadrilateral

List of supported elements

  • Arbogast-Correa (alternative names: AC, AC full, Arbogast-Correa full)
  • Arnold-Boffi-Falk (alternative names: ABF)
  • Bogner-Fox-Schmit (alternative names: BFS)
  • Brezzi-Douglas-Fortin-Marini (alternative names: BDFM)
  • bubble
  • direct serendipity
  • dPc
  • enriched Galerkin (alternative names: EG)
  • enriched vector Galerkin (alternative names: locking-free enriched Galerkin, LFEG)
  • Huang-Zhang (alternative names: HZ)
  • NCE (alternative names: RTCE, Qcurl, Nedelec, Ncurl)
  • NCF (alternative names: RTCF, Qdiv)
  • P1-iso-P2 (alternative names: P2-iso-P1, iso-P2 P1)
  • Q (alternative names: Lagrange, P)
  • Rannacher-Turek
  • Regge
  • serendipity (alternative names: S)
  • serendipity Hcurl (alternative names: Scurl, BDMCE, AAE)
  • serendipity Hdiv (alternative names: Sdiv, BDMCF, AAF)
  • tiniest tensor (alternative names: TNT)
  • tiniest tensor Hcurl (alternative names: TNTcurl)
  • tiniest tensor Hdiv (alternative names: TNTdiv)
  • trimmed serendipity Hcurl (alternative names: TScurl)
  • trimmed serendipity Hdiv (alternative names: TSdiv)
  • vector dPc
  • vector Q (alternative names: vQ)

Tetrahedron

The reference tetrahedron has vertices (0, 0, 0), (1, 0, 0), (0, 1, 0), and (0, 0, 1). Its sub-entities are numbered as follows.

The numbering of a reference tetrahedron

List of supported elements

  • Bernardi-Raugel
  • Bernstein (alternative names: Bernstein-Bezier)
  • Brezzi-Douglas-Fortin-Marini (alternative names: BDFM)
  • Brezzi-Douglas-Marini (alternative names: BDM, N2div)
  • bubble
  • Crouzeix-Raviart (alternative names: CR, Crouzeix-Falk, CF)
  • enriched Galerkin (alternative names: EG)
  • enriched vector Galerkin (alternative names: locking-free enriched Galerkin, LFEG)
  • Gopalakrishnan-Lederer-Schoberl (alternative names: GLS)
  • Guzman-Neilan first kind (alternative names: Guzman-Neilan)
  • Guzman-Neilan second kind
  • Hellan-Herrmann-Johnson (alternative names: HHJ)
  • Hermite
  • Kong-Mulder-Veldhuizen (alternative names: KMV)
  • Lagrange (alternative names: P)
  • Mardal-Tai-Winther (alternative names: MTW)
  • matrix Lagrange
  • Morley-Wang-Xu (alternative names: MWX)
  • Nedelec (alternative names: Nedelec1, N1curl)
  • Nedelec2 (alternative names: N2curl)
  • Raviart-Thomas (alternative names: RT, N1div)
  • Regge
  • symmetric matrix Lagrange
  • Taylor (alternative names: discontinuous Taylor)
  • transition
  • vector Lagrange (alternative names: vP)
  • Wu-Xu

Hexahedron

The reference hexahedron has vertices (0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), (0, 0, 1), (1, 0, 1), (0, 1, 1), and (1, 1, 1). Its sub-entities are numbered as follows.

The numbering of a reference hexahedron

List of supported elements

  • Brezzi-Douglas-Duran-Fortin (alternative names: BDDF)
  • Brezzi-Douglas-Fortin-Marini (alternative names: BDFM)
  • bubble
  • dPc
  • enriched Galerkin (alternative names: EG)
  • enriched vector Galerkin (alternative names: locking-free enriched Galerkin, LFEG)
  • NCE (alternative names: RTCE, Qcurl, Nedelec, Ncurl)
  • NCF (alternative names: RTCF, Qdiv)
  • Q (alternative names: Lagrange, P)
  • Rannacher-Turek
  • Regge
  • serendipity (alternative names: S)
  • serendipity Hcurl (alternative names: Scurl, BDMCE, AAE)
  • serendipity Hdiv (alternative names: Sdiv, BDMCF, AAF)
  • tiniest tensor (alternative names: TNT)
  • tiniest tensor Hcurl (alternative names: TNTcurl)
  • tiniest tensor Hdiv (alternative names: TNTdiv)
  • trimmed serendipity Hcurl (alternative names: TScurl)
  • trimmed serendipity Hdiv (alternative names: TSdiv)
  • vector dPc
  • vector Q (alternative names: vQ)

Prism

The reference prism has vertices (0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), and (0, 1, 1). Its sub-entities are numbered as follows.

The numbering of a reference prism

List of supported elements

  • Lagrange (alternative names: P)
  • Nedelec (alternative names: Ncurl)

Pyramid

The reference pyramid has vertices (0, 0, 0), (1, 0, 0), (0, 1, 0), (1, 1, 0), and (0, 0, 1). Its sub-entities are numbered as follows.

The numbering of a reference pyramid

List of supported elements

  • Lagrange (alternative names: P)

Dual polygon

The reference dual polygon (hexagon example shown) has vertices (1, 0), (3/4, sqrt(3)/4), (1/2, sqrt(3)/2), (0, sqrt(3)/2), (-1/2, sqrt(3)/2), (-3/4, sqrt(3)/4), (-1, 0), (-3/4, -sqrt(3)/4), (-1/2, -sqrt(3)/2), (0, -sqrt(3)/2), (1/2, -sqrt(3)/2), and (3/4, -sqrt(3)/4). Its sub-entities are numbered as follows.

The numbering of a reference dual polygon

List of supported elements

  • Buffa-Christiansen (alternative names: BC)
  • dual polynomial (alternative names: dual P, dual)
  • rotated Buffa-Christiansen (alternative names: RBC)

Owner

  • Name: Matthew Scroggs
  • Login: mscroggs
  • Kind: user
  • Location: King's Lynn

JOSS Publication

Symfem: a symbolic finite element definition library
Published
August 24, 2021
Volume 6, Issue 64, Page 3556
Authors
Matthew W. Scroggs ORCID
Department of Engineering, University of Cambridge
Editor
Nikoleta Glynatsi ORCID
Tags
finite element method basis functions symbolic algebra numerical analysis

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you use this software, please cite it as below.
authors:
  - family-names: Scroggs
    given-names: Matthew W.
    orcid: 0000-0002-4658-2443
title: Symfem
version: 2025.6.0
date-released: 2025-06-09
license: MIT
url: https://github.com/mscroggs/symfem
preferred-citation:
  type: article
  authors:
  - family-names: Scroggs
    given-names: Matthew W.
    orcid: https://orcid.org/0000-0002-4658-2443
  doi: 10.21105/joss.03556
  journal: Journal of Open Source Software
  title: "Symfem: a symbolic finite element definition library"
  volume: 6
  issue: 64
  start: 3556
  month: 8
  year: 2021

CodeMeta (codemeta.json)

{
  "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld",
  "@type": "Code",
  "author": [
    {
      "@id": "0000-0002-4658-2443",
      "@type": "Person",
      "email": "mws48@cam.ac.uk",
      "name": "Matthew Scroggs",
      "affiliation": "Department of Engineering, University of Cambridge"
    }
  ],
  "identifier": "",
  "codeRepository": "https://github.com/mscroggs/symfem",
  "datePublished": "2021-01-23",
  "dateModified": "2025-11-04",
  "dateCreated": "2021-01-23",
  "description": "A symbolic finite element definition library",
  "keywords": "Python, finite element method, numerical analysis",
  "license": "MIT",
  "title": "Symfem",
  "version": "2025.11.0"
}

GitHub Events

Total
  • Create event: 23
  • Release event: 3
  • Issues event: 7
  • Watch event: 13
  • Delete event: 15
  • Issue comment event: 6
  • Push event: 87
  • Pull request event: 36
  • Pull request review event: 4
  • Pull request review comment event: 4
  • Fork event: 2
Last Year
  • Create event: 23
  • Release event: 3
  • Issues event: 7
  • Watch event: 13
  • Delete event: 15
  • Issue comment event: 6
  • Push event: 87
  • Pull request event: 36
  • Pull request review event: 4
  • Pull request review comment event: 4
  • Fork event: 2

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 744
  • Total Committers: 6
  • Avg Commits per committer: 124.0
  • Development Distribution Score (DDS): 0.101
Past Year
  • Commits: 46
  • Committers: 2
  • Avg Commits per committer: 23.0
  • Development Distribution Score (DDS): 0.087
Top Committers
Name Email Commits
Matthew Scroggs m****s@g****m 669
Finite element bot 7****t 60
github-actions[bot] 4****] 12
anzil a****l 1
Sigvald Marholm m****m@m****m 1
Nuno Nobre n****e@s****k 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 51
  • Total pull requests: 158
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 7 days
  • Total issue authors: 4
  • Total pull request authors: 8
  • Average comments per issue: 0.24
  • Average comments per pull request: 0.63
  • Merged pull requests: 146
  • Bot issues: 0
  • Bot pull requests: 20
Past Year
  • Issues: 9
  • Pull requests: 41
  • Average time to close issues: 14 days
  • Average time to close pull requests: 11 days
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 0.56
  • Average comments per pull request: 0.07
  • Merged pull requests: 35
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • mscroggs (44)
  • stefanhiemer (2)
  • zolabar (1)
  • avieira (1)
Pull Request Authors
  • mscroggs (129)
  • github-actions[bot] (23)
  • symfembot (14)
  • anzil (3)
  • sigvaldm (2)
  • nmnobre (2)
  • UZerbinati (1)
  • jmv2009 (1)
Top Labels
Issue Labels
enhancement (36) bug (10) new element (8) housekeeping (2) documentation (2)
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 756 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 63
  • Total maintainers: 1
pypi.org: symfem

a symbolic finite element definition library

  • Versions: 54
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 756 Last month
Rankings
Dependent packages count: 10.0%
Downloads: 10.7%
Average: 14.1%
Dependent repos count: 21.7%
Maintainers (1)
Last synced: 4 months ago
conda-forge.org: symfem

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

  • Versions: 9
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent repos count: 34.0%
Stargazers count: 43.7%
Average: 44.6%
Forks count: 49.6%
Dependent packages count: 51.2%
Last synced: 4 months ago

Dependencies

docs/requirements.txt pypi
  • sphinx-autoapi *
setup.py pypi
  • sympy *
.github/workflows/check-version-numbers.yml actions
  • actions/checkout master composite
.github/workflows/coveralls.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/defelement.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/push-packages.yml actions
  • actions/checkout master composite
  • actions/setup-python v1 composite
  • pypa/gh-action-pypi-publish master composite
.github/workflows/run-tests.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/style-checks.yml actions
  • actions/checkout v3 composite
.github/workflows/test-packages.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • conda-incubator/setup-miniconda v2 composite