Finite Volume

#### Next topic

Zero Dimensional Spatial Method

# Scikit Finite Elements¶

class pybamm.ScikitFiniteElement(mesh)[source]

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 stifnness 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).

Parameters: mesh (pybamm.Mesh) – Contains all the submeshes for discretisation **Extends (“”: pybamm.SpatialMethod) –
assemble_mass_form(symbol, boundary_conditions, region='interior')[source]

Assembles the form of the finite element mass matrix over the domain interior or boundary.

Parameters: 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. pybamm.Matrix
bc_apply(M, boundary, zero=False)[source]

Adjusts the assemled finite element matrices to account for boundary conditons.

Parameters: 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.
boundary_integral(child, discretised_child, region)[source]

Implementation of the boundary integral operator. See pybamm.SpatialMethod.boundary_integral()

boundary_integral_vector(domain, region)[source]

A node in the expression tree representing an integral operator over the boundary of a domain

$I = \int_{\partial a}\!f(u)\,du,$

where $$\partial a$$ is the boundary of the domain, and $$u\in\text{domain boundary}$$.

Parameters: 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 pybamm.Matrix
boundary_mass_matrix(symbol, boundary_conditions)[source]

Calculates the mass matrix for the finite element method assembled over the boundary.

Parameters: 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. pybamm.Matrix
boundary_value_or_flux(symbol, discretised_child)[source]

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()

definite_integral_matrix(domain, vector_type='row')[source]

Matrix for finite-element implementation of the definite integral over the entire domain

$I = \int_{\Omega}\!f(s)\,dx$

for where $$\Omega$$ is the domain.

Parameters: domain (list) – The domain(s) of integration vector_type (str, optional) – Whether to return a row or column vector (default is row) The finite element integral vector for the domain pybamm.Matrix
divergence(symbol, discretised_symbol, boundary_conditions)[source]

Matrix-vector multiplication to implement the divergence operator. See pybamm.SpatialMethod.divergence()

gradient(symbol, discretised_symbol, boundary_conditions)[source]

Matrix-vector multiplication to implement the gradient operator. See pybamm.SpatialMethod.gradient()

gradient_squared(symbol, discretised_symbol, boundary_conditions)[source]

Matrix-vector multiplication to implement the inner product of the gradient operator with itself. See pybamm.SpatialMethod.gradient_squared()

indefinite_integral(child, discretised_child)[source]

Implementation of the indefinite integral operator. The input discretised child must be defined on the internal mesh edges. See pybamm.SpatialMethod.indefinite_integral()

integral(child, discretised_child)[source]

Vector-vector dot product to implement the integral operator. See pybamm.SpatialMethod.integral()

laplacian(symbol, discretised_symbol, boundary_conditions)[source]

Matrix-vector multiplication to implement the laplacian operator.

Parameters: 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
mass_matrix(symbol, boundary_conditions)[source]

Calculates the mass matrix for the finite element method.

Parameters: 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. pybamm.Matrix
spatial_variable(symbol)[source]

Creates a discretised spatial variable compatible with the FiniteElement method.

Parameters: symbol (pybamm.SpatialVariable) – The spatial variable to be discretised. Contains the discretised spatial variable pybamm.Vector
stiffness_matrix(symbol, boundary_conditions)[source]

Laplacian (stiffness) matrix for finite elements in the appropriate domain.

Parameters: 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 pybamm.Matrix