Python API

Python API#

One page per layer, in the order of the import graph: symbolic, discrete, solvers, post-processing and plotting, the models built on them, and the models of electrochemistry built on those.

Finite element models written as summable components, on FEniCSx.

The generic framework has three layers, imported as subpackages:

  • sumfem.symbolic, the symbolic description, without mesh data: domains, fields, parameters, residuals and functionals, systems of equations, sequences of stages, time derivatives, boundary conditions, transfers and dimensional analysis.

  • sumfem.discrete, which binds them to meshes: discretizations, and the discrete systems and boundary conditions.

  • sumfem.solvers, which solves the discrete systems, and steps them in time.

The names users need most are exported here too, so that a model can be written with import sumfem alone:

import sumfem

domain = sumfem.Domain("square", "triangle")
u = sumfem.Field("u", domain, ("Lagrange", 1))

Where a symbolic and a discrete class share a name, such as System or DirichletBC, the symbolic one is exported.

The model families are in sumfem.models, and models of electrochemistry, built on them, in sumfem.electrochemistry.

Post-processing, such as integrals, norms and errors against exact solutions, is in sumfem.post_processing, and plotting with PyVista in sumfem.plotting, which are imported on their own.