# Models

The model element is just a simplified version of its SBML counterpart. However, in an SBML file there is a single model element. Cain files can have any number of models. Below is the top-level structure.

      <model id="Identifier" name="String">
        <listOfParameters>
          One or more <parameter> elements.
        </listOfParameters>
        <listOfCompartments>
          One or more <compartment> elements.
        </listOfCompartments>
        <listOfSpecies>
          One or more <species> elements.
        </listOfSpecies>
        <listOfReactions>
          One or more <reaction> elements.
        </listOfReactions>
        <listOfTimeEvents>
          One or more <timeEvent> elements.
        </listOfTimeEvents>
        <listOfTriggerEvents>
          One or more <triggerEvent> elements.
        </listOfTriggerEvents>
      </model>

Parameters are Python expressions which may use mathematical functions and other parameter identifiers. Parameters must evaluate to a numerical value; functions of time are not allowed.

      <parameter id="Identifier" expression="PythonExpression" name="String"/>

Compartments are only used for information. They do not affect simulation output.

      <compartment id="Identifier" name="String" spatialDimensions="Dimension"
       size="Number" constant="Boolean" outside="Identifier"/>

The initial amount of a species must evaluate to a non-negative integer.

      <species id="Identifier" initialAmount="PythonExpression" name="String" compartment="Identifier"/>

The reaction element is simpler than its SBML counterpart. There is no reversible attribute. In stochastic simulations one represents a reversible reaction by specifying both the forward and backward reactions along with their kinetic laws. Note that while the listOfReactants and listOfProducts elements are optional, at least one of the two must be present. Instead of containing a kineticLaw element, the reaction element has the propensity attribute. For mass-action kinetics, the propensity is a python expression.

      <reaction id="Identifier" massAction="true" propensity="PythonExpression" name="String">
        <listOfReactants>
          One or more <speciesReference> elements.
        </listOfReactants>
        <listOfProducts>
          One or more <speciesReference> elements.
        </listOfProducts>
      </reaction>

If the reaction does not use a mass-action kinetics law, the propensity is a C++ expression. (See the Reaction Editor section.)

      <reaction id="Identifier" massAction="false" propensity="C++Expression" name="String">
        ...
      </reaction>

The speciesReference element is used to represent reactants and products. The stoichiometry attribute must be a positive integer. Omitting it indicates that the stoichiometry is one.

      <speciesReference species="Identifier" stoichiometry="Integer"/>

Time events execute assignments at a specified list of times.

      <timeEvent id="Identifier" times="PythonExpression" assignments="PythonExpression" name="String"/>

Trigger events execute assignments when the trigger condition becomes true. If the delay is omitted, it has the value zero. That is, there is no delay between triggering the event and executing the event. If the useValuesFromTriggerTime attribute is omitted, it is false.

      <triggerEvent id="Identifier" trigger="PythonExpression" assignments="PythonExpression" delay="Number" useValuesFromTriggerTime="Boolean" name="String"/>