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, 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.

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

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

    1. The units attribute.

      1. The value of the units attribute MUST be a valid units reference, as defined in 3.2 Units references.

  2. Every variable element MAY contain one or more of the following attributes:

    1. The interface attribute.

      1. If the attribute is present, it MUST have value of public, private, public_and_private, or none.

    1. The initial_value attribute.

      1. If the attribute is present, it MUST meet the requirements described by 3.6 Interpretation of initial_value attributes.

See more

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

Reusing Einstein’s example from 2.7 The component element 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 3.6 Interpretation of initial_value attributes.

Finally, where one variable (A) has been mapped to another (B) in a different component (BB), both A and B must specify interface attributes. These prescribe the relative positions in the encapsulation that the components AA and BB must have in order for their respective variables A and B to access one another. This is outlined in more detail in 2.13 The encapsulation element.