Nelson banner
NFlow blocks

The nflow_blocks module provides the simulation blocks used by NFlow, including their ports, parameters, phases, and runtime behavior.

NFlow is currently released as 1.0.0-beta.1: it is functional and tested, but details of its interfaces and file format may still evolve based on feedback.

Electrical (acausal)

Acausal (physical) blocks with undirected pins, simulated natively through the differential-algebraic engine.

  • CCC
    Current-controlled current source: i_pn = gain i_cp (the sense branch cp-cn is a short).
  • CCV
    Current-controlled voltage source: v_pn = gain i_cp (the sense branch cp-cn is a short).
  • Capacitor
    Ideal linear capacitor: i = C dv/dt.
  • Conductor
    Ideal linear conductor: i = G (v_p - v_n).
  • ConstantCurrent
    Constant current source: current I flows p -> n.
  • ConstantVoltage
    Constant voltage source: v_p - v_n = V.
  • CurrentSensor
    Measures the branch current p -> n (ideal ammeter).
  • Diode
    Exponential (Shockley) diode: i = Is (exp(vd/Vt) - 1).
  • ExpSineCurrent
    Exponentially damped sine current source.
  • ExpSineVoltage
    Exponentially damped sine voltage source.
  • Ground
    Reference node (0 V) for an electrical island.
  • Gyrator
    Gyrator: i1 = G2 v2, i2 = -G1 v1 (across<->through transducer).
  • HeatingResistor
    Resistor that dissipates its power P = v^2 / R as heat into a thermal port.
  • IdealDiode
    Ideal diode switching at the knee voltage Vknee: off below it (leak conductance Goff), on above it (on-resistance Ron in series with Vknee); the mode flip is an event.
  • IdealOpAmp
    Ideal op-amp (nullor): virtual short e_+ = e_-, output current free.
  • IdealSwitch
    Ideal switch: control > 0.5 -> closed short, else open (i = 0).
  • IdealTransformer
    Ideal transformer: v1 = n v2, i2 = -n i1 (structural, no state storage).
  • Idle
    Ideal open branch: i = 0 (branch voltage free).
  • Inductor
    Ideal linear inductor: v = L di/dt.
  • NMOS
    N-channel MOSFET (square law): drain, gate and source pins.
  • NPN
    NPN bipolar transistor (Ebers-Moll): collector, base and emitter pins.
  • PMOS
    P-channel MOSFET (square law): drain, gate and source pins.
  • PNP
    PNP bipolar transistor (Ebers-Moll): collector, base and emitter pins.
  • PotentialSensor
    Measures the absolute node potential.
  • RampCurrent
    Ramp current source: i = Slope (t - StartTime) for t >= StartTime, else 0.
  • RampVoltage
    Ramp voltage source: v = Slope (t - StartTime) for t >= StartTime, else 0.
  • Resistor
    Ideal linear resistor: i = (v_p - v_n) / R.
  • Short
    Ideal short circuit: e_p = e_n (branch current free).
  • SignalCurrent
    Current source driven by the input signal.
  • SignalVoltage
    Voltage source driven by the input signal.
  • SineCurrent
    Sine current source: i = Amplitude sin(2 pi Frequency t + Phase).
  • SineVoltage
    Sine voltage source: v = Amplitude sin(2 pi Frequency t + Phase).
  • TrapezoidCurrent
    Trapezoidal current source (continuous ramp-up / hold / ramp-down).
  • TrapezoidVoltage
    Trapezoidal voltage source (continuous ramp-up / hold / ramp-down).
  • VCC
    Voltage-controlled current source: i = gain (v_cp - v_cn).
  • VCV
    Voltage-controlled voltage source: v_pn = gain (v_cp - v_cn).
  • VariableCapacitor
    Capacitor whose capacitance C is set by a signal (exact charge Q formulation).
  • VariableConductor
    Conductor whose conductance G is set by the input signal.
  • VariableInductor
    Inductor whose inductance L is set by a signal (exact flux phi formulation).
  • VariableResistor
    Resistor whose resistance R is set by the input signal.
  • VoltageSensor
    Measures the voltage v_p - v_n (ideal, no loading).
  • ZDiode
    Zener diode: forward Shockley conduction plus reverse breakdown at -Vz.
Planar (acausal)

Acausal (physical) blocks with undirected pins, simulated natively through the differential-algebraic engine.

  • PlanarAccelerationSensor
    Absolute acceleration of the body at frame a along the chosen axis (x, y) or the angular acceleration (alpha).
  • PlanarBody
    Rigid body: mass m, central inertia I; six states (xc, yc, phi, vx, vy, w). Named frames are body-fixed offsets from the COM.
  • PlanarDamper
    Linear 2D damper between the points at frames a and b: F = -d dv.
  • PlanarDistance
    Rigid rod: holds a fixed distance L between the points at frames a and b.
  • PlanarDistanceSensor
    Distance between the points at frames a and b.
  • PlanarFixed
    Frame rigidly fixed at the world point (x, y).
  • PlanarForce
    External world force (fx, fy) applied at the frame-a point (adds a torque when offset from the COM).
  • PlanarPointMass
    Point mass (no orientation): four states (xc, yc, vx, vy); attach joints at its point.
  • PlanarPositionSensor
    Absolute position of the frame-a point along the chosen axis (x, y) or the body angle (phi).
  • PlanarPrismatic
    Prismatic joint: frame b slides along the world axis (dx, dy) through frame a, relative rotation locked.
  • PlanarRelPositionSensor
    Relative position of the frame-a point minus the frame-b point along the chosen axis (x, y).
  • PlanarRelativeTorque
    Actuator torque: +tau on the body at frame a, -tau on the body at frame b (drives a joint).
  • PlanarRevolute
    Revolute (pin) joint: frames a and b share position, free relative rotation.
  • PlanarRollingWheel
    Wheel at frame a rolls without slipping on the fixed surface line (px,py)+(dx,dy), staying at height radius.
  • PlanarSpring
    Linear 2D spring between the points at frames a and b: F = -c dr.
  • PlanarSpringDamper
    Linear 2D spring-damper between the points at frames a and b: F = -(c dr + d dv).
  • PlanarTorque
    External torque tau applied to the body at frame a.
  • PlanarVelocitySensor
    Absolute velocity of the frame-a point along the chosen axis (x, y) or the angular velocity (omega).
  • PlanarWorld
    Inertial world with uniform gravity (down = -y); provides a fixed frame at the origin.
Rotational (acausal)

Acausal (physical) blocks with undirected pins, simulated natively through the differential-algebraic engine.

  • AngleSensor
    Measures the absolute angle of a flange.
  • BearingFriction
    Regularised bearing friction (event-free): tau = -tau_c tanh(w / w_eps).
  • Clutch
    Rotational clutch (event-free stick-slip): tau = tau_max tanh((w_a - w_b) / w_eps) reduces the slip toward a common speed.
  • ConstantRotSpeed
    Prescribed motion: the flange rotates at a constant angular velocity w.
  • ConstantTorque
    Constant torque on a flange.
  • EMF
    Electro-mechanical converter (motor/generator): back-emf v = k w, torque tau = k i.
  • ElastoBacklash
    Rotational backlash: elastic torque with a dead zone of total play b.
  • ExpSineTorque
    Exponentially damped sine torque on a flange.
  • Freewheel
    One-way clutch: couples flange a to b only while a overruns b (freewheels otherwise).
  • IdealGear
    Ideal gear phi_a = ratio phi_b (structural node merge, inertia folded).
  • Inertia
    Rotational inertia: J dw/dt = tau_net.
  • LinearSpeedDependentTorque
    Speed-proportional resistance to ground: tau = -d w.
  • QuadraticSpeedDependentTorque
    Quadratic (drag) resistance to ground: tau = -d w |w|.
  • RampTorque
    Ramp torque on a flange: tau = Slope (t - StartTime) for t >= StartTime, else 0.
  • RelAngleSensor
    Measures the relative angle phi_a - phi_b between two flanges.
  • RelRotSpeedSensor
    Measures the relative angular velocity w_a - w_b between two flanges.
  • RotAccelerate
    Prescribed motion: the flange angular acceleration follows the input signal.
  • RotBrake
    Signal-actuated rotational brake to ground: the input sets the peak braking torque.
  • RotDamper
    Rotational damper: tau = d (w_a - w_b).
  • RotFixed
    Flange fixed at a prescribed angle phi0.
  • RotSpeed
    Prescribed motion: the flange angular velocity follows the input signal.
  • RotSpeedSensor
    Measures the absolute angular velocity of a flange.
  • RotSpring
    Rotational spring: tau = c (phi_a - phi_b).
  • RotSpringDamper
    Parallel rotational spring and damper: tau = c (phi_a - phi_b) + d (w_a - w_b).
  • SineTorque
    Sine torque on a flange: tau = Amplitude sin(2 pi Frequency t + Phase).
  • Torque
    External torque on a flange, driven by the input signal.
  • Torque2
    Equal and opposite torque between two flanges: +tau on a, -tau on b (signal-driven).
  • TrapezoidTorque
    Trapezoidal torque on a flange (continuous ramp-up / hold / ramp-down).
Thermal (acausal)

Acausal (physical) blocks with undirected pins, simulated natively through the differential-algebraic engine.

Translational (acausal)

Acausal (physical) blocks with undirected pins, simulated natively through the differential-algebraic engine.

  • Accelerate
    Prescribed motion: the flange acceleration follows the input signal.
  • Brake
    Signal-actuated friction brake to ground: the input sets the peak braking force.
  • ConstantForce
    Constant force on a flange.
  • ConstantSpeed
    Prescribed motion: the flange moves at a constant velocity v.
  • Damper
    Linear translational damper: F = d (v_a - v_b).
  • ElastoGap
    One-sided contact spring-damper: acts only while the gap is closed (s_rel < s_rel0).
  • ExpSineForce
    Exponentially damped sine force on a flange.
  • Fixed
    Flange fixed at a prescribed position s0.
  • Force
    External force on a flange, driven by the input signal.
  • Force2
    Equal and opposite force between two flanges: +F on a, -F on b (signal-driven).
  • Friction
    Regularised Coulomb friction (event-free): F = -Fc tanh(v / vEps).
  • Lever
    Lever (small-angle): s_a = ratio s_b, the arm ratio (structural merge).
  • LinearSpeedDependentForce
    Speed-proportional resistance to ground: F = -d v.
  • Mass
    Sliding mass with inertia: m dv/dt = F_net.
  • MassWithWeight
    Sliding mass under gravity: m dv/dt = F_net - m g (expands to Mass + ConstantForce).
  • PositionSensor
    Measures the absolute position of a flange.
  • Pulley
    Ideal pulley: s_a = ratio s_b (structural merge; ratio = radius ratio).
  • QuadraticSpeedDependentForce
    Quadratic (drag) resistance to ground: F = -d v |v|.
  • RampForce
    Ramp force on a flange: F = Slope (t - StartTime) for t >= StartTime, else 0.
  • RelPositionSensor
    Measures the relative position s_a - s_b between two flanges.
  • RelSpeedSensor
    Measures the relative velocity v_a - v_b between two flanges.
  • Rod
    Rigid massless rod: s_a = s_b (structural merge; ratio defaults to 1).
  • SineForce
    Sine force on a flange: F = Amplitude sin(2 pi Frequency t + Phase).
  • SlidingMass
    Sliding mass of length L: m dv/dt = F_net (L is geometric, does not affect the dynamics).
  • Speed
    Prescribed motion: the flange velocity follows the input signal.
  • SpeedSensor
    Measures the absolute velocity of a flange.
  • Spring
    Linear translational spring: F = k (s_a - s_b).
  • SpringDamper
    Parallel spring and damper: F = k (s_a - s_b) + d (v_a - v_b).
  • TranslationalEMF
    Linear electro-mechanical converter: back-emf v = k v_flange, force F = k i.
  • TrapezoidForce
    Trapezoidal force on a flange (continuous ramp-up / hold / ramp-down).
Continuous blocks

Stateful continuous-time blocks updated with the simulation step.

  • constraint
    Algebraic (differential-algebraic) constraint state solved by the DAE solver.
  • delay
    Delays a signal with a circular buffer.
  • derivative
    Estimates the time derivative of an input.
  • hpf
    Applies a first-order high-pass filter.
  • integrator
    Integrates the input over time with optional clamps.
  • lpf
    Applies a first-order low-pass filter.
  • pid
    Implements a scalar PID controller with output limits.
  • stateSpace
    Implements a scalar continuous state-space model.
  • tf
    Implements a continuous transfer function approximation.
Dashboard blocks

Interactive dashboard widgets that bind to signals and parameters to observe or drive a running model.

Discrete blocks

Sampled blocks that store values, histories, or discrete states.

  • ddelay
    Delays a sampled signal by an integer number of steps.
  • detectChange
    Outputs 1 on any step where the input differs from the previous step.
  • detectDecrease
    Outputs 1 when the input strictly decreases from the previous step.
  • detectIncrease
    Outputs 1 when the input strictly increases from the previous step.
  • difference
    Outputs the difference from the previous input.
  • dstateSpace
    Implements a scalar discrete state-space model.
  • dtf
    Implements a discrete transfer function.
  • fallingEdge
    Outputs 1 on the step where the input crosses from >= 0 to < 0.
  • foh
    First-order hold for sampled input values.
  • rateTransition
    Resamples a signal at its own sample time (zero-order hold).
  • risingEdge
    Outputs 1 on the step where the input crosses from <= 0 to > 0.
  • unitDelay
    Delays the input by one update.
  • zoh
    Samples an input and holds the last sampled value.
FMI and Modelica blocks

Blocks that import, execute, or compile Functional Mock-up Units and models.

  • fmu
    Runs a co-simulation FMU inside an NFlow diagram.
  • fmuMe
    Integrates a model-exchange FMU with the NFlow solver.
  • modelica
    Compiles a Modelica model and uses it as an NFlow block.
Logic blocks

Boolean and comparison blocks for numeric signals.

  • and
    Outputs the logical AND of two inputs.
  • bitClear
    Clears the bit at position BitIndex of the integer input to 0.
  • bitSet
    Sets the bit at position BitIndex of the integer input to 1.
  • bitwiseOperator
    Bit-wise AND/OR/XOR/NAND/NOR/NOT of the input against a constant BitMask.
  • combinatorialLogic
    Truth-table lookup: an N-bit input vector indexes a 2^N-entry TruthTable.
  • compareToConstant
    Compares one input to a constant threshold.
  • compareToZero
    Compares one input to zero.
  • extractBits
    Extracts NumBitsToExtract bits starting at StartBit, right-aligned.
  • if
    Selects an action output from a boolean expression over the inputs.
  • intervalTest
    Outputs 1 when the input lies within [LowerLimit, UpperLimit], else 0.
  • intervalTestDynamic
    Like intervalTest but the bounds come from input ports (lo, u, up).
  • logicalOperator
    Configurable logical AND/OR/NAND/NOR/XOR/XNOR/NOT of the inputs.
  • not
    Outputs the logical negation of one input.
  • or
    Outputs the logical OR of two inputs.
  • relationalOperator
    Compares two input signals.
  • shiftArithmetic
    Arithmetic bit shift left/right by ShiftNumber (signed 64-bit).
  • switchCase
    Routes an integer control to one of several action outputs.
  • xor
    Outputs the logical exclusive OR of two inputs.
Lookup Tables

Interpolated and direct lookup-table blocks (1-D, 2-D, n-D and direct).

  • directLookup
    Direct (n-D) lookup table without interpolation.
  • interpolationPrelookup
    Interpolates a static Table from a prelookup [k, f] pair.
  • lookup1D
    1-D interpolated lookup table.
  • lookup2D
    2-D interpolated lookup table.
  • lookupDynamic
    1-D interpolated lookup with breakpoints and table taken from input ports.
  • lookupND
    n-D interpolated lookup table.
  • prelookup
    Computes the interval index k and fraction f for a shared breakpoint search.
Math blocks

Algebraic scalar math operations.

  • abs
    Outputs the absolute value of its input.
  • atan2
    Four-quadrant arctangent of the two inputs.
  • bias
    Adds a constant bias to the input.
  • complexToMagnitudeAngle
    Outputs the magnitude and angle of a complex signal.
  • complexToRealImag
    Splits a complex signal into real and imaginary outputs.
  • conjugate
    Complex conjugate of the input signal.
  • crossProduct
    Cross product of two 3-element vectors.
  • divide
    Divides input 1 by input 2.
  • dotProduct
    Dot product of two vector inputs.
  • gain
    Multiplies the input by a scalar gain.
  • magnitudeAngleToComplex
    Builds a complex signal from magnitude and angle inputs.
  • mathFunction
    Mathematical function of the input.
  • matmul
    Multiplies two matrix signals or applies element-wise multiplication.
  • max
    Outputs the maximum of two inputs.
  • min
    Outputs the minimum of two inputs.
  • mult
    Multiplies connected inputs.
  • negate
    Negates the input signal.
  • polynomial
    Evaluates a polynomial with constant Coefficients (highest power first).
  • productOfElements
    Product of the elements of a vector input.
  • realImagToComplex
    Builds a complex signal from real and imaginary inputs.
  • roundingFunction
    Rounds the input to an integer value.
  • sign
    Signum of the input (-1, 0 or +1).
  • sqrt
    Square-root family of the input.
  • sum
    Adds connected inputs with configurable signs.
  • sumElements
    Sum of the elements of a vector input.
  • trigFunction
    Trigonometric function of the input.
  • wrapToZero
    Outputs 0 when the input reaches Threshold, else passes it through.
Nonlinear blocks

