1

Is there a way to call an external function right before finishing a simulation in dymola? I need to call the destroyer of some objects before terminating the simulation, but I couldn't find a way to do it.

user3751857
  • 91
  • 1
  • 5

2 Answers2

5

The solution is to use the terminal() function as condition

when terminal() then
...
end when;
user3751857
  • 91
  • 1
  • 5
2

In addition to the other answer you might consider switching to ExternalObject:

https://modelica.org/documents/ModelicaSpec33Revision1.pdf Section 12.9.7.

One major difference is that if your simulation fails then external objects will be destroyed, but 'when terminal()' will not be called.

Hans Olsson
  • 11,123
  • 15
  • 38