Variable#

class pybamm.Variable(name: str, domain: list[str] | str | None = None, auxiliary_domains: dict[str, str] | None = None, domains: dict[str, list[str] | str] | None = None, bounds: tuple[Symbol] | None = None, print_name: str | None = None, scale: float | Symbol | None = 1, reference: float | Symbol | None = 0)[source]#

A node in the expression tree represending a dependent variable.

This node will be discretised by Discretisation and converted to a pybamm.StateVector node.

Parameters:
  • name (str) – name of the node domain : iterable of str, optional list of domains that this variable is valid over

  • auxiliary_domains (dict, optional) – dictionary of auxiliary domains ({‘secondary’: …, ‘tertiary’: …, ‘quaternary’: …}). For example, for the single particle model, the particle concentration would be a Variable with domain ‘negative particle’ and secondary auxiliary domain ‘current collector’. For the DFN, the particle concentration would be a Variable with domain ‘negative particle’, secondary domain ‘negative electrode’ and tertiary domain ‘current collector’

  • domains (dict) – A dictionary equivalent to {‘primary’: domain, auxiliary_domains}. Either ‘domain’ and ‘auxiliary_domains’, or just ‘domains’, should be provided (not both). In future, the ‘domain’ and ‘auxiliary_domains’ arguments may be deprecated.

  • bounds (tuple, optional) – Physical bounds on the variable

  • print_name (str, optional) – The name to use for printing. Default is None, in which case self.name is used.

  • scale (float or pybamm.Symbol, optional) – The scale of the variable, used for scaling the model when solving. The state vector representing this variable will be multiplied by this scale. Default is 1.

  • reference (float or pybamm.Symbol, optional) – The reference value of the variable, used for scaling the model when solving. This value will be added to the state vector representing this variable. Default is 0.

Extends: pybamm.expression_tree.variable.VariableBase

diff(variable: Symbol)[source]#

Differentiate a symbol with respect to a variable. For any symbol that can be differentiated, return 1 if differentiating with respect to yourself, self._diff(variable) if variable is in the expression tree of the symbol, and zero otherwise.

Parameters:

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

class pybamm.VariableDot(name: str, domain: list[str] | str | None = None, auxiliary_domains: dict[str, str] | None = None, domains: dict[str, list[str] | str] | None = None, bounds: tuple[Symbol] | None = None, print_name: str | None = None, scale: float | Symbol | None = 1, reference: float | Symbol | None = 0)[source]#

A node in the expression tree represending the time derviative of a dependent variable

This node will be discretised by Discretisation and converted to a pybamm.StateVectorDot node.

Parameters:
  • name (str) – name of the node

  • domain (iterable of str) – list of domains that this variable is valid over

  • auxiliary_domains (dict) – dictionary of auxiliary domains ({‘secondary’: …, ‘tertiary’: …, ‘quaternary’: …}). For example, for the single particle model, the particle concentration would be a Variable with domain ‘negative particle’ and secondary auxiliary domain ‘current collector’. For the DFN, the particle concentration would be a Variable with domain ‘negative particle’, secondary domain ‘negative electrode’ and tertiary domain ‘current collector’

  • domains (dict) – A dictionary equivalent to {‘primary’: domain, auxiliary_domains}. Either ‘domain’ and ‘auxiliary_domains’, or just ‘domains’, should be provided (not both). In future, the ‘domain’ and ‘auxiliary_domains’ arguments may be deprecated.

  • bounds (tuple, optional) – Physical bounds on the variable. Included for compatibility with VariableBase, but ignored.

  • print_name (str, optional) – The name to use for printing. Default is None, in which case self.name is used.

  • scale (float or pybamm.Symbol, optional) – The scale of the variable, used for scaling the model when solving. The state vector representing this variable will be multiplied by this scale. Default is 1.

  • reference (float or pybamm.Symbol, optional) – The reference value of the variable, used for scaling the model when solving. This value will be added to the state vector representing this variable. Default is 0.

Extends: pybamm.expression_tree.variable.VariableBase

diff(variable: Symbol) Scalar[source]#

Differentiate a symbol with respect to a variable. For any symbol that can be differentiated, return 1 if differentiating with respect to yourself, self._diff(variable) if variable is in the expression tree of the symbol, and zero otherwise.

Parameters:

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

get_variable() Variable[source]#

return a Variable corresponding to this VariableDot

Note: Variable._jac adds a dash to the name of the corresponding VariableDot, so we remove this here