Scikit Finite Elements 3D#
- class pybamm.ScikitFiniteElement3D(options=None)[source]#
A class which implements the steps specific to the 3D finite element method during discretisation using scikit-fem.
- Parameters:
options (dict-like, optional) – A dictionary of options to be passed to the spatial method.
Extends:
pybamm.spatial_methods.spatial_method.SpatialMethod- assemble_mass_form(symbol, boundary_conditions, region='interior')[source]#
Assembles the form of the 3D finite element mass matrix.
- Parameters:
symbol (
pybamm.Variable) – The variable corresponding to the equationboundary_conditions (dict) – The boundary conditions of the model
region (str, optional) – The domain over which to assemble
- Returns:
The (sparse) mass matrix
- Return type:
- bc_apply(M, boundary_dofs, zero=False)[source]#
Adjusts matrices for 3D boundary conditions.
- Parameters:
M (scipy.sparse matrix) – Matrix to modify
boundary_dofs (array_like) – Boundary degrees of freedom
zero (bool, optional) – Whether to zero the diagonal entries
- boundary_integral(child, discretised_child, region)[source]#
Implementation of the 3D boundary integral operator.
- Parameters:
child (
pybamm.Symbol) – The symbol being integrateddiscretised_child (
pybamm.Symbol) – The discretised symbol being integratedregion (str) – The boundary region over which to integrate
- Returns:
The result of the boundary integration
- Return type:
- boundary_integral_vector(domain, region)[source]#
A vector representing an integral operator over the boundary.
- Parameters:
- Returns:
The finite element boundary integral vector
- Return type:
- boundary_mass_matrix(symbol, boundary_conditions)[source]#
Calculates the mass matrix assembled over the 3D boundary.
- Parameters:
symbol (
pybamm.Variable) – The variable corresponding to the equationboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The (sparse) boundary mass matrix
- Return type:
- boundary_value_or_flux(symbol, discretised_child, bcs=None)[source]#
Returns the boundary value or flux of a variable in 3D.
- Parameters:
symbol (
pybamm.Symbol) – The boundary symboldiscretised_child (
pybamm.Symbol) – The discretised variablebcs (dict, optional) – Boundary conditions
- Returns:
The boundary value or flux
- Return type:
- definite_integral_matrix(child, vector_type='row')[source]#
Matrix for definite integral vector (vector of ones). The child is used to determine the domain and size.
- Parameters:
child (
pybamm.Symbol) – The symbol whose domain/mesh determines the size.vector_type (str, optional) – “row” or “column” for the shape of the resulting vector of ones.
- Returns:
A matrix representing a vector of ones (either row or column).
- Return type:
- divergence(symbol, discretised_symbol, boundary_conditions)[source]#
Matrix-vector multiplication to implement the 3D divergence operator. Expects discretised_symbol to be a Concatenation of [Fx, Fy, Fz].
- Parameters:
symbol (
pybamm.Symbol) – The symbol representing the divergence operationdiscretised_symbol (
pybamm.Concatenation) – The discretised vector field as concatenation [Fx, Fy, Fz]boundary_conditions (dict) – The boundary conditions of the model
- Returns:
The divergence of the vector field
- Return type:
- gradient(symbol, discretised_symbol, boundary_conditions)[source]#
Matrix-vector multiplication to implement the 3D gradient operator. Returns a Concatenation of [grad_x, grad_y, grad_z] or [grad_r, grad_theta, grad_z].
- Parameters:
symbol (
pybamm.Symbol) – The symbol that we will take the gradient of.discretised_symbol (
pybamm.Symbol) – The discretised symbol of the correct sizeboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The 3D gradient as concatenation of x, y, z or z, r, theta components
- Return type:
- gradient_matrix(symbol, boundary_conditions)[source]#
Gradient matrices for finite elements in 3D.
- Parameters:
symbol (
pybamm.Symbol) – The symbol for which we want to calculate the gradient matrixboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The (sparse) finite element gradient matrices.
- Return type:
tuple of
pybamm.Matrix
- gradient_squared(symbol, discretised_symbol, boundary_conditions)[source]#
Multiplication to implement the inner product of the gradient operator with itself in 3D.
- indefinite_integral(child, discretised_child, direction)[source]#
Implementation of the indefinite integral operator in 3D.
- integral(child, discretised_child, integration_dimension, integration_variable)[source]#
Vector-vector dot product to implement the 3D integral operator.
- Parameters:
child (
pybamm.Symbol) – The symbol being integrateddiscretised_child (
pybamm.Symbol) – The discretised symbol being integrated (vector of nodal values)integration_dimension (str) – The dimension over which to integrate (e.g. “primary” for volume)
- Returns:
The result of the integration (a scalar value).
- Return type:
- laplacian(symbol, discretised_symbol, boundary_conditions)[source]#
Matrix-vector multiplication to implement the 3D Laplacian operator. This should be called only after boundary conditions have been properly discretised by the PyBaMM discretisation process.
- Parameters:
symbol (
pybamm.Symbol) – The symbol for which we want to calculate the Laplaciandiscretised_symbol (
pybamm.Symbol) – The discretised symbol of the correct sizeboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The Laplacian of the symbol
- Return type:
- laplacian_boundary_load(symbol_for_laplacian, boundary_conditions_dict)[source]#
Assembles the boundary load vector for the 3D Laplacian.
- Parameters:
symbol (
pybamm.Symbol) – The symbol for which we want to calculate the boundary loadboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The boundary load vector
- Return type:
- mass_matrix(symbol, boundary_conditions)[source]#
Calculates the mass matrix for the 3D finite element method.
- Parameters:
symbol (
pybamm.Variable) – The variable corresponding to the equationboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The (sparse) mass matrix for the spatial method.
- Return type:
- process_binary_operators(bin_op, left, right, disc_left, disc_right)[source]#
Process binary operators, with a specific fix for Inner products involving Concatenations that may have been created without a concatenation_function.
- Parameters:
bin_op (
pybamm.BinaryOperator) – The binary operator to process.left (
pybamm.Symbol) – The left child of the operator.right (
pybamm.Symbol) – The right child of the operator.disc_left (
pybamm.Symbol) – The discretised left child of the operator.disc_right (
pybamm.Symbol) – The discretised right child of the operator.
- Returns:
The discretised binary operator.
- Return type:
- spatial_variable(symbol)[source]#
Creates a discretised spatial variable for x, y, z, r or theta.
- Parameters:
symbol (
pybamm.SpatialVariable) – The spatial variable to discretise (must be ‘x’, ‘y’, ‘z’, ‘r’ or ‘theta’)- Returns:
The discretised spatial variable as a vector of nodal values
- Return type:
- stiffness_matrix(symbol, boundary_conditions)[source]#
Laplacian (stiffness) matrix for finite elements in 3D.
- Parameters:
symbol (
pybamm.Symbol) – The symbol for which we want to calculate the stiffness matrixboundary_conditions (dict) – The boundary conditions of the model
- Returns:
The (sparse) finite element stiffness matrix
- Return type: