Reputation: 29
I try with python to read the.mat files generated by dymola, but with each simulation I run the .mat file is saved in different folders. How can I have a single exit path?
Thank you.
Upvotes: 1
Views: 613
Reputation: 29
Thank you for your answer, I could not solve the problem but I will try explain the situation better. I call my model dymola from python with (s = Simulator(modelName=modelName, simulator="dymola", outputDirectory=outputDirectory, packagePath=packagePath) of buildingspy. With this command the file ". mat "generated by dymola should end up in the outputDirectory. However, every time I run a dymola simulation from python the .mat file is saved in different folders that are already in my working directory and at each simulation the .mat is saved in one of these files. is it necessary to specify the output file ". mat" in dymola or normally it should work as I described? Thank you
Upvotes: -1
Reputation: 6645
Dymola writes the simulation results to the working directory. Use cd
to change it.
If you use openModel
to load additional models, be aware that it changes the working directory with default parameters. Set changeDirectory=False
to prevent that.
You can make the Dymola GUI visible while writing the python code, which should make debugging easier.
Here is a minimal example which starts Dymola with the window visible, changes the working directory and simulates a model. The .mat file will be written to C:/tmp/dymola
:
dymola = DymolaInterface(showwindow=True)
dymola.cd("C:/tmp/dymola")
dymola.openModel("C:/path/to/some-package.mo", changeDirectory=False)
dymola.simulateModel("someModel")
As an alternative you can set the path to the output file when you call simulateModel
.
With the following code Dymola will create the the my-result.mat
at C:/tmp
:
dymola.simulateModel("someModel", resultFile="C:/tmp/my-result")
Upvotes: 3