Jacobian#
- class pybamm.Jacobian(known_jacs: dict[Symbol, Symbol] | None = None, clear_domain: bool = True)[source]#
Helper class to calculate the Jacobian of an expression.
- Parameters:
known_jacs (dict {variable ids ->
pybamm.Symbol
}) – cached jacobiansclear_domain (bool) – whether or not the Jacobian clears the domain (default True)
- jac(symbol: Symbol, variable: Symbol) Symbol [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 ofvariable (
pybamm.Symbol
) – The variable with respect to which to differentiate
- Returns:
Symbol representing the Jacobian
- Return type: