Search code examples
modelicadymola

How to use Multiple threading in Dymola's script file?


I am trying to use the .mos file to do multiple simulations in Dymola, so I use a for loop, but it can't open Multiple threading on my computer, I'd like to ask if there is a function that allows me to open Multiple threading in the .mos file? I already know the "sweep parameters" could open Multiple threading, but I'd like to use the .mos file, cause I need to do simulations on a few different models, and I could only use "sweep parameters" on one model?

enter image description here


Solution

  • I don't think multi-threading/parallelization is possible from a .mos file, like it is from e.g. Python (look for MultithreadingExample.py in the "Full User Manual") or Java (looking for MultithreadingExample.java).

    But there is a function that could do what you want: simulateMultiResultsModel. It is described in more detail in the Dymola User Manual (see section "Built-in functions in Dymola"). The most important paragraph says:

    The function by default runs the simulations in parallel on multiple cores on the CPU. By default, all cores are used, but if needed the number of parallel runs can be specified by setting the flag Advanced.ParallelSimulations. The default value is 0, meaning all cores are used. Setting it to 1 disables parallelization; as it will only run on one core