-
-
Notifications
You must be signed in to change notification settings - Fork 4
Description
@jClugstor, after adding inlining we managed to get 8/534 models of the Modelica Standard Library to be successfully exported as Base Modelica and imported with your tool.
An issue that is plaguing a lot of the currently failing models is demonstrated, e.g., by Modelica.Electrical.Digital.Examples.Adder4.mo.
The Base Modelica model starts with
//! base 0.1.0
package 'Adder4'
type 'Modelica.Electrical.Digital.Interfaces.Logic' = enumeration('\'U\'', '\'X\'', '\'0\'', '\'1\'', '\'Z\'', '\'W\'', '\'L\'', '\'H\'', '\'-\'');
model 'Adder4' "4 Bit Adder Example"
parameter 'Modelica.Electrical.Digital.Interfaces.Logic'[2] 'b4.x' = {'Modelica.Electrical.Digital.Interfaces.Logic'.'\'1\'', 'Modelica.Electrical.Digital.Interfaces.Logic'.'\'0\''} "Vector of values";The parser fails on the last line, as soon as it encounters the array size declaration [2]. I guess this is because Modelica and Base Modelica allows two forms of array declaration:
Real x[2];
Real[2] y;and BaseModelica.jl does not support the latter. This raises two questions.
The first question is whether or not ModellingToolikit can handle array variables and array equations/for-loop equations natively. If it does, then the BaseModelica.jl parser should be able to handle both forms of the declaration.
If it doesn't, or if we currently don't want to rely on that feature, then the other option is to have OpenModelica flatten the system to scalar basic types and scalar equations by setting --baseModelicaOptions=scalarize, so we'd have
Real 'x[1]';
Real 'x[2]';
Real 'y[1]';
Real 'y[2]';In this case, the indeces become part of the quoted identifiers. Any explicit reference to the original array structure is lost, which may lead to less efficient handling of the code for large systems, but on the other hand the flat model has no arrays at all, so it's easier to handle.
@jClugstor what do you think? Which direction should we take in the short an long term?
Keeping @AnHeuermann in the loop.