Previous topic

EvaluatorPython

Next topic

Convert to CasADi

This Page

Jacobian

class pybamm.Jacobian(known_jacs=None, clear_domain=True)[source]

Helper class to calculate the jacobian of an expression.

Parameters:
  • known_jacs (dict {variable ids -> pybamm.Symbol}) – cached jacobians

  • clear_domain (bool) – wether or not the jacobian clears the domain (default True)

jac(symbol, variable)[source]

This function recurses down the tree, computing the Jacobian using the Jacobians defined in classes derived from pybamm.Symbol. E.g. the Jacobian of a ‘pybamm.Multiplication’ is computed via the product rule. If the Jacobian of a symbol has already been calculated, the stored value is returned. Note: The Jacobian is the derivative of a symbol with respect to a (slice of) a State Vector.

Parameters:
  • symbol (pybamm.Symbol) – The symbol to calculate the Jacobian of

  • variable (pybamm.Symbol) – The variable with respect to which to differentiate

Returns:

Symbol representing the Jacobian

Return type:

pybamm.Symbol