NREL / SOEP-QSS-Test

0 stars 1 forks source link

Event indicator directional derivative missing time contribution #16

Closed DeadParrot closed 2 years ago

DeadParrot commented 3 years ago

The ACControl10 model event indicator 22 generates an incorrect directional derivative that is missing the time contribution.

Debugging showed that QSS gives the correct der(time) = 1 to the FMI call to get the directional derivative but zero is returned instead of 1.

The event indicator for the same "when time > nextSample then" conditional in the TimeTest model generates the correct directional derivative.

DeadParrot commented 3 years ago

This issue also occurs in the TimeTest and TimeTestCross models if the zero-crossing function is of the form time > pre(nextSample) instead of time > nextSample.

DeadParrot commented 3 years ago

Versions

The issue was observed with these component versions (may occur with others):

Component Version Date
OCT OCT-r23206_JM-r14295 2021/05
Buildings 9c37781 2021/05/04
QSS e4a0f62 2021/06/08

Build

Build the FMU with bld from the OCT directory as described in the Status page.

The dependencies can be examined in the modelDescription.xml file.

Run

Run the models with PyFMI or QSS from a console configured as described in the Status page.

PyFMI: Use run under the model OCT directories to generate the CVode simulation.

QSS: Use run under the model QSS directory in a method subdirectory such as QSS2.

DeadParrot commented 2 years ago

Here's a simple model that gives the zero directional derivative contribution for the time variable:

model TimeTest
  discrete output Real nextSample( start = 1, fixed = true );
algorithm
  when time > pre(nextSample) then
    nextSample := pre(nextSample) + 1;
  end when;
annotation( experiment( StartTime=0, StopTime=2, Tolerance=1e-4 ) );
end TimeTest;

If the when line is changed to:

  when time > nextSample then

the arguments to the FMIL get directional derivatives call are the same but the correct event indicator derivative value, 1, is returned instead of 0.

DeadParrot commented 2 years ago

These models gives the correct directional derivatives with the OCT-r28312_JM-r14295 update.