.FUNC Statement

Functions allow you to define reusable mathematical expressions. Variables in function definitions are replaced by values when evaluated.

.FUNC fname(<x1<,x2<,x3...>>>)={ function body }

Where:

  • fname - Function name used for calling this function

  • x1, x2, x3, ... - Variables (up to 15) in parentheses

  • { function body } - Expression in curly braces that can contain the variables

Functions and Parameters should not depend on themselves in infinite loops. For clarity, we recommend to name nodes, parameters and functions differently. The names of Predefined Parameters and Functions must not be used as parameter name.

Functions may contain Circuit State Access as long as they are only evaluated in function based source expressions. The curly braces are optional as long as the equals sign is present. The equal signs can be skipped when the function body is wrapped into curly braces.

.FUNC f x = sin(x+V(n1)+I(V1))
V1 n1 0 1
B1 n 0 V=f(5)

Examples

.FUNC f(x,y)={sin(x+y)}
.FUNC g(x,y,z)={f(x,y)+z}
.PARAM a=7
.FUNC h()={6*a}
R1 n 0 {f(1,2)} ; sin(1+2)
R2 n 0 {g(3,4,5)+h()} ; sin(3+4)+5+6*7