2.7. The component
element¶
A component
element information item (referred to in this specification as a component
element) is an element in the CellML namespace with a local name equal to component
, which appears as a child of a model
element.
See more
Components are a convenient way to modularise a model, and allow parts to be removed, replaced, and reused easily. They define the scope of their contents, meaning that the items within a component need only be uniquely named in that local scope. Commonly needed variables (like time, for example) can be given the same name in multiple components without triggering an error.
Components are the largest building blocks of the model, and have three important parts to them.
The first is their naming and contents, similar to all the other CellML items, and described below.
The second relates to their structure in relation to other component
items: this structure is called their encapsulation and is described in 2.13 The encapsulation element.
The third relates to the import component
item, as described in 2.4 The import component element.
Every
component
element MUST contain aname
attribute.The value of the
name
attribute MUST be a CellML identifier.The value of the
name
attribute MUST NOT be identical to the value of thename
attribute on any othercomponent
element orimport component
element in the CellML infoset.
See more
A component
item, as with every other part of CellML, must use a name unique to its scope, and obey the format definitions outlined in 1.3 Data representation formats in CellML.
For example:
<!-- This is valid: -->
<component name="myValidName"> ... </component>
<!-- Not valid: the units name attribute is not a valid CellML identifier. -->
<component name="I'm not valid!"> ... </component>
<!-- Not valid: duplicted component names are not allowed. -->
<component name="duplicatedName"> ... </component>
<component name="duplicatedName"> ... </component>
<!-- Not valid: duplicating the name of an imported component item is not allowed. -->
<import xlink:href="handyComponentsForImport.cellml">
<component component_ref="myComponentRef" name="duplicatedName">
</import>
A
component
element MAY contain one or more specific element children, each of which MUST be of one of the following types:A
math
element;A
reset
element; orA
variable
element.
See more
The mathematics of a component
Perhaps the most important part of a component
item is the mathematics it contains.
This is stored inside a collection of <math>
blocks as described in 2.12 The math element.
The math
then defines the operation of the local variable
items and how they relate to each other mathematically.
For example, a component to calculate Einstein’s \(E=mc^2\) could be represented by:
<component name="mass_into_energy">
<math>
<apply><eq/>
<ci>E</ci>
<apply><times/>
<ci>m</ci>
<apply><power/>
<ci>c</ci>
<cn cellml:units="dimensionless">2</cn>
</apply>
</apply>
</apply>
</math>
...
</component>
Please refer to 2.12 The math element for information on the math
items and MathML format.
The variables of a component
The MathML block above refers to three variables named E
, m
and c
.
These variable names must be the same as the name
attributes of the child variable
items in this component.
<component name="mass_into_energy">
...
<variable name="E" units="joule" />
<variable name="m" units="kilogram" />
<variable name="c" units="metres_per_second" />
</component>
Please refer to 2.8 The variable element for information on variable
items.
The reset items of a component
Please refer to 2.9 The reset element for more information on reset
items.