octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59063] Event Handling different between Ode-S


From: Hg200
Subject: [Octave-bug-tracker] [bug #59063] Event Handling different between Ode-Solvers (especially ode15s)
Date: Thu, 12 Nov 2020 13:48:12 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0

Follow-up Comment #11, bug #59063 (project octave):

Thank you for the feedback. Here are some thoughts on this:

I have tested a lot and can confirm that the mentioned code section causes the
problem. The suggested fix in comment #10 solves the problem in principle. But
I wonder to what extent "corner cases" have to be considered. I have tested
the following cases with Matlab R2018b. "val" refers to the "value" - variable
returned by the event callback function: 

Case 1).
"direction = 0" and "val = [0, 0, 0, ...]"
--> Matlab continues with the integration (does not stop). My interpretation
is that "val" is not monotic (neither increasing nor decreasing)

Case 2).
"direction = 0" and "val = [-2, -1, 0, ...]"
--> Matlab stops at (and includes) the value of i = 3. "val" is "increasing".
A similar case as the function would "decrease".

Case 3).
"direction = +1" (locates only zeros where the event function is increasing)
and "val = [1, 1, 0, 0, 0, 1, 1, 1, 1, ...]".
--> R2018b outputs the values for the indices i = 1..5. The value i=6 (equal
to 1) is rejected.

I do not know much about ODE, but I can imagine that somebody wants to control
the integration e.g. by a state machine (e.g. if clause), which returns
boolean values {0, 1} only. In this case it would matter if we stop the
integration in case 3) or not. The fix in comment #10 does not do this.

The following patch also catches case #3, but does not discard the value of
i=6.

++
if ((val(i) >= 0 && oldval(i) < 0 && dir(i) != -1) // increasing
   || (val(i) <= 0 && oldval(i) > 0 && dir(i) != 1) // decreasing
   || (val(i) > 0 && oldval(i) <= 0 && dir(i) != -1) // increasing
   || (val(i) < 0 && oldval(i) >= 0 && dir(i) != 1)) // decreasing
 {
    index.resize (index.numel () + 1);
    index (index.numel () - 1) = i;
 }
--

Please let me know if this too hypothetically.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59063>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]