Sample Time and Solver Restrictions
The default sample times of Simscape™ blocks are continuous. You cannot simulate Simscape blocks with discrete solvers using the default sample times.
If you switch to a local solver in the Solver Configuration block, the states of the associated physical network become discrete. If there are no continuous Simulink® or Simscape states anywhere in a model, you are free to use a discrete solver to simulate the model.
You cannot override the sample time of a nonvirtual subsystem containing Simscape blocks.
A Simscape physical network should not exist within a Simulink algebraic loop. This means that you should not directly connect an output of a PS-Simulink Converter block to an input of a Simulink-PS Converter block of the same physical network.
For example, the following model contains a direct feedthrough between the PS-Simulink Converter block and the Simulink-PS Converter block (highlighted in magenta). To avoid the algebraic loop, you can insert a Transfer Function block anywhere along the highlighted loop.
A better way to avoid an algebraic loop without introducing additional dynamics is shown in the modified model below.
Unsupported Simulink Tools and Features
Certain Simulink tools and features do not work with Simscape software:
Exporting a model to a format used by an earlier version (Simulation > Save > Previous Version) is not supported for models containing Simscape blocks.
The Simulink Profiler tool does not work with Simscape models.
Physical signals and physical connection lines between conserving ports are different from Simulink signals. Therefore, the Viewers and Generators Manager tool and the signal label functionality are not supported.
Restricted Simulink Tools
Certain Simulink tools are restricted for use with Simscape software:
You can use the Simulink
get_paramcommands to set or get Simscape block parameters, if the parameters correspond to fields in the block dialog box or Property Inspector. It is not recommended that you use these commands to find or change any other block parameters.
When you hover over a parameter name in the block dialog box or Property Inspector, the tooltip displays the corresponding programmatic names for the parameter value and unit. Use these programmatic names with the
If you make changes to block parameters at the command line, run your model first before saving it. Otherwise, you might save invalid block parameters. Any block parameter changes that you make with
set_paramare not validated unless you run the model.
Simscape blocks accept
Simulink.Parameterobjects as parameter values in
set_param, within the restrictions specified here.
Enabled subsystems can contain Simscape blocks. Always set the States when enabling parameter in the Enable dialog to
heldfor the subsystem's Enable port.
Setting States when enabling to
resetis not supported and can lead to fatal simulation errors.
You can place Simscape blocks within nonvirtual subsystems that support continuous states. Nonvirtual subsystems that support continuous states include Enabled subsystems and Atomic subsystems. However, physical connections and physical signals must not cross nonvirtual boundaries. When placing Simscape blocks in a nonvirtual subsystem, make sure to place all blocks belonging to a given Physical Network in the same nonvirtual subsystem.
Nonvirtual subsystems that do not support continuous sample time blocks (such as If Action, For Iterator, Function-Call, Triggered, While Iterator, and so on) cannot contain Simscape blocks.
An atomic subsystem with a user-specified (noninherited) sample time cannot contain Simscape blocks.
Simulink configurable subsystems work with Simscape blocks only if all of the block modeling options have consistent port signatures.
When you save a Simulink operating point of a model as a
Simulink.op.ModelOperatingPointobject, you cannot modify Simscape blocks in the model between saving the
ModelOperatingPointobject and using it as the initial state for another simulation.
You can use Simscape operating points to initialize models containing Simscape blocks. For more information, see Using Operating Point Data for Model Initialization.
For models containing both Simulink and Simscape blocks, exact state restoration between releases is not guaranteed. Updates to Simscape library blocks or algorithms, such as variable elimination, can result in a different number of logged Simulink states than in a previous release, even when you do not change the model content. Therefore, restoring an operating point saved in a previous release by using Simulink operating points, datasets, and similar tools, may lead to a different result.
For models containing Simscape blocks only, using Simscape operating points provides consistent initialization results in different releases. For more information, see Using Operating Point Data for Model Initialization.
If you apply both a Simulink and a Simscape operating point at the same time, the Simulink operating point overwrites the data in the Simscape operating point.
You cannot change a Simscape operating point when fast restart is on.
Linearization with the Simulink
linmodfunction or with equivalent Simulink Control Design™ functions and graphical interfaces is not supported with Simscape models if you use local solvers.
Model referencing is supported, with some restrictions:
All physical connection lines must be contained within the referenced model. Such lines cannot cross the boundary of the referenced model subsystem in the referencing model.
The referencing model and the referenced model must use the same solver.
For protected model references containing Simscape blocks, you cannot run them in accelerator or rapid accelerator mode without a Simscape license.
You cannot create Simulink signal objects directly on the PS-Simulink Converter block outputs. Insert a Signal Conversion block after the output port of a PS-Simulink Converter block and specify the signal object on the output of the Signal Conversion block instead.
Simscape run-time parameters are run-to-run tunable. Therefore, for Dashboard blocks linked to Simscape blocks, changing the dials during simulation does not affect the simulation results.
To use Dashboard blocks for run-to-run tuning of Simscape block parameters, designate the parameter as
Run-timeconfigurable, associate it with a workspace variable, and link the Dashboard block to the workspace variable. For more information, see About Simscape Run-Time Parameters.
In rapid accelerator mode, Simulink Compiler does not support Simscape data logging.
Simulink Tools Not Compatible with Simscape Blocks
Some Simulink tools and features do not work with Simscape blocks:
Execution order tags do not appear on Simscape blocks.
Simscape blocks do not invoke user-defined callbacks.
You cannot set breakpoints on Simscape blocks.
Reusable subsystems cannot contain Simscape blocks.
You cannot use the Simulink Fixed-Point Tool with Simscape blocks.
The Report Generator reports Simscape block properties incompletely.
Code generation is supported for Simscape physical modeling software and its family of add-on products. However, there are restrictions on code generated from Simscape models.
Encapsulated C++ code generation is not supported.
Tunable parameters are not supported.
Run-time parameter inlining ignores global exceptions.
MaxStackSizeis not supported.
Simulation of Simscape models on fixed-point processors is not supported.
Block diagnostics in error messages are not supported. This means that if you get an error message from simulating generated code, it does not contain a list of blocks involved.
Conversion of models or subsystems containing Simscape blocks to S-functions is not supported.
There are variations and exceptions as well in the code generation features of the add-on products based on Simscape platform. For details, see documentation for individual add-on products.
Code Generation and Fixed-Step Solvers
Most code generation options for Simscape models require the use of fixed-step Simulink solvers. This table summarizes the available solver choices, depending on how you generate code.
|Code Generation Option
Rapid Accelerator mode
|Variable-step or fixed-step
|Simulink Coder™ software: RSim Target*
|Variable-step or fixed-step
|Simulink Coder software: Targets other than RSim
* For the RSim Target, Simscape software supports only the Simulink solver module. In the model Configuration Parameters dialog box, see the Code Generation: RSim Target: Solver selection menu. The default is automatic selection, which might fail to choose the Simulink solver module.