Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

dynamic array size?

dynamic array size?

Hi,

adrian pop stated:

There aren't any "references" yet in Modelica, everything is static!
The arrays have predetermined size (at compile time).

can't I read a parameter  from a file - as shown in utilities.readRealParameterModel -
and instantiate the array size using this parameter?

Is the txt file parsed at compile time? or can I change the parameter and rerun a compiled simulation?


alex

Re: dynamic array size?

I made the test - the txt file is only evaluated at compile time....

so if I would like to make a parameterscan does it mean that i have to compile the modelica code for each run?

in dymola there are some parameterscan functions, e.g. 2d scan. so if I make 10x10 steps - does dymola compile the model 100 times?


alex

Re: dynamic array size?

This is all because the arrays whose sizes are being determined by the initialization process are actually part of solving the initialization problem.
It should be possible to use a fixed=false parameter in an initial equation in OpenModelica with the following caveat: You need to make sure that when doing buildModel, you have the largest number of elements in your matrix because this is the size that will be allocated (so if you want to scan 8x1, 4x4, 3x5, you need to use buildModel and evaluate 4x4; then it should be possible to change the init-file or use some other method to change parameter values during runtime). You might get terribly weird results if you do this wrong though, so it's not recommended (structural parameters are more like constants than parameters).

There are 0 guests and 0 other users also viewing this topic
You are here: