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
  • Index
  • » Users
  • » jamesclementsiii
  • » Profile

Posts

Posts

Sep-21-11 05:32:13
Using the terminate() function in simulation runs

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;

  • Index
  • » Users
  • » jamesclementsiii
  • » Profile
You are here: