Message Boards Message Boards

0
|
6312 Views
|
5 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Using WSMLink for simulation of Modelica generating wrong file paths

Posted 10 years ago

Hello,

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"
    name="BouncingBall"
    start="0."
    end="10."
    stepSize="0"
    outputSteps="-1"
    tolerance="1.e-6"
    method="dassl"
    filePath="BouncingBall.exe"
    resultFilePath="BouncingBall.mat">

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.

Attachments:
POSTED BY: Alachew Mengist
5 Replies

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: http://reference.wolfram.com/system-modeler/UserGuide/SimulationCenterImportingAndExporting.html

POSTED BY: Malte Lenz
Posted 10 years ago

Hi,

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('Needs["WSMLink`"]')
   m.eval('Import["' + mofile + '",{"ModelicaModel"}]')
   res = m.eval('WSMSimulate["' + self.name + '",{' + 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

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: http://reference.wolfram.com/system-modeler/UserGuide/SimulationCenterSimulationResultFiles.html

POSTED BY: Malte Lenz
Posted 10 years ago

Hey Malte, thank you for your quick reply.

Let me try to elaborate my questions

Needs["WSMLink`"]     
Import["C:\\Dev\\OpenModelica\\Examples\\BouncingBall.mo", {"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.

Attachments:
POSTED BY: Alachew Mengist

As noted in the other thread ( http://community.wolfram.com/groups/-/m/t/339700?p_p_auth=q7hVqLPX ), 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: http://reference.wolfram.com/system-modeler/WSMLink/ref/WSMSimulationData.html

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

Group Abstract Group Abstract