4
$\begingroup$

A support case with the identification [CASE:4272760] was created.


I am having some difficulties to provide vector inputs for a Modelica model using Mathematica. To demonstrate this I am using a simple block that will pass a real vector of length 3 unchenaged to its output of the same dimension:

model = ImportString[
    "block VectorPassThrough
         input Real[3] u;
         output Real[3] y;
       equation
         y = u;
     end VectorPassThrough;"
   , 
   "mo"
];

model["ModelicaDisplay"]

Modelica Code

Now I would like to simulate this simple block and provide a vector input:

sim = SystemModelSimulate[ model, {"y"}, {0, 1}, Association[
   "Inputs" -> {
     "u" -> Function[ t, {1., 2., 3.}]
     }
   ]
]

Will throw the error SystemModelSimulate::val :

The variables {u} were not recognized, or the types do not match the model.

Using a time Series also will not help:

sim = SystemModelSimulate[ model, {"y"}, {0, 1}, 
    Association[    
        "Inputs" -> {
            "u" -> TimeSeries[ { {1, 2, 3}, {1, 2, 3} }, { {0, 1} }]
        }
    ] 
]

In what format shall vector (and matrix) inputs be given for SystemModelSimulate?

| improve this question | | | | |
$\endgroup$
4
$\begingroup$

I have received answer from Technical Support at WRI:

At present we cannot feed vectors as lists; instead we have to use array variables such as u[1], u[2] and so on.

[...]

The developers are currently working on implementing the feature for feeding vectors as lists.

Since arrays/vectors can also be indexed using enumerations (e.g. "myEnumeration.first", "myEnumeration.second", ... ), having to address individual arguments in this way will be very cumbersome. Expanding the functionality of SystemModelSimulate would be very welcome.

Update

... but the most important reason for implementing vector input is, that in Modelica array dimensions can be left unspecified (e.g. mat[:,:], vec[:]). We cannot simply assign a value to vec[1] because the Modelica compiler needs to be able to determine the dimensions form the dimensions of the input given. It would be really cumbersome, having to work around this using additional components like the Multiplex.

| improve this answer | | | | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.