1

I have stated to use MSL CombiTimeTable and replace my own code for a similar function. Is there a way to specify only the size of the table at time of compilation and later give the table values?

The following declaration code works

    CombiTimeTable pump(
        smoothness=Modelica.Blocks.Types.Smoothness.ConstantSegments,
        extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint,
        table=[0,0; 1001,1; 1002,2; 1003,3; 1004,4; 1005,5]);

But I want to avoid giving table dummy values. The documentation of MSL for this block does not indicate that it is possible, but here is perhaps some way to do it?

https://doc.modelica.org/Modelica%203.2.3/Resources/helpMapleSim/Blocks/Sources/index.html#CombiTimeTable

I usually compile the Modelica code to FMUs and set parameters in a Python script. There is a possibility to read the CombiTimeTable information from a file, but I want to have all parameters for the FMU in the Python script, for simplicity.

janpeter
  • 681
  • 8
  • 22

2 Answers2

1

It depends. You could try:

  CombiTimeTable pump(
        nout=1,
        smoothness=Modelica.Blocks.Types.Smoothness.ConstantSegments,
        extrapolation = Modelica.Blocks.Types.Extrapolation.HoldLastPoint,
        table=table);
  parameter Real table[6,2];

which uses an unspecified table of the right-size.

However, tools may require special settings (Dymola seems to require Advanced.IssueErrorForUnassignedParameter=false)- and/or generate default values like 0 regardless.

Hans Olsson
  • 11,123
  • 15
  • 38
  • The drawback with this solution is that table is addressed outside pump. I could of course give it a name like pump_table to make the relation clear, but still then a different kind of name than for all other parameters. I hoped that here, after all, was some size parameter inside CombiTimeTable. The documentation in the link to MSL blocks after all not that complete. – janpeter May 14 '21 at 10:04
  • 1
    Currently I see no way around that since table already has a default. In the future it might work to do CombiTimeTable pump(..., redeclare parameter Real table[6,2]=break); - but I'm not sure if it is more readable. – Hans Olsson May 14 '21 at 10:32
0

Would it be an option to specify the table data from file, i.e., tableFromFile=true? This way you do not need to care for the number of table rows in an explicit way as it all is handled within the Modelica external function code.

tbeu
  • 1,235
  • 7
  • 12
  • I know that specifying a table from a file gives gives you this flexibility of size of table at time of compilation which I am looking for and therefore I thought it must be possible to do without text file to. But seems not. And no, I do not want to have extra files for tables to keep track of. Everything should be handled with FMU and a Python script. That is my wish. – janpeter May 21 '21 at 05:41
  • 1
    Your wish came true. The extra files (like table data) are handled as resources within the FMU (= zipped archive). – tbeu May 21 '21 at 13:18
  • Sounds interesting. Is this FMU 2.0 or upcoming FMU 3.0? Where can I read more about it? – janpeter May 21 '21 at 13:33