Opened 12 years ago

Closed 10 years ago

#2130 closed defect (fixed)

Parameters in FMU's

Reported by: Karim Kanso <kkanso@…> Owned by: Adeel Asghar
Priority: high Milestone: 1.9.2
Component: FMI Version: 1.9.0Beta
Keywords: Cc: Willi Braun

Description

The parameters are not set for imported FMU's.

For example, given the following model

model test
parameter Integer i;
output Real x;
equation
der(x) = i-x;
end test;

Export as FMU, and import again. When the imported module is used in another model, and parameter i is set to a given value this is not reflected in the simulation.

As a workaround to this problem I have been adding fmiSetInteger/Bool/Real assignments during the initialisation of the model. So the generated initialisation code induced from importing the above module is

  flowInstantiate:=fmiFunctions.fmi1InstantiateModel(fmi, "testFMU", debugLogging);
  flowParamsStart:=0;
  eventInfo:=fmiFunctions.fmi1Initialize(fmi, eventInfo);
  fmi_x:=fmiFunctions.fmi1GetContinuousStates(fmi, numberOfContinuousStates, flowParamsStart);

which I modify to

  flowInstantiate:=fmiFunctions.fmi1InstantiateModel(fmi, "testFMU", debugLogging);
  flowParamsStart:=0;
  flowParamsStart:=fmiFunctions.fmi1SetInteger(fmi, {0.0}, {i});
  eventInfo:=fmiFunctions.fmi1Initialize(fmi, eventInfo);
  fmi_x:=fmiFunctions.fmi1GetContinuousStates(fmi, numberOfContinuousStates, flowParamsStart);

It has the desired effect, but should have been done automatically.

Change History (7)

comment:1 by Karim Kanso <kkanso@…>, 12 years ago

Just tested on head and got same issues.

comment:2 by Adeel Asghar, 11 years ago

It doesn't make any difference. The fmiSet* functions should be called for variables that have a start value defined i.e they should have start element inside the ScalarVariable element in the xml description file. We don't call fmiSet* since we set it in the variable declaration if it has a start value. The fmiSet* functions are also called for input variables.

comment:3 by Adeel Asghar, 11 years ago

Resolution: fixed
Status: newclosed

comment:4 by levg@…, 10 years ago

The problem still exists, so why this ticket was closed?

Here is the typical scenario:
1) import FMU A with parameter x. the default value of x is 0 => model A_me_FMU will be created
2) create Context model that include instance of A_me_FMU and overwrite x to 1:
A_me_FMU instance_A(x=1);
3) simulate Context model => instance_A.x will be equal to 1, BUT FMU A will not be updated with new value of x. So internally FMU will still use default value of x = 0.

There is a need to call fmiSet to update parameters value in FMU, which is currently missing.

comment:5 by levg@…, 10 years ago

Milestone: 1.9.01.9.1
Resolution: fixed
Status: closedreopened

comment:6 by Adeel Asghar, 10 years ago

Cc: Willi Braun added
Component: OMEditFMI
Milestone: 1.9.11.9.2

comment:7 by Adeel Asghar, 10 years ago

Resolution: fixed
Status: reopenedclosed

Fixed in r23669.

Note: See TracTickets for help on using tickets.