Search code examples
assertmodelica

Modelica assert(condition, message, level=AssertionLevel.warning);


Part 8.3.7 of the Modelica Spec describes the function assert and gives two examples, but whenever I try to use one of the following commands, it does not work as expected:

assert(T > 250 and T < 400, 
    "Medium model outside full accuracy range", 
    AssertionLevel.warning);

or

assert(T > 250 and T < 400, 
    "Medium model outside full accuracy range", 
    level=AssertionLevel.warning);

What is wrong here? Did I miss something obvious?


Solution

  • So I checked with Dymola (2012FD01) and it looks like Dymola has not implemented the level argument:

    > document("assert")
    function assert "assert that a condition is true"
    input Boolean _condition;
    input String _error;
    
    The given condition should be true.
    If it is false an error message will be given
    end assert;
    

    Or maybe it's simply not documented. You probably should ask the DS support on that. In OpenModelica it seems they have implemented as described in the specs (see also http://build.openmodelica.org/Documentation/assert.html).