Open DeadParrot opened 2 years ago
Here are some specific examples of OCT Dependencies that will need changing to work with this proposed design.
Variables modified within an event indicator's "handler" block are missing dependencies from those equations. So with this usage v
will not show a dependency on time
:
when h < 0 then
reinit(v, time);
end when;
Edit: Fixed as of OCT-master-8bb4688ea939e98a3f23be67236795ab5f2d3ac4.
And with this usage discrete variable d
will not show a self-dependency:
when time >= pre(d) + 1 then
d = pre(d) + 1;
end when;
OCT short-circuits intermediate (not continuous state) variables out of the dependencies but QSS can exploit the option of keeping them as active update signaling variables.
For this model OCT gives a dependency of the time < 1
event indicator on t
instead of time
:
model X
output Real t;
output Real r(start = 0, fixed = true);
equation
t = time + 1;
if time < 1 then
r = time * time;
else
r = t;
end if;
annotation( experiment(StartTime=0, StopTime=5, Tolerance=1e-4) );
end X;
While time
and t
are closely related this is not the natural dependency that QSS will expect.
For this model OCT gives a dependency of the time >= 1
event indicator on the time < 1
event indicator instead of time
:
model X
output Real r1(start = 0, fixed = true);
output Real r2(start = 1, fixed = true);
equation
when time < 1 then
r1 = sin(time);
r2 = cos(time);
elsewhen time >= 1 then
r1 = pre(r2) + time;
r2 = pre(r1) + time;
end when;
annotation( experiment(StartTime=0, StopTime=5, Tolerance=1e-4) );
end X;
QSS needs the actual direct dependencies in this case because dependencies between event indicators are used when an intermediate signaling variable modified in conditional "handler" block that also appears in the zero-crossing function of an event indicator is short-circuited out of the dependencies. The meaning of the dependency here is different, that OCT finds the event indicators to share the same form or dependencies, which QSS cannot distinguish from the other meaning. Note: A temporary work-around was added to QSS to allow for both meanings when EI->EI dependencies are present, which should allow correct simulation at some efficiency cost.
The Dependencies behavior described is based on the OCT update version OCT-master-7245bce03ab2ebdfdaaf0805d75209efaa009c67.
Dependencies were added for QSS use based on the need to actively track some algebraic variables that can interact with event triggering outside of a dependency graph path that includes a continuous state variable (e.g. see, DepTest5). The approach was to list all direct dependencies between algebraic, state, and input variable in a
<Dependencies>
section of the modelDescription.xml file to give QSS the full dependency graph that it could use as needed. Testing and discussions have turned up some problems with this approach:To address these obstacles we believe that a revised approach can work. Essentially, the QSS active simulation dependency graph is reduced to only contain dependencies on continuous states and inputs and event indicators, with the last an addition to cover the effect of event indicator "signaling" via algebraic variables. The details to make this work include:
<ModelStructure>
except for event indicator inter-dependencies).Dependencies for QSS
Dependencies in QSS have two related purposes that the exposed dependencies must represent:
Outputs
<Outputs>
the state and input dependencies are provided for output variables that should allow their value to be retrieved from the FMU by setting the values of the dependencies in the FMU (confirm this).Implementation Proposal
<Dependencies>
section for QSS for now so that we can adjust/add dependencies beyond what is in<ModelStructure>
. If we find there is no difference we can eventually drop<Dependencies>
.<Dependencies>
section would work.Open Questions
<Dependencies>
provide the "raw" or short-circuited dependency graphs?