We have implemented the sliding mode algorithm as part of a hybrid system simulation engine using a variable step, forward Euler numerical integration scheme. When a mode switch between fields and is detected (see Fig. 19), a binary search determines the point of switching to within a pre-specified accuracy. After the mode switch is executed and the state vector is transferred between modes to , it is checked whether the new mode, , persists for at least one maximum time step, . If not, sliding mode simulation is activated. The sliding mode simulation algorithm (Algorithm 1) first computes based on with as initial point. Discontinuous changes may take place, and the resulting is inferred. Next, is computed to infer and , which may differ from when jumps in the state vector occur between and . Next, is computed based on and , and jumps between and are taken into account when is inferred. Now, is taken as the inital point of a vector . A binary search is performed along this vector given a pre-specified number of steps to determine on the sliding surface. After and its corresponding field are determined, it is checked whether chattering persists and the process continues.
Figure 19: The sliding mode numerical simulation algorithm.