Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

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é

Edited by: lambu0815 - Aug-25-15 13:36:45

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.


Re: build() + system() vs. simulate()

thank you.
I'll try to come up with a simple example (day after tomorrow).

Re: build() + system() vs. simulate()

Sorry,
not reproducible in a simple case, I'll live with it for now. Should I run into that issue more frequently, I'll come back to you.
Regards - André

There are 0 guests and 0 other users also viewing this topic
You are here: