Tutorial: Advanced System Dynamics Modelling

From End-User Wiki
Revision as of 11:09, 23 September 2010 by Teemu Lempinen (talk | contribs)
Jump to: navigation, search

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.


In this tutorial, we are going to bild a work model with two projects and shared workforce. Both the workforce and a separate project (work) are going to be created as modules, so they can be reused several times. Actually the model doesn't limit the number of projects at all.

Creating model and modules

Let's start by creating the work model and the needed modules. First create a new model by right-clicking on the model browser and selecting New->Model. Alternatively you can select File->New Model from the main menu.

Then create two new modules to your model. Right-click on the Modules folder and select New->Module.

Name your model WorkModel and modules Workforce and Work. You can rename them by right-clicking on the item on the model browser and selecting Rename.

Creating a new model
Creating a new module
Model after renaming

Initial configuration

Workforce and Work modules

We will use a top-down approach in our model, so first we will make a simple model configuration with our modules. Open our model configuration by double-clicking Configuration in your model browser.

Drag one Workforce module and one Work module from your model browser to the WorkModel diagram. The modules are automatically named with a suffix number. Rename the modules to Workforce and Work1. You can rename objects on the diagram by double-clicking them or selecting them with one click and renaming them on the properties view below the diagram.

Workforce and Work modules, first inputs and connections

When the modules are on the diagram, we should think what values we would like to get from the modules and what values would we like to use in the modules.

Workforce needs to know, how much work is required and it should give provide information on how much work can be done. To provide the information on how much work can be done, we need an Input variable. Variables can be dragged to the diagram from Symbols view or by using shortcut keys (Shift+I for Input variable). Drag an input variable to the diagram and name it TotalPossibleWorkingSpeed.

Work module on the other hand provides information on how much work is required in it and it needs to know when the work has to be ready. Create an input variable RequiredWorkingSpeed1 and an Auxiliary variable Work1CompletionTime and place all variables like in the picture on the right.

Connect the variables to modules using dependency connections (arrows). Connections are created by holding down Alt key and first clicking on the variable where to start the connection and then clicking on the variable where to end.

Now we have the initial idea of the model, so let's configure the modules.

Workforce module

Cloud, Valve, Flow and Stock

Open Workforce module by selecting it from the diagram, right-clicking it and selecting Show Module.

Create a Stock variable and name it WorkforceStock. Stock variables are created the same way as Input and Auxiliary variables. The level of the stock is controlled with a valve and a flow. To create the flow, hold down Alt and right-click on an empty space left of the stock. Then left-click on the stock. A cloud, valve and a flow is created. Rename the valve to NetResourcing.

Cloud, Valve, Flow and Stock. Flow works both on directions.

NetResourcing works both ways. To display this also visually, delete the cloud by selecting it and pressing delete on your keyboard. Then create a flow starting from NetResourcing valve and ending on an empty space next to it.

Auxiliaries in Workforce module

Now you have used all the basic components and connections. From now on the instructions will be a more simplified.

Next we will create four Auxiliary variables: TimeToAllocateResources, WorkforceRequired, Productivity and PossibleWorkingSpeed. Place and connect them accordign to the picture on the right.

To be able to simulate the model, all variables must have valid equations. To configure an equation, select a variable. Variables properties are shown in the Equation view and you can input the required equations in the text fields. For some variables, you need to change the type of the variable to Parameter. The change is made from the pull-down menu Type. You can copy the equations directly from here or type them manually. Variables connected to the selected variable are shown in the Variables list. To speed up typing, you can double click on a variable name and it will be inserted to the equation.

WorkforceStock
Initial value: 0

NetResourcing
= (WorkforceRequired - WorkforceStock)/TimeToAllocateResources

PossibleWorkingSpeed
= WorkforceStock * Productivity

TimeToAllocateResources
= 2
Type: Parameter

Productivity
= 1
Type: Parameter



RequiredWorkingSpeedInput

On a previous phase, we wanted to give the value of RequiredWorkingSpeed1 to this workforce module. To get that value, we need to create an input. Create input RequiredWorkingSpeedInput, connect it to WorkforceRequired and write the following equation to WorkforceRequired.

WorkForceRequired
= RequiredWorkingSpeedInput/Productivity

Now this module is ready to be used as a part of the model.


Work module

Basic work with errors

Open Work module by selecting it from the WorkModel diagram, right-clicking it and selecting Show Module. Alternatively you can double click Work on the model browser.

Create the basic flow of work with stocks and flows like in the picture on the right.

The idea of the model is that first there is work. Work is done at a certain speed. When working, errors are also made. When errors are found, the amount of Errors is reduced, errors are removed from WorkDone and moved back to WorkToDo.



Smoothener for work is done

Work needs to be stopped when the project is ready. Since the simulator might face some difficulties to determine the projects readyness when project is almost ready, we need to implement some smoothing to the limit. OpenModelica doesn't yet have a builtin function for smoothing, so we need to implement our own.

Use the following equations for variables:

ProjectIsReady
Initial value: 0

ProjectReadyness
= (xidz(WorkDone, ProjectWorkAmount, 0.0) - ProjectIsReady) / 0.08

xidz is short for function X if devided by zero.

Smoothener for work is done

As you can see, ProjectWorkAmount is highlighted. Your model doesn't contain such variable and it is not connected to ProjectReadyness. Create an Input variable ProjectWorkAmount with default value 1000 and connect it to ProjectReadyness. The reason we are using input variable is that you can determine the default size of a project, but if you want to change it, you can change it from outside the module.