- Index
- » Programming
- » Modelica Language
- » build() + system() vs. simulate()
build() + system() vs. simulate()
build() + system() vs. simulate()
Hi again,
I'm slowly getting closer to a solution. My model runs fine when I call it using
Code:
simulate(mymodel, startTime=250,stopTime=260)
When I try to build it first and then run it via system() I get an error "-34".
Code:
buildModel(mymodel)
system("mymodel -override startTime=250,stopTime=260 -r D:\\path\\to\\output.mat")
I can get the build/system approach to work, when I compile startTime and stopTime, too:
Code:
buildModel(mymodel, startTime=250,stopTime=260)
system("mymodel -override startTime=250,stopTime=260 -r D:\\path\\to\\output.mat")
this gives me a "0", everything is fine. (And of course I actually don't even need to override start and stop in the system call. However, it will only then also accept a different startTime=251.)
But then I try to rerun the simulation using the last output as input and get an "-1":
Code:
system("mymodel -override startTime=250,stopTime=260 -iif D:\\path\\to\\output.mat -r D:\\path\\to\\output.mat")
API-Documentation is not accessible (https://github.com/OpenModelica/OpenMod … HowTo.pdf) and I couldn't find any other documentation of error codes.
edit:
the last issue can be omitted, when the start file (output.mat) is read from the current working directory (without path):
Code:
system("mymodel -override startTime=250,stopTime=260 -iif output.mat -r D:\\path\\to\\output.mat")
Oh, this is funny, it works the other way around, too. Init file and output file must obviously not be in the same directory (at least, when they have the same name).
OK: so I have a working solution. Only still would like to understand the "-34" and why I have to compile startTime/stopTime.
Thank you all.
André
Re: build() + system() vs. simulate()
Hi,
I don't know why it returns -34.
Can you post the model so I can test with it?
If is not public you might send it to us via email at OpenModelica [at] ida.liu.se
and we'll only use it for debugging and delete it afterwards.
How about if you do without -r:
Code:
buildModel(mymodel);
system("mymodel -override startTime=250,stopTime=260");
Also, have you tried to use forward slash instead of backward slash for paths -r D:/path/to/output.mat
Yes, you cannot use the same file for input and output at the same time.
- adrpo
- 885 Posts
- Index
- » Programming
- » Modelica Language
- » build() + system() vs. simulate()