Message Boards Message Boards

5 Replies
2 Total Likes
View groups...
Share this post:

Using WSMLink for simulation of Modelica generating wrong file paths

Posted 10 years ago


I used WSMLink to simulate modelica model from Mathematica. However, The simulation settings file (.sim) is generating wrong filePath and resultFilePath.

See an example below.

 <?xml version="1.0"?>
 <!DOCTYPE simulation>
 <simulation version="1.0"

From the above resultfilePath is " BouncingBall.mat" .However, The actual result file is "32608BouncingBall_1.mat"

Why resultfilePath refers to the " BouncingBall.mat" while the generated file is with file name "32608BouncingBall_1.mat"?

The Simulation settings file generated is also attached below.

POSTED BY: Alachew Mengist
5 Replies

As noted in the other thread ( ), if you are using version 3 there is no way to specify or retrieve the name of the result file.

You can continue using the functionality in WSMLink to read data from the simulation result, see WSMSimulationData documentation:

POSTED BY: Malte Lenz
Posted 10 years ago

Hey Malte, thank you for your quick reply.

Let me try to elaborate my questions

Import["C:\\Dev\\OpenModelica\\Examples\\", {"ModelicaModel"}]
M = WSMSimulate["BouncingBall", {0, 10}]

From Mathemathica I used the above API to simulate a Modelica model. Then, the simulation result files are generated and stored to the path ../tmp/. Some files generated during the simulation are attached below.

After the simulation is done, I want to get the name of the generated files such as the result file(.mat). For example for the above model the result file(.mat) is named 12112BouncingBall_1. Is it possible to get this name using WSMLink from WSMSimulationData and/or WSMPlot object?

or Any possible ways to change the result file name during the simulation ? This can be illustrated as follows

WSMSimulate["BouncingBall", {0, 10}, resultfilename = BouncingBall.mat]

Something like it where I can choose the result file name to be BouncingBall.mat instead of the default name used by Wolfram i.e 12112BouncingBall_1 for the above model.

Anything that I could be able to know the name of the result file , or renaming the result file or choose the result file name using WSMLink is fine for me.

POSTED BY: Alachew Mengist

Not having used pyhonica, I guess you could just continue calling the relevant Mathematica functions to read the results and create a plot (look up WSMSimulationData and/or WSMPlot).

If you want to read the raw data from the result file yourself, that would of course require a quite large amount of work, but the file format is specified in the documentation here:

POSTED BY: Malte Lenz
Posted 10 years ago


I want to simulate and plot a modelica model via pythonica (Python package for the sane interface between Mathematica and python via mathlink).

Here is the pseudocode

   import pythoinica
   m = pythonica.Pythonica()
   m.eval('Import["' + mofile + '",{"ModelicaModel"}]')
   res = m.eval('WSMSimulate["' + + '",{' + str('0') + str(',') + str('10')+ '} ]')

It worked fine and generates the result file, simulation settings and simulation executable. However I want to read the result file , load it and create a plot.

POSTED BY: Alachew Mengist

I'm not sure what your intention or actual steps to get here were, but in general, WSMLink cannot currently be used to export simulation executables or simulation settings files. This functionality is available in Simulation Center. This is documented at the bottom of this page:

POSTED BY: Malte Lenz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract