Opened 8 years ago

Closed 7 years ago

#4424 closed defect (fixed)

Wrong ModelStructure in FMI 2 modelDescription.xml

Reported by: Rüdiger Franke Owned by: Willi Braun
Priority: blocker Milestone: 1.13.0
Component: FMI Version:
Keywords: Cc: Willi Braun

Description

Here are two simple continuous and discrete-time models. When exported through FMI 2.0, the ModelStructure is wrong in both cases. This blocks the use of OpenModelica for non-trivial uses, such as the ones investigated in the PARADOM project.

Continuous-time example:

model DIC "Double Integrator Continuous-time"
  parameter Real p = 1 "gain for input";
  parameter Real y1_start = 1 "start value for first state";
  parameter Real y2_start = 0 "start value for second state";
  input Real u(start = -2);
  output Real y1, y2;
initial equation
  y1 = y1_start;
  y2 = y2_start;
equation
  der(y1) = p * u;
  der(y2) = y1;
end DIC;

The ModelStructure is:

  <ModelStructure>
    <Outputs>
      <Unknown index="1" dependencies="5" dependenciesKind="dependent" />
      <Unknown index="2" dependencies="1" dependenciesKind="dependent" />
    </Outputs>
    <Derivatives>
      <Unknown index="3" dependencies="5" dependenciesKind="dependent" />
      <Unknown index="4" dependencies="1" dependenciesKind="dependent" />
    </Derivatives>
  </ModelStructure>

The ModelStructure should be:

  <ModelStructure>
    <Outputs>
      <Unknown index="1" dependencies="1" dependenciesKind="dependent" />
      <Unknown index="2" dependencies="2" dependenciesKind="dependent" />
    </Outputs>
    <Derivatives>
      <Unknown index="3" dependencies="5" dependenciesKind="dependent" />
      <Unknown index="4" dependencies="1" dependenciesKind="dependent" />
    </Derivatives>
  </ModelStructure>

Discrete-time example:

model DID "Double Integrator Discrete-time"
  parameter Real p = 1 "gain for input";
  parameter Real y1_start = 1 "start value for first state";
  parameter Real y2_start = 0 "start value for second state";
  input Real u(start = -2);
  output Real y1(start = y1_start, fixed = true);
  output Real y2(start = y2_start, fixed = true);
  Real ud;
equation
  ud = sample(u, Clock(Clock(/*inferred*/), solverMethod = "ImplicitEuler"));
  der(y1) = p * ud;
  der(y2) = previous(y1) + 0.5 * p * ud * interval(ud);
end DID;

The ModelStructure is:

  <ModelStructure>
    <Outputs>
      <Unknown index="7" dependencies="5" dependenciesKind="dependent" />
      <Unknown index="8" dependencies="5" dependenciesKind="dependent" />
    </Outputs>
    <DiscreteStates>
      <Unknown index="7" dependencies="" dependenciesKind="" />
      <Unknown index="8" dependencies="" dependenciesKind="" />
    </DiscreteStates>
  </ModelStructure>

The ModelStructure should be:

  <ModelStructure>
    <Outputs>
      <Unknown index="7" dependencies="1 5" dependenciesKind="dependent dependent" />
      <Unknown index="8" dependencies="1 2 5" dependenciesKind="dependent dependent dependent" />
    </Outputs>
    <DiscreteStates>
      <Unknown index="7" dependencies="1 5" dependenciesKind="dependent dependent" />
      <Unknown index="8" dependencies="1 2 5" dependenciesKind="dependent dependent dependent" />
    </DiscreteStates>
  </ModelStructure>

Change History (13)

comment:1 by Lennart Ochel, 8 years ago

Owner: changed from Lennart Ochel to Willi Braun
Status: newassigned

Good ticket, I just wanted to create a similar one. We should also mention the InitialUnknowns are not exported at all. I reassign this, because wbraun said a few weeks ago that he will fix it.

comment:2 by Lennart Ochel, 8 years ago

Component: BackendFMI

@wbraun Are you already working on this? It has a high priority for good reasons and should be fixed ASAP.

Today, I've discussed the first case (continuous-time) with Bernhard and it seems to be an issue with states that are declared as outputs. A possible solution would be to introduce alias variables for those states. Therewith, the dependencies get generated correctly. However, it should also be possible to fix it without that kind of workaround.

in reply to:  2 comment:3 by Willi Braun, 7 years ago

Replying to lochel:

Today, I've discussed the first case (continuous-time) with Bernhard and it seems to be an issue with states that are declared as outputs. A possible solution would be to introduce alias variables for those states. Therewith, the dependencies get generated correctly. However, it should also be possible to fix it without that kind of workaround.

This is really an issue in our current Backend design, because of the states variables, which are basically derivatives, and also the dependency is here for the states derivatives and not for the states. Yes, probably a suitable solution would introduce alias variables for this, since to fix the Backend would take much longer.

comment:4 by Lennart Ochel, 7 years ago

@wbraun So what is the status? Is there any progress?

comment:5 by Lennart Ochel, 7 years ago

This ticket is marked as blocker for the 1.12.0 release. @wibraun, can you please give a quick update? Will you manage to push your changes soon or do you think it has to be postponed for the next release?

comment:6 by Lennart Ochel, 7 years ago

There are also other tickets reporting the same or similar issues with the ModelStructure information: #2764, #3786

comment:7 by Adrian Pop, 7 years ago

Milestone: 1.12.01.13.0

comment:8 by Willi Braun, 7 years ago

Resolution: fixed
Status: assignedclosed

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

Replying to wbraun:

Fixed in OMCompiler/bba43625.

What is the status of the initial unknowns?

comment:10 by Willi Braun, 7 years ago

I let there for the #3786 open.

comment:11 by Willi Braun, 7 years ago

This ticket is also about the discrete structure which is still missing, therefor I open it again.

comment:12 by Willi Braun, 7 years ago

Resolution: fixed
Status: closedreopened

comment:13 by Willi Braun, 7 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in PR2253.

Note: See TracTickets for help on using tickets.