Skip to main content
The mesh defines how each domain in the battery geometry is divided into discrete cells. PyBaMM provides several 1D submesh types with different node distributions, plus a 2D submesh for current-collector problems.

pybamm.Mesh

dict
required
Geometry dictionary produced by e.g. pybamm.battery_geometry() after calling param.process_geometry(geometry).
dict
required
Maps domain name → submesh class or MeshGenerator instance. Example:
dict
required
Maps spatial variable → number of cell-centre nodes. Can use variable objects or name strings as keys:

pybamm.MeshGenerator

A thin wrapper that pairs a submesh class with any extra keyword arguments needed at construction time.

Submesh Types

Uniform1DSubMesh

Uniformly spaced nodes across the domain.
Best for homogeneous domains with no boundary layers.

Exponential1DSubMesh

Exponentially stretched nodes — concentrated near one or both boundaries.
str
default:"\"symmetric\""
Which boundary to cluster near: "left", "right", or "symmetric".
float
default:"1.15 (symmetric) / 2.3 (left or right)"
Stretching factor α. As node count → ∞, the ratio of largest to smallest cell → exp(α).

Chebyshev1DSubMesh

Nodes placed at Chebyshev collocation points on (a, b), clustered near both boundaries.
Useful when you need polynomial interpolation properties or are solving with spectral methods.

UserSupplied1DSubMesh

Use your own array of edge locations.

Uniform2DSubMesh

Uniform 2D mesh for current-collector domains. Requires ScikitFiniteElement as the corresponding spatial method.

Controlling Resolution with var_pts

The var_pts dictionary is the primary knob for trading accuracy against speed:
String keys are also accepted: