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

terminate() usage

terminate() usage

Newby question: What is the intended use of the terminate() function?  I would like a simulation to run 10 seconds unless there is a reason to stop it sooner.  I would like the data for plotting to stop early too.  When running the following test case for 10 seconds, the simulation does not seem to stop.  Am I missing something? What is the proper way to end a simulation early?  I'm using OMEdit 1.7.0 under Ubuntu.  The simulation code for test_terminate was generated by the OpenModelica Compiler 1.7.0 (r9861).

Thanks in advance,
Jim


model test_terminate
  Real x(start = 0);
  Real y(start = 0.0);
  annotation(experiment(StartTime = 0.0, StopTime = 10.0, Tolerance = 1e-06));
algorithm
  if time > 3 then
    x:=time;
  end if;
  if time > 5 then
    y:=time;
  end if;
  if time > 7 then
    terminate("done");
  end if;
end test_terminate;

Re: terminate() usage

terminate is basically the same as assert(false,msg), but should exit with a success rather than failure. So you are using it correctly. However, not a lot of libraries rely on terminate so the OpenModelica runtime does not yet support it (it used to, but was accidentally removed when trying to fix assert for multi-step solvers). Also see bug #1515: http://openmodelica.org:8080/cb/issue/1 … tion=true.

There are 0 guests and 0 other users also viewing this topic