A class which implements the steps specific to the finite element method during discretisation. The class uses scikit-fem to discretise the problem to obtain the mass and stiffness matrices. At present, this class is only used for solving the Poisson problem -grad^2 u = f in the y-z plane (i.e. not the through-cell direction).
For broadcast we follow the default behaviour from SpatialMethod.
mesh (pybamm.Mesh
) – Contains all the submeshes for discretisation
**Extends (“”: pybamm.SpatialMethod
) –
Assembles the form of the finite element mass matrix over the domain interior or boundary.
symbol (pybamm.Variable
) – The variable corresponding to the equation for which we are
calculating the mass matrix.
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
region (str, optional) – The domain over which to assemble the mass matrix form. Can be “interior” (default) or “boundary”.
The (sparse) mass matrix for the spatial method.
Adjusts the assemled finite element matrices to account for boundary conditons.
M (scipy.sparse.coo_matrix
) – The assemled finite element matrix to adjust.
boundary (numpy.array
) – Array of the indicies which correspond to the boundary.
zero (bool, optional) – If True, the rows of M given by the indicies in boundary are set to zero. If False, the diagonal element is set to one. default is False.
Implementation of the boundary integral operator.
See pybamm.SpatialMethod.boundary_integral()
A node in the expression tree representing an integral operator over the boundary of a domain
where \(\partial a\) is the boundary of the domain, and \(u\in\text{domain boundary}\).
domain (list) – The domain(s) of the variable in the integrand
region (str) – The region of the boundary over which to integrate. If region is entire the integration is carried out over the entire boundary. If region is negative tab or positive tab then the integration is only carried out over the appropriate part of the boundary corresponding to the tab.
The finite element integral vector for the domain
Calculates the mass matrix for the finite element method assembled over the boundary.
symbol (pybamm.Variable
) – The variable corresponding to the equation for which we are
calculating the mass matrix.
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
The (sparse) mass matrix for the spatial method.
Returns the average value of the symbol over the negative tab (“negative tab”) or the positive tab (“positive tab”) in the Finite Element Method.
Overwrites the default pybamm.SpatialMethod.boundary_value()
Matrix for finite-element implementation of the definite integral over the entire domain
for where \(\Omega\) is the domain.
child (pybamm.Symbol
) – The symbol being integrated
vector_type (str, optional) – Whether to return a row or column vector (default is row)
The finite element integral vector for the domain
Matrix-vector multiplication to implement the divergence operator.
See pybamm.SpatialMethod.divergence()
Matrix-vector multiplication to implement the gradient operator. The gradient w of the function u is approximated by the finite element method using the same function space as u, i.e. we solve w = grad(u), which corresponds to the weak form w*v*dx = grad(u)*v*dx, where v is a suitable test function.
symbol (pybamm.Symbol
) – The symbol that we will take the laplacian of.
discretised_symbol (pybamm.Symbol
) – The discretised symbol of the correct size
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
A concatenation that contains the result of acting the discretised gradient on the child discretised_symbol. The first column corresponds to the y-component of the gradient and the second column corresponds to the z component of the gradient.
class: pybamm.Concatenation
Gradient matrix for finite elements in the appropriate domain.
symbol (pybamm.Symbol
) – The symbol for which we want to calculate the gradient matrix
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
The (sparse) finite element gradient matrix for the domain
Multiplication to implement the inner product of the gradient operator
with itself. See pybamm.SpatialMethod.gradient_squared()
Implementation of the indefinite integral operator. The
input discretised child must be defined on the internal mesh edges.
See pybamm.SpatialMethod.indefinite_integral()
Vector-vector dot product to implement the integral operator.
See pybamm.SpatialMethod.integral()
Matrix-vector multiplication to implement the laplacian operator.
symbol (pybamm.Symbol
) – The symbol that we will take the laplacian of.
discretised_symbol (pybamm.Symbol
) – The discretised symbol of the correct size
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
Contains the result of acting the discretised gradient on the child discretised_symbol
class: pybamm.Array
Calculates the mass matrix for the finite element method.
symbol (pybamm.Variable
) – The variable corresponding to the equation for which we are
calculating the mass matrix.
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
The (sparse) mass matrix for the spatial method.
Creates a discretised spatial variable compatible with the FiniteElement method.
symbol (pybamm.SpatialVariable
) – The spatial variable to be discretised.
Contains the discretised spatial variable
Laplacian (stiffness) matrix for finite elements in the appropriate domain.
symbol (pybamm.Symbol
) – The symbol for which we want to calculate the laplacian matrix
boundary_conditions (dict) – The boundary conditions of the model ({symbol.id: {“negative tab”: neg. tab bc, “positive tab”: pos. tab bc}})
The (sparse) finite element stiffness matrix for the domain