Skip to content

User-Defined Expression

Symbol

Description

User-Defined Expression

This control block allows the user to write any mathematical expression that are evaluated at every time-step/iterations. Variables named "i1","i2"..."in" can be used to represent model inputs.

Example of supported expressions:

  • sin(2*i1)
  • max(i1, i2)
  • sqrt(i1ˆ2 + i2ˆ2)

This device should be used for "continuous" variables only. SIMBA will not consider discontinuities generated by user-defined expressions as such and therefore will not reduce the time steps. For example, it should not be used in place of a comparator controlling a switch.

The tables below present the list of functions and operators supported by this model.

Function name Description Example
abs absolute value abs(i1)
acos arcus cosine acos(i1)
acosh hyperbolic arcus cosine acosh(i1)
asin arcus sine asin(i1)
asinh hyperbolic arcus sine asinh(i1)
atan arcus tangent atan(i1)
atanh hyperbolic arcus tangent atanh(i1)
atan2 2-arguments arcus tangent atan2(i1, i2) where i1 is y-coordinate, i2 is x-coordinate
avg average value avg(i1,i2,...)
cos cosine cos(i1)
cosh hyperbolic cosine cosh(i1)
exp exponential function exp(i1)
ln natural logarithm ln(i1)
log natural logarithm log(i1)
log2 2-base logarithm log2(i1)
log10 10-base logarithm log10(i1)
max maximal value max(i1,i2,...)
min minimal value min(i1,i2,...)
rint round to nearest interger rint(i1)
sign sign of the number (1 or -1) sign(i1)
sin sine sin(i1)
sinh hyperbolic sine sinh(i1)
sqrt square root value sqrt(i1)
sum sum of all arguments sum(i1,i2,...)
tan tangent tan(i1)
tanh hyperbolic tangent tanh(i1)
Operator Description Example
+ addition i1+i2
- subtraction i1-i2
* multiplication i1*i2
/ division i1/i2
^ raise to the power i1^i2
?: conditional (ternary) operator i1 >= 0 ? 3 : 2
Variable Description
time current simulation time
dt current time step

Library

Control > Math

Parameters

Property Display Name Parameter Type Description
Expression Expression StringParameter Mathematical expression
NumberOfInputs Number of Inputs IntParameter Number of Inputs
SamplingTime Sampling Time [s] DoubleParameter Sampling Time

Pins

Property Pin Name Type Description
i1 i1 ControlIn Input 0
Out Out ControlOut Output

Default Size

Width Height
8 4