Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3513 closed defect (fixed)

Missing support for operator interval

Reported by: Lennart Ochel Owned by: Lennart Ochel
Priority: high Milestone: 1.9.4
Component: Run-time Version:
Keywords: Synchronous Features Cc: Maksimov Doe, Rüdiger Franke

Description (last modified by Lennart Ochel)

This can be used as test case: Modelica_Synchronous.Examples.CascadeControlledDrive.SubClocked.

Change History (13)

comment:1 by Lennart Ochel, 9 years ago

Owner: changed from somebody to Lennart Ochel
Status: newaccepted

comment:2 by Lennart Ochel, 9 years ago

It's the same issue for Modelica_Synchronous.Examples.SimpleControlledDrive.ExactlyClockedWithDiscreteController.

Version 0, edited 9 years ago by Lennart Ochel (next)

comment:3 by Lennart Ochel, 9 years ago

Description: modified (diff)

comment:4 by Lennart Ochel, 9 years ago

I think the generated code for interval operator should be something like this:

/*
 equation index: 129
 type: SIMPLE_ASSIGN
 PI._Ts = interval(PI.u)
 */
void Modelica_Synchronous_Examples_CascadeControlledDrive_SubClocked_eqFunction_129(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  const int equationIndexes[2] = {1,129};
  $PPI$PTs = data->simulationInfo.clocksData[clock_index].interval;
  TRACE_POP
}

The issue is that clock_index need to be resolved. I think it should be idx within the function handleTimers in synchronous.c, right? Should we just pass it through the call hierarchy?

comment:5 by Lennart Ochel, 9 years ago

Cc: Maksimov Doe Rüdiger Franke added

comment:6 by Rüdiger Franke, 9 years ago

The clock index is known for the system for which the equation is generated. In the C++ runtime we generate a constant clockIndex for each equation. This is passed through one level (from the system to the equation).

void SubClocked::evaluate_129()
{
  const int clockIndex = 2;
  _PI_P_Ts = _clockInterval[clockIndex - 1];
}

comment:7 by Maksimov Doe, 9 years ago

According to Modelica specification partitioning algorithm, variables on left and right sides of interval operator belong to the same subpartition. So in fact this operator will always return the interval of current subpartition.

comment:8 by Lennart Ochel, 9 years ago

Thanks for the input. I adjusted the code generation similar to the cpp runtime.

comment:9 by Rüdiger Franke, 9 years ago

Do you also consider models with inferred sample time?

This is important for FMU export. The interval is not known in this case and must be obtained at simulation time.

in reply to:  9 comment:10 by Lennart Ochel, 9 years ago

Compilation is fixed with 3a9e48.
All models mentioned in this ticket do simulate now. However I didn't compare the results yet.

Replying to rfranke:

Do you also consider models with inferred sample time?

I think that was already implemented, but I am not sure right now. Once we have verified simulations available it will be much easier to identify what is missing.

comment:11 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in 3a9e48.

comment:12 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.4-1.9.x

Milestone renamed

comment:13 by Martin Sjölund, 9 years ago

Milestone: 1.9.4-1.9.x1.9.4

Milestone renamed

Note: See TracTickets for help on using tickets.