πŸ”©Simulation and Output Settings

Getting you familiar with the simulation configuration settings

Simulation

Simulation settings

These settings apply whenever you run a simulation from the model editor, no matter the solver being used.

Start time

Default value: 0.0

If you want to start your simulation from a value other than 0, for example to focus on a specific time interval, set it to the desired value. Any model parameters will set the initial state as though the time started from 0, however any data source blocks will reference time series data from the Start time.

End time

Default value: 10.0

If you want a longer time to be simulated, increase this value. If you want a shorter simulation time, decrease this value. It is an error for this time to be set to a value lower than the Start time.

Numerical backend

Auto | Numpy | Jax

Chooses the backend library to use when simulating your model.

  • Auto: This is the default setting. The appropriate library is chosen for you to maximize performance and correctness, depending on the content of your model. This should work fine most of the time.

  • Numpy: Choose this in the case where you know you don't want auto-differentiation (a Jax feature), or you have Python Script Blocks in your model that are not Jax compatible.

  • Jax: Choose this in the case where you know you want auto-differentiation (e.g., during optimizations or when running very long, complex simulations).

Maximum major steps

Default value: auto (numerical)

This is a setting that applies only when Jax is used as your numerical backend. It helps the library to allocate buffers to increase performance. If your simulations are ending prematurely with errors referencing major steps, you can try manually setting and increasing this value, starting with 4096. If you set this too high, however, you may get out-of-memory errors instead.

Discrete solver

These settings apply only to discrete time blocks in your model, with one exception: if you have a hybrid model (i.e., a mix of discrete and continuous blocks) then the calculation of major step size takes discrete intervals into account.

Global discrete interval

Default value: 0.1

Any blocks in your models that use discrete time (as opposed to continuous time) will use this value by default as their update interval. Submodels that you create or edit can be configured to use a different rate. This is useful for modeling, e.g., micro-controllers that run at a fixed clock rate.

ODE Solver

These settings apply when a continuous solver is used, specifically whenever your model contains blocks with continuous state (e.g., Integrator or Derivative blocks).

Solver method

Non-stiff | Stiff

Non-stiff solvers are a good default for many situations. If your model exhibits stiff behavior, a stiff solver could be not only more accurate, but also more efficient.

Our non-stiff solver uses a Runge-Kutta 5/4 method. It’s a 5th order ODE solver, so is similar in accuracy to the β€œode45” solver you may be familiar with.

Our stiff solver uses a method with a good balance of accuracy and efficiency.

Absolute error tolerance

Default value: 1.0e-6

Error is computed using a combination of absolute and relative error tolerance. Set this value if you need solutions within an absolute tolerance down to a specific number of decimal places.

Relative error tolerance

Default value: 1.0e-3

Error is computed using a combination of absolute and relative error tolerance. Set this value if you need correct solutions to within a certain number of significant digits.

Minimum step size

Default value: 0.0

If the ODE solver estimates that taking a minor step will result in an error outside the error tolerance, it will try to take a smaller step. If that step results in too large an error, it will try to take yet a smaller step, and so on. This setting determines the smallest step size the solver is allowed to try.

Increasing this value will potentially decrease accuracy, and may result in errors due to exceeding tolerance, but it may also speed up long simulations. It is not recommended to change this setting, but it's there if you need it.

Maximum step size

Default value: 1.0e6

When the ODE solver takes a minor step and the error estimate is below tolerance, the next step is allowed to be larger. If that step results in an error estimate that is also below tolerance, the following step is allowed to be bigger yet. This setting sets the maximum size these steps are allowed to take.

Decreasing this value can increase the resolution of your simulation output, but possibly at the expense of longer simulation time.

Explanation of error estimation

This section is informative only. The intent is to provide some context for what the tolerance settings mean.

For each state in the set of ODEs, the solver estimates the error magnitude of the approximated state value. This error is then normalized using the Absolute and Relative tolerance settings. The set of normalized errors are then used to compute the root-mean-square error for the system of ODEs.

The normalizing scale for each state is computed as follows:

scale(i)=atol+max(∣yiβˆ’1∣,∣yi∣)Γ—rtolscale(i) = atol + max(|y_{i-1}|, |y_i|) \times rtol

The error tolerance is used to optimize the step size of the variable solver. If the RMS error is above 1.0, the step size needs to be decreased. If the error is below 1.0 , the step size can be increased. Smaller tolerances produce more accurate solutions. Smaller tolerances also require more computation time.

Output settings

These settings affect the data being output from the simulation. They are separated out from simulation settings because they only affect the data recorded from the simulation, not the method used or results.

Simulation output

Output mode

Automatic | Discrete steps only | Fixed Interval

These modes work as follows:

  • Automatic: The default setting. Will output at every major and minor step and/or discrete interval. If you set Max. results interval to something other than Auto, interpolation will be used to calculate results between major/minor steps.

  • Discrete steps only (coming soon): When your model has both discrete and continuous blocks, this option will ignore data produced by the ODE solver.

  • Fixed Interval (coming soon): No matter the content of your model, nor the step sizes of your simulation, choosing this setting will generate output data at a fixed rate, either through downsampling or through interpolation, as needed. When choosing this option, set the Fixed results interval value as desired, e.g., a setting of 0.1 will produce a data point at simulation times 0.0, 0.1, 0.2, and so on. If you leave the setting at Auto, it will default to the total simulation time divided by 1000, giving a total of 1001 samples in the output.

Recording

These settings specify which signals should be recorded.

Record outputs

Only selected | All outputs

The default Only selected will only record signals from the outputs that have been selected in the model diagram. This is useful when you only have a few known signals that you want to inspect, and it will reduce overall perceived simulation time, since post-processing will be faster.

You can also choose to record All outputs, in which case every block output at the top level of your model will be recorded. This is useful in the case where you don't know which signals you might want to inspect, since all signals will be made available for visualizing or downloading.

Download simulation data

This button is enabled after a successful simulation run, and initiates a download of your selected signal outputs in .CSV format. You can then load this file in other tools for further analysis.

Last updated