Skip to main content

Algorithms

Numerical algorithms

Characteristic curve, "lookup" characteristic field

The ```lookup()`` function can be used to linearly interpolate data for one to three input variables from characteristic curves or maps.

L1 = lookup(x, {...});
L2 = lookup(x, y, {...});
L3 = lookup(x, y, z, {...});
// The configuration object is mandatory and must
// refer to a resource:
Lx = lookup(..., {$ref:'myLookupData'});

The configuration object follows its own syntax and must therefore be obtained from the resource area of the math module using {$ref:'myLookupData'}. Two formats are supported: the classic text format and a description in simplified JSON format1

Description of the inputs / axes

An axis is assigned to each input signal. This is defined by its unit <unit>, a start value <from>, the increment <step> and the number of interpolation points <count>. The axes do not necessarily have to be sorted in numerically ascending order.

Configuration in text format (classic)

For each axis, add the following description at the beginning of the text block, i.e. at least one, maximum three:

IN <unit> <from> <step> <count>
Configuration in JSON format:

In JSON format, it is also possible to specify a descriptive, informal name <name> and, as an alternative to one of the aforementioned value parameters, the end value <to>. This means that exactly three of the four properties <from>, <step>, <count> or <to> must be defined and the fourth is calculated.

{
axes: [
{ name: <str>, // optional description
unit: <str>, // recommended
// choose 3 as mandatory of the following 4:
from: <dbl>, // left-side value of input axis
step: <dbl>, // increment between interpolation points
count: <uint>, // number of interpolation points
to: <dbl> // right-side value of input axis
}, ...
], ...
}

Description of the outputs

The output signal is described by a unit <unit>.

Configuration in text format (classic)

The following definition must be listed once after the definition of the inputs:

OUT <unit>
Configuration in JSON format:

In JSON format, it is also possible to specify a descriptive, informal name <name>. Instead of the JSON object for each output (recommended), only the physical unit can be specified as a string.

{
outputs: [
{ name: <str>, // optional description
unit: <str> // recommended
}, ... // prepared to support vector output in future
<str>, ... // alternative to define output by unit
], ...

Data field

The data field consists of <dbl> values. The sequence of the grid points results from the following Pseuso code:

foreach(z : axis3)
foreach(y : axis2)
foreach(x : axis1)
Value[x,y,z];
Configuration in text format (classic)

The data values are simply separated from each other by spaces, tabs or line feeds and read into the interpolation points of the characteristic curve or map one after the other.

0 42.942 87.924 134.946
184.008 235.11 288.252
... continued up to 161 data points
Configuration in JSON format:

In JSON format, all data values are specified in an array of floating point numbers.

{
data: [
<dbl>, ...
], ...
}

Summary

Configuration in text format (classic)

Characteristic curve:

IN kPa 0.0 0.167751 161
OUT l

0
42.942
87.924
134.946
184.008
235.11
288.252
343.434
400.656
459.918
521.22
... continued up to 161 data points

Map:

IN g/h 0 10000 22
IN 1/min 900 100 10
OUT kW
0.0 40.8 81.6 132.9 185.2 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0 200.0
0.0 40.0 80.0 131.3 184.3 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0 230.0
0.0 38.5 76.9 125.8 182.4 233.5 286.9 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0 310.0
... 7 more rows with 22 data points each
Configuration in simplified JSON format

The configuration object can also be described in simplified JSON format1.

{
axes: [
{ name: <str>, // optional description
unit: <str>, // recommended
from: <dbl>, // left-side value of input axis
step: <dbl>, // increment between interpolation points
count: <uint>, // number of interpolation points
to: <dbl> // right-side value of input axis
}, ...
],
outputs: [
{ name: <str>, // optional description
unit: <str> // recommended
}, ... // prepared to support vector output in future
<str>, ... // alternative to define output by unit
],
data: [
<dbl>, ...
]
}

Provision as a resource

There are many ways to include these characteristic curves or map descriptions in the resources of the math module.

Formatting as a text resource is suitable for small maps or characteristic curves:

    "resources": {
"myLookupData": [
"IN kPa 0.0 0.167751 161"
, "OUT l"
, "0 42.942 87.924 134.946 184.008 235.11 288.252 343.434"
, "400.656 459.918 521.22 584.562 649.944 717.366 785.90745"
, "854.45145 ... and more"
], ...

Alternatively, the same map in simplified JSON format:

    "resources": {
"myLookupData": {
axes: [{ name: "HydroStatPressure", unit: "kPa"
, from: 0.0, step: 0.167751, count: 161 }],
outputs: [{ name: "Volume", unit: "l" }],
data: [
0, 42.942, 87.924, 134.946, 184.008, 235.11, 288.252, 343.434
, 400.656, 459.918, 521.22, 584.562, 649.944, 717.366, 785.90745
, 854.45145, // ... and more
]
}, ...

For larger maps or those that do not appear in the JSON configuration of the smartCORE or should be readable, a processed character string would be useful.

First with a map file myLookupData.tab as the data source, which follows the above syntax (text/Json):

    "resources": {
"myLookupData": {
"decoder": ["file"],
"value": "myLookupData.tab"
}, ...

or, if the map is available in compressed form:

    "resources": {
"myLookupData": {
"decoder": ["file", "unzip"],
"value": "myLookupData.gz"
}, ...

Alternatively, the data can also be included in the resource as a base64 string:

    "resources": {
"myLookupData": {
"decoder": ["base64"],
"value": "Q09MCWcvaAkwCTEwMDAwCTIyDQpST1cJMS9taW4JOTAwCTEw..."
}, ...

... or the compressed file as a base64 string:

    "resources": {
"myLookupData": {
"decoder": ["base64", "unzip"],
"value": "UEsDBBQAAgAIACt3cUoHOG6qmgEAAD4FAAAcAAAAUF9lZmZf..."
}

Footnotes

  1. With the exception of the commentary 2