Opened 15 years ago
Last modified 11 years ago
#1261 closed defect
Modelica.Blocks.Sources.TimeTable does not work (bug in event-handling) — at Version 2
Reported by: | asodja | Owned by: | asodja |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Simulation Code Generation | Version: | 1.6.0 |
Keywords: | Cc: | asodja, Willi Braun |
Description (last modified by )
In attachment is a test model consisting of only one block of the Modelica.Blocks.Sources.TimeTable component.
The output (TimeTable.y) is zero all the time.
The problem is that the {{initial()}} and {{time >= pre(nextEvent)}} (nextEvent is initalized to 0) never happens, e.g., {{functionDAE_output2()}} is not called at appropriate time so the if-statment is never evaluated to true:
int functionDAE_output2() { /* ... */ tmp0 = initial(); tmp1 = pre($PtimeTable$PnextEvent); RELATIONGREATEREQ(tmp2, time, tmp1); localData->helpVars[0] = tmp2; localData->helpVars[1] = tmp0; if (edge(localData->helpVars[0]) || edge(localData->helpVars[1])) { real_array_create(&tmp3, &$PtimeTable$Ptable, 2, 7, 2); tmp4 = _Modelica_Blocks_Sources_TimeTable_getInterpolationCoefficients(tmp3, $PtimeTable$Poffset, $PtimeTable$PstartTime, time, (modelica_integer)$PtimeTable$Plast, 1e-13); $PtimeTable$Pa = tmp4.targ1; $PtimeTable$Pb = tmp4.targ2; $PtimeTable$PnextEvent = tmp4.targ3; $PtimeTable$Plast = tmp4.targ4; }
Change History (4)
by , 15 years ago
comment:1 by , 15 years ago
by , 15 years ago
Attachment: | ttTest2.mo added |
---|
Bug in event-handling is also evident when {{CombiTimeTable}} is used instead of {{TimeTable}}.
In that case, parameter {{t_min}} and {{t_max}} never get initialized properly.
They are initialized in initial-equation section:
{{{initial equation
t_min = tableTimeTmin(tableID);
t_max = tableTimeTmax(tableID);
}}}
But equations from inital-equation section get evaluated before the initial() event is handeled.
In this case, in initial() event {{tableTimeInit()}} is called which return valid value of variable {{tableID}}.
comment:2 by , 11 years ago
Cc: | asodja, → asodja |
---|---|
Description: | modified (diff) |
An important note is also that if {{_Modelica_Blocks_Sources_TimeTable_getInterpolationCoefficients()}} would get called, it would result in a segmentation fault. See bug #1262.