Broadcasting Operators#

class pybamm.Broadcast(child: Symbol, domains: dict[str, list[str] | str], name: str | None = None)[source]#

A node in the expression tree representing a broadcasting operator. Broadcasts a child to a specified domain. After discretisation, this will evaluate to an array of the right shape for the specified domain.

For an example of broadcasts in action, see this example notebook

Parameters:
  • child (Symbol) – child node

  • domains (iterable of str) – Domain(s) of the symbol after broadcasting

  • name (str) – name of the node

Extends: pybamm.expression_tree.unary_operators.SpatialOperator

reduce_one_dimension()[source]#

Reduce the broadcast by one dimension.

to_json()[source]#

Method to serialise a Symbol object into JSON.

class pybamm.FullBroadcast(child_input: int | float | number | Symbol, broadcast_domain: list[str] | str | None = None, auxiliary_domains: dict[str, str] | None = None, broadcast_domains: dict[str, list[str] | str] | None = None, name: str | None = None)[source]#

A class for full broadcasts.

Extends: pybamm.expression_tree.broadcasts.Broadcast

check_and_set_domains(child: Symbol, broadcast_domains: dict)[source]#

See Broadcast.check_and_set_domains()

reduce_one_dimension()[source]#

Reduce the broadcast by one dimension.

class pybamm.PrimaryBroadcast(child: int | float | number | Symbol, broadcast_domain: list[str] | str, name: str | None = None)[source]#

A node in the expression tree representing a primary broadcasting operator. Broadcasts in a primary dimension only. That is, makes explicit copies of the symbol in the domain specified by broadcast_domain. This should be used for broadcasting from a “larger” scale to a “smaller” scale, for example broadcasting temperature T(x) from the electrode to the particles, or broadcasting current collector current i(y, z) from the current collector to the electrodes.

Parameters:
  • child (Symbol, numeric) – child node

  • broadcast_domain (iterable of str) – Primary domain for broadcast. This will become the domain of the symbol

  • name (str) – name of the node

Extends: pybamm.expression_tree.broadcasts.Broadcast

check_and_set_domains(child: Symbol, broadcast_domain: list[str])[source]#

See Broadcast.check_and_set_domains()

reduce_one_dimension()[source]#

Reduce the broadcast by one dimension.

class pybamm.SecondaryBroadcast(child: Symbol, broadcast_domain: list[str] | str, name: str | None = None)[source]#

A node in the expression tree representing a secondary broadcasting operator. Broadcasts in a secondary dimension only. That is, makes explicit copies of the symbol in the domain specified by broadcast_domain. This should be used for broadcasting from a “smaller” scale to a “larger” scale, for example broadcasting SPM particle concentrations c_s(r) from the particles to the electrodes. Note that this wouldn’t be used to broadcast particle concentrations in the DFN, since these already depend on both x and r.

Parameters:
  • child (Symbol) – child node

  • broadcast_domain (iterable of str) – Secondary domain for broadcast. This will become the secondary domain of the symbol, shifting the child’s secondary and tertiary (if present) over by one position.

  • name (str) – name of the node

Extends: pybamm.expression_tree.broadcasts.Broadcast

check_and_set_domains(child: Symbol, broadcast_domain: list[str])[source]#

See Broadcast.check_and_set_domains()

reduce_one_dimension()[source]#

Reduce the broadcast by one dimension.

class pybamm.FullBroadcastToEdges(child: int | float | number | Symbol, broadcast_domain: list[str] | str | None = None, auxiliary_domains: dict[str, str] | None = None, broadcast_domains: dict[str, list[str] | str] | None = None, name: str | None = None)[source]#

A full broadcast onto the edges of a domain (edges of primary dimension, nodes of other dimensions)

Extends: pybamm.expression_tree.broadcasts.FullBroadcast

reduce_one_dimension()[source]#

Reduce the broadcast by one dimension.

class pybamm.PrimaryBroadcastToEdges(child: int | float | number | Symbol, broadcast_domain: list[str] | str, name: str | None = None)[source]#

A primary broadcast onto the edges of the domain.

Extends: pybamm.expression_tree.broadcasts.PrimaryBroadcast

class pybamm.SecondaryBroadcastToEdges(child: Symbol, broadcast_domain: list[str] | str, name: str | None = None)[source]#

A secondary broadcast onto the edges of a domain.

Extends: pybamm.expression_tree.broadcasts.SecondaryBroadcast

pybamm.ones_like(*symbols: Symbol)[source]#

Returns an array with the same shape and domains as the sum of the input symbols, with each entry equal to one.

Parameters:

symbols (Symbol) – Symbols whose shape to copy

pybamm.zeros_like(*symbols: Symbol)[source]#

Returns an array with the same shape and domains as the sum of the input symbols, with each entry equal to zero.

Parameters:

symbols (Symbol) – Symbols whose shape to copy

pybamm.full_like(symbols: tuple[Symbol, ...], fill_value: float) Symbol[source]#

Returns an array with the same shape and domains as the sum of the input symbols, with a constant value given by fill_value.

Parameters:
  • symbols (Symbol) – Symbols whose shape to copy

  • fill_value (number) – Value to assign