Simulate a Hybrid System

The seExampleTankFilling model incorporates both time-based and event-based modeling. It models tanks queuing up to be filled.

The seExampleTankFilling example has two sections, a SimEvents® part that models event-based behavior and a Simulink® part that models continuous-time dynamics.

SimEvents Part of Model

The SimEvents part models the flow of tanks.

  • The Entity Generator block generates the tanks.

  • The Entity Queue block queues each tank in FIFO mode.

  • The Entity Server block calls the startFilling Simulink function to fill each tank.

Simulink Part of Model

The Simulink part models the time-driven process of filling tanks.

  • The Simulink side of the model contains the logic to fill the tanks.

  • Each tank has a Capacity attribute. The continuous time part models the process of filling up a tank, modeled by the Integrator block. When a tank is filled to capacity, the Entity Gate block releases the tank and it departs.

  • The Simulink side of the model also contains the Simulink function startFilling.

  • The Flip Completion Logic subsystem completes the filling of the tank and reinitializes for the next fill. It uses the Entity Gate block to release each tank.

Run the Hybrid Model

Run the seExampleTankFilling model. In the first scope, observe the fill process.

In the second scope, observe the number of trucks leaving after being filled.

Event-Based and Time-Based Dynamics in the Simulation

In the seExampleTankFilling model, the time-based dynamics of the tank fill coexist with the event-based dynamics of the tank flow subsystem. When you run the simulation, the solver and the event calendar both play a role. Upon major time steps of the solver, the simulation solves the ordinary differential equations that represent the dynamics of the tank fill system. Solving the event-based dynamics entails scheduling and processing events, such as service completion and entity generation, on the SimEvents event calendar. Because the model uses a variable-step solver, when events occur in the discrete-event system, the solver has a major time step.

See Also

| |

Related Topics

Was this topic helpful?