Numerical Integration Software for Hybrid Systems

Beta-test distribution of MATLAB integration routines for the solution of ordinary differential equations with state events (ODEs with discontinuities or switching lines in the state space). Note: These routines only work under MATLAB; they are invalid for SimuLink.

Note: These routines were tested to work under MATLAB 5.3, MATLAB 6.1, MATLAB 6.5 (release 13 for unix) and MATLAB 7.4 (release R2007a for unix); more recently they were tested under matlab_R2015b (mac version) and still performed all the examples flawlessly.

Simply download the hybrid_sim.zip file (377kB) to obtain and install the entire set of files containing the algorithms, documentation and demonstrations (models and scripts to run them). Alternatively, the list below outlining these files may be used to acquire any subset of them.

To use the entire distribution, I recommend that you create a new directory (e.g.,
> mkdir hybrid_sim - sorry, I only "speak" unix), download hybrid_sim.zip into that location, and add that directory to your MATLAB search path (i.e., append the full path to the new directory onto the setenv MATLABPATH statement in your .cshrc file, e.g.:

setenv MATLABPATH (stuff_already_there):/home1/jtaylor/Simulation/hybrid_sim

I also recommend (request) that you register with me, NOW (jtaylor@unb.ca), so I can inform you of updates and bug-fixes. Also, please let me know about any bugs or defects you might discover (of course, this is highly unlikely . . . ;-).

The following files are available individually for your information and use:

  • manual.pdf, a short tutorial guide on how to use our approach and software for modeling and simulating ODEs with discontinuous right-hand sides

  • relay.m, relay_seh.m, run_relay.m, a simple example of state-event handling (a relay switching a double integrator to yield closed trajectories in the phase plane; the mode switches from -1 to 1 and vice versa as a switching curve x1 = 0 is crossed), and a demonstration macro for running it that compares our method with the direct use of MATLAB's ODE45 (in its uncompiled or m-file form)

  • rdz.m, rdz_seh.m, run_rdz.m, a slightly more complicated model (involving a relay with deadzone) that illustrates the use of three mode levels (-1, 0 +1), plus a non-mode-based version of the same model (rdz.m), and a demonstration macro for running them that compares the simulation times for the state-event handling routines with that of the old uncompiled ODE45 algorithm

  • twin_ball_reset.m, run_tbr.m, another slightly more complicated model that illustrates state resetting as part of state-event handling, and a macro for running it

  • stick.m, stick_seh.m, run_stick.m, stick_seh.m represents a more physical example of state-event handling, involving an electro-mechanical system with saturation and stiction; the mode switches from -1 or 1 to 0 (when the motor and load "stick" at zero velocity) and vice versa (as the motor and load become "unstuck") -- also, stick.m models the same system without state-event handling (for use with MATLAB's ode45), and run_stick.m is a demonstration macro for running the models

  • trap_101.m, a fixed-step trapezoidal method for state-event handling

  • ode45_101.m, a variable-step Runge-Kutta-Fehlberg routine (ode45) extended to handle state events, and ode45m.m, if you wish to compare these two methods (with and without the use of modes)

    Note: The integration routines trap_101.m and ode45_101.m contain fragments (good-sized chunks) of MATLAB's FZERO and ODE45 algorithms, with permission from MathWorks.

    The tutorial guide manual.pdf contains a few listings and figures for the examples that are discussed (to keep the guide relatively short); the models and macros listed above may be run to obtain a larger variety of illustrative examples.

    Note that we have extended this methodology to handle hybrid systems comprised of a mixture of discrete- and continuous-time components. The main focus of that effort was precise timing and coordination of state and time events during simulation. The resulting software, described in ifac_wc_hsmns.pdf (which is included in the zip file), has not been tested sufficiently for distribution; it will be made available here eventually . . . especially if there is demand!

  • Return to my Home Page

    Information supplied by: James H. Taylor
    Updated by: James H. Taylor
    Last update: 2016 January 19
    Email comments/suggestions to: Jim Taylor (jtaylor@unb.ca)