Use of MATLAB Simulink
Enterprise Architect supports exporting models to MATLAB Simulink to simulate directed messages between Blocks, producing charts of the simulation results. It will also use the optional extension products Simscape and Stateflow:
- Simscape is used to model physical systems with physical flows, translating SysML Internal Block diagrams into a Simulink model
- Stateflow is used to translate StateMachine diagrams into a Stateflow model for simulation
Simulation with Simulink is similar to using OpenModelica, which is also available in Enterprise Architect; the introduction to simulating SysML parametric models in the Parametric Simulation Help topic applies to both products.
Comparison of Modelica, Simulink, Simscape and Stateflow
Modelica supports modeling either Signals or physical systems, whereas Simulink can only model Signal flow; that is, one Block sends a piece of information to another Block. This means, for Simulink modeling, all Ports must have a direction defined as either in or out. Item Flows between Ports must match the in/out directions.
Simscape is an optional extension to Simulink that allows modeling of physical systems. This means the Blocks represent a physical object, and the flows represent the physical flow of a substance or energy (that is, liquid, current, gas, flux, force/torque, heat flow and so on).
See the Basic Principles of Modeling Physical Networks online document for details on using Simulink and Simscape.
Physical flow properties must be typed by block that include one conserved PhSVariable and one non-conserved PhSVariable. Use the Model Wizard patterns for SysPhS available under the SysML perspective. They include:
- SysPhS Elements for physical interaction
- SysPhS Elements for signal flow
Of Simulink simulation:
- Ports must have direction defined as either 'in' or 'out'
- Ports must be connected consistent with their direction; for example, an 'in' Port cannot be connected to another 'in' Port
- Constraint parameters will be considered to be variables unless specified as stereotype ‘PhSConstant’ (or set to SimConstant in the Configure SysML Simulation window)
- Constraint equations must have a single term on the left-hand-side (lhs) of the equals sign, and this term must be either an output or a derivative
Of Simscape simulation:
- Ports with 'inout' direction (or none) will be assumed to be physical flows and will generate Simscape models
- Any Block with an 'inout' Port will be generated as Simscape – if it also has 'in' or 'out' Ports, these will be set to Simscape 'physical signals'. These can be connected to out 'physical signals' or to Simulink inputs and outputs.
Of Stateflow simulation :
- A SysML Block can have a child StateMachine element with a StateMachine diagram under it
- The Block cannot also have an Internal Block Diagram (IBD)
- Stateflow models are in an 'alpha' state - some parts will work, some parts won’t; most StateMachine models should be visible in MATLAB, but might or might not translate the equations and triggers correctly
- Simulink will only allow the output Ports to be plotted; there could be a future enhancement to allow other variables to be plotted too - note that an input Port is inherently the same as the output Port that connects to it