Normally, when simulating or analyzing a model in SimBiology®, the model is expressed in MATLAB® code. You can accelerate the simulation by converting the model to compiled C code, which executes faster. Because this compilation step has a small time overhead, acceleration is not recommended for individual simulations of small models. However, for large models, or for repeated simulations during analysis, acceleration can provide a significant speed increase that outweighs the small time overhead.
The functionality to accelerate simulations performs optimally under the following conditions:
Running repeated simulations with different initial conditions
Running very long simulations (for example, simulations that take longer than a minute to run)
To prepare your models for accelerated simulations, install and set up a compiler:
Install a C compiler (if one is not already installed on your system). For a current list of supported compilers, see Supported and Compatible Compilers.
Ensure that any user-defined functions in your model can be used for code generation from MATLAB, so they can convert to compiled C. For more information, see Language, Function, and Object support for C and C++ code generation (MATLAB Coder) or contact MathWorks Technical Support.
On 32-bit Windows® platforms, the LCC compiler is automatically installed. However, for better performance of the acceleration functionality, you may want to install a supported compiler other than LCC, and it will be selected automatically.
On 64-bit Windows platforms, if you have not installed another compiler, SimBiology uses the LCC64 compiler for model accelerations. If you have installed another supported compiler, it will be selected automatically.
Microsoft® Visual Studio® 2010 run-time libraries must be available on any computer running accelerated models generated using Microsoft Windows SDK.
If you plan to redistribute your accelerated models to other MATLAB users, be sure they have the same run-time libraries.
Follow the two-step process for acceleration.
sbioaccelerate to prepare
your model for accelerated simulations. Use the same input arguments
that you plan to use with
the next step. For example:
For a very large model, this step may take a minute or longer to complete.
the same input arguments that you used with
If you pass in an array of doses to
you can simulate the model using any subset of these doses and do
not need to run acceleration again.
For illustrated examples, see the following.
SimFunction object is automatically accelerated
at the first function execution. Hence it is not necessary to accelerate
the model before you create the object. However, manually accelerate
of the object if you want it accelerated in your deployment applications.
For exported model, see
If you make any modifications to the model, such as changes to reactions or adding events, you need to rerun the acceleration, before running simulations.
However, there are exceptions. You do not need to accelerate again if you are making the changes to:
If you have user-defined functions, do not use persistent variables in these functions. Persistent variables are not compatible with the functionality used for accelerating simulations.
If you specify user-defined functions in SimBiology expressions, you might see the following warning if your code is not compatible with code generation from MATLAB:
The SimBiology Expression and any user-defined functions could not be accelerated. Please check that these expressions and any user-defined functions are supported for code generation as described in the Code Generation from MATLAB documentation.
where Expression is any of the following:
Reaction rate/rule expression
Repeated assignment rule expression
Event trigger expression
Event function expression
For more information, see Language, Function, and Object support for C and C++ code generation (MATLAB Coder) or contact MathWorks Technical Support.