From 0a461385b4c6b5ba783de750f7d9916671ab2efa Mon Sep 17 00:00:00 2001 From: ElmirNahodovic <210350926+ElmirNahodovic@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:26:49 +0200 Subject: [PATCH 1/3] added combitable1ds example --- .../modelDescription_CombiTable1Ds.xml | 50 ++++++++++++++++ .../terminalsAndIcons_CombiTable1Ds.xml | 28 +++++++++ docs/index.adoc | 59 +++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 docs/examples/modelDescription_CombiTable1Ds.xml create mode 100644 docs/examples/terminalsAndIcons_CombiTable1Ds.xml diff --git a/docs/examples/modelDescription_CombiTable1Ds.xml b/docs/examples/modelDescription_CombiTable1Ds.xml new file mode 100644 index 0000000..319b28b --- /dev/null +++ b/docs/examples/modelDescription_CombiTable1Ds.xml @@ -0,0 +1,50 @@ +... + + + + + + + + + + + + + + + + + + + + + + + + + +... \ No newline at end of file diff --git a/docs/examples/terminalsAndIcons_CombiTable1Ds.xml b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml new file mode 100644 index 0000000..378c5ba --- /dev/null +++ b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/docs/index.adoc b/docs/index.adoc index 200853c..bd65546 100644 --- a/docs/index.adoc +++ b/docs/index.adoc @@ -226,8 +226,67 @@ These variables are grouped in a terminal with the terminalKind `org.fmi-standar include::examples/terminalsAndIcons.xml[] ---- +=== 1-d example of a CombiTable1Ds as a rectilinear grid +In the Modelica Standard Library, `CombiTable1Ds` is a lookup table (part of the link:https://doc.modelica.org/Modelica%204.0.0/Resources/helpDymola/Modelica_Blocks_Tables.html#Modelica.Blocks.Tables[Modelica.Blocks.Tables] package) used to interpolate data based on one input variable and multiple output variables. It performs univariate interpolation on a table matrix using methods such as constant, linear, or cubic Hermite splines. +The data in a `CombiTable1Ds` is stored in a parameter-matrix called `table[i,j]`. The first column represents the domain, while the rest of the columns define the codomain. Below is a simple example of such a table: +[[combiTable1D_example]] +[cols="1,1,1,1"] +|==== +| x (input) | y (output 1) | y (output 2) | y (output 3) + +| 1 | 2 | 4 | 7 +| 2 | 3 | 2 | 5 +| 3 | 4 | 1 | 2 +|==== + +The following Modelica model uses `Modelica.Blocks.Tables.CombiTable1Ds` to represent the data shown above. +``` +model ExampleWithCombi + Modelica.Blocks.Tables.CombiTable1Ds combiTable1Ds1( + table={{1,2,4,7}, + {2,3,2,5}, + {3,4,1,2}}, + columns={2,3}, + smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments) annotation(Placement(transformation(extent={{-70,15},{-50,35}}))); + Modelica.Blocks.Sources.RealExpression realExpression1(y=time) annotation(Placement(transformation(extent={{-115,15},{-95,35}}))); +equation + connect(realExpression1.y,combiTable1Ds1.u) annotation(Line( + points={{-94,25},{-89,25},{-77,25},{-72,25}}, + color={0,0,127})); + annotation( + uses(Modelica(version="4.0.0")), + experiment( + StopTime=3, + StartTime=1, + Interval=0.001)); +end ExampleWithCombi; +``` +Both the domain and codomain are contained in the matrix: + +``` +table={{1,2,4,7}, + {2,3,2,5}, + {3,4,1,2}}. +``` +The first column always represents the domain, while the rest of the columns contain the codomain values. The assignment `columns = {2,3}` specifies which columns are interpreted as output variables and interpolated based on the input. Therefore the third output in the table above is omitted. + +The variables representing the table, inputs, and outputs are given in the modelDescription.xml: +[source, xml] +---- +include::examples/modelDescription_CombiTable1Ds.xml[] +---- + +The structured representation of the data is defined in `terminalsAndIcons.xml`: +[source, xml] +---- +include::examples/terminalsAndIcons_CombiTable1Ds.xml[] +---- + +The `combiTable1Ds1.table` variable appears twice: once with `variableKind="org.fmi-standard.fmi-ls-struct.map.domain"` and again with `variableKind="org.fmi-standard.fmi-ls-struct.map.codomain"`, since both domain and codomain data are stored in the same variable. The `terminalMemberVariable`, `combiTable1Ds1.y`, is a 2D-array, since the Modelica code specified two outputs with `columns = {2,3}`. + +_[Note: According to this FMI layered standard, the domain must be represented as a 1-dimensional array variable. In this example, the first column of the `combiTable1Ds1.table` variable conceptually represents the 1D domain. While the full table is a 2D array, the domain values are treated as a separate 1D array. Therefore, even though `combiTable1Ds1.table` is a 2D array in the FMU and Modelica model, the domain is interpreted as a 1D array by the terminal definition, through the domain input `combiTable1Ds1.u`.]_ == Maps sampled on irregular grids ("Point Cloud") From 08fbca9b3ace9ee02642b705fc2181892202a8a4 Mon Sep 17 00:00:00 2001 From: ElmirNahodovic <210350926+ElmirNahodovic@users.noreply.github.com> Date: Wed, 29 Oct 2025 11:52:55 +0100 Subject: [PATCH 2/3] Rework CombiTable1Ds description Split CombiTable1Ds Example to a separate section "Maps represented by `CombiTable1Ds` " with definition and example. This defines a third terminalKind for CombiTable1Ds --- .../terminalsAndIcons_CombiTable1Ds.xml | 4 +- docs/index.adoc | 145 ++++++++++-------- 2 files changed, 85 insertions(+), 64 deletions(-) diff --git a/docs/examples/terminalsAndIcons_CombiTable1Ds.xml b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml index 378c5ba..e5b9823 100644 --- a/docs/examples/terminalsAndIcons_CombiTable1Ds.xml +++ b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml @@ -4,8 +4,8 @@ fmiVersion="3.0.1"> > above is omitted. + +The variables representing the table, inputs, and outputs are given in the modelDescription.xml: +[source, xml] +---- +include::examples/modelDescription_CombiTable1Ds.xml[] +---- + +The structured representation of the data is defined in `terminalsAndIcons.xml`: +[source, xml] +---- +include::examples/terminalsAndIcons_CombiTable1Ds.xml[] +---- + +Note the `terminalMemberVariable` `combiTable1Ds1.y` is a 2D-array, since the Modelica code specified two outputs with `columns = {2,3}`. + == Known Limitations of This Standard General limitations: From d19084a0f99a269dca992f027b536d5426daef81 Mon Sep 17 00:00:00 2001 From: ElmirNahodovic <210350926+ElmirNahodovic@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:57:00 +0100 Subject: [PATCH 3/3] Combitable mapping and example moved to rectilineargrid section --- .../terminalsAndIcons_CombiTable1Ds.xml | 2 +- docs/index.adoc | 150 ++++++++---------- 2 files changed, 69 insertions(+), 83 deletions(-) diff --git a/docs/examples/terminalsAndIcons_CombiTable1Ds.xml b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml index e5b9823..2a881bf 100644 --- a/docs/examples/terminalsAndIcons_CombiTable1Ds.xml +++ b/docs/examples/terminalsAndIcons_CombiTable1Ds.xml @@ -5,7 +5,7 @@ > above is omitted. + +The variables representing the table, inputs, and outputs are given in the modelDescription.xml: +[source, xml] +---- +include::examples/modelDescription_CombiTable1Ds.xml[] +---- + +The structured representation of the data is defined in `terminalsAndIcons.xml`: +[source, xml] +---- +include::examples/terminalsAndIcons_CombiTable1Ds.xml[] +---- + +Note the `terminalMemberVariable` `combiTable1Ds1.y` is a 2D-array, since the Modelica code specified two outputs with `columns = {2,3}`. + == Maps sampled on irregular grids ("Point Cloud") @@ -370,86 +436,6 @@ include::examples/irregular2d_terminalsAndIcons.xml[] include::examples/irregular2d_modelDescription.xml[] ---- -== Maps represented by `CombiTable1Ds` -In the Modelica Standard Library, `CombiTable1Ds` is a lookup table (part of the link:https://doc.modelica.org/Modelica%204.0.0/Resources/helpDymola/Modelica_Blocks_Tables.html#Modelica.Blocks.Tables[Modelica.Blocks.Tables] package) used to interpolate data based on one input variable and multiple output variables. It performs univariate interpolation on a table matrix using methods such as constant, linear, or cubic Hermite splines. - -Unlike maps sampled on rectilinear or irregular grids, a `CombiTable1Ds` instance stores both the domain and codomain data within the **same variable** (the `table` parameter of the link:https://doc.modelica.org/Modelica%204.0.0/Resources/helpDymola/Modelica_Blocks_Tables.html#Modelica.Blocks.Tables.CombiTable1Ds[Modelica.Blocks.Tables.CombiTable1Ds] component). The first column of this matrix defines the domain values, and the remaining columns define the codomain values. - -=== Definitions -terminalKind:: -A terminal with `terminalKind="org.fmi-standard.fmi-ls-struct.map.CombiTable1Ds"` defines a map whose domain and codomain data are contained within a single variable. The first column of the variable represents the domain, and the remaining columns represent the codomain. - -domain:: -The first column of the table variable defines the domain values. The corresponding FMU variable must be referenced with `variableKind="org.fmi-standard.fmi-ls-struct.map.domain"`. - -codomain:: -The remaining columns of the same table variable define the codomain values. The same FMU variable must also be referenced with `variableKind="org.fmi-standard.fmi-ls-struct.map.codomain"`. - -domainInput:: -Optionally, a separate scalar variable may be referenced with `variableKind="org.fmi-standard.fmi-ls-struct.map.domainInput"` to represent the input signal of the map. - -codomainOutput:: -Optionally, a variable may be referenced with `variableKind="org.fmi-standard.fmi-ls-struct.map.codomainOutput"` to represent the output signal(s) of the map. - -_[Note: Since both the domain and codomain are stored in the same variable, this mapping differs from the rectilinear and irregular grid cases, which reference distinct domain and codomain variables. Therefore, a seperate terminalKind is required to express this structure unambiguously.]_ - -=== Example -The following table shows the data layout of a `CombiTable1Ds`: -[[combiTable1D_example]] -[cols="1,1,1,1"] -|==== -| x (input) | y (output 1) | y (output 2) | y (output 3) - -| 1 | 2 | 4 | 7 -| 2 | 3 | 2 | 5 -| 3 | 4 | 1 | 2 -|==== - -The corresponding Modelica model uses `Modelica.Blocks.Tables.CombiTable1Ds` to represent the data shown above. -``` -model ExampleWithCombi - Modelica.Blocks.Tables.CombiTable1Ds combiTable1Ds1( - table={{1,2,4,7}, - {2,3,2,5}, - {3,4,1,2}}, - columns={2,3}, - smoothness=Modelica.Blocks.Types.Smoothness.LinearSegments) annotation(Placement(transformation(extent={{-70,15},{-50,35}}))); - Modelica.Blocks.Sources.RealExpression realExpression1(y=time) annotation(Placement(transformation(extent={{-115,15},{-95,35}}))); -equation - connect(realExpression1.y,combiTable1Ds1.u) annotation(Line( - points={{-94,25},{-89,25},{-77,25},{-72,25}}, - color={0,0,127})); - annotation( - uses(Modelica(version="4.0.0")), - experiment( - StopTime=3, - StartTime=1, - Interval=0.001)); -end ExampleWithCombi; -``` -Both the domain and codomain are contained in the matrix: - -``` -table={{1,2,4,7}, - {2,3,2,5}, - {3,4,1,2}}. -``` -The first column always represents the domain, while the rest of the columns contain the codomain values. The assignment `columns = {2,3}` specifies which columns are interpreted as output variables and interpolated based on the input. Therefore the third output in the table <> above is omitted. - -The variables representing the table, inputs, and outputs are given in the modelDescription.xml: -[source, xml] ----- -include::examples/modelDescription_CombiTable1Ds.xml[] ----- - -The structured representation of the data is defined in `terminalsAndIcons.xml`: -[source, xml] ----- -include::examples/terminalsAndIcons_CombiTable1Ds.xml[] ----- - -Note the `terminalMemberVariable` `combiTable1Ds1.y` is a 2D-array, since the Modelica code specified two outputs with `columns = {2,3}`. - == Known Limitations of This Standard General limitations: