πŸ“‰Simulation Overview

How to get simulations running in Collimator

Hybrid Dynamical Systems Simulation

Collimator is a hybrid dynamical system simulator, which uses a canvas with blocks and lines to represent the system. The collection of blocks, lines, and parameters is called a model.

Continuous and Discrete Portions of the Model

The continuous and discrete portions of a hybrid system require different solvers to advance them in time, and produce the simulation results. Because these portions require different solvers, it is important that Collimator assign the blocks of a model into continuous and discrete sets.

At Collimator, the property of a block defining it’s association to continuous or discrete is called time_mode.

Some blocks are continuous time_mode by design, these are listed in Block Library/Continuous.

These blocks require a continuous solver.

Similarly, some blocks are discrete time_mode by design, these are listed in Block Library/Discrete.

These can be isolated in the library browser by filtering with the keyword discrete. These blocks require a discrete solver.

Most blocks in the library are neither continuous nor discrete by design, they can be either. These are gain, lookup table, saturation, etc. Before Collimator can run a simulation, each of these blocks in the model is assigned to either continuous or discrete sets, such that the appropriate solver is applied. Collimator creates the Continuous and Discrete sets by applying some simple steps to propagate the time_mode from blocks which have time_mode defined by design, to blocks which do not. The rules applied are:

  1. For all unassigned blocks for which all upstream blocks are Discrete, the block is assigned Discrete. When a block’s time_mode is changed, revisit all blocks downstream to see if they need to be changed. Once there are no more blocks to visit, this step is done.

  2. Any remaining unassigned blocks are assigned Continuous.

With the blocks of the model all assigned to either Continuous or Discrete time_mode, the simulation may begin.

Simulation Loop Pseudo Code

The pseudo code below illustrates how Continuous and Discrete portions are advanced in time.

while time < stop_time
	major_step_end_time = time + next_discrete_update_time
	# presently, next_discrete_update_time == discrete_update_interval (a.k.a sample_time)
	update discrete portion of the model
	store signal results to memory at beginning of major_step
	while time < major_step_end_time
		perform continuous solver step to update continuous portion
    time += solver_step_dt
		if solver_step_dt > interpolation
			interpolation_time = time - solver_step_dt
			while interpolation_time < time
				compute interpolated results
				store signal results to memory at interpolation_time
				interpolation_time += interpolation
		store signal results to memory at end of solver step

The outer loop iterations are referred to as major_steps, this is when discrete solver is at work. The middle loop iterations are referred to as minor_steps, this is where the continuous solver is at work. The inner loop iterations are referred to as continuous result interpolation, this is where, if needed, the continuous solver interpolant can be used to produce results that are higher resolution in time than just the steps taken by the solver.

That is how Collimator starts with your model of continuous, discrete, and other blocks, and produces the simulation results.

Discontinuities Modeled as Events

The continuous portion is a set of ordinary differential equations (ODE). Some systems that can be modeled with ODEs include some discontinuities, like contact between two objects. The discontinuities can be modeled using blocks with events, e.g. the comparator block, so that numerical integration of the ODEs progresses correctly before and after the discontinuity. To configure Collimator to do this, set events to normal. If you know that your model does not need any events handling, then select none, as this will be most efficient. More granular user controls of events handling may be available in the future.

Last updated