Prev | Next |
Creating Models for Simulation
The example that we looked at in the How it Works section of this Guide was deliberately trivial; in this section we will look at these steps in more detail, including options for configuring the models. Enterprise Architect provides a lot of flexibility and allows trivial once-off models to be defined, or sophisticated library based multipurpose models to be created that can be reused across multiple projects and domains using different data sets and contexts. In this topic we will explore some of these options for configuring the models so that they are fit for purpose and will create the required engineering outcomes.
Creating a Simulation Model Package
A Model Package can be set up at any location in the Browser window, but typically it is considered best practice to set up a Simulations Package under each project or initiative. This could then contain sub-Packages for each simulation. It is anticipated that for a given project there could be a number of different simulations required. It is also likely, as discussed in the Data-Sets section, that an organization will want to reuse some of the simulations across multiple projects. These simulations could be set up in the Project Browser and defined at a supra-project level - for example at an enterprise, organization or engineering department level.. They could then be included in a diagram at the project level, indicating that they are applicable to a given project or problem context. It is also likely that an engineering team will want to reuse Value Types and their concomitant Quantity and Unit Libraries between projects, and these, as discussed in an earlier topic of the guide, are best defined and modeled at a supra-project level.
Enterprise Architect uses the SysML Package Import mechanism to ensure the Value Types defined at the enterprise level can be included and reused at each Simulation Package level. The structure would typically contain these Packages:
- Value Types (specific to this project)
- Blocks
- Constraint Properties
In the next section we will learn how to create and configure the SysML Simulation Artifact, which is stereotyped as <<SysMLSimConfiguration>>.
Creating the Simulation Elements
The main effort in preparing a simulation is in the definition of the model elements, using the SySML with the appropriate level of precision to allow the OpenModelica platform to run the simulation. There are a number of ways that the models can be defined, and in this Guide we will focus on the most robust and flexible method as this is what will be used by most practicing engineers and teams.
At this point it is worth looking before the topic of simulation to ensure we understand its relevance and connection to other parts of the model, and how simulation elements might be connected to other model elements such as Requirements, Test Cases and more. Typically, simulations are used as a way of investigating some cyber-physical problem without the need to construct a time-consuming and often expensive physical model. The simulation could be part of problem analysis, trade off analysis, performance analysis or a number of other investigations. The Blocks that are defined as part of the simulation could be allocated to behavioral elements and ultimately to Requirements.
The first elements to be created are the Blocks, which are the fundamental structural elements of the solution. We have learnt how to do this in a previous example; this diagram shows a number of the compartments that have elements, namely the properties.
In preparation for defining the equations that define the behavior of the pendulum system, we will define the value types required to ensure the model is precise and check that the simulation parameters are correctly specified. This is done using a Block Definition diagram (bdd), using the Value Type element available from the Diagram Toolbox.
The next step is to define the constraints using ConstraintBlocks. These elements are where we will define the Modelica equations that will govern the behavior of the system being modeled - in our case, a pendulum. As described earlier in this Guide, ConstraintBlocks are defined on a Block Definition diagram, and have a series of parameters defined and a constraint that expresses those parameters in an equation written in Modelica. For example, the equation that constrains the vertical aspect of the pendulum is written as:
m * der(vy) = -(y/L) * F - m * g
Notice the Modelica keywords such as 'der' signifying a first order derivative. L is the length (parameter) of the Pendulum, g is the acceleration due to gravity (constant), m is the mass (parameter) of the pendulum, x and y are the coordinates in two-dimensional space, and F is the force. Notice that Modelica uses:
The next step is to create the Parametric diagrams that bind the equations together. As discussed earlier in the Guide, these diagrams are a specialized type of Internal Block diagram and contain instances of ConstraintBlocks called ConstraintProperties that expose their parameters, which are bound by connectors to parameters on other ConstraintProperties.
Specifying a Configuration Artifact
The SysML Simulation Artifact is the element that binds the model elements to the OpenModelica platform. The model elements expressed in SysML in the form of Blocks, ConstraintBlocks and their related ConstraintProperties bound together on Parametric diagrams appear in the Simulation window and can be configured with other settings to drive the simulation.
The first step in setting up this facility is to create a SysMLSim Configuration element, available from the 'Artifact' Toolbox page as shown in this screen capture.
Enterprise Architect does most of the heavy lifting with respect to populating the Configure SysML Simulation window. The engineer simply has to select the Package using the icon on the 'Configuration' panel of the Simulation Artifact window.
Enterprise Architect will display the Package selection window, and once the Package is selected the 'Configuration' panel will be populated with the Blocks, ConstraintBlocks and Value Types from the model. From this point the values can be entered for various parameters, or data-sets can be defined. The simulation configuration parameters can be entered and the simulation is ready to run.
Once the data has been entered for the simulation, including Start and Stop values and Output formats, the Simulation can be run by selecting the
as shown in this screen illustration.