Scalable Compilation for Textual Components: Reduce compilation time for models containing component arrays
Scalable compilation for models containing a large number of repeated components was
introduced in R2021b. For more information, see Scalable Compilation. In the previous release, the
reusable components had to be included in the model as either referenced subsystems or
linked subsystems. This functionality has now been extended to include textual components.
A new attribute, CompileReuse, lets you specify whether the components
are reusable or not. This attribute is available for components only. If set to
true, the compilation artifacts for these components are reusable.
The default is false.
For example, if you model repeated components by using component arrays, you can use
the CompileReuse attribute to specify which component arrays are
reusable:
component battery_pack
...
for i =1:Ncells
components(ExternalAccess=none,CompileReuse=true)
battery_cell(i) = BatteryPack.battery_cell(cell_mass=cell_mass);
end
...
end
...
for i=1:Ncells-1
components(ExternalAccess=none)
conduction(i) = foundation.thermal.elements.conduction(area={1e-3,'m^2'},...
th_cond={200,'W/(m*K)'});
end
...
end
...If scalable compilation is enabled for a model containing this battery pack component,
then the members of the first component array, battery_cell, are
reusable. Members of the second array, conduction, are not designated
as reusable because the conduction element in the Foundation library is not complex enough
to benefit from scalable compilation.
LoggingUnit Annotation: Specify the preferred display unit for
intermediates, variables, inputs, and outputs
A new annotation option, LoggingUnit, lets you specify a preferred
data logging unit for component members, such as intermediates, variables, inputs, and
outputs. If specified, the same unit is also used for other display purposes, such as in
the Variable Viewer or in the operating point.
The specified logging unit must be commensurate with the intrinsic unit of the component member, such as the declared unit of a variable, typed input, or typed output. For intermediates and untyped inputs and outputs, the intrinsic unit is computed by the compiler. For example:
component mycomp
parameters
p1 = {10,'lb'};
p2 = {5, 'ft'};
end
intermediates
i = p1*p2;
end
annotations
i : LoggingUnit = 'J'
end
...Standalone Property Inspector for Simscape Blocks: Unified look and feel of the block user interface
In previous releases, double-clicking a Simscape block opened the block dialog box, where you viewed the block description and modified its parameters. Alternatively, you could view and modify the block properties in the Property Inspector pane in the model window.
Starting in R2022a, when you double-click a Simscape block, the Property Inspector opens in a standalone window. This window has the same content and appearance as the Property Inspector pane in the model window.
To view and modify the block parameter values and initialization targets for the block variables, double-click the block, click the Settings tab, and modify the values of the parameters, variable priorities, and targets.
By default, changing a value in the Property Inspector immediately applies the new
value. To remove a series of changes, use the Undo
button and Redo
button in the upper-right corner of the model window.
To manually apply parameter changes, clear the Auto Apply check box in the upper-right corner of the Property Inspector to enable the Reset and Apply buttons. You can use these buttons to apply or reset parameter changes, similar to using the Apply and Cancel buttons in the block dialog in previous releases.
To view the description of a block, click the Description tab. This tab also contains the Source code link. Click this link to open the Simscape source file for this block in the MATLAB Editor.
If a block has no parameters or variable targets that can be set, then the Property Inspector has only a Description tab.
To view the documentation for a block, click the Help
button in the upper-right corner of the Property
Inspector.
Note
In previous releases, to make the run-time parameter settings visible in block
dialogs, you had to set the Show run-time parameter settings
preference. This check box has been removed from the Simscape
Preferences pane because the
Compile-time/Run-time drop-down
is always visible in Property Inspector.
Network Couplers Library: Split your system into multiple coupled networks with different solver configurations
The new Network Couplers library blocks let you split a Simscape network in your model into multiple coupled networks. Each of these networks can then have its own solver settings. For example, you can use a variable solver for one of the coupled networks and a fixed-step solver for another, or use two fixed-step solvers with different step sizes.
The Network Couplers library is available as a sublibrary in the Utilities library. For more information, see Using Network Couplers to Split Physical Networks.
Vector Format Parameter in PS-Simulink Converter Block: Choose format for outputting vector physical signals
The new Vector format parameter in the PS-Simulink Converter block lets you specify how to output vector physical signals:
inherit — Format the Simulink® output signal to match the format of the physical signal: scalar, row or
column vector, or 2-D matrix. This is the default setting for new models.
1-D array — If the physical signal is a row or column
vector, format the output signal as a Simulink 1-D array. This option corresponds to how the PS-Simulink
Converter block handled vector physical signals in previous
releases. To preserve backward compatibility, in models created prior to R2022a, the
Vector format parameter is automatically set to
1-D array.
Compact Boundaries for Block Display: Improved model layout and readability
Simscape blocks that do not have a solid boundary line around the block icon, such as Resistor or Capacitor, now get a more compact boundary in block diagrams. This enhancement results in improved model layout and better automatic routing of lines. Blocks that have a solid boundary line, such as PS Ramp or Gear Box, are not affected by this change. For detailed information and compatibility considerations, see Release Notes for Simulink.
Comment Through Simscape Blocks: Exclude blocks from simulation without physically removing them from model
You can now comment through a Simscape block in a model to temporarily disable and short-circuit the block from simulation. To comment through a block, right-click on the block and select the Comment Through option. Check that there are exactly two connection ports and that both the ports are from the same domain.
Functionality being removed or changed
Default amount of entrained air changed for isothermal liquid domain
Behavior change
To improve simulation robustness, the default amount of entrained air for the isothermal liquid domain has been changed from 0 to 0.005. The new value applies to:
The domain parameter air_fraction.
The default value of the Volumetric fraction of entrained air in mixture at atmospheric pressure parameter in the Isothermal Liquid Properties (IL) block.
The default value of the Volumetric fraction of air that is entrained at atmospheric pressure parameter in the Isothermal Liquid Predefined Properties (IL) (Simscape Fluids) block, available with a Simscape Fluids™ license.
If you specify the working fluid properties by using an Isothermal Liquid Properties (IL) or Isothermal Liquid Predefined Properties (IL) block, as recommended in Specifying the Working Fluid, then these blocks in existing models retain the parameter value saved with the block in the previous release, whether the default value of 0 or a custom value, and the simulation results stay the same.
However, if your model contains isothermal liquid circuits without a fluid
properties block, these circuits use the default domain properties and the simulation
results for the model might change. To preserve compatibility with previous releases,
add an Isothermal Liquid Properties (IL) block to the
isothermal liquid circuit and set its Volumetric fraction of entrained air
in mixture at atmospheric pressure parameter to
0.
Scalable Compilation Enhancement: Reduce compilation time for models containing multiple instances of the same Simscape block
When your model contains a large number of repeated components, such as a transmission
line or a battery pack, you can reduce its compilation time by enabling scalable
compilation. In the previous release, the reusable components had to be included in the
model as either referenced subsystems or linked subsystems. Now, if your model contains
multiple instances of the same block, you can use the simscape.scalable.setBlockConfig function to make these instances reusable.
For more information, see Scalable Compilation.
New Index Reduction Options: Choose nonlinear index reduction method best suited for each network
If your model contains high-index differential algebraic equations (DAEs), you now have a choice of nonlinear index reduction methods. Use the new Index reduction method parameter in the Solver Configuration block to select the method best suited for that network:
Derivative replacement — In this method, parts of the
DAE are differentiated analytically and appended to the original system. For each
additional equation, a derivative is selected to be replaced by a new algebraic
variable called a dummy derivative. For more information, see
https://epubs.siam.org/doi/abs/10.1137/0914043?journalCode=sjoce3. This option corresponds to the nonlinear index reduction method used in previous
releases. It is recommended that you start with this method. This is the default
setting.
Projection — Use this option if the
Derivative replacement method fails due to issues with
dynamic state selection.
None — If your model does not contain nonlinear
high-index DAEs, use this option to completely bypass nonlinear index reduction and
remove the analysis overhead.
Multithread Linear Algebra: Speed up desktop simulations that use local solver and sparse linear algebra
If your model uses a local solver and sparse linear algebra, you can now use
multithread linear algebra to speed up desktop simulation on a multicore machine. The new
Number of threads (specify n for 2^n) parameter in the
Solver Configuration block lets you specify the number of
threads by providing an integer exponent for 2. The number of threads equals 2 to the
power of the parameter value. The default, 0, corresponds to
single-thread linear algebra and is equivalent to the algorithm used in previous
releases.
This parameter is available only if you select the Use local
solver check box and set the Linear algebra parameter to
Sparse. For a global solver, Simulink solves the equations without using Simscape linear algebra algorithms.
For small models, multithread algorithms that use numbers higher than 0 may be slower than single-thread.
simscape.op.Target Enhancement: Use simscape.Value
objects to specify operating point targets
When creating or manipulating operating point targets, you no longer specify the value
and unit separately. Instead, use simscape.Value objects to specify both
the value and the unit.
The underlying operating point data has not changed. However, if you use scripts for
programmatic target manipulation, you might need to update portions of the code related
to accessing the Value property of a
simscape.op.Target object.
Simscape Hardware-in-the-Loop Workflow Enhancement: Use sign(x) in
Simscape models
If you have an HDL Coder™ license, you can now generate an HDL code from Simscape models that use sign(x) in component equations. In
previous releases, the use of this function was not supported.
Simscape Variable Scaling Analyzer App: Identify issues with model scaling to improve performance
Now you can access the Simscape Variable Scaling Analyzer app from the
Simscape section of the app library. Previously, you could only
access the Simscape Variable Scaling Analyzer by using the
simscapeVariableScalingAnalyzer command. The app performs an
analysis of the model variables and equations, highlights problem areas that may cause
issues with performance or accuracy, and provides scaling recommendations for nominal
values. To learn more, see Select Nominal Values Using the Variable Scaling Analyzer.
New look and feel for Simscape Results Explorer and Variable Viewer
Simscape Results Explorer and Variable Viewer have a new look and feel and a streamlined interface, but all the workflows are similar to those in previous releases.
For more information, see About the Simscape Results Explorer and About Variable Viewer.
Code reuse support in code generation
In previous releases, code generated from Simscape models did not support code reuse. This limitation has now been removed.
New examples
Examples introduced in this version include:
Functionality being removed or changed
New algorithm for physical signal variable elimination
Behavior change
To speed up simulations, the new algorithm eliminates variables generated by inputs and outputs of blocks from the Physical Signals library from the system of model equations. In most cases, these variables represent operations on known data and therefore including them in the overall system of model equations makes these equations unnecessarily complicated. Eliminating these variables shortens compilation time and increases robustness.
Because of the new algorithm, some models might require more input derivatives than in previous releases. This issue mostly affects models with conditional high-index equations. If, upon simulating an existing model, you get a request for additional derivatives for a Simulink-PS Converter block, you can:
Use the input filtering option in the Simulink-PS Converter block.
Add an additional input signal to the Simulink-PS Converter block to provide the derivative.
Eliminate the Simulink-PS Converter block by using a physical signal as an input.
Improved simulation accuracy for Partitioning solver in Robust
simulation mode
Behavior change
To improve simulation accuracy when using the Partitioning solver in
Robust simulation mode, more partitions may be generated
than in previous releases. The solver uses the new partitions to ensure that all the
algebraic constraints are satisfied up to the consistency tolerance.
In R2021a, when improving the stability of the Partitioning solver in
Robust simulation mode, one of the changes was to delay
the computation of some nonlinear terms in algebraic equations. That change, while
improving computation efficiency, in some cases may have led to lower simulation
accuracy. The new algorithm does not delay the computation of nonlinear terms.
However, because of this change, some models may slow down or fail during simulation.
If this happens, you can:
Use the Partitioning solver in Fast simulation
mode.
Use a different local solver.