Difference between revisions of "Simantics System Dynamics"

From End-User Wiki
Jump to: navigation, search
(System Dynamics)
(System Dynamics Workbench)
Line 48: Line 48:
 
== System Dynamics Workbench ==
 
== System Dynamics Workbench ==
  
===Install / Use===
+
===Requirements===
How to install and start the program. What is required (Modelica, VC90)
+
System dynamics tool is a component of the Simantics platform.
 +
 
 +
To be able to simulate system dynamics models, you need to install [http://www.openmodelica.org/index.php/download OpenModelica]. The tool transforms model configurations to modelica language before building the model and simulating it.
  
 
===Layout===
 
===Layout===

Revision as of 09:07, 28 September 2010

Introduction to System Dynamics Simulation

System Dynamics

System dynamics is an approach to understanding different organizations, markets and other complex systems and their dynamic behavior.

Model

Model structure

System dynamics model is generally understood as the model configuration. In this tool, the model contains also other components. Model can have Operating interfaces that enable the use of the model with simple controls. Operating interfaces are configured separately and when using them, the complex model is hidden from the user. Experiments are the way to simulate the model. In the future, you can have experiments with different configurations, for example different initial values for some parameters. In that way, you don't have to always configure the model for different scenarios. Modules folder contains all the different module types in your model and you can create new module types there.


Components

Most of the components you can use in your models are basic system dynamics components. The modularity of the models introduces two additional components, Modules and Inputs. All the components are explained below.

Component types
Auxiliary
Auxiliary is the most basic variable you can use. It represents a single value or a mathematical expression. There are different types of auxiliary variables currently in the system: Auxiliary, Parameter, Constant and WithLookup. Auxiliary is the default type. Parameters are single values that the user can change. When only parameters are changed, the model simulates faster, because the system does not have to recompile the model. WithLookup is a special variable that has an expression and a lookup table. The expresssion defines what value is taken from the defined table.
Dependency
Dependency is an arrow that connects two components. It means that the value of the variable from which the arrow starts is used to calculate the value of the variable where the arrow ends.
Flow
Flow connects clouds, valves and stocks. Flow represents an actual flow of something from stocks or clouds to stocks or clouds. There has to be at least one valve in a flow and the system creates it automatically, if none of the ends of the flow is a valve.
Valve
Valve regulates the rate of a flow. The value of a valve is automatically used in calculating the level of an adjacent stock. Valves behave just like Auxiliary variables but look different and you can connect also flows to them.
Stock
The value of a stock variable is an integral of flows leaving and flows arriving to the variable. The integral is calculated automatically from the valves that are connected to the variable with flow connections. You must give an initial value to the stock. Initial value can be a single value or an equation. You can use values of other variables to calculate the initial value.
Cloud
Cloud is not a variable. It represents a starting or ending point of a flow, if it is not in the scope of the model.
Module
Modules enable structural modeling. Modules are defined just like the basic model configuration, but the module component hides the actual configuration. You can only connect dependency connections into the module and dependency connections from the module must end to Input variables. The interface of the module is defined using input and output variables in the configuration of the module. All variable types can be set as output variables. If a variable is an output variable, its font is bold.
Input
Input variables are the way of getting values from other modules. Inputs look like auxiliary variables except their font is italics. You can set a default value to the input variable in case it is not connected to any variable. Connections are made from the modules properties, when the module is populated. Input doesn't have to be connected with an arrow to a module. If the variable has no connections, it can get values from a higher level in the hierarchy. If an input is connected to an output, the output and its module are shown below the variable using dot notation.


Modeling principles

System dynamics modelling is much more than just mathematical formulas and nice graphs. Models are ways of communicating. There are some basic principles in system dynamics modelling that make the models easier to read and understand. You do not have to apply these principles to simulate models, but using them makes it easier for you to communicate your model to others.

Variable names
Variables names should be nouns, not verbs. The names should be positive: for example it is easier to understand that satisfaction decreases than dissatisfaction rises.
Variable names can and should have multiple words, if they are needed. Unfortunately current version of the tool does not support spaces in variable names. A good practice is to use CamelCase if name contains multiple words. This means that you start every word woth a capital letter (example: ExampleVariable).
Connections
You should try to avoid overlapping dependency arrows. In some situations, however, it is not possible. Dependencies should also form distinctive loops, if there is a loop. It makes it easier to read and understand the model and its behavior.
Graphical annotations
System dynamics contains usually annotations for loops, polarities, delays and so on. Currently those annotations are not supported, but the support will be added later. Annotations are important, again, for communicating the behavior of the model.

System Dynamics Workbench

Requirements

System dynamics tool is a component of the Simantics platform.

To be able to simulate system dynamics models, you need to install OpenModelica. The tool transforms model configurations to modelica language before building the model and simulating it.

Layout

BasicWorkbench.png

  1. Diagram
    Diagram is the area where you will graphically modify your model. Diagrams are built from elements that can be dragged from Symbols view or populated using shortcut keys.
  2. Model Browser
    Model browser shows the structure of your model and all items related to it.
    Symbols view is behind the model browser and used for dragging elements to diagrams.
  3. Equation
    Equation view shows the selected variable's properties. Equation view has a different layout depending on the type of the selected variable. The view can also have different tabs depending on the variable type. Basic tabs are Equation and Additional information.
  4. Trend
    Trend view shows the graphical representation of the values of the selected value over time. For the trend to be shown, a simulation has to be run. The view shows always the results of the latest run, but you can save results of a simulation and show them in the same trend with results from another simulation. Values view and Dependencies are located at the same place and can also be used for analyzing the model.
  5. Experiment controls
    Experiment controls are shown when an experiment is active. Experiment is activated by double clicking an experiment in the model browser. With the experiment control, you can start simulation runs and save simulation results.

System Dynamics Modelling

Basic modelling

Basic modelling functions enable you to create and configure models. System dynamics modeling is basically pretty simple, so with these instructions you can build small and also very large models. The tricky part is writing all the expressions and adjusting the model so that it actually tells you something.

Basic 1.png
Creating a new model
Start a new model by right-clicking the model browser and selecting New->Model or from the main menu File->New Model.


Basic 2.png
Creating a new module type
Create a new module type by right-clicking on the Modules-folder and selecting New->Module. This creates a new module type that you can populate to your other modules and the model configuration.


Configuring a model
Model configuration can be opened by double clicking Configuration in the model browser.
Configuring modules
Configuration of a module type can be opened by double clicking the module type you want to configure. You can also open the configuration of a module from a diagram, when a module has been populated to that diagram, by right-clicking the module and selecting Show Module. When opening modules from diagram, the opened diagram knows to which diagram the module has been populated and can show the connections between the modules. Keep in mind that when making changes to a module, the changes apply to all instances of the module!
Populate variables
You can drag variables to a diagram from symbol view. You can also populate variables using shortcut keys
Populate modules
Modules are populated from the model browser. Just drag the module you want to populate from the Modules folder to a diagram.
Create connections
There are two types of connections: dependencies and flows. Both are created basically the same way. Hold Alt down and click on a variable. Left click starts a dependency, right click starts a flow. Both are ended to another variable with a left click.
Flows can also be started and ended to an empty spot in the diagram. If there is no start or end variable, a cloud will be created. Also if start or end is not a valve, a new valve is created in the middle of the flow.
There are some restrictions on what connections can be made, but don't worry, the user interface won't let you do connections that are not allowed.
Connections between modules
Outside the module
You can connect variables to variables in modules like this:
MODULE -----> INPUT
or
ANY VARIABLE -----> MODULE 
This is just the visual configuration, but you need those connections to really connect variables in the module's properties.
In Inputs -tab you select which variables you connect to inputs inside the module. In Outputs -tab you select which variables you lift from the module to inputs outside it.
Inside the module
Input variables get values from outside the module
Output variables can send their values outside the module. From the variable properties, select Additional Information and press Is Output
Configure variables
Select a single variable from diagram or model browser. The properties of the variables are shown in the equation view and you can modify them.
Export model
To export your model to a file, select your model from the model browser, right-click and from the context menu choose Export... Select the folder where to export your model, give the file a name and press Save. You do not need to export a model to Save it, the model is automatically saved in your database. Export can be used to for example create different versions of the model, create backups or to transport it to another database.
Import model
Right-click on the model browser and select Import... Browse to your .tg file and select open. The model is added to your model browser.

Shortcut and control keys

Shortcut keys for configuring a model on diagram.

Shift + A Hover Auxiliary at the cursor position, populate with left mouse button.
Shift + S Hover Stock at the cursor position, populate with left mouse button.
Shift + C Hover Cloud at the cursor position, populate with left mouse button.
Shift + V Hover Valve at the cursor position, populate with left mouse button.
Shift + I Hover Input at the cursor position, populate with left mouse button.
Alt + left mouse button Start an arrow from a variable. End to another variable by clicking left mouse button.
Alt + right mouse button Start flow from a variable. End by clicking left mouse button.

If a flow is not started or ended on to a variable, a cloud will be created to that end.
If a new flow does not have a valve at either end, a valve will be created in the middle of the flow.

Delete Remove selected variables
Ctrl + left mouse button Select multiple variables
Mouse wheel or
+ and -
Diagram zoom
drag(mouse3) or
drag(shift + any mouse button)
Diagram pan
Ctrl + Z Undo diagram action
Ctrl + Y Redo diagram action
Ctrl + C Copy selected elements
Ctrl + X Cut selected elements
Ctrl + V Paste copied or cut elements

System Dynamics Simulation

Simulate model
To simulate a model, you need to activate an experiment. Browse to an experiment in you model browser and double click on the experiment. Experiment controls appear to the main tool bar. Click on the play button to run a simulation.
Analyze results
There are currently three analysis tools in the system dynamics tool.
Trend
Shows you the values of the selected variable(s) graphically over the simulation time. You can modify the trend and zoom it using the context menu (right-click) of the trend.
Trend.png
Values
Shows you the values of the selected variable(s) in a table form. If the value has a star (*) at the end, it means that the value is an approximate. There is no value for that variable for the given time step.
Values.png
Dependencies
Dependencies is not actually an analysis tool for simulation results. It can show even without simulation which variables affect and which are affected by the selected variable. The direction and number of steps that are traveled from the selected variable can be selected at the bottom of the view.
Dependencies.png
Compare results
You can compare different results of the same model by saving simulation results and displaying the saved results side by side with other results. You can save your results after simulating by clicking the save button Saveresults.png on your experiment controls. The saved results appear to model browser under the active experiment. To show the results on trends and tables, right-click on the result and select Show on charts.
CompareTrend.png

System Dynamics Operating User Interfaces

How interfaces can be created, how they can be used, current components

Create
Right-click on Operating interfaces and select New->Operating UI. Open the Operating User Interface by double clicking it.
Configure
Operating UIs have their own set of widgets. Widget symbols can be seen in the Symbols view and dragged to the diagram. The properties of the widgets can be modified from the properties view (same as equation view).
To connect a variable to a widget, just drag it from the model browser to the widget.
You can use monitors as labels, but to change the text on the monitor, you have to switch to operating mode by clicking OperatingModeSwitch.png.
Use
To use the interface you have created, you have to switch to operating mode by clicking OperatingModeSwitch.png. Activate a simulation, run it and the trends will show the results. You can switch values of parameters with the widgets and simulate again.


Getting Started with Simantics | Project Management | Discrete Event System Modelling | System Dynamics Modelling | Ontology Development


Preferences-system.svg

Tutorial: System Dynamics Modelling
System dynamics modelling in Simantics is another free domain specific modelling tool that is included into the basic installation. This tutorial introduces the basic features of the system dynamcics modelling tools.