# Multi-dimensional Valis¶

Often, parameters of components and parts are not single values, but vary over time or voltage or any other dimension. Valispace handles two dimensional parameters with **Datasets** and **Functions**. Datasets are point-wise specifications of a varying Vali and Functions are defined by a formula and a variable range (which can also be from minus infinity to infinity). Datasets and Functions can be used in calculations and formulas of other Valis as usual and the results will be new Datasets or Functions. They can also be evaluated at a certain point where the value is well defined, e.g. Mass(5), where Mass is time-dependent (unit=s), results in the value of Mass at time T = 5s.

## Datasets¶

Datasets are point-wise specifications of a varying Vali. Datasets can also be measurements added to a Vali for reference.

### Adding a dataset¶

To add a dataset to a Vali, click the "Add dataset" button in the Vali details.

Add points to the dataset by adding a new row with the plus symbol underneath the table.

You can also import data points from .xls or .csv files by clicking the import button underneath the table and then choosing the file. Check the "Clear existing entries" checkbox if you want to remove the current data points and then click "Import".

The variable will by default have the name "X" and no unit. You can change the name by clicking on the current name and typing a new name. You can change the unit by hovering over the name and clicking the settings symbol over the name cell.

### Interpolation and extrapolation¶

Interpolation and extrapolation decides the values of the Vali between and beyond the specified points. It is used when datasets are used in calculations and evaluated.

Interpolation can be:

- No interpolation - values are not defined between the points
- Stepwise interpolation - constant value between points
- Linear interpolation - linear function between points

Extrapolation can be:

- No extrapolation - values are not defined outside of the data points range
- Assume zero - values are all 0 outside of the data points range
- Constant extrapolation - the values are constant outside of the data points range, defined by the first and last specified point
- Continue interpolation - same extrapolation as specified interpolation

### Calculating with datasets¶

When adding a dataset to a Vali, the formula will automatically be changed to `average_of_datasets()`

, which means that the result of the Vali used in calculations is the dataset. The Vali can be used in normal calculations, e.g. `Car.mass = sum_of_children()`

will sum up the masses of the subcomponents and if one of the subcomponents' masses is time-dependent `Car.mass`

will also become time-dependent. Mathematical operations on datasets always do the operation point-wise, e.g. `sqrt(Car.mass)`

will take the square root of each data point and the result itself will be a dataset.

## Functions¶

Valis can be a function by defining a formula dependent on a function variable, such as `vali = 2*X + 4`

. `X`

is a function variable with a name and unit. The function variable can be valid in its full (infinite) range or can be limited so that the function is only valid between a minimum and maximum value.

### Function variables¶

Function variables must start with a capital letter. `X`

, `T`

and `Time`

and valid function variables while `time`

is not. The name of the function variable is global throughout all Valis, meaning that if `X`

is used in one function, it is the same `X`

as used in another function.

### Calculating with functions¶

Functions can be calculated with in normal calculation. As an example, if `Vali1 = X^2`

and `Vali2 = 2*X`

then `Vali3 = $Vali1 + $Vali2`

will result in the function `X^2 + 2*X`

. If two Valis with different variables are used in a calculation the result will be a multi-dimensional function.

Valis which are functions can be evaulated at any valid point of the function variable. For example, if `Vali1 = X^2`

you can specify `Vali2 = $Vali1(1)`

which results in `Vali2 = 1`

.