Functions#

class pybamm.Function(function: Callable, *children: Symbol, name: str | None = None, differentiated_function: Callable | None = None)[source]#

A node in the expression tree representing an arbitrary function.

Parameters:
  • function (method) – A function can have 0 or many inputs. If no inputs are given, self.evaluate() simply returns func(). Otherwise, self.evaluate(t, y, u) returns func(child0.evaluate(t, y, u), child1.evaluate(t, y, u), etc).

  • children (pybamm.Symbol) – The children nodes to apply the function to

  • differentiated_function (method, optional) – The function which was differentiated to obtain this one. Default is None.

Extends: pybamm.expression_tree.symbol.Symbol

create_copy(new_children: list[Symbol] | None = None, perform_simplifications: bool = True)[source]#

See pybamm.Symbol.new_copy().

diff(variable: Symbol)[source]#

See pybamm.Symbol.diff().

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

See pybamm.Symbol.evaluate().

is_constant()[source]#

See pybamm.Symbol.is_constant().

to_equation()[source]#

Convert the node and its subtree into a SymPy equation.

to_json()[source]#

Method to serialise a Symbol object into JSON.

class pybamm.SpecificFunction(function: Callable, child: Symbol)[source]#

Parent class for the specific functions, which implement their own diff operators directly.

Parameters:
  • function (method) – Function to be applied to child

  • child (pybamm.Symbol) – The child to apply the function to

Extends: pybamm.expression_tree.functions.Function

to_json()[source]#

Method to serialise a SpecificFunction object into JSON.

class pybamm.Arcsinh(child)[source]#

Arcsinh function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.arcsinh(child: Symbol)[source]#

Returns arcsinh function of child.

class pybamm.Arctan(child)[source]#

Arctan function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.arctan(child: Symbol)[source]#

Returns hyperbolic tan function of child.

class pybamm.Cos(child)[source]#

Cosine function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.cos(child: Symbol)[source]#

Returns cosine function of child.

class pybamm.Cosh(child)[source]#

Hyberbolic cosine function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.cosh(child: Symbol)[source]#

Returns hyperbolic cosine function of child.

class pybamm.Erf(child)[source]#

Error function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.erf(child: Symbol)[source]#

Returns error function of child.

pybamm.erfc(child: Symbol)[source]#

Returns complementary error function of child.

class pybamm.Exp(child)[source]#

Exponential function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.exp(child: Symbol)[source]#

Returns exponential function of child.

class pybamm.Log(child)[source]#

Logarithmic function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.log(child, base='e')[source]#

Returns logarithmic function of child (any base, default ‘e’).

pybamm.log10(child: Symbol)[source]#

Returns logarithmic function of child, with base 10.

class pybamm.Max(child)[source]#

Max function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.max(child: Symbol)[source]#

Returns max function of child. Not to be confused with pybamm.maximum(), which returns the larger of two objects.

class pybamm.Min(child)[source]#

Min function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.min(child: Symbol)[source]#

Returns min function of child. Not to be confused with pybamm.minimum(), which returns the smaller of two objects.

pybamm.sech(child: Symbol)[source]#

Returns hyperbolic sec function of child.

class pybamm.Sin(child)[source]#

Sine function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.sin(child: Symbol)[source]#

Returns sine function of child.

class pybamm.Sinh(child)[source]#

Hyperbolic sine function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.sinh(child: Symbol)[source]#

Returns hyperbolic sine function of child.

class pybamm.Sqrt(child)[source]#

Square root function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.sqrt(child: Symbol)[source]#

Returns square root function of child.

class pybamm.Tanh(child)[source]#

Hyperbolic tan function.

Extends: pybamm.expression_tree.functions.SpecificFunction

pybamm.tanh(child: Symbol)[source]#

Returns hyperbolic tan function of child.

pybamm.normal_pdf(x: Symbol, mu: Symbol | float, sigma: Symbol | float)[source]#

Returns the normal probability density function at x.

Parameters:
Returns:

The value of the normal distribution at x

Return type:

pybamm.Symbol

pybamm.normal_cdf(x: Symbol, mu: Symbol | float, sigma: Symbol | float)[source]#

Returns the normal cumulative distribution function at x.

Parameters:
Returns:

The value of the normal distribution at x

Return type:

pybamm.Symbol