State-Space Discretization
This document explains how continuous-time state-space circuit models are converted into discrete-time equivalents suitable for a simulation with fixed timestep and how the choice of discretization method affects accuracy and stability.
The Continuous-Time State-Space Model
The standard continuous state-space formulation is used to describe each circuit that is being simulated. This formulation uses four matrices - A, B, C, and D - and two vector equations that together capture the complete dynamic behavior of a linear time-invariant (LTI) circuit at any instant in time.
The state equation describes how the internal energy-storing elements evolve:
The output equation describes how measured quantities are derived from the states and inputs:
| Matrix | Name | Physical meaning |
|---|---|---|
| A | System matrix | Captures how the states (inductor currents, capacitor voltages) interact with and influence each other over time. Encodes the circuit's internal dynamics. |
| B | Input matrix | Describes how external driving signals - voltage sources, current sources, control inputs - push energy into the states. |
| C | Output matrix | Defines how the internal states translate into observable quantities, such as the readings of voltage and current sensors placed in the circuit. |
| D | Feedthrough matrix | Represents any direct, instantaneous path from inputs to outputs that does not pass through the energy-storing elements. |
The state vector x collects all the energy-storing quantities in the circuit - one entry per inductor current and per capacitor voltage. The input vector u collects all external driving signals. The output vector y collects all measured quantities of interest.
Circuit Modes and Per-Mode Discretization
Models usually contain switching elements, most commonly converter blocks. Converters are modeled using ideal switches, where a controllable switch (IGBT/MOSFET) and its anti-parallel diode are represented as a single switch. Each combination of switch states (open or closed) results in a different circuit topology and therefore a different set of differential equations describing the circuit behavior. Each unique topology corresponding to a particular combination of switch states is called a circuit mode. A model typically contains multiple circuit modes. Whenever a switch changes state, the circuit transitions from one circuit mode to another. For example, a three-phase two-level converter contains six ideal switches, resulting in 26 = 64 possible circuit modes.
For every circuit mode, a separate set of continuous-time matrices A, B, C, D is derived. Discretization is then applied independently to each mode, producing a separate set of discrete-time matrices Az, Bz, Cz, Dz. During runtime, the simulator selects the appropriate discrete-time set for the currently active circuit mode and uses it to calculate the circuit variables for the next timestep.
Circuits with many switches can have a very large number of modes. All modes within a same device partition share the same simulation timestep and the same discretization method, but each has its own numerically computed discrete matrices.
Simulation timestep
Simulation timestep Ts - also called the sampling period - is the fixed interval at which the simulator evaluates the circuit state. Every Ts seconds, it reads the current state and inputs, applies the discrete-time equations, and computes the state at the next step.
The choice of Ts is a trade-off between accuracy and hardware resources:
- A smaller Ts approximates the continuous-time behavior more closely and can capture faster dynamics, but requires more computation per simulated second and places greater demands on the FPGA.
- A larger Ts reduces computational load but may miss fast transients and can introduce discretization error or numerical instability, depending on the discretization method chosen.
As a practical guide, Ts should be at least an order of magnitude smaller than the fastest significant dynamics in the circuit, determined by both the smallest time constant (the smallest L/R or R·C product among the dominant branches) and the highest relevant resonant frequencies.
Discretization Methods
Four discretization methods are available for real-time simulation. All of them answer the same fundamental question: given the circuit state x[k] and inputs u[k] at timestep k, what is the state x[k+1] at the next step? They differ in the assumptions they make about how the circuit evolves between two consecutive timesteps, and in how faithfully they reproduce the behavior of the original continuous-time system.
Exact (Zero-Order Hold)
The exact discretization converts a continuous state-space model into discrete domain using the analytical solution over a sampling period (timestep). It provides an exact representation of the system dynamics under a zero-order hold assumption - that the input vector u is held constant throughout each timestep. A solution to the continuous-time state equation over one step involves the matrix exponential of A·Ts.
To compute both Az and Bz simultaneously and efficiently, an augmented matrix M is formed by placing A and B side by side in the upper block row, with zeros below:
The matrix exponential of M·Ts is then computed. The upper-left block of the result is Az and the upper-right block is Bz:
The C and D matrices pass through to the discrete domain unchanged, as in the Forward Euler method. The exact method is unconditionally stable for any stable continuous-time circuit, regardless of how stiff the dynamics are. It is the recommended choice when accuracy is the primary concern. Its only practical limitation is that very ill-conditioned or near-singular A matrices can cause the matrix exponential algorithm to produce numerical overflow (Inf) or undefined (NaN) results; in such cases the compiler raises a warning and the user should consider switching to the Simplified Bilinear method.
Simplified bilinear
The simplified bilinear method is applied only to state matrices (A and B), while the output matrices (C and D) remain unchanged. It is an implicit method that approximates the average rate of change over the interval as the mean of the rates at both ends - the current step and the next. This midpoint averaging is what makes it implicit: the result at the next step appears on both sides of the equation and must be solved for. The discrete matrices are:
This method is unconditionally stable for all stable continuous-time circuits. It introduces a small phase error compared to the Exact method (because the input is still assumed constant over each step), but avoids the potential numerical issues of the matrix exponential computation. It is a reliable general-purpose alternative to the Exact method and is particularly recommended when the exact method raises NaN or Inf warnings.
Bilinear
The bilinear method uses the same midpoint-averaging approach as the simplified version for the state matrices Az and Bz, but goes one step further: it also transforms the output matrix C and the feedthrough matrix D. This preserves a one-to-one mapping between continuous-time and discrete-time frequencies, which generally provides more accurate frequency-domain behavior than simpler discretization methods in cases when the simulation timestep is not much smaller than the system's fastest time constant of interest. The discrete matrices are:
The bilinear method is unconditionally stable and is particularly useful when the simulation timestep is not sufficiently small relative to the fastest time constant of interest. However, when the simulation timestep is small enough, the differences between discretization methods become less pronounced and the benefit of the bilinear method may be negligible. This improved frequency-domain accuracy can come at the cost of increased computational complexity due to reduced matrix sparsity and additional calculations during simulation.
Forward Euler
The forward Euler method is the simplest of the four methods. It replaces the derivative on the left-hand side of the state equation with a plain forward difference: the next state is approximated by taking the current state and adding the instantaneous rate of change, scaled by the timestep. The output matrices C and D pass through to the discrete domain unchanged. The discrete matrices are:
The forward Euler method is computationally inexpensive and easy to reason about. Its main limitation is stability: it is an explicit method, meaning the next state is computed entirely from known quantities without any implicit correction. For circuits with stiff dynamics, characterized by a combination of fast and slow time constants, including oscillatory poles associated with resonant frequencies, the forward Euler method can become numerically unstable unless Ts is sufficiently small. In most cases, the instability is caused by resonant frequencies that are too high relative to timestep.
Post-Processing of the Discrete Matrices
After the core discretization formula is applied, some adjustments are made before the discrete matrices are passed further.
-
State-vector reordering. The ordering of state variables in the discrete matrices is permuted to match the canonical ordering defined for the solver partition. This ensures that when the simulator switches between circuit modes during runtime, the state vector is interpreted consistently regardless of which mode is active.
-
Feed-forward correction. For measurement components that have the Exact measurement property enabled, the corresponding rows of Cz and Dz are updated so that the measurement reflects the state at the end of the current timestep rather than its beginning. This reduces the effective measurement delay by one timestep. The correction is not applied when the Bilinear method is used, because bilinear's transformation of C and D already achieves this implicitly.
Summary of Discretization Methods
Table 2 summarizes the key characteristics of each method to guide the choice for a given simulation scenario.
| Method | Stability | Accuracy | Recommended when |
|---|---|---|---|
| Exact | Unconditional | Exact under ZOH | Highest fidelity is needed and the system matrix A is well-conditioned. The default choice for most circuits. |
| Simplified Bilinear | Unconditional | Second-order | The exact method raises numerical warnings (NaN/Inf), or as a robust alternative for stiff circuits. |
| Bilinear | Unconditional | Second-order, frequency-preserving | Frequency-domain accuracy is critical - resonant circuits, filters, or systems where pole/zero locations must match the continuous-time design. |
| Forward Euler | Conditional | First-order | Ts is very small relative to all circuit time constants and periods of dominant resonant frequencies. |