2.8. The variable element

A variable element information item (referred to in this specification as a variable element) is an element in the CellML namespace with a local name equal to variable, and which appears as a child of a component element.

  1. Every variable element MUST have exactly one of each of the following attributes:

    1. The name attribute. The value of the name attribute MUST be a valid CellML identifier.

      The value of the name attribute MUST NOT be identical to the name attribute on any sibling variable element.

    1. The units attribute. The value of the units attribute MUST be a valid CellML identifier, and MUST meet the constraints described in the Effect of units on variables section.
  2. Every variable element MAY contain one or more of the following attributes:

    1. The interface attribute. If the attribute is present, it MUST have value of public, private, public_and_private, or none.
    1. The initial_value attribute. If the attribute is present, it MUST meet the requirements described by the Interpretation of initial values section.
See more

In addition to the standard name attribute, each variable must also define a units attribute too.

Reusing Einstein’s example from the component item section we can give the three variables their fuller definitions:

<component name="mass_into_energy">
    <math>
      ...
    </math>
    <variable name="E" units="joule"/>
    <variable name="m" units="kilogram"/>
    <variable name="c" units="metre_per_second"/>
</component>

Extra attributes that can be used as needed include the initial_value, which will either set a constant value for a variable, or set its initial conditions if it’s being solved for. More information about initialisation can be found in the Interpretation of initial values section.

Finally, where one variable has been mapped to another in a different component, the interface attribute must be specified. This determines the relative position in the encapsulation that the mapped component must have in order to access this variable. This is outlined in more detail in the encapsulation item section.