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

Speeding up Modelica Simulation

Speeding up Modelica Simulation

Hello

I'm importing a complex model from MapleSim to OpenModelica, and generating an exe file.
since i'm using this application with other tools (optimizers for example) - i'm generating a .csv external file to get the informations.
However, i'm interested in just two variables and, more than that, in just the last simulated value. In maplesim i can select how many probes i want to track.
In openmodellica the output file gets all the variables, and since my model is huge and i have more than 30000 number of intervals, the file is very large, and the time to simulate is very slower. (Running on outputformat=empty is much, much faster)
Is it possible to select which variable would be printted in the .csv file? For instance, one or two instead of all. Is it possible to do better than that and just get the final simulated result?

Thank you very much for the support.

Re: Speeding up Modelica Simulation

I think the interactive client does what you want, but I have not tried it.
when terminal() does not work in OpenModelica so it can't be used either.

However, you can terminate the simulation and print any result you want:

Code:

$ omc +s a.mo

class A
  Real a = time;
equation
  when time >= 0.9999 then
  terminate("a");
  end when;
end A;
trunk marsj@marsj-laptop:~/tmp
$ make -f A.makefile
g++ -I"/home/marsj/dev/trunk/build//include/omc" -march=native -mfpmath=sse  -I. -o A A.cpp A_functions.cpp   -lsim -L"/home/marsj/dev/trunk/build//lib/omc" -lc_runtime -lf2c -linteractive -lsendDataHumbug -lpthread
trunk marsj@marsj-laptop:~/tmp
$ ./A
Simulation call terminate() at time 0.9999
Message : a

Simulation terminated at time 0.9999

This might suit your needs if you just want a quick and dirty solution

Re: Speeding up Modelica Simulation

I've tried to use it, but it has not worked.
I'm trying to put an external code in C to do what I need.
I'm running outside openModelica (in an exe application)- so I need to get the variable outside the environment.

Re: Speeding up Modelica Simulation

My collegue developepd a simple opensource tool to extract data from big plt files generated from OpenModelica for complex models. You can select which variable to plot or to export its data and you can also sample your data results also to generate a less big plt file. If you are interested he can give you the tool or post a direct link to download it in the forum.

Best Regards,
Hassen

Re: Speeding up Modelica Simulation

I don't think that suits his requirements either (creating a 3+ GB file just to get the last 2 results is crazy anyway).

The method I listed does work from another application though. You just need to redirect stdout to a file and parse it. It's quite fast but might be difficult to maintain if OpenModelica output changes or if your simulation usually outputs dassl warnings, etc.

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