Jack
Jack

Reputation: 1232

modify model's parameters in dymola's script file

I am trying to use a .mos file in Dymola to do multiple simulations, here is an example from claytex's blog:

openModel("C:/Dymola/Testing/Test1.mo")
translateModel ("Test1");
for i in 1:10 loop
         a=i;
         simulate();
         system("copy dsres.mat results"+String(i) +".mat");
end for;

It seems when I translate a model in the script file, I could modify the model's parameters again, which is different when I use Dymola's GUI. In Dymola's GUI, if I try to modify the parameter after I translate the model, I have to re-translate the model. My question is:
In Dymola's script file, when I modify the parameter, how does Dymola deal with it?

Upvotes: 1

Views: 582

Answers (2)

Markus A.
Markus A.

Reputation: 7500

The above comment by "user2024223" is correct, but I think "variable browser" is not stressed enough and some more explanation could help:

When changing the model's parameters after translation, make sure you are not using the model editing (either "Graphical" or "Text"-Ribbon), because this will change the model's code and therefore (usually) force re-translation. The same is true for the "Model View" in the "Simulation" Ribbon.

The code will not be changed if you use the "Variable Browser" in the "Simulation"-Ribbon. An alternative (which actually does the same) is typing the parameter value in the "Commands"-line. E.g. this could be J1.J=5 for the CoupledClutches example. Both of the variants in the paragraph should behave similarly to the script.

Upvotes: 4

Hans Olsson
Hans Olsson

Reputation: 12507

Dymola deals with parameter changes after translation by modifying the dsin.txt file. Some/many parameters have been evaluated and cannot be changed in this way - these variables are not editable in the Variable Browser.

You will get a warning if you try to change non-editable variables in a script.

Note: You should in most cases not have to deal with re-translating the model even after modifying the editable parameters of that model in the GUI. Just simulate the model again - hopefully it does not need re-translation.

Upvotes: 3

Related Questions