Symbol Unpacker

class pybamm.SymbolUnpacker(classes_to_find, unpacked_symbols=None)[source]

Helper class to unpack a (set of) symbol(s) to find all instances of a class. Uses caching to speed up the process.

Parameters:
  • classes_to_find (list of pybamm classes) – Classes to identify in the equations

  • unpacked_symbols (set, optional) – cached unpacked equations

unpack_list_of_symbols(list_of_symbols)[source]

Unpack a list of symbols. See SymbolUnpacker.unpack()

Parameters:

list_of_symbols (list of pybamm.Symbol) – List of symbols to unpack

Returns:

Set of unpacked symbols with class in self.classes_to_find

Return type:

list of pybamm.Symbol

unpack_symbol(symbol)[source]

This function recurses down the tree, unpacking the symbols and saving the ones that have a class in self.classes_to_find.

Parameters:

symbol (list of pybamm.Symbol) – The symbols to unpack

Returns:

List of unpacked symbols with class in self.classes_to_find

Return type:

list of pybamm.Symbol