Opened 7 years ago

Closed 7 years ago

#4424 closed defect (fixed)

Wrong ModelStructure in FMI 2 modelDescription.xml

Reported by: rfranke Owned by: wbraun
Priority: blocker Milestone: 1.13.0
Component: FMI Version:
Keywords: Cc: wbraun

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 Changed 7 years ago by lochel

  • Owner changed from lochel to wbraun
  • Status changed from new to assigned

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 follow-up: Changed 7 years ago by lochel

  • Component changed from Backend to FMI

@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.

comment:3 in reply to: ↑ 2 Changed 7 years ago by wbraun

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 Changed 7 years ago by lochel

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

comment:5 Changed 7 years ago by lochel

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 Changed 7 years ago by lochel

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

comment:7 Changed 7 years ago by adrpo

  • Milestone changed from 1.12.0 to 1.13.0

comment:8 follow-up: Changed 7 years ago by wbraun

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:9 in reply to: ↑ 8 Changed 7 years ago by lochel

Replying to wbraun:

Fixed in OMCompiler/bba43625.

What is the status of the initial unknowns?

comment:10 Changed 7 years ago by wbraun

I let there for the #3786 open.

comment:11 Changed 7 years ago by wbraun

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

comment:12 Changed 7 years ago by wbraun

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:13 Changed 7 years ago by wbraun

  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed in PR2253.

Note: See TracTickets for help on using tickets.