pybamm.SpatialMethod(options=None)[source]¶A general spatial methods class, with default (trivial) behaviour for some spatial operations. All spatial methods will follow the general form of SpatialMethod in that they contain a method for broadcasting variables onto a mesh, a gradient operator, and a divergence operator.
| Parameters: | mesh – Contains all the submeshes for discretisation |
|---|
boundary_integral(child, discretised_child, region)[source]¶Implements the boundary integral for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised boundary integral on the child discretised_symbol |
| Return type: | class: pybamm.Array |
boundary_value_or_flux(symbol, discretised_child, bcs=None)[source]¶Returns the boundary value or flux using the approriate expression for the spatial method. To do this, we create a sparse vector ‘bv_vector’ that extracts either the first (for side=”left”) or last (for side=”right”) point from ‘discretised_child’.
| Parameters: |
|
|---|---|
| Returns: | The variable representing the surface value. |
| Return type: |
broadcast(symbol, domain, auxiliary_domains, broadcast_type)[source]¶Broadcast symbol to a specified domain.
| Parameters: |
|
|---|---|
| Returns: | broadcasted_symbol – The discretised symbol of the correct size for the spatial method |
| Return type: | class: pybamm.Symbol |
concatenation(disc_children)[source]¶Discrete concatenation object.
| Parameters: | disc_children (list) – List of discretised children |
|---|---|
| Returns: | Concatenation of the discretised children |
| Return type: | pybamm.DomainConcatenation |
delta_function(symbol, discretised_symbol)[source]¶Implements the delta function on the approriate side for a spatial method.
| Parameters: |
|
|---|
divergence(symbol, discretised_symbol, boundary_conditions)[source]¶Implements the divergence for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised divergence on the child discretised_symbol |
| Return type: | class: pybamm.Array |
gradient(symbol, discretised_symbol, boundary_conditions)[source]¶Implements the gradient for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised gradient on the child discretised_symbol |
| Return type: | class: pybamm.Array |
gradient_squared(symbol, discretised_symbol, boundary_conditions)[source]¶Implements the inner product of the gradient with itself for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of taking the inner product of the result of acting the discretised gradient on the child discretised_symbol with itself |
| Return type: | class: pybamm.Array |
indefinite_integral(child, discretised_child, direction)[source]¶Implements the indefinite integral for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised indefinite integral on the child discretised_symbol |
| Return type: | class: pybamm.Array |
integral(child, discretised_child, integration_dimension)[source]¶Implements the integral for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised integral on the child discretised_symbol |
| Return type: | class: pybamm.Array |
internal_neumann_condition(left_symbol_disc, right_symbol_disc, left_mesh, right_mesh)[source]¶A method to find the internal neumann conditions between two symbols on adjacent subdomains.
| Parameters: |
|
|---|
laplacian(symbol, discretised_symbol, boundary_conditions)[source]¶Implements the laplacian for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | Contains the result of acting the discretised laplacian on the child discretised_symbol |
| Return type: | class: pybamm.Array |
mass_matrix(symbol, boundary_conditions)[source]¶Calculates the mass matrix for a spatial method.
| Parameters: |
|
|---|---|
| Returns: | The (sparse) mass matrix for the spatial method. |
| Return type: |
process_binary_operators(bin_op, left, right, disc_left, disc_right)[source]¶Discretise binary operators in model equations. Default behaviour is to return a new binary operator with the discretised children.
| Parameters: |
|
|---|---|
| Returns: | Discretised binary operator |
| Return type: |
spatial_variable(symbol)[source]¶Convert a pybamm.SpatialVariable node to a linear algebra object that
can be evaluated (here, a pybamm.Vector on either the nodes or the
edges).
| Parameters: | symbol (pybamm.SpatialVariable) – The spatial variable to be discretised. |
|---|---|
| Returns: | Contains the discretised spatial variable |
| Return type: | pybamm.Vector |