Concatenations#

class pybamm.Concatenation(*children: Symbol, name: str | None = None, check_domain=True, concat_fun=None)[source]#

A node in the expression tree representing a concatenation of symbols.

Parameters:

children (iterable of pybamm.Symbol) – The symbols to concatenate

Extends: pybamm.expression_tree.symbol.Symbol

create_copy()[source]#

See pybamm.Symbol.new_copy().

evaluate(t: float | None = None, y: ndarray | None = None, y_dot: ndarray | None = None, inputs: dict | str | None = None)[source]#

See pybamm.Symbol.evaluate().

get_children_domains(children: Sequence[Symbol])[source]#

Combine domains from children, at all levels.

is_constant()[source]#

See pybamm.Symbol.is_constant().

to_equation()[source]#

Convert the node and its subtree into a SymPy equation.

class pybamm.NumpyConcatenation(*children: Symbol)[source]#

A node in the expression tree representing a concatenation of equations, when we don’t care about domains. The class pybamm.DomainConcatenation, which is careful about domains and uses broadcasting where appropriate, should be used whenever possible instead.

Upon evaluation, equations are concatenated using numpy concatenation.

Parameters:

children (iterable of pybamm.Symbol) – The equations to concatenate

Extends: pybamm.expression_tree.concatenations.Concatenation

class pybamm.DomainConcatenation(children: Sequence[Symbol], full_mesh: Mesh, copy_this: DomainConcatenation | None = None)[source]#

A node in the expression tree representing a concatenation of symbols, being careful about domains.

It is assumed that each child has a domain, and the final concatenated vector will respect the sizes and ordering of domains established in mesh keys

Parameters:
  • children (iterable of pybamm.Symbol) – The symbols to concatenate

  • full_mesh (pybamm.Mesh) – The underlying mesh for discretisation, used to obtain the number of mesh points in each domain.

  • copy_this (pybamm.DomainConcatenation (optional)) – if provided, this class is initialised by copying everything except the children from copy_this. mesh is not used in this case

Extends: pybamm.expression_tree.concatenations.Concatenation

to_json()[source]#

Method to serialise a DomainConcatenation object into JSON.

class pybamm.SparseStack(*children)[source]#

A node in the expression tree representing a concatenation of sparse matrices. As with NumpyConcatenation, we don’t care about domains. The class pybamm.DomainConcatenation, which is careful about domains and uses broadcasting where appropriate, should be used whenever possible instead.

Parameters:

children (iterable of Concatenation) – The equations to concatenate

Extends: pybamm.expression_tree.concatenations.Concatenation

pybamm.numpy_concatenation(*children)[source]#

Helper function to create numpy concatenations.

pybamm.domain_concatenation(children: list[Symbol], mesh: Mesh)[source]#

Helper function to create domain concatenations.