Opened 10 years ago

Closed 10 years ago

#3205 closed defect (fixed)

Wrong causality in FMI 2 export

Reported by: rfranke Owned by: adeas31
Priority: high Milestone: 1.9.2
Component: FMI Version: trunk
Keywords: Cc:

Description

The following model combines an input and an output in one connector:

package ConnectorIO
  connector IO
    input Real u;
    output Real y;
  end IO;

  model Test
    IO io;
  equation
    io.y = 2*io.u + 1;
  end Test;
end ConnectorIO;

When exporting ConnectorIO.Test as FMU 2.0, the model description contains the right ModelStructure, listing io.y in the Outputs section. The ModelVariables declare io.y with causality local though, which is wrong:

<ModelVariables>
  <!-- Index of variable = "1" -->
  <ScalarVariable name="io.u" valueReference="0" variability="continuous"
    causality="input" initial="approx">
    <Real/>
  </ScalarVariable>
  <!-- Index of variable = "2" -->
  <ScalarVariable name="io.y" valueReference="1" variability="continuous"
    causality="local" initial="calculated">
    <Real/>
  </ScalarVariable>
</ModelVariables>
<ModelStructure>
    <Outputs>
      <Unknown index="2" dependencies="1" dependenciesKind="dependent" />
    </Outputs>
    <Derivatives>
    </Derivatives>
    <InitialUnknowns>
    </InitialUnknowns>
</ModelStructure>

Change History (2)

comment:1 Changed 10 years ago by rfranke

Here is a patch that seems to solve the problem. It appears that the frontend already filters out internal outputs of nested components. This is why the check for DAE.CREF_IDENT might not be needed in SimCodeUtil.getCausality. Can someone check if this is true?

  • Compiler/SimCode/SimCodeUtil.mo

     
    90569056    local
    90579057      DAE.ComponentRef cr;
    90589058      BackendDAE.Variables knvars;
    9059     case (BackendDAE.VAR(varName = DAE.CREF_IDENT(), varDirection = DAE.OUTPUT()), _) then SimCodeVar.OUTPUT();
     9059    case (BackendDAE.VAR(varName = cr, varDirection = DAE.OUTPUT()), _) then SimCodeVar.OUTPUT();
    90609060    case (BackendDAE.VAR(varName = cr, varDirection = DAE.INPUT()), knvars)
    90619061      equation
    90629062        (_, _) = BackendVariable.getVar(cr, knvars);

comment:2 Changed 10 years ago by adeas31

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

Done in r25001.

Note: See TracTickets for help on using tickets.