NREL / SOEP-QSS-Test

0 stars 1 forks source link

Missing self-dependencies with pre() usage #31

Closed DeadParrot closed 1 year ago

DeadParrot commented 1 year ago

Self-dependencies created by pre() usage are not appearing in the OCT-generated <Dependencies> section of the modelDescription.xml file. This causes incorrect or inaccurate QSS simulations.

The BouncingBall model has this conditional block:

  when h < 0 then
    reinit(v, -e*pre(v));
  end when;

and no self-dependency for v is generated. For correct QSS simulation the FMU value of v must be set just before the FMU event handling occurs so v needs a self-dependency. (Due to the dependency of h on v the value of v in the FMU may not be that out of date at the zero-crossing event but similar models without this dependency produce much larger QSS simulation errors.)

Discrete variables updated via pre() calls in when blocks such as:

  when time > pre(d) then
    d = pre(d) + 1.0;
  end when;

are also missing the self-dependency. If those variables aren't updated via a non-event-generating operation then their "old" FMU value will still be current when the event loop is run, so the missing dependency won't be an issue in QSS unless such updating is possible.

Tested with OCT 1.43.4.

DeadParrot commented 1 year ago

The reinit + pre issue was resolved by OCT-master-8bb4688ea939e98a3f23be67236795ab5f2d3ac4.

Since the pre scenario with discrete variables isn't currently known to be an issue (or is better addressed with non-event-generating functions) I am closing this.