modelica-tools / FMUComplianceChecker

FMI Compliance Checker for validation of FMUs 1.0 and 2.0
BSD 3-Clause "New" or "Revised" License
42 stars 31 forks source link

Validation of FMI 2.0 InitialUnknown indices #31

Open ghost opened 6 years ago

ghost commented 6 years ago

The compliance checker does not validate indices used in unknowns in the ModelStructure/InitialUnknowns element of modelDescription.xml.

The FMI 2.0 standard (p. 60) specifies that InitialUnknowns is an

Ordered list of all exposed Unknowns in Initialization Mode. This list consists of all variables with (1) causality = "output" and (initial="approx" or "calculated"), and (2) causality = "calculatedParameter" and (3) all continuous-time states and all state derivatives (defined with element from ) with initial="approx" or "calculated" [if a Co-Simulation FMU does not define the element, (3) cannot be present.].

However, the following example passes an XML check:

<ModelVariables>
  <ScalarVariable name="v1" valueReference="0" causality="parameter" variability="fixed" initial="exact">
    <Real start="0"/>
  </ScalarVariable>
  <ScalarVariable name="v2" valueReference="1" causality="parameter" variability="fixed" initial="exact">
    <Real start="0"/>
  </ScalarVariable>
</ModelVariables>
<ModelStructure>
 <InitialUnknowns>
    <Unknown index="1"/>
    <Unknown index="2"/>
  </InitialUnknowns>
</ModelStructure>

A check should be made that the listed unknowns are actually unknowns. This could also be extended to cover the knowns it depends on.