What Is Event-Based Flow Simulation?

How discrete event simulation unifies material flow, physics, and PLC signals in a single model – and why that matters for factory planning.

flow simulationdiscrete event simulationSimPyPLCvirtual commissioningmaterial flowdigital twin

From Time Steps to Events: What is discrete event simulation (DES)?

Traditional simulations compute the state of a plant at fixed time intervals – say, every 10 milliseconds. It works, but it's wasteful: when a workpiece sits inside a CNC machine for three minutes, the engine burns through 18,000 calculation steps where nothing changes.

Event-based simulation – also known as Discrete Event Simulation (DES) – flips this approach. Instead of advancing time uniformly, the simulation jumps straight to the next meaningful event. The workpiece enters the machine (Event 1), processing finishes (Event 2), the workpiece leaves (Event 3). Simulation time passes between these events, but computation time doesn't. This makes DES orders of magnitude faster than time-step approaches – especially for long runs spanning days or weeks.

How an Event Queue Works

At its core, a DES engine maintains a priority queue of events sorted by their scheduled timestamp. The loop is always the same: take the next event from the queue, advance the simulation clock to its timestamp, execute the associated logic – and that logic typically generates new events that go back into the queue.

An example: a machine finishes processing a workpiece. This event triggers several follow-ups – the workpiece is handed off to the downstream conveyor, the machine checks its input buffer for the next part, and a sensor at the conveyor entrance registers the arrival. Each follow-up event is inserted into the queue with its calculated timestamp and processed at the right moment.

FactoryLine Pro uses a powerful DES engine. It leverages generators and cooperative multitasking, which means parallel processes – such as multiple machines working simultaneously – can be modeled naturally without classical threading. Resource conflicts like buffer capacities or shared transport paths are handled directly through SimPy's built-in resource model.

Beyond Throughput: Physics Inside the Event Model

Many flow simulators treat transport between stations as a simple delay – a fixed time span for a workpiece to travel from A to B. That's sufficient for rough planning, but it falls short when it comes to real equipment sizing.

FactoryLine Pro integrates a physics-based transport model directly into the event simulation. Conveyors aren't calculated with a flat transport time but with multiple trapezoidal velocity profiles – acceleration, cruise, deceleration – based on real drive parameters. The drive train model follows real methodology and accounts for motor types, gearbox variants, variable frequency drives, brake wear, and thermal limits.

This yields simulation results that go well beyond pure throughput numbers: energy consumption in kWh per conveyor, thermal utilization of drives, brake wear over the simulation period, and detection of overload conditions. Speed zones – sensor-triggered sections where conveyors decelerate before stations for positioning accuracy – are also simulated with full physical accuracy.

The Signal Landscape: Where Flow Simulation Meets PLC

The real difference between an academic flow simulator and a tool for real-world factory planning lies in the signal layer. In a real plant, a PLC controls every actuator and reads every sensor – and FactoryLine Pro models this entire signal landscape.

Every component in the layout automatically generates its associated signals: a machine with a pneumatic clamp produces output signals for the clamp valve and input signals for the end-position sensors. A conveyor generates motor control signals and sensor feedback. These signals follow a configurable naming convention (compatible with EPLAN P8 or Siemens KKS) and are assigned validated PLC addresses in Siemens S7 format.

This signal layer isn't a bolt-on afterthought – it's woven directly into the simulation. In co-simulation mode, signals are exchanged with Siemens PLCSIM Advanced via shared memory in a deterministic synchronization cycle with configurable cycle times. The simulation writes sensor states to the PLC input area, the PLC processes its program, and the simulation reads back the actuator outputs. This allows PLC code to be tested against the physical plant model before any real hardware exists.

Making PLC Overhead Visible

In practice, the timing of a PLC-controlled plant always deviates from the physical ideal. A PLC works in scan cycles – typically 10 to 50 milliseconds – and every signal change is only processed in the next cycle. On top of that come program execution times, communication delays, and the order in which function blocks are called.

FactoryLine Pro makes this PLC overhead explicitly measurable. In hybrid mode (Mode C), the software combines fast SimPy simulation for transport sections with cycle-accurate co-simulation for station logic. An integrated timing analyzer compares the physically predicted time for each operation against the time actually taken by the PLC. The result is displayed per station as a deviation – with OK, warning, and violation ratings.

This feature is particularly valuable during virtual commissioning: engineers can immediately see whether a PLC program serves the plant physics fast enough, or whether cycle times, timeouts, or handshake protocols need adjustment. The AI-powered analysis can provide concrete recommendations – such as timeout adjustments or signal processing optimizations – and generate the corresponding SCL code for TIA Portal.

Stochastics and Monte Carlo: Realism Through Variance

Real factories never behave deterministically. Processing times fluctuate, machines break down, shift models change utilization patterns. FactoryLine Pro captures this variability through stochastic overlays: cycle times follow normal or log-normal distributions, failures are modeled via exponential or Weibull distributions with configurable MTBF and MTTR.

For statistically robust conclusions, the software supports Monte Carlo parameter sweeps – automated simulation runs with different random seeds, whose results are aggregated in DuckDB. This enables not just average values but also worst-case scenarios and confidence intervals. The headless runner allows batch simulations over arbitrary time spans – from a single shift to an entire year – without a graphical interface.

From Planning Tool to Digital Twin

Event-based simulation isn't a one-time tool for the planning phase. Through integration with OPC-UA connectivity and continuous monitoring, the simulation model becomes a living digital twin. A drift engine continuously compares target values from the simulation against actual values from the real plant, detecting gradual deviations before they turn into production problems. Weibull-based wear models estimate remaining useful life for components and enable predictive maintenance scheduling.

The transition from planning model to operational model is seamless: same layout, same parameters, same signal configuration – only the data source changes from simulation to the real plant.

Summary

Event-based flow simulation forms the foundation for realistic factory planning. Only by combining it with physics-based transport and a complete signal model do you get a tool that serves both material flow optimization and virtual commissioning – while enabling the transition to a living digital twin.

CharacteristicTime-step basedEvent-based (DES)DES + signal layer
SpeedSlow for long runsFast via event jumpingFast with optional co-sim
PhysicsSimplifiedModel-dependentSEW drive model integrated
PLC signalsNot representedNot representedFull model with address validation
PLC overheadNot measurableNot measurablePer-station timing analysis
Virtual commissioningNot possibleNot possiblePLCSIM Advanced co-simulation
StochasticsPossiblePossibleMonte Carlo with DuckDB aggregation