
2-9. Numerical Integration of Switch and Limiter Outputs,
Event Prediction, and Display Problems
Switch-function outputs are discontinuous step functions, and limiter out-
puts have discontinuous derivatives.
7
Numerical-integration steps must not
cross such discontinuities, which violate the smooth-interpolation assump-
tions underlying all higher-order integration formulas. We already encoun-
tered the same problem with sampled-data integrands and solved it by
providing integration routines that never step across the periodic sampling
points (Section 1-8). But switch and limiter functions used in differential-
equation problems will not, in general, switch at known periodic sampling
times. To ensure correct numerical integration we must, therefore, modify
either integration steps or switching times.
Early simulation projects simply reduced the integration step size
DT, typ-
ically with a variable-step Runge–Kutta routine, and then ignored the prob-
lem. This often works (perhaps because models of stable control systems
tend to reduce computing errors), but it is not the way to get reliable results.
In particular, variable-step integration may fail at the switching points as it
tries to decrease the integration-step size. Models requiring frequent switch-
ing (e.g., models of solid-state ac motor controllers) are especially vulnerable
[5,6]. The situation is worse when simulations of mechanical and electrical
systems involve several switching devices.
Two alternative methods can produce correct integration:
1. Some simulation programs predict the time
Tevent when a function
such as
swtch(x) will switch by extrapolating future values of x from a
number of past values. The integration routine is then designed to force
the nearest integration step to end at
t = Tevent. The software must
select the first function likely to switch, and the extrapolation formula
must be as accurate as the integration rule [6–9].
2. We can execute program lines containing switch and limiter functions
only at the end of integration steps (Section 2-11). This involves a com-
promise between switching-time resolution and integration step size;
small integration steps slow down the computation.
The following sections describe two simple schemes for correct integra-
tion, but another problem remains. Computer displays cannot correctly dis-
play switched functions that switch more than once between display
Modeling Limiters and Switches 45
7
Sometimes one can replace switch or limiter functions with smooth approximations. One
can, for instance, approximate
sat(x) with tanh(a * x). Note that this technique also requires
small integration steps.