How to trigger an event repeatedly at constant intervals?

9 views
Skip to first unread message

Matthias König

unread,
Apr 8, 2019, 8:14:27 AM4/8/19
to libsbml-development
Hi all,

I want to trigger an event every 200 time units.
The problem is that equality comparisons in event triggers are highly unreliable.
E.g. if I want to trigger an event after 100 time units one should write the trigger expression
(i) time>= 100
instead of
(ii) time == 100
because the version (ii) is highly unreliable (often not triggered by solvers because they step over the trigger event) and depends strongly on implementation details, e.g., the minimal time steps and stepping of the solver.

I am now looking for a more general expression which reliable triggers every 200 time units.
The version (ii) of this would be

(ii) time%200 == 0

which will be highly unreliable. How can I get a reliable trigger which triggers every 200 time units?

Best Matthias

Frank T. Bergmann

unread,
Apr 8, 2019, 8:29:31 AM4/8/19
to libsbml-d...@googlegroups.com

Hello Matthias,

 

See the attached model, here I have an event that triggers when:

 

{Time}-{Values[last]} >= 200

 

At that point I set last to the current time and do whatever else needs doing. That should be easy enough for simulators.

 

Cheers

Frank

 

--
You received this message because you are subscribed to the Google Groups "libsbml-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libsbml-develop...@googlegroups.com.
To post to this group, send email to libsbml-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libsbml-development/54e9b78e-2dd3-44ef-bc8f-d8d9d32dc0b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

event_every_200_secs.xml

Hoops, Stefan (sh9cq)

unread,
Apr 8, 2019, 8:52:56 AM4/8/19
to libsbml-d...@googlegroups.com
Hello Matthias,

You can also make use of a parameter (period) with an assignment:
period := sin(2*pi*omega*time) and check for period >= 0

Thanks,
Stefan



On Mon, 2019-04-08 at 05:14 -0700, 'Matthias König' via libsbml-
--
Stefan Hoops, Ph.D.
Research Associate Professor
Biocomplexity Institute & Initiative
University of Virginia
995 Research Park Boulevard
Charlottesville, VA 22911

Phone: +1 540 570 1301
Email: sho...@virginia.edu

Matthias König

unread,
Apr 8, 2019, 9:54:43 AM4/8/19
to libsbml-development
Hi Frank and Stefan,

thanks a lot for the help. This solves my issue, both solutions work.
The sinus trick is very nice.

Best Matthias
Reply all
Reply to author
Forward
0 new messages