Expression (Fcn) (expr)
Computes its output from a formula of up to eight inputs, the time and the circuit variables.
Group: Control · Kind: {"block":"expr","kind":"control"}
When to use it
Use it for a formula no other block gives: a power p = in1*in2, a square root, a sensor's equation or a piecewise function. Importers make it for behavioural sources. Use Gain, Sum or Product for one plain operation.
Pins
| Pin | Domain | Meaning |
|---|---|---|
in1 |
signal | First input, in1 in the formula |
in2 |
signal | Second input |
in3 |
signal | Third input |
in4 |
signal | Fourth input |
in5 |
signal | Fifth input |
in6 |
signal | Sixth input |
in7 |
signal | Seventh input |
in8 |
signal | Eighth input |
out |
signal | Value of the formula |
Common parameters
f: Formula of in1 … in8, time and the circuit variables, for example in1*in2 (Default: required)
Parameters
| Key | Unit | Default | Typical range | Description |
|---|---|---|---|---|
f |
— | required | Formula of in1 … in8, time and the circuit variables, for example in1*in2 |
Parameter descriptions are in English in both languages.
Model
out = f(in1 … in8, time, circuit variables), evaluated once per accepted solver step with the same expression language as parameters (+ − * / ^, sqrt, exp, log, sin, cos, abs, min, max, if and the rest). An unconnected input reads 0. The expression is checked when the circuit is built, so a syntax error or an unknown name stops the build; a value that is not finite during the run stops it with the block's name. The block has direct feedthrough.
Common mistakes
- The formula runs once per step after the meters read the solution, so a source it drives follows one step late. Inside a tight loop keep maxStep small against the loop's time constants.
- Code generation leaves this block out. A division by an input that reaches 0 stops the run; guard it, for example in1/max(in2, 1e-9).
Problems rules: compile.error, solver.control
Datasheet and sources
There is no datasheet.
Example
Open the example with the command file.openExample and the name demo:expr.
Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.