A class which implements the steps specific to the Spectral Volume
discretisation. It is implemented in such a way that it is very
similar to FiniteVolume; that comes at the cost that it is only
compatible with the SpectralVolume1DSubMesh (which is a certain
subdivision of any 1D mesh, so it shouldn’t be a problem).
For broadcast and mass_matrix, we follow the default behaviour from
SpatialMethod. For spatial_variable,
divergence, divergence_matrix, laplacian, integral,
definite_integral_matrix, indefinite_integral,
indefinite_integral_matrix, indefinite_integral_matrix_nodes,
indefinite_integral_matrix_edges, delta_function
we follow the behaviour from FiniteVolume. This is possible since
the node values are integral averages with Spectral Volume, just
as with Finite Volume. delta_function assigns the integral value
to a CV instead of a SV this way, but that doesn’t matter too much.
Additional methods that are inherited by FiniteVolume which
technically are not suitable for Spectral Volume are
boundary_value_or_flux, process_binary_operators, concatenation,
node_to_edge, edge_to_node and shift. While node_to_edge (as well as
boundary_value_or_flux and process_binary_operators)
could utilize the reconstruction approach of Spectral Volume, the
inverse edge_to_node would still have to fall back to the Finite
Volume behaviour. So these are simply inherited for consistency.
boundary_value_or_flux might not benefit from the reconstruction
approach at all, as it seems to only preprocess symbols.
Parameters:
mesh (pybamm.Mesh) – Contains all the submeshes for discretisation
noe (integer) – The number of the collocation points. “number of edges”
dod (integer) – The maximum order of differentiation for which a
differentiation matrix shall be calculated. Note that it has
to be smaller than ‘noe’. “degrees of differentiation”
Returns:
The differentiation matrices in ascending order of
differentiation order. With exact arithmetic, the diff.
matrix of order p would just be the pth matrix power of
the diff. matrix of order 1. This method computes the higher
orders in a more numerically stable way.
“Broadcasts” the basic edge value reconstruction matrix to the
actual shape of the discretised symbols. Note that the product
of this and a discretised symbol is a vector which represents
duplicate values for all inner SV edges. These are the
reconstructed values from both sides.
Parameters:
domains (dict) – The domains in which to compute the gradient matrix
Returns:
The (sparse) CV reconstruction matrix for the domain
Gradient matrix for Spectral Volume in the appropriate domain.
Note that it contains the averaging of the duplicate SV edge
gradient values, such that the product of it and a reconstructed
discretised symbol simply represents CV edge values.
On its own, it only works on non-concatenated domains, since
only then the boundary conditions ensure correct behaviour.
More generally, it only works if gradients are a result of
boundary conditions rather than continuity conditions.
For example, two adjacent SVs with gradient zero in each of them
but with different variable values will have zero gradient
between them. This is fixed with “penalty_matrix”.
Parameters:
domains (dict) – The domains in which to compute the gradient matrix
Returns:
The (sparse) Spectral Volume gradient matrix for the domain
Penalty matrix for Spectral Volume in the appropriate domain.
This works the same as the “gradient_matrix” of FiniteVolume
does, just between SVs and not between CVs. Think of it as a
continuity penalty.
Parameters:
domains (dict) – The domains in which to compute the gradient matrix
Returns:
The (sparse) Spectral Volume penalty matrix for the domain
discretised_symbol (pybamm.Vector) – Contains the discretised variable
bcs (dict of tuples (pybamm.Scalar, str)) – Dictionary (with keys “left” and “right”) of boundary
conditions. Each boundary condition consists of a value and
a flag indicating its type (e.g. “Dirichlet”)
Returns:
Matrix @ discretised_symbol + bcs_vector. When evaluated,
this gives the discretised_symbol, with its boundary values
replaced by the Dirichlet boundary conditions.
discretised_gradient (pybamm.Vector) – Contains the discretised gradient of symbol
bcs (dict of tuples (pybamm.Scalar, str)) – Dictionary (with keys “left” and “right”) of boundary
conditions. Each boundary condition consists of a value and
a flag indicating its type (e.g. “Dirichlet”)
Returns:
Matrix @ discretised_gradient + bcs_vector. When
evaluated, this gives the discretised_gradient, with its
boundary values replaced by the Neumann boundary conditions.