Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

FMU: Input at an inner block

FMU: Input at an inner block

I have a model, create an FMU out of it, and want to import it in to python.

Having inputs on the first canvas works, and transferring them to the blocks which are used works, too.

Because of the architecture of the python code, i need to have the prefix for the inputs as for the rest of the block.

I made a minimal example:

Code:


package testi
  model source
    Modelica.Electrical.Analog.Sources.SignalVoltage signalVoltage annotation(
      Placement(visible = true, transformation(origin = {0, 36}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground annotation(
      Placement(visible = true, transformation(origin = {48, 22}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
      Placement(visible = true, transformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealInput u annotation(
      Placement(visible = true, transformation(origin = {0, 108}, extent = {{-20, -20}, {20, 20}}, rotation = -90), iconTransformation(origin = {0, 108}, extent = {{-20, -20}, {20, 20}}, rotation = -90)));
  equation
    connect(signalVoltage.n, ground.p) annotation(
      Line(points = {{10, 36}, {48, 36}, {48, 32}}, color = {0, 0, 255}));
  connect(signalVoltage.p, pin) annotation(
      Line(points = {{-10, 36}, {-20, 36}, {-20, 0}, {100, 0}, {100, 0}}, color = {0, 0, 255}));
  connect(signalVoltage.v, u) annotation(
      Line(points = {{0, 48}, {0, 48}, {0, 108}, {0, 108}}, color = {0, 0, 127}));
  end source;

  model base
  testi.source source1 annotation(
      Placement(visible = true, transformation(origin = {-42, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  testi.measurement measurement1 annotation(
      Placement(visible = true, transformation(origin = {44, 40}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  equation
    connect(source1.pin, measurement1.pin) annotation(
      Line(points = {{-32, 40}, {34, 40}}, color = {0, 0, 255}));
  end base;

  model measurement
  Modelica.Electrical.Analog.Basic.Resistor resistor annotation(
      Placement(visible = true, transformation(origin = {-24, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Interfaces.Pin pin annotation(
      Placement(visible = true, transformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0), iconTransformation(origin = {-100, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.Analog.Basic.Ground ground annotation(
      Placement(visible = true, transformation(origin = {30, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  equation
    connect(pin, resistor.p) annotation(
      Line(points = {{-100, 0}, {-34, 0}}, color = {0, 0, 255}));
  connect(resistor.n, ground.p) annotation(
      Line(points = {{-14, 0}, {30, 0}, {30, -18}, {30, -18}}, color = {0, 0, 255}));
  end measurement;
  annotation(
    uses(Modelica(version = "3.2.3")));
end testi;

Trying to create the FMU causes the error: Undetermined equation system: 23 equations, 24 variables, although i would provide the input "source.u" via python. If I create an additional Input directly in the base model and connect it to the input of the source, it works, but then i do not have the same prefix "source.u" in my python code, which i would really like to have.

Does anyone know a way to solve this problem?

There are 0 guests and 0 other users also viewing this topic
You are here: