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

Termination Time

Termination Time

Hi,
I created a simple model in which i have a cylindrical tank open at one end. (I know the tank volume) The flow rate is the parameter. My model is such that it terminates when tank volume = flow rate * time. (I used the terminate() condition).  Is there any way to store this termination time in a variable?

Re: Termination Time

Perhaps the following works for you:

Code:

model M

  discrete Real r(start=0, fixed=true);
equation
  when time>0.5 then
    terminate("end");
  end when;
  when terminal() then
    r = time;
  end when;
end M;

I get the expected output:

Code:

$ ./M -output=r

[/home/martin/tmp/a.mo:5:5-5:21:writable]
stdout            | info    | Simulation call terminate() at time 0.500000
|                 | |       | Message : end
time=0.50000000015000567455,r=0.50000000015000567455

Re: Termination Time

Thanks. Works like a charm.

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