Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically create conversion script in Dymola

Tags:

dymola

In https://trac.modelica.org/Modelica/ticket/2229#comment:2 it is mentioned that Dymola has the capability to automatically update a conversion script when changes are applied to a library. I was searching the Dymola manuals but could not find any actual guidelines how to apply this feature.

However, I could find some settings in the options, but I cannot force Dymola to create / update a conversion script.

enter image description here

Does anyone have some guidelines on how to enable the feature of automatically creating a conversion script?

like image 1000
christiankral Avatar asked May 16 '19 18:05

christiankral


People also ask

How do I create a script in Dymola?

In this experiment the vehicle accelerates from rest, going up through the gears, as shown in the video below. The easiest route to create your plot script is to generate the plots you need with the plot options in Dymola and then use the inbuilt script generation tool to capture your plots in a script for later reuse.

How to view the animation of the robot in Dymola?

and select r3.mos. Dymola then translates the model, simulates and plot automatically. To view the animation of the robot, open the iconized animation window. Start the animation by selecting Animation / Run or using key F3. F4 is used to suspend animation, F5 and F6 to step forward and backward respectively.

What can I do in the Dymola main window?

The Dymola main window has a toolbar with five buttons to: Run a command script Modify parameter values Modify initial conditions Specify simulation run (e.g., start and stop times) Perform simulation. Simulating a model — industrial robot

How do I edit a model in Dymola?

Start Dymola or if it is already started then give the command File / Clear All in the model window. Go to the model window. It has the title "Unnamed". A model has different layers that can be edited. To specify a behavior directly in terms of equations, the Equation Layer has to be edited.


1 Answers

Generate commands for conversion

There are three advanced variables for that, namely:

Integer Advanced.ActivateSmartDelete = 3 "Updates other classes when deleting class/component [0 - no, 1 - ask, 2 yes (if possible)]";
Integer Advanced.ActivateSmartRename = 3 "Updates other classes when renaming component [0 - no, 1 - ask, 2 yes, 3 - also script]";
Integer Advanced.ActivateSmartRenameClass = 3 "Updates other classes when renaming class [0 - no, 1 - ask, 2 yes, 3 - also script]";

As the comments indicate, setting these variables on 3 (using the Dymola Command window or, in newer Dymola versions, the options which can be seen in your screenshot) results in automatically created conversion commands.

Dymola will write the conversion commands to the model annotation of your library. They will look something like this:

  from(
    version="3.2.3",
    to="Intermediate",
    change(item=convertClass("Modelica.Blocks.Continuous.PID", "Modelica.Blocks.Continuous.PID_Controller"),
           item=convertClass("Modelica.Blocks.Continuous.FirstOrder", "Modelica.Blocks.Continuous.PT1")))

Export commands to a file

Before Dymola 2022x

You have to convert the commands a little, if you want to have the conversion script in a separate file (instead of the package.mo of your library).

In a script the above commands would look as follows:

convertClear()
convertClass("Modelica.Blocks.Continuous.PID", "Modelica.Blocks.Continuous.PID_Controller"),
convertClass("Modelica.Blocks.Continuous.FirstOrder", "Modelica.Blocks.Continuous.PT1")

so the same commands, but without item= and trailing ,.

With Dymola 2022x

Dymola 2022x can export the commands to a file.

  • Open the Attributes dialog of your library from the package browser
  • Use the button Convert from Pre-Release... in the Version tab

Version tab in package attributes in Dymola

Dymola will then remove the previously generated commands from the library annotation and copy them in the correct format to the specified file. Note that Dymola will also update the version number of the library and adjust the from command. If this is not desired, change it back.

like image 139
marco Avatar answered Oct 21 '22 15:10

marco