xso.variable

xso.variable(foreign=False, flux=None, negative=False, list_input=False, dims=None, description='', attrs={})[source]

Create a state variable.

This can be a local state variable for the component, or a reference to a state variable initialized in another component. A flux function can be applied to that variable.

The variable stores a single state variable, if no dimension (argument: dims) is supplied, but can also define an array or matrix of state variables, depending on the argument. In the model it is always assigned to a single label, and can only be used in a flux with appropriate dimensionality.

Parameters:
  • foreign (boolean, optional) – Defines whether the variable is initialized and labeled in the component, or is simply a reference to a variable in another component.

  • flux (str, optional) – Name of the flux function defined in this component, the result of which is applied to this state variable.

  • negative (boolean, optional) – If true, the result of the flux function is substracted, if false, it is added to the variable.

  • list_input (list, optional) – If it is a foreign variable, a list of labels of other state variables can be supplied, as a handy way of applying the same flux to multiple variables.

  • dims (str or tuple or list, optional) – Dimension label(s) of the variable. An empty tuple corresponds to a scalar variable (default), a string or a 1-length tuple corresponds to a 1-d variable and a n-length tuple corresponds to a n-d variable. A list of str or tuple items may also be provided if the variable accepts different numbers of dimensions.

  • description (str, optional) – Short description of the variable.

  • attrs (dict, optional) – Dictionnary of additional metadata (e.g., standard_name, units, math_symbol…).