how to vary a parameter after compiling in modelica

905 views Asked by At

I have written a finite volume model. The parameter n represents the number of volumes. After translating, the parameter can't be modified. Dymola gives this message:

Warning: Setting n has no effect in model. After translation you can only set literal start-values and non-evaluated parameters.

I think the problem is that the parameter n is used in the equation section. There I use the following code:

equation
...
for i in 2:n-1 loop
T[i] = some equation
end for

I also use n for the calculation of the initial values of T.

The purpose is to make a script that repeatedly executes the model but with a different n. How can I do this?

1

There are 1 answers

1
Michael Tiller On BEST ANSWER

The issue here is that your parameter n affects the number of variables in the problem. Dymola (and all other Modelica compilers I know of) evaluate such parameters at compile time. In other words, they hard code the value at compile time into the model.

One potential workaround in your case is to perform the translation or simulation inside your loop. Note that in the translate and simulate commands in Dymola you can include modifications. Just add them after the model name. For example MyModel would become MyModel(n=10).