Blocks with saturation, thresholds, hysteresis, or rate limits.

  • backlash
    Models backlash with a dead band around the previous output.
  • coulombViscousFriction
    Static friction: viscous term Gain*u plus signed Coulomb term Offset*sign(u).
  • deadZone
    Suppresses values inside a dead zone.
  • hitCrossing
    Outputs 1 on the step where the input crosses HitCrossingOffset.
  • hysteresis
    Relay: latching two-threshold switch (uHigh, uLow, yHigh, yLow).
  • quantizer
    Rounds the input to the nearest interval.
  • rate
    Limits rising and falling signal rates.
  • saturation
    Clamps the input between min and max.
Sink blocks

Blocks that consume, display, or name signals.

  • display
    Stores the latest input value for display.
  • fileSink
    Represents a file output sink.
  • labelSink
    Names an input signal for label routing.
  • scope
    Stores time-series samples for display.
  • stopSimulation
    Ends the run at the end of the step where its input first becomes nonzero.
  • terminator
    Consumes an intentionally unused signal.
  • toWorkspace
    Writes the input signal to a Nelson workspace variable.
  • xyScope
    Stores paired X/Y samples for display.
  • xyzScope
    Stores X/Y/Z samples for 3D display.
Source blocks

Blocks that generate signals from parameters, time, labels, or files.

  • chirp
    Generates a sine chirp from f0 to f1.
  • clock
    Outputs the current simulation time.
  • constant
    Outputs a constant numeric value.
  • counterFreeRunning
    Free-running up-counter, wraps modulo 2^NumBits.
  • counterLimited
    Up-counter that wraps back to 0 once it reaches UpperLimit.
  • enumeratedConstant
    Outputs a fixed enumeration value (EnumClass documents it, Value is the number).
  • fileSource
    Outputs values from preloaded times and values arrays.
  • fromWorkspace
    Reads a signal from a Nelson workspace variable.
  • impulse
    Outputs an impulse at a configured time.
  • labelSource
    Reads a signal from a matching labelSink.
  • noise
    Generates deterministic pseudo-random noise.
  • pulse
    Pulse Generator: a periodic pulse train (Amplitude, Period, Width, StartTime, Offset).
  • ramp
    Generates a ramp beginning at start.
  • repeatingSequenceInterpolated
    Periodic piecewise-linear source interpolating a (TimeValues, OutValues) table.
  • repeatingSequenceStair
    Periodic staircase: one OutValues entry per sample, repeating.
  • signalGenerator
    Configurable periodic source: sine, square or sawtooth (Amplitude, Frequency).
  • sine
    Generates a sinusoidal signal.
  • step
    Generates a unit step at stepTime.
User-Defined Function blocks

Blocks that evaluate user-provided expressions or Nelson functions.

  • expression
    Evaluates a restricted math expression of u during simulation and in generated code.
  • nelsonFunction
    Evaluates a Nelson function at every simulation step.
Utility blocks

Blocks for routing, grouping, annotation, and interactive switching.

  • assignment
    Writes elements into a signal: out = base with out[Indices] = values.
  • busAssignment
    Replaces selected members of a bus, passing the rest through unchanged.
  • busCreator
    Groups heterogeneous signals (or nested buses) into one bus.
  • busSelector
    Extracts members from a bus by path.
  • comment
    Adds non-executed annotation text to a diagram.
  • concatenate
    Concatenates input signals along a selected dimension.
  • convert
    Converts a signal to a selected data type.
  • dataStoreMemory
    Declares a named scalar memory shared across the model (initial value).
  • dataStoreRead
    Outputs the value of the named data store.
  • dataStoreWrite
    Writes its input to the named data store.
  • demux
    Routes one input to multiple output ports.
  • functionCallGenerator
    Drives a function-call subsystem a fixed number of times per step.
  • functionCallSplit
    Fans one function-call out to several callees in order.
  • initialCondition
    Forces the output to InitialValue at the first step, then passes the input.
  • iteratorCondition
    carries the continue predicate of a While Iterator subsystem
  • iteratorNumber
    outputs the current iteration index inside a For/While iterator subsystem
  • merge
    Recombines the outputs of mutually-exclusive conditional subsystems.
  • multiportSwitch
    Routes one of several data inputs to the output, selected by a control input.
  • mux
    Groups multiple input routes into one output route.
  • reshape
    Changes signal dimensions without changing element values.
  • selector
    Selects elements from an input signal by one-based indices.
  • signalConversion
    Pass-through that copies its input to its output unchanged (conversion point).
  • subsystem
    Runs a nested block diagram as a single block.
  • switch
    Selects between top and bottom inputs using a condition input.
  • toggleSwitch
    Outputs one of two configured values from state.
  • width
    Outputs the number of elements (width) of its input signal, as a scalar.