modelicaopenmodelica

In OpenModelica, is there a constant component that can take multiple input values?


in the model below i have a convection component that is composed of 4 elements (table(4,1)). what i did is define the product and the const componant as a table of 4 elemnts but the coefficient table do not accept this definition. is there any way to calculate the product of the constant "const" and a intrepoleted value from the coeffcient table and inserted as GC input for the convection components ?

enter image description here

code :

model test
  Modelica.Blocks.Sources.TimeTable coefficient(table = [0, 10722; 64, 10746; 68, 10568; 74, 8656; 524, 0; 530, 1508; 534, 2885; 538, 4298; 542, 5486; 548, 6780; 552, 7469; 558, 8335; 562, 8846; 566, 9297; 570, 9535; 576, 9831; 582, 10211; 586, 10342; 590, 10461; 594, 10603; 600, 10686]) annotation(
    Placement(transformation(origin = {-72, 46}, extent = {{10, -10}, {-10, 10}}, rotation = 180)));
  Modelica.Blocks.Math.Product product annotation(
    Placement(transformation(origin = {14, 8}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Blocks.Sources.Constant const(k = 10) annotation(
    Placement(transformation(origin = {-72, -32}, extent = {{10, -10}, {-10, 10}}, rotation = 180)));
  Modelica.Thermal.HeatTransfer.Components.Convection convection_serpentin_1[4] annotation(
    Placement(transformation(origin = {68, 8}, extent = {{-10, 10}, {10, -10}}, rotation = -90)));
equation
  connect(const.y, product.u2) annotation(
    Line(points = {{-61, -32}, {-51, -32}, {-51, 2}, {1, 2}}, color = {0, 0, 127}));
  connect(coefficient.y, product.u1) annotation(
    Line(points = {{-61, 46}, {-51, 46}, {-51, 14}, {1, 14}}, color = {0, 0, 127}));
  connect(product.y, convection_serpentin_1.Gc) annotation(
    Line(points = {{26, 8}, {58, 8}}, color = {0, 0, 127}));

annotation(
    uses(Modelica(version = "3.2.3")));
end test;

Solution

  • You have defined a vector of convection components, so what looks like a single component, is actually four elements named convection_serpentin_1. Then you have a connection connect(product.y, convection_serpentin_1.Gc) this means that you connect all product.y with all four inputs of the vector of convection_serpentin_1. This is what the check complains about. You need to take care of the size and indexes manually.

    There are multiple possibilities to solve this.

    1. Use the dialog that pops up when you draw the connection graphically.

    Connection Dialog

    Above, you see the settings for which product.y will be connected to the input of the first element of the vector of convection_serpentin_1. This will result in the a connect statement with an index: connect(product.y, convection_serpentin_1[1].Gc).
    Following this, you will need to connect the other three inputs in a similar fashion (and of course the thermal interfaces, also minding the vectorization).

    As an alternative to that, in case you want all convection elements to have the same Gc, you can use a Modelica.Blocks.Routing.Replicator to create a vector from the scalar output of product.y. To do so, set the parameter nout=4 and create a connection with the above dialog having colons for both selections.

    The result should look similar to this: Screenshot of Replicator used in the model