What is the difference between the openModelFile and openModel commands in Dymola/Modelica?

StackOverflow https://stackoverflow.com/questions/18409803

  •  26-06-2022
  •  | 
  •  

Question

In this question, I asked how I can add a custom package to the MODELICAPATH on startup, but there was some ambiguity in the answers. Based on the answers, I can use either

openModel("path\to\file.mo")

or

openModelFile("Fully.Qualified.Model.Name")

I would like to know how these commands differ, if at all, and when to use one or the other.

EDIT: if you answer please provide sources in the Modelica documentation. I am not sure how to even navigate the documentation to find these commands so this is probably a big handicap.

Was it helpful?

Solution

Chad,

For any questions related to the "built-in" commands in Dymola, please be aware that you can get some basic documentation by using the document(...) function (apparently, help was too pedestrian and elucidate was too pretentious?). This command can be invoked from the command line on the bottom of the "Simulation" tab in Dymola. It takes a string of the function name as the argument. So, to answer your question:

document("openModel");

  function openModel "open a Modelica-file"
    input String path "File-path to open";
    input Boolean mustRead := true "If false we can skip reading the file";
    output Boolean result "true if successful";

    "Opens a Modelica-file and pops up a window with the model in it"
  end openModel;

document("openModelFile");

  function openModelFile "open a Modelica-model from a file"
    input String model "Model to open";
    input String path := "" "File-path to open (can be the empty string)";
    input String version := "" "Version to open (can be the empty string)";
    output Boolean result "true if successful";

    "Opens a Modelica-file and pops up a window with the given model in it"
  end openModelFile;

Sadly, I don't think the documentation quite captures the difference here. In fact, I would argue the names are really backward if you think about it. openModel takes a file as an argument and opens the definition contained in that file (typically a package but not necessarily). On the other hand, openModelFile takes a model name as an argument and opens that model in the model browser (searching the MODELICAPATH, if necessary, to find and open the model).

I hope that helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top