0

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?

Jack
  • 1,094
  • 6
  • 16
  • 1
    Modifying a parameter using a script is equivalent to modifying a parameter in the Dymola GUI variable browser. See section 1.2 of the Dymola User Manual volume 1A. – user2024223 Oct 04 '21 at 06:10

2 Answers2

4

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.

Markus A.
  • 6,300
  • 10
  • 26
3

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.

Hans Olsson
  • 11,123
  • 15
  • 38