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

FMU Checker does not perform semantic checks on scalar variables #34

Open chrbertsch opened 6 years ago

chrbertsch commented 6 years ago

(moved from https://trac.fmi-standard.org/ticket/398; reported by Lausdahl)

The FMU Checker seems to be missing the semantics checks from the standard and thus not reporting any error for modelDescription.xml which contain obvious errors.

Here is an example. The model description includes this scalar variable:

<ScalarVariable

    name="logicalNot.y"
    valueReference="186">
    <Boolean/>

</ScalarVariable>

This is of cause not allowed since the standard says as follows:

    variability
    "continuous": Only a variable of type = “Real” can be “continuous”.
    ModelExchange: No restrictions on value changes.
    CoSimulation: By convention, the variable is from a differential

and

The default is “continuous”

So the above scalar variable can be expanded as follows:

<ScalarVariable

    name="logicalNot.y"
    variability="continuous"
    valueReference="186">
    <Boolean/>

</ScalarVariable>

So defining this with type Boolean is an error and should be reported.

Some of the Test_FMUs have this issue e.g: Test_FMUs/FMI_2.0/CoSimulation/win32/MWorks/2016/ControlledTemperature/ControlledTemperature.fmu Test_FMUs/FMI_2.0/CoSimulation/win32/MWorks/2016/BooleanNetwork1/BooleanNetwork1.fmu Reason

nickbattle commented 5 years ago

This problem is picked up by VDMCheck:

$ VDMCheck.sh scalartest.xml 
2.2.7 Variability/causality <continuous>/<local> invalid at line 8
2.2.7 ScalarVariables["logicalNot.y"] invalid at line 8
2.2.1 ScalarVariables invalid
false
$

I can confirm that the same problem occurs in the two Test FMU examples you cite, and also in DFFREG.fmu (various versions). There are various other ScalarVariable problems in Test FMUs as well, for example:

VDMCheck.sh ./cs/win32/MWorks/2016/MixtureGases/MixtureGases.fmu
2.2.7 start -1 is not within min 1/max 10000
2.2.7 Variable min/max/start invalid at line 1143
2.2.7 ScalarVariables["Medium2.fluidConstants[6].normalBoilingPoint"] invalid at line 1143
2.2.1 ScalarVariables invalid
2.2.8 Derivatives declared, but no Real/derivative variables at line 3130
2.2.8 InitialUnknowns must include: {353, 354}
false

We're Still trying to verify the VDM model that produces these results, but I think these errors are valid.