From: Jani Mäkinen Date: Thu, 27 Aug 2020 11:25:58 +0000 (+0300) Subject: New tutorials and updated wiki X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=c10a4c82ea1507b18421245f22b743ffdf8352c6;p=simantics%2Fsysdyn.git New tutorials and updated wiki gitlab #79 Change-Id: Ie4c1882d2f18de504d783596d3aaddfe70c4904f --- diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorial.html b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorial.html index 80b4307b..ed781e7d 100644 --- a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorial.html +++ b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorial.html @@ -1,8 +1,8 @@ -Tutorial: Advanced System Dynamics Modelling

Tutorial: Advanced System Dynamics Modelling

-

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. A basic tutorial is also available. This tutorial is part of the sysdyn documentation.

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 WorkforceModule and WorkModule. You can rename them by right-clicking on the item on the model browser and selecting Rename.

+Tutorial: Advanced System Dynamics Modelling

Tutorial: Advanced System Dynamics Modelling

+

This tutorial goes more in-depth on the advanced features of the Simantics System Dynamic tool. Namely modules, custom Modelica functions, special variables and enumerations (i.e. vector variables). We are going to build a model that simulates how a shared workforce works on several overlapping projects. You can think of the resulting model as a framework on which to build models that, for example, simulate a project portfolio of a company. It is advised that you complete the basic tutorial before starting. If you find yourself stuck, seek help from the documentation.

Creating model and modules

+

Start by creating a new model from File→New→SD Model, rename the model to WorkModel. Then create two new modules by right-clicking on the Modules folder under the WorkModel tree and selecting New→Module. Rename the modules to Workforce and Project by selecting them in the Model Browser and using the properties view.


Creating a new model

@@ -12,141 +12,220 @@

Model after renaming

Initial configuration

-
+

We will use a top-down approach in creating our model - focusing first on the bigger picture of the model and implementing the internal structure of the modules later.

Open the model configuration by double-clicking Configuration in your model browser. Drag one Workforce and one Project from your Model Browser to the WorkModel diagram. The modules are automatically named with a suffix number.


-

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 WorkforceModule and one WorkModule 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 Project modules

+

You can think of modules as user made components that communicate with rest of the model by having some input(s) and output(s). In this model the internal implementation of Workforce module should handle resourcing people to projects according to their needs. The Project module should simulate how the people that are assigned to that specific project are advancing the project.

While not used in this tutorial, Simantics System Dynamics supports nested modules, i.e. modules inside modules. Modules can also be exported and imported independent of the model.

Let's consider what kind of information we need to pass between the modules. First of all, the Project needs to tell the Workforce module how much workforce it needs. Create an input variable and name it to RequestedWorkingSpeed to pass this information along. Connect Project1 module to RequestedWorkingSpeed and RequestedWorkingSpeed to Workforce1 with a dependency arrow.

Input variable is a special type of symbol that acts as an interface between modules and the rest of the model. They are the only symbol type that can be connected directly to module outputs and they also act as the only way of creating inputs inside modules, as we will see later.

We also need to assign people to work for the project - the Workforce module needs to tell the Project module how well we can respond to the request. Create a new input variable called ResponsedWorkingSpeed and connect it to the modules with dependency arrows.


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 we would like to use in the modules.

Workforce needs to know, how much work is required and it should 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

-
+

Now we have the first version of the top-level model structure completed, we can start configuring the modules.

Workforce module

+

Open the Workforce module by double-clicking it under the Modules folder.

First, create an input variable and name it to RequestedNumberOfPeople, this variable receives the request provided by the Project module. Then, create 3 auxiliary variables and name them NumberOfEmployees, EmployeesAssigned and NumberOfFreeEmployees. Lastly connect the variables as shown in the picture. The unit of these variables is number of people.


-

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 according 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. Variable's properties are shown in the Property view and you can input the required equations in the text fields. 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
-
-TimeToAllocateResources 
-= 2
-
-Productivity 
-= 1
-
-PossibleWorkingSpeed 
-= WorkforceStock * Productivity
-Is Output
-

Variables can be set as output by selecting Is Output option from the Equation tab.

-
-

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

-
+

Internal structure of the Workforce module

+

Now we need to give the symbols equations, these are written below. To configure an equation, select a variable and write (or copy-paste) the corresponding equation to the text field in the Properties view. Connected variables are shown in the Variables list on the right side of the properties view. You can double-click on a variable name to insert it to the equation.

NumberOfEmployees
+= 10
+
+NumberOfFreeEmployees
+= NumberOfEmployees-EmployeesAssigned
+
+EmployeesAssigned
+= min(RequestedNumberOfPeople, NumberOfEmployees)
+

Also, we need to decide what value(s) we want the module to output. Make sure that the Is Output checkbox is ticked on the EmployeesAssigned variable, as this is the variable that tells how many people can be provided for the project.

We are using a built-in function min() for calculating how many employees we are going to assign. You can find a list of these in the Model Browser under WorkModel→Functions→Built-in Functions.

On the first iteration of this model, we are going to have 10 fulltime employees that get assigned to a single project according to the request. We are going to expand the structure of this module to handle several projects later on in the tutorial. This module is now ready to be used as a part of the first iteration of the model.

Work module

+

Open Project module by double-clicking it on the Model Browser.

Create a flow of work with stocks and flows like in the picture. This loop says that there is some initial amount of work that is done at a certain speed, gradually becoming completed work. However, our workers are not perfect, as such errors can occur during work. These errors are first undiscovered, and as they are found they become work that needs to be completed.

You will see red exclamation mark next to the symbols due to empty equation fields, these are omitted from the tutorial images for clarity reasons. We will return to fill in these fields later.


Basic work with errors

-

Open Work1 module by selecting it from the WorkModel diagram, right-clicking it and selecting Show Module. Alternatively you can double click Work1 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. Create variables and connections according to the picture on the right.

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. This means that the simulation calculates ''WorkDone / ProjectWorkAmount''. If ProjectWorkAmount is zero, the result is the third argument ''0.0''.

-
-

ProjectWorkAmount input variable

-

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.

-
-

Variables needed for error handling

-

Next we need to define how errors are found. For that we need new variables: WorkQuality and ErrorsFoundTime. Create the variables and connections according to the picture and give variables their equations.

ErrorsGenerated
-= (1-WorkQuality) * WorkingSpeed
+

Next let's create variables that control the parameters of a project and handle the request of asking people for work. Create auxiliary variables: StartTime, Deadline, ProjectDuration, TimeToStartTime, TimeToDeadline, RequestedWorkingSpeed, ProjectWorkAmount and NumberOfWorkdaysInProject. Connect the symbols as in the picture and write the following expression to their expression fields. Click the checkbox Is Output on RequestedWorkingSpeed variable to make the module output the value of this variable.

+
+

Structure of requesting people to work

+
StartTime
+= 5
 
-ErrorsFoundRate
-= Errors/ErrorsFoundTime
+Deadline
+= 20
 
-WorkQuality
-= 0.9
+ProjectDuration
+= Deadline-StartTime
 
-ErrorsFoundTime
-Type: WithLookup
-With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0) 
-Lookup table: {{0,5},{0.5,3},{1,0.5},{2,0.5}}
-

WithLookup is a variable type where the value is interpolated from a 2-dimensional table (Lookup table) using the value determined in the "With Lookup" field. Type can be changed from the drop-down menu Type.

-
-

WorkAllocation and RequiredWorkingSpeed

-

To calculate our own need for workforce we need to create and connect WorkCompletionTime input variable and the following auxliary variables:

RequiredWorkingSpeed 
-= if ProjectIsReady < 1 then xidz(WorkToDo, TimeToDeadline, MaximumWorkingSpeed) else 0
-Is Output
-
-MaximumWorkingSpeed 
+TimeToStartTime
+= max(0, StartTime-time)
+
+TimeToDeadline
+= Deadline-time
+
+RequestedWorkingSpeed
+= if WorkToDo > 0 and TimeToStartTime == 0 then NumberOfWorkdaysInProject/ProjectDuration else 0
+
+ProjectWorkAmount
 = 500
 
-TimeToDeadline 
-= max(0, WorkCompletionTime-time)
-

time is a universal variable that gives the current simulation time.

We need to decide how the workforce is allocated between all the work modules that are using the same workforce. For that we need to know how much work can be done and how much workforce other works require.

Create two Inputs, RequiredWorkingSpeedTotalInput and PossibleWorkingSpeedInput, and an auxiliary variable WorkAllocation. Connect the variables like int the picture.

WorkAllocation
-= xidz(RequiredWorkingSpeed, RequiredWorkingSpeedTotalInput, 0.0) * PossibleWorkingSpeedInput
-

Finally let's give initial values for all the remaining variables:

WorkingSpeed 
-= if ProjectIsReady < 1 then WorkAllocation else 0
+NumberOfWorkdaysInProject
+= ProjectWorkAmount/7
+

The project has parameters for starting time, deadline and budgeted hours of work. Based on these we calculate how many people the project needs, assuming that an average worker works for 7 hours per day. The number of people is handled as a floating point integer, meaning that one worker can work on multiple different projects.

Now let's create an input variable to take in the information of how much workforce we got from our request. Create an input variable and name it ResponseWorkingSpeedInput. We are also going to calculate how many hours a day the workers need to work in order to get the project ready in time and limit the result between 7 and 9 hours a day. Create two auxiliary variables and name them RequiredWorkHoursPerDay and TotalWorkHoursPerDay, connect them to other variables as in the image.

+
+

Input for responsed working speed

+

Write the following expression to the equation fields of the new auxiliary variables:

RequiredWorkHoursPerDay
+= if ResponseWorkingSpeedInput == 0 then 0 else if TimeToDeadline < 0 then 9 else minmax(WorkToDo/ResponseWorkingSpeedInput/TimeToDeadline, 7, 9)
+
+TotalWorkHoursPerDay
+= RequiredWorkHoursPerDay*ResponseWorkingSpeedInput
+
+WorkingSpeed
+= TotalWorkHoursPerDay
+

Next we focus on completing the structure of the work loop. Create 2 auxiliary variables and name them WorkQuality and ErrorsFoundTime. Also, create two Shadow variables and select WorkQuality and ProjectWorkAmount as the referred variables. Shadow variable is a special type of variable, whose role is to pass along the referred variable value to a place where drawing a dependency arrow from the original symbol would make the graph difficult to read. Place the new symbols as in the image and make the dependency connections.

+
+

Completed work loop structure

+

Now that the structure of the work loop is completed let's input equations to the variables.

WorkToDo
+Integral: ErrorsFoundRate - WorkingSpeed
+Initial Value: ProjectWorkAmount
+
+WorkDone
+Integral: WorkingSpeed - ErrorsFoundRate
+Initial Value: 0
+
+ErrorsGenerated
+= (1-WorkQuality) * WorkingSpeed
 
-WorkToDo 
-Initial value: ProjectWorkAmount
+UndiscoveredErrors
+Integral: ErrorsGenerated - ErrorsFoundRate
+Initial Value: 0
 
-WorkDone 
-Initial value: 0
+ErrorsFoundRate
+= UndiscoveredErrors/ErrorsFoundTime
+

For ErrorsFoundTime we are going to use a special type of auxiliary variable called WithLookup. WithLookup is a variable type where the value is interpolated from a 2-dimensional (Lookup) table using the value determined in the "With Lookup" field. Input the following values.

ErrorsFoundTime
+Type: WithLookup
+With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0)
+Lookup table: {{0,5},{0.5,3},{1,0.5},{2,0.5}}
+

This variable makes it so that the less we have completed work the larger the variable value is and vice versa. And as we use this value in ErrorsFoundRate variable to divide the number of undiscovered errors, a practical interpretation would be that when we start working on a project we don't discover errors easily. But, as the project gets more and more completed we start to discover more and more errors made earlier on in the project.

+
+

Choosing WithLookup as the auxiliary type

+

Now we are going to create a small feedback structure around WorkQuality. The purpose is to simulate how working overtime for a prolonged period causes fatigue. Create a stock variable called Fatigue and two flows, WorkingOverTime and SlowRecovery. Also create a shadow variable of RequiredWorkingHoursPerDay. Connect the variables as shown in the image.

+
+

Structure around WorkQuality

+

Input the following equations to the variables:

WorkingOverTime
+= if RequiredWorkHoursPerDay == 0 then 0 else (RequiredWorkHoursPerDay-7)*0.025
+
+SlowRecovery
+= if Fatigue >= 0 then 0.03 else 0
+
+Fatigue
+Integral: WorkingOverTime - SlowRecovery
+Initial Value: 0
 
-Errors 
-Initial value: 0
-

Connecting modules

-

Our modules are complete. Let's get back to the WorkModel Configuration.

Set Work1CompletionTime to 10.
-
+WorkQuality += max(0.95*(1-Fatigue), 0.7) +

Now working overtime causes fatigue to build up slowly, and fatigue in return causes work quality to decrease. This in return makes the workers more prone to do errors while working, causing more work to do, increasing the need for overtime work.

There is only one thing left to do for this module, we are going to create variables that tell when the project was completed. An intuitive approach would be to claim that a project is complete when the value of WorkToDo goes to zero. However, due to the structure of the work loop we are likely to find some errors even after the WorkToDo goes to zero. We solve this by recording the time when WorkToDo is zero (or under) for the first time.

Create a ghost variables of WorkToDo and Deadline. Then, create three auxiliary variables called ProjectIsCompleted, ProjectCompletitionTime and DaysLateOnDeadline. Connect the variables as in the image.

+
+

Structure of DaysLateOnDeadline

+

The variables use the following equations:

ProjectIsCompleted
+= if time == 0 then 0 else if WorkToDo > 0 and ProjectIsCompleted == 0 then 0 else 1
+
+ProjectCompletitionTime
+= if ProjectIsCompleted == 0 then time else ProjectCompletitionTime
+
+DaysLateOnDeadline
+= ProjectCompletitionTime-Deadline
+

You can think of ProjectIsCompleted as a Boolean variable that goes to 1 and stays there when WorkToDo goes to 0 for the first time. ProjectCompletitionTime keeps track of time until the project is completed.

Now the Project module is complete.

+
+

Completed Project module

+

Connecting modules

+

Now that our modules are complete, let's get back to the WorkModel Configuration and connect the inputs and outputs of the modules. Select Project1 and then select Outputs tab from the properties view. Select the only available variable as the connection. Do the same in the Inputs tab. And repeat this process for Workforce1 also.


Module input connections

-

Connections between modules are made in the properties of the module. Select Work1 and open tab Inputs from the properties. The table lists all input variables in the module that are available. Clicking on the Refers to output column will open a drop-down menu that shows all available variables that are connected to the module. By selecting a variable, you connect that variable to the input.

-
-

Module input connections

-

Work1 need also information on how much working speed is required by all works. Since Work1 is the only work, create a dependency connection from RequiredWorkingSpeed1 to Work1 and in Work1's properties connect it to RequiredWorkingSpeedTotalInput.

In Outputs tab, make the only possible connection: from RequiredWorkingSpeed to RequiredWorkingSpeed1.

Workforce module has only one input and one output. Create the only possible connections: -(Inputs) RequiredWorkingSpeedInput -> RequiredWorkingSpeed1 -(Outputs) PossibleWorkingSpeed -> TotalPossibleWorkingSpeed

Now your model is ready for simulation!

Simulating the model

-

To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 24.0

+

Now your model is ready for simulation!

Simulating the model

+

To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 50.


Experiment activation

-
To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button:
-

System shows the simulation progress in the progress bar on the lower right corner of the screen.

+

To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double-click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button:

+
+

System shows the simulation progress in the progress bar on the lower right corner of the screen.


-

When the progress indicator disappears, the simulation is complete.

If the Console view pops up and shows an error "Error: Too few equations, underdetermined system. The model has X equation(s) and Y variable(s)", the simulation has failed. The reason might be that you forgot to assign an equation to some variable or some connection in modules. See through all the variables, write the missing equation and simulate again.

After the simulation is succesfully run, you can select a variable and see its simulation results in the trend view. For example WorkDone variable in Work1 module will give the following graph.

+

When the progress indicator disappears, the simulation is complete.

If the Console view pops up and shows an error "Error: Too few equations, underdetermined system. The model has X equation(s) and Y variable(s)", the simulation has failed. The reason might be that you forgot to assign an equation to some variable or some connection in modules. See through all the variables, write the missing equation and simulate again.

After the simulation has successfully completed, you can select a variable from model browser under Configuration to see its values over time in the trend view. You can also right-click on a module and select Show Module. This brings up a view of the internal structure of the module instance used in the simulation. Selecting a variable from there will show its values in the trend view.

+
+

For example, RequiredWorkingHoursPerDay variable in Project1 module should give the following graph. At first assigned workers are working 7 hours per day, but they start working more when the deadline starts closing in. After the project is completed, a few undiscovered errors are found and workers return to correct them.


-

Adding modules

-
-
-

Final configuration with two modules

-

We created the WorkModule to be reusable. To use two WorkModules in the model, you must do the following.

Populate a second WorkModule to WorkModel configuration and name it Work2.

Create RequiredWorkingSpeed2 input variable and Work2CompletionTime auxiliary variable.

We need a sum of all working speed requirements to give to the work modules. For this purpose, create an auxiliary variable RequiredWorkingSpeedTotal which sums the requirements.

You can also have a different size work. To make Work2 smaller, create an auxiliary variable Work2Amount.

Use the following equations:

Work2CompletionTime
-= 13
-
-Work2Amount
-= 800
-
-RequiredWorkingSpeedTotal
-= RequiredWorkingSpeed1 + RequiredWorkingSpeed2
-

Update connections to match connections shown in the picture and connect the inputs and outputs to the modules.

Workforce
-RequiredWorkingSpeedInput -> RequiredWorkingSpeedTotal
-
-Work1 Inputs
-RequiredWorkingSpeedTotalInput -> RequiredWorkingSpeedTotal
-
-Work2 Outputs
-RequiredWorkingSpeed -> RequiredWorkingSpeed2
-
-Work2 Inputs
-
-
-

When all the connections are made, you can simulate the model again. Now you have model with two work modules. Select variables from both modules in model browser to display them in trend view.

-
-
\ No newline at end of file +

Adding modules

+

Now that we have a model with one Project module we are going to expand the model to support as many Projects as we want. First, we need to make some restructuring on the top level. Delete the dependency arrow that goes from ResponsedWorkingSpeed to Project1 module, also delete RequestedWorkingSpeed symbol entirely. Now create two new auxiliary variables and name them RequestedWorkingSpeed and WorkforceProject1. Connect the new auxiliaries as in the picture, remember make the connection inside the module properties as well.

+
+

Updated model structure

+

Write the following equations inside the new variables:

RequestedWorkingSpeed
+= Project1.RequestedWorkingSpeed
+
+WorkforceProject1
+= ResponsedWorkingSpeed
+

Notice that we can access variable values without having dependency arrows connected, we are given a warning next to the symbol as this should be done only when you know exactly what you are doing. Also, note that we can access values inside modules by using a dot notation modulename.variablename.

Simulate the model once to make sure nothing broke.

Next create a new Project module and a corresponding auxiliary variable WorkforceProject2, connect the auxiliary variable to the module and make the input connection in the module settings.

+
+

Updated model structure

+

Now we need to make the Workforce1 module to work with several projects at the same time, for this we use enumerations. You can think of enumerations as indices of a vector variable. To create an enumeration right-click on Configuration and select New→Enumeration.

+
+

Creating a new enumeration

+

Select the newly created enumeration under Configuration and rename it to Projects. Then, select the enumeration and from properties view click twice on Add, rename index and index2 to Project1 and Project2 respectively.

+
+

Creating new indices for Projects enumeration

+

Now we have created the needed enumeration for the top level model. We need to create one for the Workforce module as well. Under the Modules folder in the model browser right-click on Workforce, select New→Enumeration, name it Projects and add a single dummy enumeration. Then make sure the checkbox Can be replaced by parent module is checked. Then select Workforce1 module and from Module Properties overwrite enumeration Projects with Projects. This way we only have to update enumerations in one place when adding new projects to the model.

Now we need to select which variables use the enumerations, i.e. what scalar variables we need to turn into vector variables. In the top-level model select RequestedWorkingSpeed and ResponsedWorkingSpeed by holding down ctrl while left-clicking on the symbols, this should bring up a view that allows you to add enumerations to the selected symbols. From the left select Projects by left-clicking and click on the arrow, Projects enumeration should appear on the right side.

+
+

Adding enumerations to symbols

+

We need to change the equations of RequestedWorkingSpeed, WorkforceProject1 and WorkforceProject2. RequestedWorkingSpeed needs information from both Project modules and WorkforceProject variables should be scalars. Input the following equations:

RequestedWorkingSpeed
+= {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed}
+
+WorkforceProject1
+= ResponsedWorkingSpeed[Project1]
+
+WorkforceProject2
+= ResponsedWorkingSpeed[Project2]
+

Next we need to update the structure of Workforce module so that it handles vector variables. Open the module by right-clicking on Workforce1 and selecting Show Module.

Select variables EmployeesAssigned and RequestedNumberOfPeople and add the Projects enumeration to them as before.

Now we are going to create a custom function that allocates people to projects. To create a custom function, in the Model Browser right-click on Functions folder and select new→Function. Now click on the newly created function and rename it to AssignWorkersToProjects.

+
+

Creating a new function

+

Write (or copy-paste) the following Modelica code to the empty text field. When working with custom Modelica functions note that you need to press shift+enter to create new lines.

public input Real requestedhr[:];
+public input Real totalrequestedhr;
+public input Real availablehr;
+public output Real allocatedhr[size(requestedhr, 1)];
+algorithm
+requestaspercentage := zeros(size(requestedhr, 1));
+nofpeople := zeros(size(requestedhr, 1));
+for i in 1:size(requestedhr, 1) loop
+	requestaspercentage[i] := xidz(requestedhr[i], totalrequestedhr, 0);
+	nofpeople[i] := min(availablehr*requestaspercentage[i], requestedhr[i]);
+	allocatedhr[i] := nofpeople[i];
+end for;
+

To give you a quick rundown of the code logic, we have 3 input variables. First one tells how much workforce each projects wants, the second tells what the total number of requested people is and the third tells how many employees we have. The function outputs a vector that tells how many people it assigned to which project. In case there is more demand than available workforce, we calculate what percentage of the whole demand each project contributes and assign people accordingly.

Now that our custom Modelica function is ready we are going to use it in the EmployeesAssigned variable. Select EmployeesAssigned and on the right of the properties view select Function tab, double-click on the custom function to make it appear in the equation field. Give the function following parameters: RequestedNumberOfPeople, sum(RequestedNumberOfPeople), NumberOfEmployees.

+
+

Our custom function in variable properties view

+

Finally we need to change the calculation logic of NumberOfFreeEmployees. As EmployeesAssigned is now a vector variable just add sum() function around it in the equation field.

NumberOfFreeEmployees
+= NumberOfEmployees-sum(EmployeesAssigned)
+

Now the Workforce module is completed!

Finally, we are going to give the projects different parameters. Select Project2 and from the properties view select Parameters tab. By slowly double-clicking on a value you can change the starting time, deadline and work amount of a project.

+
+

Parameters of Project2

+

Set the following parameters.

Deadline: 40
+ProjectWorkAmount : 900
+StartTime: 0
+

Now we have completed a model with two Project modules, simulate to make sure your model is working.

By following the steps below you can add a new project module to the model. Our current implementation supports any number of projects.

1. Add a new Project module to the diagram
+2. Add a new auxiliary variable and name it WorkforceProject3
+3. Connect the new auxiliary variable with the module using a dependency arrow and connect it to the module in the input tab
+4. Update the equation field of RequestedWorkingSpeed to {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed, Project3.RequestedWorkingSpeed}
+5. Choose Project enumeration under configuration and add click add, name the new index to Project3
+6. Write ResponsedWorkingSpeed[Project3] as the equation for the new auxiliary variable
+7. Finally, customize the parameters of Project3 module in the Parameters tab
+

Create a third Project module using the instructions above with the following parameters.

Deadline: 20
+ProjectWorkAmount : 300
+StartTime: 10
+

To make the results of the simulation more readable we can add auxiliary variables that collect information from each of the Project modules. For example, we might be interested the behaviour of WorkQuality, RequiredWorkingHoursPerDay and DaysLateOnDeadline. Create an auxiliary variable for each of these, add Project enumeration to them and input the following equations.

DaysLateOnDeadline
+ = {Project1.DaysLateOnDeadline, Project2.DaysLateOnDeadline, Project3.DaysLateOnDeadline}
+
+ RequiredWorkHoursPerDay
+ = {Project1.RequiredWorkHoursPerDay, Project2.RequiredWorkHoursPerDay, Project3.RequiredWorkHoursPerDay}
+
+ WorkQuality
+ = {Project1.WorkQuality, Project2.WorkQuality, Project3.WorkQuality}
+

Remember to update these variables also if you intend to use more than 3 projects.

If you now simulate the model the results of RequiredWorkHoursPerDay should look like this.

+
+

RequiredWorkHoursPerDay results

+

And WorkQuality should look like this.

+
+

WorkQuality results

+

Reading results from DaysLateOnDeadline variable is hard as the variable keeps track of time before the deadline. To see the results more clearly we are going to create a custom bar chart. Right-click on Charts folder under the WorkModel and select New→Bar Chart, rename the chart to Project deadlines and rename the Title to Days late on deadline. Then choose the tab Variables, click on Add, select Write variable name and write DaysLateOnDeadline to the field. Bar charts automatically use the last time step of the simulation when retrieving variable values. The chart should like this.

+
+

DaysLateOnDeadline results

+

Now you have completed the advanced Simantics System Dynamics tutorial.

There are some features that neither of the tutorials cover that can be found in the documentation.

If you still want to practice using the tool, here are some ideas on how to further develop the model we just made.

1. The number of employees is currently a static variable, think of ways to simulate the hiring procedure of a company using stocks and flows
+2. Add more projects and think of ways to optimize project scheduling
+3. Add wages to employees and an external workforce that is used in case internal workforce isn't enough, minimize total costs
+

Happy simulating!

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ActivateExperiment.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ActivateExperiment.png index 8843321e..6f1162c4 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ActivateExperiment.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ActivateExperiment.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png new file mode 100644 index 00000000..08737377 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerations.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerations.png new file mode 100644 index 00000000..390ffe27 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddEnumerations.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules1.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules1.png new file mode 100644 index 00000000..caaddd4a Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules2.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules2.png new file mode 100644 index 00000000..49ef6c2f Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/AddingModules2.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CompletedProjectModule.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CompletedProjectModule.png new file mode 100644 index 00000000..9e2021f2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CompletedProjectModule.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ConfigurationStart.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ConfigurationStart.png index 185d9e27..a4208b65 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ConfigurationStart.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ConfigurationStart.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png new file mode 100644 index 00000000..4d47176d Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png new file mode 100644 index 00000000..5d6be548 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png new file mode 100644 index 00000000..a52c45c2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png new file mode 100644 index 00000000..51721c42 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/FirstSimulation.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/FirstSimulation.png index e1087cb1..a1cb24b0 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/FirstSimulation.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/FirstSimulation.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModelStructure2.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModelStructure2.png index fcb32883..8698b404 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModelStructure2.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModelStructure2.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModuleConnections1.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModuleConnections1.png index 34122819..21b27256 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModuleConnections1.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ModuleConnections1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NetResourcing1.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NetResourcing1.png index b47e9474..36de92eb 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NetResourcing1.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NetResourcing1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewEnumeration.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewEnumeration.png new file mode 100644 index 00000000..ea2f8b55 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewEnumeration.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunction.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunction.png new file mode 100644 index 00000000..297eb875 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunction.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunctionLibrary.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunctionLibrary.png new file mode 100644 index 00000000..44a316a2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewFunctionLibrary.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModel.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModel.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModule.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModule.png index 1e28ea43..ce5535c0 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModule.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/NewModule.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectParameters.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectParameters.png new file mode 100644 index 00000000..39e57ceb Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectParameters.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectRequestPeople.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectRequestPeople.png new file mode 100644 index 00000000..b7b51e1f Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ProjectRequestPeople.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png new file mode 100644 index 00000000..21d02e3d Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png new file mode 100644 index 00000000..169a89ff Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ShowModule.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ShowModule.png new file mode 100644 index 00000000..3d150060 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/ShowModule.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/TwoModules.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/TwoModules.png index 16fdd64b..c7b560a7 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/TwoModules.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/TwoModules.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkLoop.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkLoop.png new file mode 100644 index 00000000..e04da74b Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkLoop.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityResults.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityResults.png new file mode 100644 index 00000000..b0610507 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityResults.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityStructure.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityStructure.png new file mode 100644 index 00000000..5fb9a3f5 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkQualityStructure.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkStocks.png b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkStocks.png index 7c787f9a..fe11f2e4 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkStocks.png and b/bundles/org.simantics.sysdyn.help/Site/AdvancedTutorialImages/WorkStocks.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorial.html b/bundles/org.simantics.sysdyn.help/Site/BasicTutorial.html index 71077962..be2e49c5 100644 --- a/bundles/org.simantics.sysdyn.help/Site/BasicTutorial.html +++ b/bundles/org.simantics.sysdyn.help/Site/BasicTutorial.html @@ -1,31 +1,31 @@ -Tutorial: Basic System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

-

This tutorial introduces you to the basic components and concepts of the System dynamics modelling tool for Simantics. After completing this tutorial, you know how to configure and simulate a system dynamics model. An advanced tutorial is also available. This tutorial is part of the sysdyn documentation.

Model

-

We are going to create a simple population model. The model consists of the basic components: Auxiliaries, valves, stocks, dependencies and flows.

Start by creating a new model. Right-click on the model browser and select New -> Model.

+Tutorial: Basic System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

+

This tutorial gives an introduction to the Simantics System Dynamic Tool. We will go over how to create, simulate and analyze a simple system dynamic model. After completing this tutorial, if you wish, there is an advanced tutorial that goes more in-depth on the advanced features of the tool. It is recommended that you give a quick glance at first few chapters of the documentation before starting. You should especially familiarize yourself with the workbench of the tool to know the terminology used in the tutorials.

We are going to create the classic prey-predator model. In our case the model will describe how the population sizes of mice (prey) and owls (predator) change over time. The basic idea around the model is to capture the dynamics of two different population sizes. Let's assume a starting scenario where there is a large mice population and a small owl population. Owls start eating mice decreasing their population, and in turn, giving the owl population the opportunity to grow due to good food availability. However, as the mice population is decreasing and the owl population increasing, at some point there won't be enough food for the entire owl population, leading to starvation and consequently to a decrease in owl population size. The decreased owl population size then allows the mice population to regrow, as they have a smaller number of natural predators on the hunt.

This tutorial is a walkthrough for creating and analyzing such a model.

Creating a new model

+

Start by creating a new model from File→New→SD Model.


Creating a new model

-

Rename the model to Population. Right-click on Model1 and select Rename.

Expand the model tree and double-click on Configuration. The model configuration diagram opens in a new editor.

Configuring the model structure

-

Our model is now empty. Let's build a population model for mice.

Open Symbols view and expand BasicSymbols. If BasicSymbols are not visible, make sure that you have the diagram open. The contents of the Symbols view depends on the active diagram editor.

+

Rename the model to Population by slowly clicking twice on the model name in the Model Browser or by clicking the model once and changing the name from the properties view at the bottom of the tool. Then, expand the model tree and open the model diagram by double-clicking the Population model from Model Browser.

Configuring the model structure

+

Let's start by building a population model for the mice.

Drag the Symbols view from right of the Model Browser to underneath it and expand BasicSymbols for easier use. If BasicSymbols is not visible, make sure that you have the diagram open as the contents of the Symbols view depends on the active diagram editor.


Symbols view

-

These are the basic symbols in System dynamics modelling. We will use these to create the model.

Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using shortcut keys

Select the variable. Properties view on the bottom of the screen shows the properties of the selected variable. Change the name to Mice and press enter.

+

These are the basic symbols in System dynamic modelling that will be used to create the model.

Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using the middle mouse button.

Select the variable to bring up Properties view on the bottom of the tool. Change the name to Mice and press enter. You should have a red exclamation mark next to the symbol telling that the variable needs to have expressions for Integral and Initial Value fields. These are not shown in the pictures of this tutorial for visual clarity. We will write expressions to these fields later. You can find a collection of warnings and errors related to the model from the Issues tab right of the Properties tab.


-

Stock variable Mice

-

Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud. Move cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in the middle of the flow. The valve controls the speed of the flow. Flow from Mice is created the same way. Drag one cloud variable from Symbols view to the right hand side of Mice. Hold down Alt and right-click on Mice. Move cursor on top of the cloud and left-click. Rename the valves to MouseBirths and MouseDeaths.

+

Stock variable Mice with the Properties view open, issues can be found on the third tab from the left

+

Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud, then move your cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in between. The valve controls the speed of the flow, in this case the birthrate of Mice. We also need a flow going out from Mice to control the death rate. Let's create this using a shortcut. Right-click Mice while holding Alt down, then drag your mouse right of the Mice and press left-click while holding Alt down. Rename the valves to MouseBirths and MouseDeaths.


Flows in and out of Mice

-

Of course mice are not alone in the world. There are also owls that hunt mice. Create a similar structure below mice for owls.

+

Of course mice are not alone in our imaginary world. We also need owls that hunt mice. Create a similar structure for owls by copy-pasting and renaming. You can copy by drag selecting components and using the all familiar Ctrl+C and Ctrl+V.


Owls and mice

-

To control the births and deaths, we need auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve to control it. Drag the variables and rename them according to the picture below.

+

To control births and deaths we use auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve. Drag the variables and rename them according to the picture below.


Auxiliaries for valves

-

Arrow connections, dependencies, are created almost like flows. The difference is that the connection is started and ended with a left click and the connection can only be made between two existing variables. Connect the auxiliary variables and valves like in the picture below.

+

Next we need to draw dependency arrows to tell which components of the system have an interaction. Dependency arrows are created by Alt+left-clicking on a symbol and then clicking on another symbol. Connect components like in the picture below.


Dependency connections

Equations

-

As you can see from the model, we have made some shortcuts in our model to make it more simple. In reality, there are lots of other factors that affect mouse and owl populations. Let's however use this model as an example.

For the model to be simulated, each variable needs to have an equation. Equations can be configured from the property view, like the names. Input the following equations into the corresponding variables:

MouseBirths
+

Now we need to give each variable an equation, stock variables also need a value for initial population. Like names, equations can be configured from the property view. Input the following equations into the corresponding variables:

MouseBirths
 = MouseBirthRate * Mice
 
 MouseDeaths
@@ -48,22 +48,51 @@ OwlsFromMice
 
 OwlDeathRate
 = 0.09
-

Finally we need initial values for our populations.

Mice
+

Finally input initial population values for Mice and Owls.

Mice
 Initial Value: 700
 
 Owls
 Initial Value: 10
 

Simulating the model

-
+

Now the model is configured and ready for simulation. An experiment needs to be activated before a model can be simulated. Expand the Experiments folder of your model and double-click on Experiment to activate it. This adds experiment control buttons to the toolbar.


Experiment activation

-
Now the model is configured and ready for simulation. Switch Symbols view back to Model Browser. Expand the Experiments folder on your model and double-click on Experiment. This activates the experiment. Experiment needs to be active before the model can be simulated. Experiment activations adds experiment control buttons to the toolbar. To simulate the model, press the play button:
-

System shows the simulation progress in the progress bar on the lower right corner of the screen.

+

To simulate the model, press the play button:

+
+

System shows the simulation progress in the progress bar on the lower right corner of the screen. As our model is very simple the progress bar will most likely go by faster that you can see it.


-

When the progress indicator disappears, the simulation is complete.

After the simulation has run, you can select variables from the diagram or model browser and their values over the simulation time will be shown on Trend View. You can select multiple variables from the diagram by holding down Ctrl key. Select Mice and Owls.

+

When the progress indicator disappears, the simulation is complete.

After the simulation has been completed, you can select variables from the diagram or Model Browser and their values over the simulation time will be shown on Trend view. You can select multiple variables from the diagram by holding down Ctrl key or by drag selecting. Select Mice and Owls.


Results for Mice and Owls

-

As you can see, the simulation is complete, but the results do not reveal any interesting behavior. Let's extend the simulation time.

Select Configuration from the model browser. In the properties-view change stop time to 300.0 and simulate again.

After the simualtion is complete, Select Mice and Owls again.

+

As you can see, the simulation is complete, but the results do not reveal anything interesting. We need to extend the simulation time.

Select Configuration from the Model Browser. In the properties view change stop time to 300.0 and simulate again.

+
+

Model configuration

+

After the simulation is complete, Select Mice and Owls again.


-

Results for Mice and Owls, Extended simulation time

-

Now the simulation reveals the traditional behavior of predator-prey models. Feel free to adjust the parameters and try the simulations again.

\ No newline at end of file +

Results for Mice and Owls, extended simulation time

+

Now we can see the wanted behavior. As the mice population reaches a certain point the number of owls start to increase as they have more food. The increase in owl population lowers the mice population, leading to starvation between owls. The lowered owl population in turn allows the mice population grow back, and the cycle continues. In fact this model simulates the behavior of a pair of first-order nonlinear differential equations also known as Lotka-Volterra equations.

However, we can see that there is something wrong with the results; the peaks of the mice population are not on the same level. We are using a step-size that is too long. On default the step size is calculated by dividing the simulation time to 500 equal steps, meaning that the previous results were obtained using a step size of (300-0)/500=0.6. (For a more bizarre behavior try simulating with a stop time of 950 using the default step size.)

To combat this we can set the step size manually from the model configuration, the same place where we changed the simulation stop time. Change the step size to 0.01 and output interval to 1. Output interval allows us to manually configure the step size of the results, meaning that we can make the numerical errors arbitrarily small by lowering the simulation step size, while only having to handle a part of the steps used for the simulation. With these new parameters we now get the correct results.

+
+

Results for Mice and Owls with a simulation step size of 0.01

+

Result analysis

+

In this chapter we are going to go over how to analyze the resulting model structure, use comment symbols, create and export graphs in form of charts and export the simulated dataset. Let's start with the model structure analysis.

Often in system dynamics we are interested in how different feedback loops are formed inside of a model. There is a built in tool analyzing these. Open Structure view that is located between Trend and Values views, then select Loops tab. The contents update depending on the active selection, select OwlBirths symbol.

+
+

The loop structure of OwlBirths

+

We can see a feedback loop of 3 variables. You could interpret this loop as follows: owl births increase the number of owls, the more owls there are the more mice are going to get eaten, the more mice that end up as food the more owls can breed.

To make a visual representation of this feedback loop on the diagram we can utilize a comment symbol called Loop. Expand the CommentSymbols from Symbols and drag the symbol between Mice and Owls symbols. Then, from the properties view select Owls→MouseDeaths→OwlBirths from Loop Items and change the Direction of Rotation to counterclockwise. The Comment option is used for telling if the loop is reinforcing (R) or balancing (B). The symbol automatically detects this behavior, but you can also choose this manually or write your own explanation, if you wish. When you make the Loop symbol as your active selection it automatically highlights the symbols that are included in the loop to visualize how it is formed.

+
+

Loop comment symbol

+

The other comment symbol, called Comment, is purely for writing text in the diagram. It is useful, for example, when you want to have memos inside the diagram, or when you want to write an explanation for a design choice.

Let's move on to graphs. There are two ways of creating them, Trend view (that we have used before) and Charts. Trend view allows you to export the graph as .svg and .png file formats from the top-right controls. However, the built in graph tool has much more options for customizing a graph. Let's create a phase-space plot of the model.

Start by creating a new chart by right-clicking on the folder Charts under your model, then select New→Line Chart.

+
+

Creating a new chart

+

Double click the newly made chart to open it and keep the chart selected to access its properties. Name the chart Phase-space plot, tick hide title and hide legend options, type Owls as the x-axis variable and change the label name to Alive owls.

+
+

Chart general properties

+

Then, select the Axis and Variables tab on the bottom, click on y-axis and rename label to Alive mice, then click Add variable. Select the <Write variable name> and write Mice as the variable name.

+
+

Chart Axis and Variables properties

+

Now you should have a completed phase-space plot of the prey-predator model. To export a graph right click on it and select either Save as→PNG or Print... and select the pdf printer of your choice. Notice that in order to see results on the graph you need to have an active experiment that has finished a simulation.

+
+

Completed phase-space plot and export options

+

You might also want to export the simulated data. Currently the easiest way is to copy it to your clipboard. First, select all components by clicking on the diagram and pressing Ctrl+A on the keyboard. Then, select Values view from the bottom left, click on any numerical value to put the field in focus, finally Ctrl+A and Ctrl+C. Now you have all of the numerical data on your clipboard for pasting to the tool of your choosing.

+
+

Values view

+

This concludes the basic tutorial. If you wish to learn more about the advanced features of the tool, please refer to the wiki or the advanced tutorial.

Happy simulating!

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ActivatePopulationExperiment.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ActivatePopulationExperiment.png index 0eeeb7e6..52b012ad 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ActivatePopulationExperiment.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ActivatePopulationExperiment.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Auxiliaries.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Auxiliaries.png index 5cec62b8..30d7da36 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Auxiliaries.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Auxiliaries.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartAxisAndVariables.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartAxisAndVariables.png new file mode 100644 index 00000000..a65d0a99 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartAxisAndVariables.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartProperties1.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartProperties1.png new file mode 100644 index 00000000..4c8f0890 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ChartProperties1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Configuration1.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Configuration1.png new file mode 100644 index 00000000..0c5e42f6 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Configuration1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Dependency_connections.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Dependency_connections.png index eeb22288..dbbb05f2 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Dependency_connections.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Dependency_connections.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/LoopCommentSymbol.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/LoopCommentSymbol.png new file mode 100644 index 00000000..d7ed191b Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/LoopCommentSymbol.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Mice.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Mice.png index 601f77ee..7ec78f2a 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Mice.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/Mice.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults1.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults1.png index bee8c180..3137184c 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults1.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults2.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults2.png index cd8426fd..18034aa8 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults2.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults2.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults3.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults3.png new file mode 100644 index 00000000..d6065fc2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwlResults3.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwls.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwls.png index 83b4b085..6964fa68 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwls.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceAndOwls.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceFlows.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceFlows.png index a910ea82..eaa381b2 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceFlows.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/MiceFlows.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/NewModel.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/NewModel.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/OwlBirthsLoopStructure.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/OwlBirthsLoopStructure.png new file mode 100644 index 00000000..26e13cd5 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/OwlBirthsLoopStructure.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png new file mode 100644 index 00000000..3a0da397 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/SymbolsView.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/SymbolsView.png index 74e6e0b5..e49faeca 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/SymbolsView.png and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/SymbolsView.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ValuesView.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ValuesView.png new file mode 100644 index 00000000..00ad3f7f Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/ValuesView.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/newChart.png b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/newChart.png new file mode 100644 index 00000000..9d92fcfc Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/BasicTutorialImages/newChart.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/BasicWorkbench.png b/bundles/org.simantics.sysdyn.help/Site/Images/BasicWorkbench.png index f5a7ebb5..1ff45779 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/BasicWorkbench.png and b/bundles/org.simantics.sysdyn.help/Site/Images/BasicWorkbench.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/CompareTrend.png b/bundles/org.simantics.sysdyn.help/Site/Images/CompareTrend.png index 35e63c2f..5466a5fd 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/CompareTrend.png and b/bundles/org.simantics.sysdyn.help/Site/Images/CompareTrend.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/ExampleFunction.png b/bundles/org.simantics.sysdyn.help/Site/Images/ExampleFunction.png index 707ab4ed..37d9e095 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/ExampleFunction.png and b/bundles/org.simantics.sysdyn.help/Site/Images/ExampleFunction.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/ModelProperties.png b/bundles/org.simantics.sysdyn.help/Site/Images/ModelProperties.png index 0c181522..b94d39aa 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/ModelProperties.png and b/bundles/org.simantics.sysdyn.help/Site/Images/ModelProperties.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/ModelStructure.png b/bundles/org.simantics.sysdyn.help/Site/Images/ModelStructure.png index 131e9204..234df3e8 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/ModelStructure.png and b/bundles/org.simantics.sysdyn.help/Site/Images/ModelStructure.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewChart.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewChart.png index 76b84c07..9d92fcfc 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/NewChart.png and b/bundles/org.simantics.sysdyn.help/Site/Images/NewChart.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewEnumeration.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewEnumeration.png index 40ecc979..ea2f8b55 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/NewEnumeration.png and b/bundles/org.simantics.sysdyn.help/Site/Images/NewEnumeration.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewFunction.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewFunction.png index 84517e28..16a43271 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/NewFunction.png and b/bundles/org.simantics.sysdyn.help/Site/Images/NewFunction.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewFunctionLibrary.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewFunctionLibrary.png index ca099d12..aaaabca4 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/NewFunctionLibrary.png and b/bundles/org.simantics.sysdyn.help/Site/Images/NewFunctionLibrary.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewModel.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewModel.png new file mode 100644 index 00000000..1280c002 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/Images/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/NewModule.png b/bundles/org.simantics.sysdyn.help/Site/Images/NewModule.png new file mode 100644 index 00000000..ce5535c0 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/Images/NewModule.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/PreferencesNew.png b/bundles/org.simantics.sysdyn.help/Site/Images/PreferencesNew.png new file mode 100644 index 00000000..1c4271d6 Binary files /dev/null and b/bundles/org.simantics.sysdyn.help/Site/Images/PreferencesNew.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/Trend.png b/bundles/org.simantics.sysdyn.help/Site/Images/Trend.png index 256e66af..3346ea1c 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/Trend.png and b/bundles/org.simantics.sysdyn.help/Site/Images/Trend.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/Values.png b/bundles/org.simantics.sysdyn.help/Site/Images/Values.png index f55734e3..80ccb976 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/Values.png and b/bundles/org.simantics.sysdyn.help/Site/Images/Values.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup1.png b/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup1.png index 08df607b..e9a7f3db 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup1.png and b/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup1.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup2.png b/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup2.png index 3f69912f..7c20b0b8 100644 Binary files a/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup2.png and b/bundles/org.simantics.sysdyn.help/Site/Images/WithLookup2.png differ diff --git a/bundles/org.simantics.sysdyn.help/Site/sysdyn.html b/bundles/org.simantics.sysdyn.help/Site/sysdyn.html index 0f3f54ac..97a86ee7 100644 --- a/bundles/org.simantics.sysdyn.help/Site/sysdyn.html +++ b/bundles/org.simantics.sysdyn.help/Site/sysdyn.html @@ -1,33 +1,33 @@ -Simantics System Dynamics

Simantics System Dynamics

Contents

What is Simantics System Dynamics

-

Simantics System Dynamics is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through some changes in the future. New features will be added and old ones improved according to the needs of the modellers.

This documentation introduces you to the current version of Simantics System Dynamics. Documentation includes the basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, install the software and try our basic and advanced tutorials!

Introduction to System Dynamics Simulation

+Simantics System Dynamics

Simantics System Dynamics

Contents

What is Simantics System Dynamics

+

Simantics System Dynamics is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through changes in the future. New features will be added and old ones improved according to the needs of modellers.

This documentation introduces you to the current version of Simantics System Dynamics. The documentation includes basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, install the software and try our basic and advanced tutorials!

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. Simantics System Dynamics is a free modelling tool for system dynamics modeling and simulation. See installation instructions.

Model

System dynamics model is generally understood as the model configuration. In this tool, the model contains also other components: Experiments are the way to simulate the model. 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. Module types allow user to create reusable component types which can be instantiated as Modules. The Modules folder contains all the different module types in your model and you can create new module types there. The Functions folder contains built-in and user-defined functions.


Model structure

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, Delay and WithLookup. Auxiliary is the default type. Parameters are static 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 and Delay are special variables. WithLookup has an expression and a lookup table. The expression defines what value is taken from the defined table. Delay variable delays an equation a given time with a given delay order.

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. Dependencies that are used for a stock initial value only are colored grey by default, in contrast to the regular blue dependency arrows.

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. Alternatively, the equation that is integrated can be defined manually by user. A stock must be given an initial value. 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.

Shadow

A shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model.

Loop

A loop element is a graphical component for highlighting selected feedback loops in a model.

Comment

A comment element is a string of text on diagram.

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. Note that due to the reserved words in Modelica, variable names such as Carbon in Atmosphere cannot be used (in is a reserved word). Capitalizing the reserved (in --> In) word can be used to sidestep the problem.

Connections

You should usually try to avoid overlapping dependency arrows. Organizing the variables on the diagram and using shadow variables can be used for that purpose. 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. Annotations are important, for communicating the behavior of the model.

Installation Instructions

-

System dynamics tool is provided with the Simantics platform.

  1. Download installer from the tool's download page

  2. Install the program to a directory without spaces (limitation inherited from OpenModelica).

  3. Run the application through the launcher generated by the installer

    (default: Simantics\Simantics-1.8.0-Sysdyn-32\Simantics-1.8.0-Sysdyn-32)

OpenModelica is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install OpenModelica. In addition to OpenModelica, a development version of a purpose-built Modelica solver is embedded in the tool.

Workbench

+

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, Delay and WithLookup. Auxiliary is the default type. Parameters are static 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 and Delay are special variables. WithLookup has an expression and a lookup table. The expression defines what value is taken from the defined table. Delay variable delays an equation a given time with a given delay order.

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. Dependencies that are used for a stock initial value only are colored grey by default, in contrast to the regular blue dependency arrows.

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. Alternatively, the equation that is integrated can be defined manually by user. A stock must be given an initial value. 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.

Shadow

Shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model.

Loop

Loop element is a graphical component for highlighting selected feedback loops in a model.

Comment

Comment element is a string of text on diagram.

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. Note that due to the reserved words in Modelica, variable names such as Carbon in Atmosphere cannot be used (in is a reserved word). Capitalizing the reserved (in → In) word can be used to sidestep the problem.

Connections

You should usually try to avoid overlapping dependency arrows. Organizing the variables on the diagram and using shadow variables can be used for that purpose. 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. Annotations are important for communicating the behavior of the model.

Installation Instructions

+

System dynamics tool is provided with the Simantics platform.

  1. Download installer from the tool's download page

  2. Install the program to a directory without spaces or special characters (limitation inherited from OpenModelica).

  3. Run the application through the launcher generated by the installer

OpenModelica is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install the latest official 64bit release of OpenModelica. In addition to OpenModelica, a development version of a purpose-built Modelica solver is embedded in the tool.

If you plan on creating large models or using a long simulation time with a small step size, it is advised that you give the tool more memory by increasing the numerical value of property -Xmx in the file Simantics-Sysdyn.ini.

Workbench


-

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

Symbols view (stacked with the model browser) is used for dragging elements to diagrams.

Search

Search view (stacked with the model browser) is used for searching elements in all models. Search can be launched also from the search field in the bottom right corner or by Ctrl+F.

3 Properties

Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, Indexes, and Additional information.

Console

Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica.

Issues

Issue view (stacked with the property view) shows the errors and warnings in all models.

Profiles

Profiles view (stacked with the property view) allows enabling/disabling some visual diagram effects.

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.

Structure

The structure view (stacked with the trend view) can be used for analyzing the varaible dependencies, loops, and the structure of the model.

Values

The values view (stacked with the trend view) shows the values of the selected value over time. For the values to be shown, a simulation has to be run.

5 Save and save as...

Save buttons can be used to export the selected model as .sysdyn file. The buttons save that model which is selected in the model browser or, if the focus is on the diagram, the model that is currently open on the diagram.

6 Diagram tool mode

With the diagram tool mode, you can select how the elements on the diagram are edited. The Lock mode prohibits editing diagram elements, the pointer mode allows moving and editing diagram elements, and with the dependency and flow modes arrows can be drawn using only mouse1 and mouse2.

7 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.

8 Perspectives

Perspectives allow changing between different layouts of the views. On start-up, only the default perspective is open. Try adding the two predefined perspectives by clicking the Open Perspective button:
-

9 Chart Panel

Chart panel is able to house multiple charts at the same time. Charts are added to the panel by dragging from model browser.

TIP! If you accidentally close a view, you can reopen them from Window->Show View->Other...

TIP! Try dragging the views to different positions (e.g. the property view to the right pane).

Global Preferences

Global preferences of Simantics System Dynamics are located under Window -> Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below.

-
-
CategoryDescription
General -> KeysAll keyboard shortcuts available.
ModelicaThe location of OpenModelica solver on file system.
SolverSolver to be used for simulation. OpenModelica or internal custom solver (experimental) can be selected.
Sysdyn DiagramsSysdyn Diagrams allows customize default colors and fonts of diagram elements.

Modelling

+

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

Symbols view (stacked with the model browser) is used for dragging elements to diagrams.

3 Properties (MouseBirths in the image above)

Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, indices, and Additional information.

Console

Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica.

Issues

Issue view (stacked with the property view) shows the errors and warnings in all models.

Profiles

Profiles view (stacked with the property view) allows enabling/disabling some visual diagram effects.

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.

Structure

The structure view (stacked with the trend view) can be used for analyzing the variable dependencies, loops, and the structure of the model.

Values

The values view (stacked with the trend view) shows the values of the selected value over time. For the values to be shown, a simulation has to be run.

5 Save and save as...

Save buttons can be used to export the selected model as .sysdyn file. The buttons save that model which is selected in the model browser or, if the focus is on the diagram, the model that is currently open on the diagram.

6 Diagram tool mode

With the diagram tool mode, you can select how the elements on the diagram are edited. The Lock mode prohibits editing diagram elements, the pointer mode allows moving and editing diagram elements, and with the dependency and flow modes arrows can be drawn using only mouse1 and mouse2.

7 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.

8 Perspectives

Perspectives allow changing between different layouts of the views. On start-up, only the default perspective is open. Try adding the two predefined perspectives by clicking the Open Perspective button:
+

9 Chart Panel

Chart panel is able to house multiple charts at the same time. Charts are added to the panel by dragging from model browser.

TIP! If you accidentally close a view, you can reopen them from Window→Show View→Other...

TIP! Try dragging the views to different positions (e.g. the property view to the right pane).

Global Preferences

Global preferences of Simantics System Dynamics are located under Window → Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below.

+
+
CategoryDescription
General → KeysAll keyboard shortcuts available.
ModelicaThe location of OpenModelica solver on file system.
SolverSolver to be used for simulation. OpenModelica or internal custom solver (experimental) can be selected.
Sysdyn DiagramsSysdyn Diagrams allows customize default colors and fonts of diagram elements.

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.

-
-

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 -> SD Model.

-
-

Creating a new module type

Create a new module type by right-clicking on the Modules-folder and selecting New -> Module type. 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 respective module type!

Populate variables

You can drag variables to a diagram from symbol view. You can also populate variables using shortcut keys. Variables can be divided into multiple lines by resizing the variable on diagram.

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. Dependencies and flows can also be created without Alt key by selecting dependency or flow mode on the toolbar.

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
+    
+

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 → SD Model.

+
+

Creating a new module type

Create a new module type by right-clicking on the Modules-folder and selecting New → Module type. 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 respective module type!

Populate variables

You can drag variables to a diagram from symbol view. You can also populate variables using shortcut keys. Variables can be divided into multiple lines by resizing the variable on diagram.

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. Dependencies and flows can also be created without Alt key by selecting dependency or flow mode on the toolbar.

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 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 the Inputs tab stacked under Module Properties you can select which variables you connect to inputs inside the module. In the Outputs tab you can 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->Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database.

Import model

Right-click on the model browser and select Import->Model. Browse to your .sysdyn file and select open. The model is added to your model browser.

Export module

To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export->Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database.

Import module

Right-click the Modules folder of a model and select Import->Module. Browse to your .sysdynModule file and select open. The module is added to your model.

Model Properties

Model properties can be viewed by selecting either the model or its configuration on the model browser.

+ANY VARIABLE -----> MODULE +

This is just the visual configuration, but you need those connections to really connect variables in the module's properties.

In the Inputs tab stacked under Module Properties you can select which variables you connect to inputs inside the module. In the Outputs tab you can 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 send their values outside the module. To make a variable output its values, from the properties view make sure the Is Output checkbox is ticked.

Configure variables

Select a single variable from diagram or model browser. The properties of the variables are shown in the properties view where you can also 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→Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database.

Import model

Select File→Import Model, browse to your .sysdyn file and select open. The model is added to your model browser.

Export module

To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export→Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database.

Import module

Right-click the Modules folder of a model and select Import→Module. Browse to your .sysdynModule file and select open. The module is added to your model.

Model Properties

Model properties can be viewed by selecting either the model or its configuration on the model browser.


-
PropertyDescription
NameThe name of the model
Start timeThe start time of the simulation.
Stop timeThe stop time of the simulation.
Step lengthThe length of the simulation step.
Output intervalInterval of witch the simulation result is presented. If the field is left empty, all steps of the output are presented.
MethodThe simulation solver (only OpenModelica).
Validate unitsUnit validation on/off. If unit validation is enabled, the unit of the simulation time is selected from the pull-down menu.
Unit equivalentsDefine if different forms of predefined units are considered equal (e.g. dollars = dollar = $) in unit validation.
ToleranceIntegrator error tolerance (only OpenModelica)
Variable filterDefine which variables are presented (only OpenModelica)

Special Variables

Auxiliary and valve variables have two special types: WithLookup and Delay. These types are selected from Type drop down menu in the variable's properties. The variable types offer more specific functionalities than normal variables, but the same functionality could be achieved using normal variables.

WithLookup

WithLookup variable has two equation fields, WithLookup and Lookup table. Lookup table has a table from which the value of the variable is interpolated using the value of WithLookup field.

+
PropertyDescription
NameThe name of the model
Start timeThe start time of the simulation.
Stop timeThe stop time of the simulation.
Step lengthThe length of the simulation step.
Output intervalInterval of witch the simulation result is presented. If the field is left empty, all steps of the output are presented.
MethodThe simulation solver (only OpenModelica).
Validate unitsUnit validation on/off. If unit validation is enabled, the unit of the simulation time is selected from the pull-down menu.
Unit equivalentsDefine if different forms of predefined units are considered equal (e.g. dollars = dollar = $) in unit validation.
ToleranceIntegrator error tolerance (only OpenModelica)
Variable filterDefine which variables are presented (only OpenModelica)

Special Variables

Auxiliary and valve variables have two special types: WithLookup and Delay. These types are selected from Type drop down menu in the variable's properties. The variable types offer more specific functionalities than normal variables, but the same functionality could be achieved using normal variables.

WithLookup

WithLookup variable has two equation fields, WithLookup and Lookup table. Lookup table has a table from which the value of the variable is interpolated using the value of WithLookup field.


-

You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clickin on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click.

+

You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clicking on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click.


Delay

Delay variables build equations for Nth order delays. Users can set the equation for the value that is to be delayed, the time and order of the delay and a possible start value. If start value is empty, the start value is set automatically.


@@ -56,25 +56,25 @@ equation end Delay3_delayClass;

The above definitions can be seen as a line of stocks and valves. The first valve, delay0, is given the value of the delayed expression. Delay3 is given the value of the valve that is coming from the last stock.

Equations:

Delay3_delayClass_instance.delay0 = Step1;
 Delay3 = Delay3_delayClass_instance.delay3;
-

Shortcut and Control Keys

Shortcut keys for configuring a model on diagram.

KeyAction
EscCancel operations (e.g. connection and rename).
Shift + AHover Auxiliary at the cursor position, populate with left mouse button.
Shift + SHover Stock at the cursor position, populate with left mouse button.
Shift + CHover Cloud at the cursor position, populate with left mouse button.
Shift + VHover Valve at the cursor position, populate with left mouse button.
Shift + IHover Input at the cursor position, populate with left mouse button.
Shift + GHover Shadow (Ghost) variable at the cursor position, populate with left mouse button.
Alt + left mouse buttonStart an arrow from a variable. End to another variable by clicking left mouse button.
Alt + right mouse buttonStart 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.
DeleteRemove selected variables
F2Rename selected variable
Ctrl + left mouse buttonSelect multiple variables
Mouse wheel or + or -Diagram zoom
drag(mouse3)Diagram pan
drag(shift + any mouse button)Diagram pan
↓, ←, ↑, → (arrow keys)Diagram pan
Ctrl + CCopy selected elements
Ctrl + XCut selected elements
Ctrl + VPaste copied or cut elements
Ctrl + FFind element in current diagram or all models
GShow / hide grid
RShow / hide ruler
1Fit diagram contents to screen
Ctrl + SpaceContent assist in equation editor

Other shortcut keys can be found selecting Window -> Preferences from the main menu. Keys are located in General -> Keys.

Unit Validation

Unit validation is useful for finding errors in the model. With unit validation, the consistency of the measurement units of variables is checked. For unit validation, the units of all variables in the model must be defined. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.

Common error sources of unit validation include the following. The respective issues are shown in the picture below.

+

Shortcut and Control Keys

Shortcut keys for configuring a model on diagram.

KeyAction
EscCancel operations (e.g. connection and rename).
Shift + AHover Auxiliary at the cursor position, populate with left mouse button.
Shift + SHover Stock at the cursor position, populate with left mouse button.
Shift + CHover Cloud at the cursor position, populate with left mouse button.
Shift + VHover Valve at the cursor position, populate with left mouse button.
Shift + IHover Input at the cursor position, populate with left mouse button.
Shift + GHover Shadow (Ghost) variable at the cursor position, populate with left mouse button.
Alt + left mouse buttonStart an arrow from a variable. End to another variable by clicking left mouse button.
Alt + right mouse buttonStart 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.
DeleteRemove selected variables
F2Rename selected variable
Ctrl + left mouse buttonSelect multiple variables
Mouse wheel or + or -Diagram zoom
drag(mouse3)Diagram pan
drag(shift + right mouse button)Diagram pan
↓, ←, ↑, → (arrow keys)Diagram pan
Ctrl + CCopy selected elements
Ctrl + XCut selected elements
Ctrl + VPaste copied or cut elements
Ctrl + FFind element in current diagram or all models
GShow / hide grid
RShow / hide ruler
1Fit diagram contents to screen
Ctrl + SpaceContent assist in equation editor

Other shortcut keys can be found selecting Window → Preferences from the main menu. Keys are located in General → Keys.

Unit Validation

Unit validation is useful for finding errors in the model. Unit validation checks the consistency of units. To use this feature you need to define units for every variable used in the model. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.

Common error sources of unit validation include the following. The respective issues are shown in the picture below.


  • The equation of a variable yields a different unit than that defined for the variable.

  • Two variables which have different units are added (+), subtracted (-), or compared (>, <, =, ...).

  • The output unit of a function is used in an inconsistent manner. (The unit validation for the output unit of a function behaves equivalently to the unit of a variable.)

  • A function is called with an argument of a prohibited unit.

  • A variable has an empty unit.

  • A variable has a misspelled unit.

Unit validation is enabled for a model by selecting the model or its configuration on the model browser and enabling "Validate units" on the properties tab. The unit warnings are shown on Issues view and, supposing the respective profile has been enabled, on the diagram as well. Warnings from unit validation do not prevent simulation.

For models that have stocks (i.e., integration), the simulation time unit must be selected from the pull-down menu next to the "Validate units" checkbox in Model Properties tab.

Unit validation can also cope with certain different forms of units, e.g., you can write dollars, dollar, or $ and the validator considers these equal. This functionality can be disabled from Model Properties tab checkbox "Unit equivalents".

As there may be cases for which the unit validation is for some reason not working as desired, the unitCast() function can be used in the equation of a variable to cast the unit of any expression within the equation to a wildcard. E.g., if expression

    Aux1 + time
 

yields a warning, it can be fixed be changing the expression to

    unitCast(Aux1) + time
-

, in which case the unit of the expression is that of time, or to

    Aux1 + unitCast(time)
-

, in which case the unit of the expression is that of Aux1.

Diagram Profiles

Diagram profiles allow selecting which visual effects are enabled. Currently the following profiles can be used:

Default

Issue warnings

When enabled, an error or a warning symbol is attached to diagram elements in which there are errors or warnings (usually in the equations).

Shadow variable visualizations

When enabled, the original and all the shadow variables are highlighted when one is selected.

Simulation Playback

Playback Colors

When enabled, colors of the elements on diagram change during a playback experiment.

Visual model elements

-

The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool offers are comment symbols which do not affect simulation but help the understandability of models.

Fonts and colors

Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window -> Preferences -> Sysdyn Diagrams.

Dependency properties

Dependency arrow properties can be changed on the property view:

Polarity

Polarity sign can be used to indicate whether the dependency increases or decreases the variable it is pointing to. The polarities serve no function for simulation, however, they are used in loop type automatic determination.

Location

Location of the polarity mark

Arrowhead

Toggle for showing arrowhead

Delay mark

Delay mark is a visual cue for helping understandability of the dynamics of the model when there are (information) delays. A delay mark is usually added to the dependency arrow when the effect the tail of the dependency has on the head of the dependency is delayed.

Line thickness

Thickness of the arrow

Loops

A loop element is a graphical component for highlighting feedback loops in a model. Usually the most interesting feedback loops that affect the behaviour of the model most are marked with a loop symbol.

Loop Items

The loop of variables which the loop symbol refers can be selected for visualization purposes.

Comment

Comment inside the loop. Usually characters 'B' and 'R' are used to denote balancing and reinforcing loops, respectfully. A feedback loop is reinforcing if and only if it has an even number of negative dependencies. Selecting 'Auto' determines automatically the type of the loop.

Direction of Rotation

Direction to which the loop rotates on diagram.

Comments

Comments are just strings of text.

Simulation

-

Experiments

There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics.

Experiments are created from the context menu of experiments folder in a model.

+

in which case the unit of the expression is that of time, or to

    Aux1 + unitCast(time)
+

in which case the unit of the expression is that of Aux1.

Diagram Profiles

Diagram profiles allow selecting which visual effects are enabled. Currently the following profiles can be used:

Default

Issue warnings

When enabled, an error or a warning symbol is attached to diagram elements in which there are errors or warnings (usually in the equations).

Shadow variable visualizations

When enabled, the original and all the shadow variables are highlighted when one is selected.

Simulation Playback

Playback Colors

When enabled, colors of the elements on diagram change during a playback experiment.

Debugging a model

If you find yourself with a model that doesn't simulate or has bizarre behavior, there are several places to look for clues for what went wrong. Firstly, if you got an error message and can't infer the problem straight from the message, look at the issues view if it can tell you what is wrong in different words. If you know how to read Modelica code, right click Configuration under the broken model and choose Open With → Modelica Code Viewer. The tool works by generating Modelica code from the graphical model and then solving it. Therefore, if something is broken it means that there is a problem with the generated Modelica code (or, very rarely, a bug in the solver you are using). You can also refer to the list below, if you still find yourself stuck.

Some of the most common errors include:

  • In a model that uses modules, you forget to connect inputs and/or outputs in the module properties

  • You forgot to add an enumeration to a variable, i.e. trying to put a vector to a scalar variable (or vice versa)

  • You increased the enumeration indices you are using, but forget to update a variable that depend on it

  • You wrote a custom Modelica function, but it is broken

  • You are comparing two numbers for equality while using OpenModelica solver (forbidden, allowed by the internal solver)

  • You have a variable that refers to itself in the equation, making the solver unable find an initial value

If you are using OpenModelica solver it can be very useful to google error messages printed in the console of the tool.

Visual model elements

+

The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool has comment symbols which do not affect simulation but help the understandability of models.

Fonts and colors

Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window → Preferences → Sysdyn Diagrams.

Dependency properties

Dependency arrow properties can be changed on the property view:

Polarity

Polarity sign can be used to indicate whether the dependency increases or decreases the variable it is pointing to. The polarities serve no function for simulation, however, they are used in loop type automatic determination.

Location

Location of the polarity mark

Arrowhead

Toggle for showing arrowhead

Delay mark

Delay mark is a visual cue for helping understandability of the dynamics of the model when there are (information) delays. A delay mark is usually added to the dependency arrow when the effect the tail of the dependency has on the head of the dependency is delayed.

Line thickness

Thickness of the arrow

Loops

A loop element is a graphical component for highlighting feedback loops in a model. Usually the most interesting feedback loops that affect the behaviour of the model most are marked with a loop symbol.

Loop Items

The loop of variables which the loop symbol refers can be selected for visualization purposes.

Comment

Comment inside the loop. Usually characters 'B' and 'R' are used to denote balancing and reinforcing loops, respectfully. A feedback loop is reinforcing if and only if it has an even number of negative dependencies. Selecting 'Auto' determines automatically the type of the loop.

Direction of Rotation

Direction to which the loop rotates on diagram.

Comments

Comments are just strings of text.

Simulation

+

Experiments

There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics. Currently some of the experiment and solver combinations are still in development.

Experiments are created from the context menu of experiments folder in a model.


-

Double-click on an experiment activates it and displays experiment type specific controls in the main tool bar.

Normal simulation

Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run.

Game simulation

Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended.

Simulation playback

Simulation playback works essentially as the basic experiment, but it offers some additional visualization options.

Sensitivity analysis simulation

Sensitivity analysis allows running multivariate Monte Carlo simulations with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters.

+

Double-click on an experiment activates it and displays experiment type specific controls in the main tool bar.

Normal simulation

Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run. Works on both the internal and OpenModelica solvers.

Game simulation

Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended. Works on the internal solver, OpenModelica version still in development.

Simulation playback

Simulation playback works essentially as the basic experiment, but it offers some additional visualization options. Works on both solvers.

Sensitivity analysis simulation

Sensitivity analysis allows running multivariate Monte Carlo simulations with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters. Works on OpenModelica solver, internal solver implementation still in development.


-
General-
NameThe name of the sensitivity analysis experiment. Displayed in e.g. model browser.
Number of runsThe total amount of individual simulation runs
MethodThe method of how the parameter values are selected from the distribution(s). Selecting "Random" yields pseudo-random values, i.e., randomly selected from the distribution(s). Selecting "Halton" yields a quasi-random Halton sequence of values selected deterministically to represent the distribution(s) better than a pseudo-random series.
SeedThe seed number for pseudo-random generator
Add parameterAdds a new parameter to be varied
RemoveRemoves a parameter
Parameter properties-
VariableThe full path of the variable of which value is varied. This field has content assistant, which shows the possible variables as you type.
RangeUsed with multidimensional values to select which dimensions are varied.
DistributionProbability distribution for the varied parameter. "Normal" is for truncated normal distribution and "Uniform" for uniform distribution. With "Interval" the values have equal intervals between each other and are selected in increasing order. In multivariate sensitivity analyses, it is recommended to select either "Normal" or "Uniform".
Distribution properties-
Min valueMinimum value of the distribution
Max valueMaximum value of the distribution
MeanMean of the normal distribution
Standard deviationStandard deviation of the normal distribution

Solvers

Simantics System Dynamics allows using the multiple solvers provided by OpenModelica, like Euler, Runge-Kutta, DASSL, etc. OpenModelica is currently the main simulation environment behind the tool and all functionalities are supported with OpenModelica.

Alternatively to OpenModelica, an internal custom Modelica solver is included in Simantics System Dynamics. The custom solver is currently at an experimental state, and thus all functionalities of the tool are not yet supported, e.g., only the basic experiment can be run with it. The advantage of the custom solver is, however, that simulation is usually a lot faster than with OpenModelica. Try out yourself which solver suits best for your needs.

The solver can be changed in Windows -> Preferences -> Solver.

Simulation Result and Model Structure Analysis

-

Simulation results can be viewed as trends in the trend view or as plain numbers in the values view. The views display results of variables that are selected in the workbench. Users can also create custom charts.

Model structure can be examined in the Structure view. There are three options: dependency structures of individual variables, the complete hierarchy structure of the model, or the feedback loops which individual variables belong to.

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.

+
General-
NameThe name of the sensitivity analysis experiment. Displayed in e.g. model browser.
Number of runsThe total amount of individual simulation runs
MethodThe method of how the parameter values are selected from the distribution(s). Selecting "Random" yields pseudo-random values, i.e., randomly selected from the distribution(s). Selecting "Halton" yields a quasi-random Halton sequence of values selected deterministically to represent the distribution(s) better than a pseudo-random series.
SeedThe seed number for pseudo-random generator
Add parameterAdds a new parameter to be varied
RemoveRemoves a parameter
Parameter properties-
VariableThe full path of the variable of which value is varied. This field has content assistant, which shows the possible variables as you type.
RangeUsed with multidimensional values to select which dimensions are varied.
DistributionProbability distribution for the varied parameter. "Normal" is for truncated normal distribution and "Uniform" for uniform distribution. With "Interval" the values have equal intervals between each other and are selected in increasing order. In multivariate sensitivity analyses, it is recommended to select either "Normal" or "Uniform".
Distribution properties-
Min valueMinimum value of the distribution
Max valueMaximum value of the distribution
MeanMean of the normal distribution
Standard deviationStandard deviation of the normal distribution

Solvers

Simantics System Dynamics allows using the multiple solvers provided by OpenModelica, like Euler, Runge-Kutta, DASSL, etc. OpenModelica is currently the main simulation environment behind the tool and all functionalities are supported with OpenModelica.

Alternatively to OpenModelica, an internal custom Modelica solver is included in Simantics System Dynamics. The custom solver is currently at an experimental state, and thus all functionalities of the tool are not yet supported, e.g., only the basic experiment can be run with it. The advantage of the custom solver is, however, that simulation is usually a lot faster than with OpenModelica. Try out yourself which solver suits best for your needs.

The solver can be changed in Windows → Preferences → Solver.

Simulation Result and Model Structure Analysis

+

Simulation results can be viewed as trends in the trend view or as plain numbers in the values view. The views display results of variables that are selected in the workbench. Users can also create custom charts.

Model structure can be examined in the Structure view. There are three options: dependency structures of individual variables, the complete hierarchy structure of the model, or the feedback loops which individual variables belong to.

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. You can also export the trend using controls in the upper right corner.


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. Selected values can be copied to other software in csv format.


-

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 Results button:

+

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. This functionality currently only works for the OpenModelica solver, internal solver implementation is in development. You can save your results after simulating by clicking the Save Results button:


-

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.

+

on your experiment controls. The saved results appear to model browser under the active experiment. To show the results on trends and tables, double click on the result to activate it.


Dependencies

Dependencies display 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 configured at the bottom of the view.


@@ -82,49 +82,49 @@ Delay3 = Delay3_delayClass_instance.delay3;

Loops

Loops display all feedback loops which the selected variable belongs to.


-

Custom Charts

+

Custom Charts

Custom charts are user-defined displays of simulation result data. They can be used and re-used in various places. The four types of custom charts (line, sensitivity, bar, and pie charts) provide model developers means for examining and developing their models and communicating the simulation results to others.

Custom charts are created to the Charts folder in model browser.


-

Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts.

Line Chart

Line chart shows the time series of a variable. It is capable of displaying multiple multi-dimensional variables at the same time. Simulation playback mode adds a marker to the chart to display the current time in playback simulation. Below is an example chart and its settings.

+

Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts.

Line Chart

Line chart shows the time series of a variable. It is capable of displaying multiple multi-dimensional variables at the same time. Simulation playback mode adds a marker to the chart to display the current time in playback simulation. Below is an example chart and its settings.



-
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleThe title of the chart. Displayed in the chart
TypeLine chart (default) or area chart
HideOptions to hide chart grid, title or legend
X-axis-
VariableA variable that is used as the x-axis variable. The default variable is time and it needs not to be typed in the field.
LabelOptional other label for the variable than its name
MinMinimum value of the x-axis
MaxMaximum value of the x-axis
HideOptions to hide x-axis label, line, tick marks and tick labels
+
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleThe title of the chart. Displayed in the chart
TypeLine chart (default) or area chart
HideOptions to hide chart grid, title or legend
X-axis-
VariableA variable that is used as the x-axis variable. The default variable is time and it needs not to be typed in the field.
LabelOptional other label for the variable than its name
MinMinimum value of the x-axis
MaxMaximum value of the x-axis
HideOptions to hide x-axis label, line, tick marks and tick labels

-
Variable-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed.
ColorColor for the lines of this variable
Line widthThe width of the lines drawn for this variable

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Sensitivity Chart

Sensitivity chart shows the time series of a variable with confidence bounds. Below is an example chart and its settings. The general settings are defined similarly to those of a line chart explained above.

+
Variable-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed.
ColorColor for the lines of this variable
Line widthThe width of the lines drawn for this variable

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Sensitivity Chart

Sensitivity chart shows the time series of a variable with confidence bounds. Below is an example chart and its settings. The general settings are defined similarly to those of a line chart explained above.



-
Axis and Variables-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
Display medianDisplay the median value of the variable at each time step.
Confidence bounds and colorsThe confidence bounds in percents and colors for them.

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Bar Chart

Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time.

+
Axis and Variables-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
Display medianDisplay the median value of the variable at each time step.
Confidence bounds and colorsThe confidence bounds in percentages and colors for them.

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Bar Chart

Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time.


-
General-
NameThe name of the chart. Name is displayed in model browser.
TitleThe title of the chart. Title is displayed in the chart, if not hidden
TypeNormal or stacked. Normal type displays all variables in separate bars. Stacked mode is able to display one-dimensional array variables in stacks.
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOption for hiding grid, title and Legend. Legend is hidden by default since it only contains the information that the current simulation is displayed.
+
General-
NameThe name of the chart. Name is displayed in model browser.
TitleThe title of the chart. Title is displayed in the chart, if not hidden
TypeNormal or stacked. Normal type displays all variables in separate bars. Stacked mode is able to display one-dimensional array variables in stacks.
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOption for hiding grid, title and Legend. Legend is hidden by default since it only contains the information that the current simulation is displayed.

Charts can be added to model diagrams simply by dragging the chart from model browser to diagram.


-
Variable-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
+
Variable-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.

-
Domain axis-
LabelAn optional label for x axis
Label angleAxis labels can be displayed in an angle. This value determines the angle in degrees.
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels
Range axis-
LabelAn optional label for y axis
MinMinimum value of y axis
MaxMaximum value of y axis
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels

Pie Chart

Pie charts display proportions of variables at a certain time. The time, similar to bar charts, can be configured for the whole chart and individually for each variable. If no time is configured, the value at the latest time step (or the time of simulation playback) is displayed.

+
Domain axis-
LabelAn optional label for x axis
Label angleAxis labels can be displayed in an angle. This value determines the angle in degrees.
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels
Range axis-
LabelAn optional label for y axis
MinMinimum value of y axis
MaxMaximum value of y axis
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels

Pie Chart

Pie charts display proportions of variables at a certain time. The time, similar to bar charts, can be configured for the whole chart and individually for each variable. If no time is configured, the value at the latest time step (or the time of simulation playback) is displayed.


-
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleTitle The title of the chart. Displayed in the chart
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOptions for hiding title, section labels and legend
+
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleTitle The title of the chart. Displayed in the chart
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOptions for hiding title, section labels and legend

-
Variables-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
ColorColor for the sector of this variable
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
ExplodedIf set, the sector(s) of the variable(s) are "exploded" away from the center of the pie chart
+
Variables-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
ColorColor for the sector of this variable
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
ExplodedIf set, the sector(s) of the variable(s) are "exploded" away from the center of the pie chart

-

Chart Panel

Chart panel is able to house multiple charts at the same time. Chart panel is a normal view in the workbench, which means it can be resized and located anywhere in the workbench. Eclipse also allows detaching the tab completely from the workbench, which means that the chart panel can be dragged to another screen.

+

Chart Panel

Chart panel is able to house multiple charts at the same time. Chart panel is a normal view in the workbench, which means it can be resized and located anywhere in the workbench. Eclipse also allows detaching the tab completely from the workbench, which means that the chart panel can be dragged to another screen.


Chart panel can be either horizontally or vertically oriented. Different orientations help in configuring the workbench perspective.


-

Charts are added to the panel by dragging from model browser. The order of the charts is easily changed by dragging charts from their header. Charts can be minimized or completely removed from the buttons in their headers.

By default, chart panel is hidden in the upper-right corner of the system dynamics perspective.

Multidimensional Variables

-

Modeling

Models with multidimensional variables look just like any other models. The structure of the models is replicated givin multiple indexes to variables. For users with programming background, notation Variable may be familiar. In system dynamic modeling we need to give names to the indexes. Instead of using numbers to define the indexes, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples):

1 Create the model structure

Model with multidimensional variables looks just like any other model.

+

Charts are added to the panel by dragging from model browser. The order of the charts is easily changed by dragging charts from their header. Charts can be minimized or completely removed from the buttons in their headers.

By default, chart panel is hidden in the upper-right corner of the system dynamics perspective.

Multidimensional Variables

+

Modeling

Models with multidimensional variables look just like any other models. The structure of the models is replicated giving multiple indices to variables. For users with programming background, notation Variable may be familiar. In system dynamic modeling we need to give names to the indices. Instead of using numbers to define the indices, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples):

1 Create the model structure

Model with multidimensional variables looks just like any other model.


-

2 Create Enumerations and define the indexes

Enumerations are created by right-clicking configuration and selecting New->Enumeration.

+

2 Create Enumerations and define the indices

Enumerations are created by right-clicking configuration and selecting New→Enumeration.


-

Define enumeration indexes by adding as many indexes as you want. Rename the indexes by selecting them and then clicking on them again.

+

Define enumeration indices by adding as many indices as you want. Rename the indices by selecting them and then clicking on them again.


-

3 Add Enumerations for variables

Select the variable that you want to be multidimensional. From the Indexes -tab in the property view, move the wanted enumerations to the right. The order of the enumerations does matter.

+

3 Add Enumerations for variables

Select the variable that you want to be multidimensional. From the indices -tab in the property view, move the wanted enumerations to the right. The order of the enumerations does matter.


-

4 Define equations for all possible indexes

Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indexes, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}.

+

4 Define equations for all possible indices

Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indices, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}.


-

Expressions

Values for all cells in the variable matrix can be defined in a single expression.

+

Expressions

Values for all cells in the variable matrix can be defined in a single expression.



@@ -136,7 +136,7 @@ Delay3 = Delay3_delayClass_instance.delay3;

4 Select the new expression


-

Repeat until there is value for each cell. There must be exactly one value for each cell.

Array Slices

Many times it is useful to access a slice of a multidimensional variable. In this chapter, we will use the following example variable:

 enumeration E1 = one, two, three
+

Repeat until there is value for each cell. There must be exactly one value for each cell.

Array Slices

Many times it is useful to access a slice of a multidimensional variable. In this chapter, we will use the following example variable:

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
 

The whole variable can be accessed in three different ways:

  1. Auxiliary

  2. Auxiliary[E1, E2]

  3. Auxiliary[:, :]

The following explains different methods for accessing parts of the variable

 // Single cell
@@ -144,35 +144,35 @@ Delay3 = Delay3_delayClass_instance.delay3;
 
 // Slices
  Auxiliary[one, E2] = {1,2,3}
  Auxiliary[E1, zwei] = {{2},{5},{8}}
- 
+
  // In addition to single cells and the whole enumeration range, a subrange of the enumeration can be used
  Auxiliary[two : three, E2] = {{4,5,6},{7,8,9}}
  Auxiliary[one : two, zwei : drei]  = {{2,3},{5,6}}
-

The syntax for accessing parts of variables can be used in both expression range definitions and in expressions.

Arithmetic Operators

Arithmetic operations are defined in Modelica. Below are examples of different operations.

Addition and substraction

Addition and substraction are calculated elementwise

 {1,2,3} - {0,2,3} = {1,0,0}
+

The syntax for accessing parts of variables can be used in both expression range definitions and in expressions.

Arithmetic Operators

Arithmetic operations are defined in Modelica. Below are examples of different operations.

Addition and substraction

Addition and substraction are calculated elementwise

 {1,2,3} - {0,2,3} = {1,0,0}
  {{2,2},{4,4}} + {{8,8},{1,1}} = {{10,10},{5,5}}
  {1,2,3} - {1,2} = ERROR! Different array sizes
 

Division

Division with a scalar

 {5,10,15} / 5 = {1,2,3}
  5 / {5,10,15} = ERROR! not allowed
 

Division with an array

 {1,2,3} / {1,2,3} = ERROR! not allowed
- 
+
  // Elementwise
  {1,2,3} ./ {1,2,3} = {1,1,1}
 

Multiplication

Multiplication with a scalar

 {1,2,3} * 2 = {2,4,6}
  5 * {1,2,3} = {5,10,15}
 

Matrix multiplication with an array

 {{3,4},{5,6}} * {1,2} = {11,17}
  {{3,4},{5,6}}  * {1,2,3} = ERROR! incompatible array sizes
- 
+
  //Elementwise
  {1,2} .* {1,2} = {1,4}
- 
- Real[3,2] c = {{1,2},{3,4},{5,6}};  
+
+ Real[3,2] c = {{1,2},{3,4},{5,6}};
  Real[2,2] d = {{3,4},{5,6}};
  Real[2,2] cd;
  cd = c[2:3, :] .* d; // Result: {{9,16},{25,36}}
 

Power

Elementwise power of array variable

 {1,2} .^ 2 = {1,4}
-

Builtin Modelica Functions

Modelica has some builtin functions that help using multidimensional variables. This chapter introduces some of the builtin functions.

Dimension and size functions

We will use the same example variable as previously.

 enumeration E1 = one, two, three
+

Built-in Modelica Functions

Modelica has some built-in functions that help using multidimensional variables. You can find the functions under any model inside the folder Functions→Built-in Functions. This chapter introduces some of the built-in functions.

Dimension and size functions

We will use the same example variable as previously.

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
- 
+
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
 

ndims(A)

The number of dimensions in array A

 ndims(Auxiliary) = 2
 

size(A, i)

The size of dimension i in array A

 size(Auxiliary, 2) = 3
@@ -188,7 +188,7 @@ Delay3 = Delay3_delayClass_instance.delay3;
    1 0 0
    0 2 0
    0 0 3
-

linspace(x1,x2,n)

Constracts a Real vector from x1 to x2 with n equally spaced elements.

 linspace(2,5,4) = {2,3,4,5}
+

linspace(x1,x2,n)

Constructs a Real vector from x1 to x2 with n equally spaced elements.

 linspace(2,5,4) = {2,3,4,5}
 

Reduction functions

Reduction functions reduce arrays to scalars.

min(A)

Returns the minimum value in array A.

 Real A = {{1,2},{3,4}}
  min(A) = 1
 

max(A)

Returns the maximum value in array A.

 Real A = {{1,2},{3,4}}
@@ -200,9 +200,9 @@ Delay3 = Delay3_delayClass_instance.delay3;
 

Using functions with iterators

Functions min(A), max(A), sum(A) and product(A) reduce arrays to scalars. When you use multidimensional variables, you will most probably like to reduce less dimensions. This can be achieved using iterators with reduction functions. The result is constructed as an array, if curly brackets {} are used to enclose the expression.

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
- 
+
  AuxiliarySum[E1] = {sum( Auxiliary[ i , E2 ] ) for i in E1} // Result: {6, 15, 24}
- 
+
  /* Same as:
  {sum(Auxiliary[one, E2]), sum(Auxiliary[two, E2]), sum(Auxiliary[three, E2])}
  {sum({1,2,3}), sum({4,5,6}), sum({7,8,9})}
@@ -210,37 +210,37 @@ Delay3 = Delay3_delayClass_instance.delay3;
 

One expression can have multiple iterators. The Modelica specification defines the following format, but it is NOT yet supported in OpenModelica:

 {sum(Array[ i, j, E3]) for i in E1, j in E2}  // Dimensions reduced from 3 to 2
 

To use multiple iterators, use the following format (NOTE the reversed order of iterators!):

 {{sum(Array[ i, j, E3]) for j in E2} for i in E1}  // Dimensions reduced from 3 to 2
 

The range doesn't have to be the whole enumeration. Subranges can also be used.

 {sum( Auxiliary[ i , eins : zwei ] ) for i in E1.one : E1.two} // Result: {3, 9}
- 
+
  /* Same as
  {sum(Auxiliary[one, eins : zwei]), sum(Auxiliary[two, eins : zwei])}
  {sum({1,2}), sum({4,5})}
  */
-

Simulation Results

Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables.

+

Simulation Results

Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables.


-

The clutter can be reduced by selecting which enumeration indexes are shown in charts. Select an enumeration and tick the indexes that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model.

+

The clutter can be reduced by selecting which enumeration indices are shown in charts. Select an enumeration and tick the indices that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model.


-

Array Variables in Modules

+

Array Variables in Modules


Replaceable enumeration inside a module

-

You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see Modeling).

When defining a module, modeler may not want to restrict the size of the array variable. In many cases the same module structure could be used for both large and small arrays. For example if the module is a project, a project may have three or even twenty phases. In this case the enumerations inside modules need to be set as replaceable.

In this example, the original enumeration that the modeler used had two indexes. We are using an instance of this module, but we need to use array variables that have three indexes instead of two. We are using two variables and an instance of the module.

+

You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see Modeling).

When defining a module, modeler may not want to restrict the size of the array variable. In many cases the same module structure could be used for both large and small arrays. For example if the module is a project, a project may have three or even twenty phases. In this case the enumerations inside modules need to be set as replaceable.

In this example, the original enumeration that the modeler used had two indices. We are using an instance of this module, but we need to use array variables that have three indices instead of two. We are using two variables and an instance of the module.


Module configuration for replacing enumerations inside the module

-

In the parent configuration, we have used an enumeration with three indexes in the two variables.

+

In the parent configuration, we have used an enumeration with three indices in the two variables.


Enumeration in the parent configuration that will replace the enumeration in the module

-

The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clickin on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model.

+

The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clicking on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model.


Enumeration in the parent configuration that will replace the enumeration in the module

-

When creating replaceable enumerations in modules, modelers need to be very careful. Direct references to single enumeration elements are not allowed, since the enumeration elements will change, if the enumeration is replaced for simulation!

Functions

-

Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models.

Creating Functions

+

When creating replaceable enumerations in modules, modelers need to be very careful. Direct references to single enumeration elements are not allowed, since the enumeration elements will change, if the enumeration is replaced for simulation!

Functions

+

Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models.

Creating Functions


-

You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New->Function.

Functions that can be found from Functions -folder can be used in your variable definitions.

Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function.

Algorithm section defines the actual functionality of the function. In algorithm sections you must use assignments ":=" instead of just plain "=". All the assignments are calculated in the order they are written.

Below is an example of a simple function. For more examples, see the built-in functions provided with the tool and Modelica specifications.

+

You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New→Function.

Functions that can be found from Functions -folder can be used in your variable definitions.

Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function.

Algorithm section defines the actual functionality of the function. In algorithm sections you must use assignments ":=" instead of just plain "=". All the assignments are calculated in the order they are written.

Also, take note that creating new lines in the Modelica code text box is done via shift+enter.

Below is an example of a simple function. For more examples, see the built-in functions provided with the tool and Modelica specifications.


-

Function Libraries

Functions can be collected into libraries. This is a good way of organizing your functions. If function is located in a library, you need to append the library name to the function call (e.g. ExampleFunctionLibrary.ExampleFunction(arg1, arg2)). With libraries, you can also have functions with same names (e.g. library1.func(arg) and library2.func(arg)).

+

Function Libraries

Functions can be collected into libraries. This is a good way of organizing your functions. If function is located in a library, you need to append the library name to the function call (e.g. ExampleFunctionLibrary.ExampleFunction(arg1, arg2)). With libraries, you can also have functions with same names (e.g. library1.func(arg) and library2.func(arg)).


-

There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually.

Create a new function library by right-clicking on Functions folder, Shared functions folder or other module library.

A function library can be exported by right clicking the function library and selecting Export -> Function library. A function library can be imported by right clicking the Functions folder and selecting Import -> Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library.

If you create a shared function library, the library can be added to other models or removed from current model by selecting the Shared Functions -folder and using the properties view.

+

There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually.

Create a new function library by right-clicking on Functions folder, Shared functions folder or other module library.

A function library can be exported by right clicking the function library and selecting Export → Function library. A function library can be imported by right clicking the Functions folder and selecting Import → Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library.

If you create a shared function library, the library can be added to other models or removed from current model by selecting the Shared Functions -folder and using the properties view.


-

External Functions

Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window -> Preferences -> Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code.

Below is a simple example of using a function that returns the sum of two arguments.

 double exampleCFunction(double x, double y)
+

External Functions

Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window → Preferences → Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code.

Below is a simple example of using a function that returns the sum of two arguments.

 double exampleCFunction(double x, double y)
  {
    double res;
    res = x + y;
@@ -264,23 +264,23 @@ Delay3 = Delay3_delayClass_instance.delay3;
    return res;
  }");
  end ExampleExternalFunction;
-

Modelica Functions

Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see builtin functions for arrays.

FunctionDescription
abs(x)Returns the absolute value of x. Expanded into "(if x >= 0 then x else -x)".
acos(x)Inverse cosine.
asin(x)Inverse sine.
atan(x)Inverse tangent.
atan2(x1,x2)four quadrant inverse tangent.
cat(n,A,B,...)General concatenation function that concatenates arrays A,B,... along the nth dimension.
ceil(x)Returns the smallest integer not less than x, the closest integer above x.
cos(x)Cosine.
cosh(x)Hyperbolic cosine.
cross(x,y)Returns the 3-vector cross product of the 3-vectors x and y.
delay(expr, delayTime)Returns the value of expr at the time time-delayTime. The value of expr is returned when time <= time.start + delayTime.
der(x)Time derivative of x. X must be have continuous-time variability.
div(x, y)Returns the algebraic quotient x/y with any fractional part discarted. E.g. div(10,3) = 3.
edge(b)Returns true when the value of the boolean expression b changes. Expanded into (b and not pre(b)).
exp(x)Exponential, base e.
floor(x)Returns the largest integer not greater than x, the closest integer below x.
initial()Returns true at the beginning of the simulation.
integer(x)Returns the largest integer not greater than x as an integer.
log(x)Natural logarithm. (base e, x > 0)
log10(x)Base 10 logarithm. (x > 0)
mod(x, y)Returns the integer modulus of x/y: mod(x,y) = x - floor(x/y) * y.
noEvent(expr)noEvent around an expression causes the expression to NOT generate event. Important: If you want a condition to be checked only on time steps, use noEvent. (e.g. if noEvent(value >= 1) then ... else ...)
pre(x)Returns the preceding value of y from time event that has occured before current time.
rem(x, y)Returns the integer remainder of x/y: rem(x,y) = x - div(x,y) * y.
sample(start, interval)Returns true and triggers time events at times start + i * interval (i=0,1,...).
sign(x)Returns -1 if x is negative, 1 if x is positive. Expanded into "(if x > 0 then 1 else if x < 0 then -1 else 0)".
sin(x)Sine.
sinh(x)Hyperbolic sine.
sqrt(x)Square root of x. The value of x must be greater or equal to 0 or an assertion error occurs.
tan(x)Tangent.
tanh(x)Hyperbolic tangent.
terminal()Returns true at the end of a successful simulation.

Spreadsheets

-

Spreadsheets allow storing and maintaining values in a familiar format. The current spreadsheet implementation is experimental and does not provide much functionality.

Variable Values

Spreadsheets are an easy way to import and manage parameter values. Sheet shells can be referenced to in models with the syntax SheetName(CellReference). Below is an example of getting a value for Auxiliary. The text "Auxiliary" is not necessary in the spreadsheet, but it helps maintaining the sheet.

+

Modelica Functions

Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see Built-in functions for arrays.

FunctionDescription
abs(x)Returns the absolute value of x. Expanded into "(if x >= 0 then x else -x)".
acos(x)Inverse cosine.
asin(x)Inverse sine.
atan(x)Inverse tangent.
atan2(x1,x2)four quadrant inverse tangent.
cat(n,A,B,...)General concatenation function that concatenates arrays A,B,... along the nth dimension.
ceil(x)Returns the smallest integer not less than x, the closest integer above x.
cos(x)Cosine.
cosh(x)Hyperbolic cosine.
cross(x,y)Returns the 3-vector cross product of the 3-vectors x and y.
delay(expr, delayTime)Returns the value of expr at the time time-delayTime. The value of expr is returned when time <= time.start + delayTime.
der(x)Time derivative of x. X must be have continuous-time variability.
div(x, y)Returns the algebraic quotient x/y with any fractional part discarded. E.g. div(10,3) = 3.
edge(b)Returns true when the value of the Boolean expression b changes. Expanded into (b and not pre(b)).
exp(x)Exponential, base e.
floor(x)Returns the largest integer not greater than x, the closest integer below x.
initial()Returns true at the beginning of the simulation.
integer(x)Returns the largest integer not greater than x as an integer.
log(x)Natural logarithm. (base e, x > 0)
log10(x)Base 10 logarithm. (x > 0)
mod(x, y)Returns the integer modulus of x/y: mod(x,y) = x - floor(x/y) * y.
noEvent(expr)noEvent around an expression causes the expression to NOT generate event. Important: If you want a condition to be checked only on time steps, use noEvent. (e.g. if noEvent(value >= 1) then ... else ...)
pre(x)Returns the preceding value of y from time event that has occurred before current time.
rem(x, y)Returns the integer remainder of x/y: rem(x,y) = x - div(x,y) * y.
sample(start, interval)Returns true and triggers time events at times start + i * interval (i=0,1,...).
sign(x)Returns -1 if x is negative, 1 if x is positive. Expanded into "(if x > 0 then 1 else if x < 0 then -1 else 0)".
sin(x)Sine.
sinh(x)Hyperbolic sine.
sqrt(x)Square root of x. The value of x must be greater or equal to 0 or an assertion error occurs.
tan(x)Tangent.
tanh(x)Hyperbolic tangent.
terminal()Returns true at the end of a successful simulation.

Spreadsheets

+

Spreadsheets allow storing and maintaining values in a familiar format. The current spreadsheet implementation is experimental and does not provide much functionality.

Variable Values

Spreadsheets are an easy way to import and manage parameter values. Sheet shells can be referenced to in models with the syntax SheetName(CellReference). Below is an example of getting a value for Auxiliary. The text "Auxiliary" is not necessary in the spreadsheet, but it helps maintaining the sheet.



-

You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indexes are not mandatory, but help reading and maintaining the sheet.

+

You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indices are not mandatory, but help reading and maintaining the sheet.


Reference to a sheet range creates an array variable.


-

ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indexes are ordered as in this example. However, if you wish to present the indexes in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3)))

+

ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indices are ordered as in this example. However, if you wish to present the indices in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3)))


-

History Data

Spreadsheets can be used to store and display external history data e.g. from some statistics. The history data should be arranged as columns or rows and include a time variable. Reference variables need to be given the exactly same name as their counterparts in model.

+

History Data

Spreadsheets can be used to store and display external history data e.g. from some statistics. The history data should be arranged as columns or rows and include a time variable. Reference variables need to be given the exactly same name as their counterparts in model.


History data is used by creating a History dataset to an experiment. The dataset is activated and deactivated in charts by double-clicking the dataset. History data reference is set in the properties of the history dataset.


-
History data properties-
NameName of the history dataset
SheetCombo box for selecting a sheet where the history data is located
OrientationColumns or rows. How the data is arranged in the sheet.
Range startThe upper-left corner cell of the history data range
Range endThe lower-right corner cell of the history data range
Time variableThe name of the time variable in the history data, if it is different than "time"
Variables in rangeThis text field displays the found variables in the given sheet and range

If the history dataset is activated, history data is displayed whenever it is available for a variable that is displayed in a chart.

+
History data properties-
NameName of the history dataset
SheetCombo box for selecting a sheet where the history data is located
OrientationColumns or rows. How the data is arranged in the sheet.
Range startThe upper-left corner cell of the history data range
Range endThe lower-right corner cell of the history data range
Time variableThe name of the time variable in the history data, if it is different than "time"
Variables in rangeThis text field displays the found variables in the given sheet and range

If the history dataset is activated, history data is displayed whenever it is available for a variable that is displayed in a chart.


-

Vensim Model Import

-

The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool Vensim. This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" -> "Vensim Model (.mdl)".

The import process has several known limitations:

  • The Vensim model must be in the .mdl file format, the other Vensim file formats are proprietary and thus not supported.

  • Only variables and connections are imported.

  • Many advanced Vensim features, such as input and output objects (e.g. graphs and parameter value editors) and other diagram customizations, are not supported.

  • Variable value range data is not always imported correctly.

  • Subscripts are automatically converted to enumerations which may sometimes lead into problems as the constructions are not exactly equivalent.

  • Dimensionless units are currently not converted correctly (in Simantics System Dynamics, dimensionless should be indicated with a constant).

  • Non-shadow duplicate variables are sometimes very problematic and may be imported incorrectly, shadow variables should work fine.

  • Only a limited subset of Vensim functions is currently implemented in Simantics System Dynamics, so some equations might require additional work before they can be evaluated correctly.

Sample Models and Molecules

-

There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import->Model.

Simantics | System Dynamics Modelling

+

Vensim Model Import

+

The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool Vensim. This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" → "Vensim Model (.mdl)".

The import process has several known limitations:

  • The Vensim model must be in the .mdl file format, the other Vensim file formats are proprietary and thus not supported.

  • Only variables and connections are imported.

  • Many advanced Vensim features, such as input and output objects (e.g. graphs and parameter value editors) and other diagram customizations, are not supported.

  • Variable value range data is not always imported correctly.

  • Subscripts are automatically converted to enumerations which may sometimes lead into problems as the constructions are not exactly equivalent.

  • Dimensionless units are currently not converted correctly (in Simantics System Dynamics, dimensionless should be indicated with a constant).

  • Non-shadow duplicate variables are sometimes very problematic and may be imported incorrectly, shadow variables should work fine.

  • Only a limited subset of Vensim functions is currently implemented in Simantics System Dynamics, so some equations might require additional work before they can be evaluated correctly.

Sample Models and Molecules

+

There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import→Model.

Simantics | System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

System dynamics modelling in Simantics is a free modelling tool that is included into the basic installation. This tutorial introduces the basic features of the system dynamics modelling tool.

Tutorial: Advanced System Dynamics Modelling

This tutorial introduces the more advanced features of the system dynamics modelling tool: Modules and Operating interfaces

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.help/commonltr.css b/bundles/org.simantics.sysdyn.help/commonltr.css index da51ac17..f01f73b7 100644 --- a/bundles/org.simantics.sysdyn.help/commonltr.css +++ b/bundles/org.simantics.sysdyn.help/commonltr.css @@ -246,6 +246,29 @@ h6.tasklabel { .warningtitle { font-weight: bold; } +.hazardstatement td, +.hazardstatement th { + padding: 0.5rem; +} +.hazardstatement th { + text-align: center; + text-transform: uppercase; +} +.hazardstatement--caution { + background-color: #ffd100; +} +.hazardstatement--danger { + background-color: #c8102e; + color: #fff; +} +.hazardstatement--warning { + background-color: #ff8200; +} +.hazardstatement--attention, .hazardstatement--fastpath, .hazardstatement--important, .hazardstatement--note, .hazardstatement--notice, .hazardstatement--other, .hazardstatement--remember, .hazardstatement--restriction, .hazardstatement--tip { + background-color: #0072ce; + color: #fff; + font-style: italic; +} /* Simple lists do not get a bullet */ ul.simple { list-style-type: none; @@ -389,6 +412,24 @@ pre.codeblock { font-family: monospace; } +/* flagging styles */ + +.flag__style--italics { + font-style: italic; +} +.flag__style--bold { + font-weight: bold; +} +.flag__style--underline { + text-decoration: underline; +} +.flag__style--double-underline { + text-decoration: double-underline; +} +.flag__style--overline { + text-decoration: overline; +} + /*! * Custom CSS declarations, to be appended to the end of existing declarations */ diff --git a/bundles/org.simantics.sysdyn.help/commonrtl.css b/bundles/org.simantics.sysdyn.help/commonrtl.css index de01f230..e04c4e02 100644 --- a/bundles/org.simantics.sysdyn.help/commonrtl.css +++ b/bundles/org.simantics.sysdyn.help/commonrtl.css @@ -250,6 +250,29 @@ h6.tasklabel { .warningtitle { font-weight: bold; } +.hazardstatement td, +.hazardstatement th { + padding: 0.5rem; +} +.hazardstatement th { + text-align: center; + text-transform: uppercase; +} +.hazardstatement--caution { + background-color: #ffd100; +} +.hazardstatement--danger { + background-color: #c8102e; + color: #fff; +} +.hazardstatement--warning { + background-color: #ff8200; +} +.hazardstatement--attention, .hazardstatement--fastpath, .hazardstatement--important, .hazardstatement--note, .hazardstatement--notice, .hazardstatement--other, .hazardstatement--remember, .hazardstatement--restriction, .hazardstatement--tip { + background-color: #0072ce; + color: #fff; + font-style: italic; +} /* Simple lists do not get a bullet */ ul.simple { list-style-type: none; @@ -393,6 +416,24 @@ pre.codeblock { font-family: monospace; } +/* flagging styles */ + +.flag__style--italics { + font-style: italic; +} +.flag__style--bold { + font-weight: bold; +} +.flag__style--underline { + text-decoration: underline; +} +.flag__style--double-underline { + text-decoration: double-underline; +} +.flag__style--overline { + text-decoration: overline; +} + /*! * Custom CSS declarations, to be appended to the end of existing declarations */ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorial.html b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorial.html index 80b4307b..ed781e7d 100644 --- a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorial.html +++ b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorial.html @@ -1,8 +1,8 @@ -Tutorial: Advanced System Dynamics Modelling

Tutorial: Advanced System Dynamics Modelling

-

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. A basic tutorial is also available. This tutorial is part of the sysdyn documentation.

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 WorkforceModule and WorkModule. You can rename them by right-clicking on the item on the model browser and selecting Rename.

+Tutorial: Advanced System Dynamics Modelling

Tutorial: Advanced System Dynamics Modelling

+

This tutorial goes more in-depth on the advanced features of the Simantics System Dynamic tool. Namely modules, custom Modelica functions, special variables and enumerations (i.e. vector variables). We are going to build a model that simulates how a shared workforce works on several overlapping projects. You can think of the resulting model as a framework on which to build models that, for example, simulate a project portfolio of a company. It is advised that you complete the basic tutorial before starting. If you find yourself stuck, seek help from the documentation.

Creating model and modules

+

Start by creating a new model from File→New→SD Model, rename the model to WorkModel. Then create two new modules by right-clicking on the Modules folder under the WorkModel tree and selecting New→Module. Rename the modules to Workforce and Project by selecting them in the Model Browser and using the properties view.


Creating a new model

@@ -12,141 +12,220 @@

Model after renaming

Initial configuration

-
+

We will use a top-down approach in creating our model - focusing first on the bigger picture of the model and implementing the internal structure of the modules later.

Open the model configuration by double-clicking Configuration in your model browser. Drag one Workforce and one Project from your Model Browser to the WorkModel diagram. The modules are automatically named with a suffix number.


-

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 WorkforceModule and one WorkModule 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 Project modules

+

You can think of modules as user made components that communicate with rest of the model by having some input(s) and output(s). In this model the internal implementation of Workforce module should handle resourcing people to projects according to their needs. The Project module should simulate how the people that are assigned to that specific project are advancing the project.

While not used in this tutorial, Simantics System Dynamics supports nested modules, i.e. modules inside modules. Modules can also be exported and imported independent of the model.

Let's consider what kind of information we need to pass between the modules. First of all, the Project needs to tell the Workforce module how much workforce it needs. Create an input variable and name it to RequestedWorkingSpeed to pass this information along. Connect Project1 module to RequestedWorkingSpeed and RequestedWorkingSpeed to Workforce1 with a dependency arrow.

Input variable is a special type of symbol that acts as an interface between modules and the rest of the model. They are the only symbol type that can be connected directly to module outputs and they also act as the only way of creating inputs inside modules, as we will see later.

We also need to assign people to work for the project - the Workforce module needs to tell the Project module how well we can respond to the request. Create a new input variable called ResponsedWorkingSpeed and connect it to the modules with dependency arrows.


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 we would like to use in the modules.

Workforce needs to know, how much work is required and it should 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

-
+

Now we have the first version of the top-level model structure completed, we can start configuring the modules.

Workforce module

+

Open the Workforce module by double-clicking it under the Modules folder.

First, create an input variable and name it to RequestedNumberOfPeople, this variable receives the request provided by the Project module. Then, create 3 auxiliary variables and name them NumberOfEmployees, EmployeesAssigned and NumberOfFreeEmployees. Lastly connect the variables as shown in the picture. The unit of these variables is number of people.


-

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 according 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. Variable's properties are shown in the Property view and you can input the required equations in the text fields. 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
-
-TimeToAllocateResources 
-= 2
-
-Productivity 
-= 1
-
-PossibleWorkingSpeed 
-= WorkforceStock * Productivity
-Is Output
-

Variables can be set as output by selecting Is Output option from the Equation tab.

-
-

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

-
+

Internal structure of the Workforce module

+

Now we need to give the symbols equations, these are written below. To configure an equation, select a variable and write (or copy-paste) the corresponding equation to the text field in the Properties view. Connected variables are shown in the Variables list on the right side of the properties view. You can double-click on a variable name to insert it to the equation.

NumberOfEmployees
+= 10
+
+NumberOfFreeEmployees
+= NumberOfEmployees-EmployeesAssigned
+
+EmployeesAssigned
+= min(RequestedNumberOfPeople, NumberOfEmployees)
+

Also, we need to decide what value(s) we want the module to output. Make sure that the Is Output checkbox is ticked on the EmployeesAssigned variable, as this is the variable that tells how many people can be provided for the project.

We are using a built-in function min() for calculating how many employees we are going to assign. You can find a list of these in the Model Browser under WorkModel→Functions→Built-in Functions.

On the first iteration of this model, we are going to have 10 fulltime employees that get assigned to a single project according to the request. We are going to expand the structure of this module to handle several projects later on in the tutorial. This module is now ready to be used as a part of the first iteration of the model.

Work module

+

Open Project module by double-clicking it on the Model Browser.

Create a flow of work with stocks and flows like in the picture. This loop says that there is some initial amount of work that is done at a certain speed, gradually becoming completed work. However, our workers are not perfect, as such errors can occur during work. These errors are first undiscovered, and as they are found they become work that needs to be completed.

You will see red exclamation mark next to the symbols due to empty equation fields, these are omitted from the tutorial images for clarity reasons. We will return to fill in these fields later.


Basic work with errors

-

Open Work1 module by selecting it from the WorkModel diagram, right-clicking it and selecting Show Module. Alternatively you can double click Work1 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. Create variables and connections according to the picture on the right.

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. This means that the simulation calculates ''WorkDone / ProjectWorkAmount''. If ProjectWorkAmount is zero, the result is the third argument ''0.0''.

-
-

ProjectWorkAmount input variable

-

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.

-
-

Variables needed for error handling

-

Next we need to define how errors are found. For that we need new variables: WorkQuality and ErrorsFoundTime. Create the variables and connections according to the picture and give variables their equations.

ErrorsGenerated
-= (1-WorkQuality) * WorkingSpeed
+

Next let's create variables that control the parameters of a project and handle the request of asking people for work. Create auxiliary variables: StartTime, Deadline, ProjectDuration, TimeToStartTime, TimeToDeadline, RequestedWorkingSpeed, ProjectWorkAmount and NumberOfWorkdaysInProject. Connect the symbols as in the picture and write the following expression to their expression fields. Click the checkbox Is Output on RequestedWorkingSpeed variable to make the module output the value of this variable.

+
+

Structure of requesting people to work

+
StartTime
+= 5
 
-ErrorsFoundRate
-= Errors/ErrorsFoundTime
+Deadline
+= 20
 
-WorkQuality
-= 0.9
+ProjectDuration
+= Deadline-StartTime
 
-ErrorsFoundTime
-Type: WithLookup
-With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0) 
-Lookup table: {{0,5},{0.5,3},{1,0.5},{2,0.5}}
-

WithLookup is a variable type where the value is interpolated from a 2-dimensional table (Lookup table) using the value determined in the "With Lookup" field. Type can be changed from the drop-down menu Type.

-
-

WorkAllocation and RequiredWorkingSpeed

-

To calculate our own need for workforce we need to create and connect WorkCompletionTime input variable and the following auxliary variables:

RequiredWorkingSpeed 
-= if ProjectIsReady < 1 then xidz(WorkToDo, TimeToDeadline, MaximumWorkingSpeed) else 0
-Is Output
-
-MaximumWorkingSpeed 
+TimeToStartTime
+= max(0, StartTime-time)
+
+TimeToDeadline
+= Deadline-time
+
+RequestedWorkingSpeed
+= if WorkToDo > 0 and TimeToStartTime == 0 then NumberOfWorkdaysInProject/ProjectDuration else 0
+
+ProjectWorkAmount
 = 500
 
-TimeToDeadline 
-= max(0, WorkCompletionTime-time)
-

time is a universal variable that gives the current simulation time.

We need to decide how the workforce is allocated between all the work modules that are using the same workforce. For that we need to know how much work can be done and how much workforce other works require.

Create two Inputs, RequiredWorkingSpeedTotalInput and PossibleWorkingSpeedInput, and an auxiliary variable WorkAllocation. Connect the variables like int the picture.

WorkAllocation
-= xidz(RequiredWorkingSpeed, RequiredWorkingSpeedTotalInput, 0.0) * PossibleWorkingSpeedInput
-

Finally let's give initial values for all the remaining variables:

WorkingSpeed 
-= if ProjectIsReady < 1 then WorkAllocation else 0
+NumberOfWorkdaysInProject
+= ProjectWorkAmount/7
+

The project has parameters for starting time, deadline and budgeted hours of work. Based on these we calculate how many people the project needs, assuming that an average worker works for 7 hours per day. The number of people is handled as a floating point integer, meaning that one worker can work on multiple different projects.

Now let's create an input variable to take in the information of how much workforce we got from our request. Create an input variable and name it ResponseWorkingSpeedInput. We are also going to calculate how many hours a day the workers need to work in order to get the project ready in time and limit the result between 7 and 9 hours a day. Create two auxiliary variables and name them RequiredWorkHoursPerDay and TotalWorkHoursPerDay, connect them to other variables as in the image.

+
+

Input for responsed working speed

+

Write the following expression to the equation fields of the new auxiliary variables:

RequiredWorkHoursPerDay
+= if ResponseWorkingSpeedInput == 0 then 0 else if TimeToDeadline < 0 then 9 else minmax(WorkToDo/ResponseWorkingSpeedInput/TimeToDeadline, 7, 9)
+
+TotalWorkHoursPerDay
+= RequiredWorkHoursPerDay*ResponseWorkingSpeedInput
+
+WorkingSpeed
+= TotalWorkHoursPerDay
+

Next we focus on completing the structure of the work loop. Create 2 auxiliary variables and name them WorkQuality and ErrorsFoundTime. Also, create two Shadow variables and select WorkQuality and ProjectWorkAmount as the referred variables. Shadow variable is a special type of variable, whose role is to pass along the referred variable value to a place where drawing a dependency arrow from the original symbol would make the graph difficult to read. Place the new symbols as in the image and make the dependency connections.

+
+

Completed work loop structure

+

Now that the structure of the work loop is completed let's input equations to the variables.

WorkToDo
+Integral: ErrorsFoundRate - WorkingSpeed
+Initial Value: ProjectWorkAmount
+
+WorkDone
+Integral: WorkingSpeed - ErrorsFoundRate
+Initial Value: 0
+
+ErrorsGenerated
+= (1-WorkQuality) * WorkingSpeed
 
-WorkToDo 
-Initial value: ProjectWorkAmount
+UndiscoveredErrors
+Integral: ErrorsGenerated - ErrorsFoundRate
+Initial Value: 0
 
-WorkDone 
-Initial value: 0
+ErrorsFoundRate
+= UndiscoveredErrors/ErrorsFoundTime
+

For ErrorsFoundTime we are going to use a special type of auxiliary variable called WithLookup. WithLookup is a variable type where the value is interpolated from a 2-dimensional (Lookup) table using the value determined in the "With Lookup" field. Input the following values.

ErrorsFoundTime
+Type: WithLookup
+With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0)
+Lookup table: {{0,5},{0.5,3},{1,0.5},{2,0.5}}
+

This variable makes it so that the less we have completed work the larger the variable value is and vice versa. And as we use this value in ErrorsFoundRate variable to divide the number of undiscovered errors, a practical interpretation would be that when we start working on a project we don't discover errors easily. But, as the project gets more and more completed we start to discover more and more errors made earlier on in the project.

+
+

Choosing WithLookup as the auxiliary type

+

Now we are going to create a small feedback structure around WorkQuality. The purpose is to simulate how working overtime for a prolonged period causes fatigue. Create a stock variable called Fatigue and two flows, WorkingOverTime and SlowRecovery. Also create a shadow variable of RequiredWorkingHoursPerDay. Connect the variables as shown in the image.

+
+

Structure around WorkQuality

+

Input the following equations to the variables:

WorkingOverTime
+= if RequiredWorkHoursPerDay == 0 then 0 else (RequiredWorkHoursPerDay-7)*0.025
+
+SlowRecovery
+= if Fatigue >= 0 then 0.03 else 0
+
+Fatigue
+Integral: WorkingOverTime - SlowRecovery
+Initial Value: 0
 
-Errors 
-Initial value: 0
-

Connecting modules

-

Our modules are complete. Let's get back to the WorkModel Configuration.

Set Work1CompletionTime to 10.
-
+WorkQuality += max(0.95*(1-Fatigue), 0.7) +

Now working overtime causes fatigue to build up slowly, and fatigue in return causes work quality to decrease. This in return makes the workers more prone to do errors while working, causing more work to do, increasing the need for overtime work.

There is only one thing left to do for this module, we are going to create variables that tell when the project was completed. An intuitive approach would be to claim that a project is complete when the value of WorkToDo goes to zero. However, due to the structure of the work loop we are likely to find some errors even after the WorkToDo goes to zero. We solve this by recording the time when WorkToDo is zero (or under) for the first time.

Create a ghost variables of WorkToDo and Deadline. Then, create three auxiliary variables called ProjectIsCompleted, ProjectCompletitionTime and DaysLateOnDeadline. Connect the variables as in the image.

+
+

Structure of DaysLateOnDeadline

+

The variables use the following equations:

ProjectIsCompleted
+= if time == 0 then 0 else if WorkToDo > 0 and ProjectIsCompleted == 0 then 0 else 1
+
+ProjectCompletitionTime
+= if ProjectIsCompleted == 0 then time else ProjectCompletitionTime
+
+DaysLateOnDeadline
+= ProjectCompletitionTime-Deadline
+

You can think of ProjectIsCompleted as a Boolean variable that goes to 1 and stays there when WorkToDo goes to 0 for the first time. ProjectCompletitionTime keeps track of time until the project is completed.

Now the Project module is complete.

+
+

Completed Project module

+

Connecting modules

+

Now that our modules are complete, let's get back to the WorkModel Configuration and connect the inputs and outputs of the modules. Select Project1 and then select Outputs tab from the properties view. Select the only available variable as the connection. Do the same in the Inputs tab. And repeat this process for Workforce1 also.


Module input connections

-

Connections between modules are made in the properties of the module. Select Work1 and open tab Inputs from the properties. The table lists all input variables in the module that are available. Clicking on the Refers to output column will open a drop-down menu that shows all available variables that are connected to the module. By selecting a variable, you connect that variable to the input.

-
-

Module input connections

-

Work1 need also information on how much working speed is required by all works. Since Work1 is the only work, create a dependency connection from RequiredWorkingSpeed1 to Work1 and in Work1's properties connect it to RequiredWorkingSpeedTotalInput.

In Outputs tab, make the only possible connection: from RequiredWorkingSpeed to RequiredWorkingSpeed1.

Workforce module has only one input and one output. Create the only possible connections: -(Inputs) RequiredWorkingSpeedInput -> RequiredWorkingSpeed1 -(Outputs) PossibleWorkingSpeed -> TotalPossibleWorkingSpeed

Now your model is ready for simulation!

Simulating the model

-

To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 24.0

+

Now your model is ready for simulation!

Simulating the model

+

To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 50.


Experiment activation

-
To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button:
-

System shows the simulation progress in the progress bar on the lower right corner of the screen.

+

To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double-click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button:

+
+

System shows the simulation progress in the progress bar on the lower right corner of the screen.


-

When the progress indicator disappears, the simulation is complete.

If the Console view pops up and shows an error "Error: Too few equations, underdetermined system. The model has X equation(s) and Y variable(s)", the simulation has failed. The reason might be that you forgot to assign an equation to some variable or some connection in modules. See through all the variables, write the missing equation and simulate again.

After the simulation is succesfully run, you can select a variable and see its simulation results in the trend view. For example WorkDone variable in Work1 module will give the following graph.

+

When the progress indicator disappears, the simulation is complete.

If the Console view pops up and shows an error "Error: Too few equations, underdetermined system. The model has X equation(s) and Y variable(s)", the simulation has failed. The reason might be that you forgot to assign an equation to some variable or some connection in modules. See through all the variables, write the missing equation and simulate again.

After the simulation has successfully completed, you can select a variable from model browser under Configuration to see its values over time in the trend view. You can also right-click on a module and select Show Module. This brings up a view of the internal structure of the module instance used in the simulation. Selecting a variable from there will show its values in the trend view.

+
+

For example, RequiredWorkingHoursPerDay variable in Project1 module should give the following graph. At first assigned workers are working 7 hours per day, but they start working more when the deadline starts closing in. After the project is completed, a few undiscovered errors are found and workers return to correct them.


-

Adding modules

-
-
-

Final configuration with two modules

-

We created the WorkModule to be reusable. To use two WorkModules in the model, you must do the following.

Populate a second WorkModule to WorkModel configuration and name it Work2.

Create RequiredWorkingSpeed2 input variable and Work2CompletionTime auxiliary variable.

We need a sum of all working speed requirements to give to the work modules. For this purpose, create an auxiliary variable RequiredWorkingSpeedTotal which sums the requirements.

You can also have a different size work. To make Work2 smaller, create an auxiliary variable Work2Amount.

Use the following equations:

Work2CompletionTime
-= 13
-
-Work2Amount
-= 800
-
-RequiredWorkingSpeedTotal
-= RequiredWorkingSpeed1 + RequiredWorkingSpeed2
-

Update connections to match connections shown in the picture and connect the inputs and outputs to the modules.

Workforce
-RequiredWorkingSpeedInput -> RequiredWorkingSpeedTotal
-
-Work1 Inputs
-RequiredWorkingSpeedTotalInput -> RequiredWorkingSpeedTotal
-
-Work2 Outputs
-RequiredWorkingSpeed -> RequiredWorkingSpeed2
-
-Work2 Inputs
-
-
-

When all the connections are made, you can simulate the model again. Now you have model with two work modules. Select variables from both modules in model browser to display them in trend view.

-
-
\ No newline at end of file +

Adding modules

+

Now that we have a model with one Project module we are going to expand the model to support as many Projects as we want. First, we need to make some restructuring on the top level. Delete the dependency arrow that goes from ResponsedWorkingSpeed to Project1 module, also delete RequestedWorkingSpeed symbol entirely. Now create two new auxiliary variables and name them RequestedWorkingSpeed and WorkforceProject1. Connect the new auxiliaries as in the picture, remember make the connection inside the module properties as well.

+
+

Updated model structure

+

Write the following equations inside the new variables:

RequestedWorkingSpeed
+= Project1.RequestedWorkingSpeed
+
+WorkforceProject1
+= ResponsedWorkingSpeed
+

Notice that we can access variable values without having dependency arrows connected, we are given a warning next to the symbol as this should be done only when you know exactly what you are doing. Also, note that we can access values inside modules by using a dot notation modulename.variablename.

Simulate the model once to make sure nothing broke.

Next create a new Project module and a corresponding auxiliary variable WorkforceProject2, connect the auxiliary variable to the module and make the input connection in the module settings.

+
+

Updated model structure

+

Now we need to make the Workforce1 module to work with several projects at the same time, for this we use enumerations. You can think of enumerations as indices of a vector variable. To create an enumeration right-click on Configuration and select New→Enumeration.

+
+

Creating a new enumeration

+

Select the newly created enumeration under Configuration and rename it to Projects. Then, select the enumeration and from properties view click twice on Add, rename index and index2 to Project1 and Project2 respectively.

+
+

Creating new indices for Projects enumeration

+

Now we have created the needed enumeration for the top level model. We need to create one for the Workforce module as well. Under the Modules folder in the model browser right-click on Workforce, select New→Enumeration, name it Projects and add a single dummy enumeration. Then make sure the checkbox Can be replaced by parent module is checked. Then select Workforce1 module and from Module Properties overwrite enumeration Projects with Projects. This way we only have to update enumerations in one place when adding new projects to the model.

Now we need to select which variables use the enumerations, i.e. what scalar variables we need to turn into vector variables. In the top-level model select RequestedWorkingSpeed and ResponsedWorkingSpeed by holding down ctrl while left-clicking on the symbols, this should bring up a view that allows you to add enumerations to the selected symbols. From the left select Projects by left-clicking and click on the arrow, Projects enumeration should appear on the right side.

+
+

Adding enumerations to symbols

+

We need to change the equations of RequestedWorkingSpeed, WorkforceProject1 and WorkforceProject2. RequestedWorkingSpeed needs information from both Project modules and WorkforceProject variables should be scalars. Input the following equations:

RequestedWorkingSpeed
+= {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed}
+
+WorkforceProject1
+= ResponsedWorkingSpeed[Project1]
+
+WorkforceProject2
+= ResponsedWorkingSpeed[Project2]
+

Next we need to update the structure of Workforce module so that it handles vector variables. Open the module by right-clicking on Workforce1 and selecting Show Module.

Select variables EmployeesAssigned and RequestedNumberOfPeople and add the Projects enumeration to them as before.

Now we are going to create a custom function that allocates people to projects. To create a custom function, in the Model Browser right-click on Functions folder and select new→Function. Now click on the newly created function and rename it to AssignWorkersToProjects.

+
+

Creating a new function

+

Write (or copy-paste) the following Modelica code to the empty text field. When working with custom Modelica functions note that you need to press shift+enter to create new lines.

public input Real requestedhr[:];
+public input Real totalrequestedhr;
+public input Real availablehr;
+public output Real allocatedhr[size(requestedhr, 1)];
+algorithm
+requestaspercentage := zeros(size(requestedhr, 1));
+nofpeople := zeros(size(requestedhr, 1));
+for i in 1:size(requestedhr, 1) loop
+	requestaspercentage[i] := xidz(requestedhr[i], totalrequestedhr, 0);
+	nofpeople[i] := min(availablehr*requestaspercentage[i], requestedhr[i]);
+	allocatedhr[i] := nofpeople[i];
+end for;
+

To give you a quick rundown of the code logic, we have 3 input variables. First one tells how much workforce each projects wants, the second tells what the total number of requested people is and the third tells how many employees we have. The function outputs a vector that tells how many people it assigned to which project. In case there is more demand than available workforce, we calculate what percentage of the whole demand each project contributes and assign people accordingly.

Now that our custom Modelica function is ready we are going to use it in the EmployeesAssigned variable. Select EmployeesAssigned and on the right of the properties view select Function tab, double-click on the custom function to make it appear in the equation field. Give the function following parameters: RequestedNumberOfPeople, sum(RequestedNumberOfPeople), NumberOfEmployees.

+
+

Our custom function in variable properties view

+

Finally we need to change the calculation logic of NumberOfFreeEmployees. As EmployeesAssigned is now a vector variable just add sum() function around it in the equation field.

NumberOfFreeEmployees
+= NumberOfEmployees-sum(EmployeesAssigned)
+

Now the Workforce module is completed!

Finally, we are going to give the projects different parameters. Select Project2 and from the properties view select Parameters tab. By slowly double-clicking on a value you can change the starting time, deadline and work amount of a project.

+
+

Parameters of Project2

+

Set the following parameters.

Deadline: 40
+ProjectWorkAmount : 900
+StartTime: 0
+

Now we have completed a model with two Project modules, simulate to make sure your model is working.

By following the steps below you can add a new project module to the model. Our current implementation supports any number of projects.

1. Add a new Project module to the diagram
+2. Add a new auxiliary variable and name it WorkforceProject3
+3. Connect the new auxiliary variable with the module using a dependency arrow and connect it to the module in the input tab
+4. Update the equation field of RequestedWorkingSpeed to {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed, Project3.RequestedWorkingSpeed}
+5. Choose Project enumeration under configuration and add click add, name the new index to Project3
+6. Write ResponsedWorkingSpeed[Project3] as the equation for the new auxiliary variable
+7. Finally, customize the parameters of Project3 module in the Parameters tab
+

Create a third Project module using the instructions above with the following parameters.

Deadline: 20
+ProjectWorkAmount : 300
+StartTime: 10
+

To make the results of the simulation more readable we can add auxiliary variables that collect information from each of the Project modules. For example, we might be interested the behaviour of WorkQuality, RequiredWorkingHoursPerDay and DaysLateOnDeadline. Create an auxiliary variable for each of these, add Project enumeration to them and input the following equations.

DaysLateOnDeadline
+ = {Project1.DaysLateOnDeadline, Project2.DaysLateOnDeadline, Project3.DaysLateOnDeadline}
+
+ RequiredWorkHoursPerDay
+ = {Project1.RequiredWorkHoursPerDay, Project2.RequiredWorkHoursPerDay, Project3.RequiredWorkHoursPerDay}
+
+ WorkQuality
+ = {Project1.WorkQuality, Project2.WorkQuality, Project3.WorkQuality}
+

Remember to update these variables also if you intend to use more than 3 projects.

If you now simulate the model the results of RequiredWorkHoursPerDay should look like this.

+
+

RequiredWorkHoursPerDay results

+

And WorkQuality should look like this.

+
+

WorkQuality results

+

Reading results from DaysLateOnDeadline variable is hard as the variable keeps track of time before the deadline. To see the results more clearly we are going to create a custom bar chart. Right-click on Charts folder under the WorkModel and select New→Bar Chart, rename the chart to Project deadlines and rename the Title to Days late on deadline. Then choose the tab Variables, click on Add, select Write variable name and write DaysLateOnDeadline to the field. Bar charts automatically use the last time step of the simulation when retrieving variable values. The chart should like this.

+
+

DaysLateOnDeadline results

+

Now you have completed the advanced Simantics System Dynamics tutorial.

There are some features that neither of the tutorials cover that can be found in the documentation.

If you still want to practice using the tool, here are some ideas on how to further develop the model we just made.

1. The number of employees is currently a static variable, think of ways to simulate the hiring procedure of a company using stocks and flows
+2. Add more projects and think of ways to optimize project scheduling
+3. Add wages to employees and an external workforce that is used in case internal workforce isn't enough, minimize total costs
+

Happy simulating!

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ActivateExperiment.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ActivateExperiment.png index 8843321e..6f1162c4 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ActivateExperiment.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ActivateExperiment.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png new file mode 100644 index 00000000..08737377 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerations.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerations.png new file mode 100644 index 00000000..390ffe27 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddEnumerations.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules1.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules1.png new file mode 100644 index 00000000..caaddd4a Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules2.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules2.png new file mode 100644 index 00000000..49ef6c2f Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/AddingModules2.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CompletedProjectModule.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CompletedProjectModule.png new file mode 100644 index 00000000..9e2021f2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CompletedProjectModule.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ConfigurationStart.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ConfigurationStart.png index 185d9e27..a4208b65 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ConfigurationStart.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ConfigurationStart.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png new file mode 100644 index 00000000..4d47176d Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png new file mode 100644 index 00000000..5d6be548 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png new file mode 100644 index 00000000..a52c45c2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png new file mode 100644 index 00000000..51721c42 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/FirstSimulation.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/FirstSimulation.png index e1087cb1..a1cb24b0 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/FirstSimulation.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/FirstSimulation.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModelStructure2.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModelStructure2.png index fcb32883..8698b404 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModelStructure2.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModelStructure2.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModuleConnections1.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModuleConnections1.png index 34122819..21b27256 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModuleConnections1.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ModuleConnections1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NetResourcing1.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NetResourcing1.png index b47e9474..36de92eb 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NetResourcing1.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NetResourcing1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewEnumeration.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewEnumeration.png new file mode 100644 index 00000000..ea2f8b55 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewEnumeration.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunction.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunction.png new file mode 100644 index 00000000..297eb875 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunction.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunctionLibrary.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunctionLibrary.png new file mode 100644 index 00000000..44a316a2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewFunctionLibrary.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModel.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModel.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModule.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModule.png index 1e28ea43..ce5535c0 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModule.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/NewModule.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectParameters.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectParameters.png new file mode 100644 index 00000000..39e57ceb Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectParameters.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectRequestPeople.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectRequestPeople.png new file mode 100644 index 00000000..b7b51e1f Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ProjectRequestPeople.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png new file mode 100644 index 00000000..21d02e3d Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png new file mode 100644 index 00000000..169a89ff Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ShowModule.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ShowModule.png new file mode 100644 index 00000000..3d150060 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/ShowModule.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/TwoModules.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/TwoModules.png index 16fdd64b..c7b560a7 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/TwoModules.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/TwoModules.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkLoop.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkLoop.png new file mode 100644 index 00000000..e04da74b Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkLoop.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityResults.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityResults.png new file mode 100644 index 00000000..b0610507 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityResults.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityStructure.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityStructure.png new file mode 100644 index 00000000..5fb9a3f5 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkQualityStructure.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkStocks.png b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkStocks.png index 7c787f9a..fe11f2e4 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkStocks.png and b/bundles/org.simantics.sysdyn.wiki/Site/AdvancedTutorialImages/WorkStocks.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorial.html b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorial.html index 71077962..be2e49c5 100644 --- a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorial.html +++ b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorial.html @@ -1,31 +1,31 @@ -Tutorial: Basic System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

-

This tutorial introduces you to the basic components and concepts of the System dynamics modelling tool for Simantics. After completing this tutorial, you know how to configure and simulate a system dynamics model. An advanced tutorial is also available. This tutorial is part of the sysdyn documentation.

Model

-

We are going to create a simple population model. The model consists of the basic components: Auxiliaries, valves, stocks, dependencies and flows.

Start by creating a new model. Right-click on the model browser and select New -> Model.

+Tutorial: Basic System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

+

This tutorial gives an introduction to the Simantics System Dynamic Tool. We will go over how to create, simulate and analyze a simple system dynamic model. After completing this tutorial, if you wish, there is an advanced tutorial that goes more in-depth on the advanced features of the tool. It is recommended that you give a quick glance at first few chapters of the documentation before starting. You should especially familiarize yourself with the workbench of the tool to know the terminology used in the tutorials.

We are going to create the classic prey-predator model. In our case the model will describe how the population sizes of mice (prey) and owls (predator) change over time. The basic idea around the model is to capture the dynamics of two different population sizes. Let's assume a starting scenario where there is a large mice population and a small owl population. Owls start eating mice decreasing their population, and in turn, giving the owl population the opportunity to grow due to good food availability. However, as the mice population is decreasing and the owl population increasing, at some point there won't be enough food for the entire owl population, leading to starvation and consequently to a decrease in owl population size. The decreased owl population size then allows the mice population to regrow, as they have a smaller number of natural predators on the hunt.

This tutorial is a walkthrough for creating and analyzing such a model.

Creating a new model

+

Start by creating a new model from File→New→SD Model.


Creating a new model

-

Rename the model to Population. Right-click on Model1 and select Rename.

Expand the model tree and double-click on Configuration. The model configuration diagram opens in a new editor.

Configuring the model structure

-

Our model is now empty. Let's build a population model for mice.

Open Symbols view and expand BasicSymbols. If BasicSymbols are not visible, make sure that you have the diagram open. The contents of the Symbols view depends on the active diagram editor.

+

Rename the model to Population by slowly clicking twice on the model name in the Model Browser or by clicking the model once and changing the name from the properties view at the bottom of the tool. Then, expand the model tree and open the model diagram by double-clicking the Population model from Model Browser.

Configuring the model structure

+

Let's start by building a population model for the mice.

Drag the Symbols view from right of the Model Browser to underneath it and expand BasicSymbols for easier use. If BasicSymbols is not visible, make sure that you have the diagram open as the contents of the Symbols view depends on the active diagram editor.


Symbols view

-

These are the basic symbols in System dynamics modelling. We will use these to create the model.

Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using shortcut keys

Select the variable. Properties view on the bottom of the screen shows the properties of the selected variable. Change the name to Mice and press enter.

+

These are the basic symbols in System dynamic modelling that will be used to create the model.

Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using the middle mouse button.

Select the variable to bring up Properties view on the bottom of the tool. Change the name to Mice and press enter. You should have a red exclamation mark next to the symbol telling that the variable needs to have expressions for Integral and Initial Value fields. These are not shown in the pictures of this tutorial for visual clarity. We will write expressions to these fields later. You can find a collection of warnings and errors related to the model from the Issues tab right of the Properties tab.


-

Stock variable Mice

-

Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud. Move cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in the middle of the flow. The valve controls the speed of the flow. Flow from Mice is created the same way. Drag one cloud variable from Symbols view to the right hand side of Mice. Hold down Alt and right-click on Mice. Move cursor on top of the cloud and left-click. Rename the valves to MouseBirths and MouseDeaths.

+

Stock variable Mice with the Properties view open, issues can be found on the third tab from the left

+

Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud, then move your cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in between. The valve controls the speed of the flow, in this case the birthrate of Mice. We also need a flow going out from Mice to control the death rate. Let's create this using a shortcut. Right-click Mice while holding Alt down, then drag your mouse right of the Mice and press left-click while holding Alt down. Rename the valves to MouseBirths and MouseDeaths.


Flows in and out of Mice

-

Of course mice are not alone in the world. There are also owls that hunt mice. Create a similar structure below mice for owls.

+

Of course mice are not alone in our imaginary world. We also need owls that hunt mice. Create a similar structure for owls by copy-pasting and renaming. You can copy by drag selecting components and using the all familiar Ctrl+C and Ctrl+V.


Owls and mice

-

To control the births and deaths, we need auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve to control it. Drag the variables and rename them according to the picture below.

+

To control births and deaths we use auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve. Drag the variables and rename them according to the picture below.


Auxiliaries for valves

-

Arrow connections, dependencies, are created almost like flows. The difference is that the connection is started and ended with a left click and the connection can only be made between two existing variables. Connect the auxiliary variables and valves like in the picture below.

+

Next we need to draw dependency arrows to tell which components of the system have an interaction. Dependency arrows are created by Alt+left-clicking on a symbol and then clicking on another symbol. Connect components like in the picture below.


Dependency connections

Equations

-

As you can see from the model, we have made some shortcuts in our model to make it more simple. In reality, there are lots of other factors that affect mouse and owl populations. Let's however use this model as an example.

For the model to be simulated, each variable needs to have an equation. Equations can be configured from the property view, like the names. Input the following equations into the corresponding variables:

MouseBirths
+

Now we need to give each variable an equation, stock variables also need a value for initial population. Like names, equations can be configured from the property view. Input the following equations into the corresponding variables:

MouseBirths
 = MouseBirthRate * Mice
 
 MouseDeaths
@@ -48,22 +48,51 @@ OwlsFromMice
 
 OwlDeathRate
 = 0.09
-

Finally we need initial values for our populations.

Mice
+

Finally input initial population values for Mice and Owls.

Mice
 Initial Value: 700
 
 Owls
 Initial Value: 10
 

Simulating the model

-
+

Now the model is configured and ready for simulation. An experiment needs to be activated before a model can be simulated. Expand the Experiments folder of your model and double-click on Experiment to activate it. This adds experiment control buttons to the toolbar.


Experiment activation

-
Now the model is configured and ready for simulation. Switch Symbols view back to Model Browser. Expand the Experiments folder on your model and double-click on Experiment. This activates the experiment. Experiment needs to be active before the model can be simulated. Experiment activations adds experiment control buttons to the toolbar. To simulate the model, press the play button:
-

System shows the simulation progress in the progress bar on the lower right corner of the screen.

+

To simulate the model, press the play button:

+
+

System shows the simulation progress in the progress bar on the lower right corner of the screen. As our model is very simple the progress bar will most likely go by faster that you can see it.


-

When the progress indicator disappears, the simulation is complete.

After the simulation has run, you can select variables from the diagram or model browser and their values over the simulation time will be shown on Trend View. You can select multiple variables from the diagram by holding down Ctrl key. Select Mice and Owls.

+

When the progress indicator disappears, the simulation is complete.

After the simulation has been completed, you can select variables from the diagram or Model Browser and their values over the simulation time will be shown on Trend view. You can select multiple variables from the diagram by holding down Ctrl key or by drag selecting. Select Mice and Owls.


Results for Mice and Owls

-

As you can see, the simulation is complete, but the results do not reveal any interesting behavior. Let's extend the simulation time.

Select Configuration from the model browser. In the properties-view change stop time to 300.0 and simulate again.

After the simualtion is complete, Select Mice and Owls again.

+

As you can see, the simulation is complete, but the results do not reveal anything interesting. We need to extend the simulation time.

Select Configuration from the Model Browser. In the properties view change stop time to 300.0 and simulate again.

+
+

Model configuration

+

After the simulation is complete, Select Mice and Owls again.


-

Results for Mice and Owls, Extended simulation time

-

Now the simulation reveals the traditional behavior of predator-prey models. Feel free to adjust the parameters and try the simulations again.

\ No newline at end of file +

Results for Mice and Owls, extended simulation time

+

Now we can see the wanted behavior. As the mice population reaches a certain point the number of owls start to increase as they have more food. The increase in owl population lowers the mice population, leading to starvation between owls. The lowered owl population in turn allows the mice population grow back, and the cycle continues. In fact this model simulates the behavior of a pair of first-order nonlinear differential equations also known as Lotka-Volterra equations.

However, we can see that there is something wrong with the results; the peaks of the mice population are not on the same level. We are using a step-size that is too long. On default the step size is calculated by dividing the simulation time to 500 equal steps, meaning that the previous results were obtained using a step size of (300-0)/500=0.6. (For a more bizarre behavior try simulating with a stop time of 950 using the default step size.)

To combat this we can set the step size manually from the model configuration, the same place where we changed the simulation stop time. Change the step size to 0.01 and output interval to 1. Output interval allows us to manually configure the step size of the results, meaning that we can make the numerical errors arbitrarily small by lowering the simulation step size, while only having to handle a part of the steps used for the simulation. With these new parameters we now get the correct results.

+
+

Results for Mice and Owls with a simulation step size of 0.01

+

Result analysis

+

In this chapter we are going to go over how to analyze the resulting model structure, use comment symbols, create and export graphs in form of charts and export the simulated dataset. Let's start with the model structure analysis.

Often in system dynamics we are interested in how different feedback loops are formed inside of a model. There is a built in tool analyzing these. Open Structure view that is located between Trend and Values views, then select Loops tab. The contents update depending on the active selection, select OwlBirths symbol.

+
+

The loop structure of OwlBirths

+

We can see a feedback loop of 3 variables. You could interpret this loop as follows: owl births increase the number of owls, the more owls there are the more mice are going to get eaten, the more mice that end up as food the more owls can breed.

To make a visual representation of this feedback loop on the diagram we can utilize a comment symbol called Loop. Expand the CommentSymbols from Symbols and drag the symbol between Mice and Owls symbols. Then, from the properties view select Owls→MouseDeaths→OwlBirths from Loop Items and change the Direction of Rotation to counterclockwise. The Comment option is used for telling if the loop is reinforcing (R) or balancing (B). The symbol automatically detects this behavior, but you can also choose this manually or write your own explanation, if you wish. When you make the Loop symbol as your active selection it automatically highlights the symbols that are included in the loop to visualize how it is formed.

+
+

Loop comment symbol

+

The other comment symbol, called Comment, is purely for writing text in the diagram. It is useful, for example, when you want to have memos inside the diagram, or when you want to write an explanation for a design choice.

Let's move on to graphs. There are two ways of creating them, Trend view (that we have used before) and Charts. Trend view allows you to export the graph as .svg and .png file formats from the top-right controls. However, the built in graph tool has much more options for customizing a graph. Let's create a phase-space plot of the model.

Start by creating a new chart by right-clicking on the folder Charts under your model, then select New→Line Chart.

+
+

Creating a new chart

+

Double click the newly made chart to open it and keep the chart selected to access its properties. Name the chart Phase-space plot, tick hide title and hide legend options, type Owls as the x-axis variable and change the label name to Alive owls.

+
+

Chart general properties

+

Then, select the Axis and Variables tab on the bottom, click on y-axis and rename label to Alive mice, then click Add variable. Select the <Write variable name> and write Mice as the variable name.

+
+

Chart Axis and Variables properties

+

Now you should have a completed phase-space plot of the prey-predator model. To export a graph right click on it and select either Save as→PNG or Print... and select the pdf printer of your choice. Notice that in order to see results on the graph you need to have an active experiment that has finished a simulation.

+
+

Completed phase-space plot and export options

+

You might also want to export the simulated data. Currently the easiest way is to copy it to your clipboard. First, select all components by clicking on the diagram and pressing Ctrl+A on the keyboard. Then, select Values view from the bottom left, click on any numerical value to put the field in focus, finally Ctrl+A and Ctrl+C. Now you have all of the numerical data on your clipboard for pasting to the tool of your choosing.

+
+

Values view

+

This concludes the basic tutorial. If you wish to learn more about the advanced features of the tool, please refer to the wiki or the advanced tutorial.

Happy simulating!

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ActivatePopulationExperiment.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ActivatePopulationExperiment.png index 0eeeb7e6..52b012ad 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ActivatePopulationExperiment.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ActivatePopulationExperiment.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Auxiliaries.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Auxiliaries.png index 5cec62b8..30d7da36 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Auxiliaries.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Auxiliaries.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartAxisAndVariables.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartAxisAndVariables.png new file mode 100644 index 00000000..a65d0a99 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartAxisAndVariables.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartProperties1.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartProperties1.png new file mode 100644 index 00000000..4c8f0890 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ChartProperties1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Configuration1.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Configuration1.png new file mode 100644 index 00000000..0c5e42f6 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Configuration1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Dependency_connections.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Dependency_connections.png index eeb22288..dbbb05f2 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Dependency_connections.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Dependency_connections.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/LoopCommentSymbol.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/LoopCommentSymbol.png new file mode 100644 index 00000000..d7ed191b Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/LoopCommentSymbol.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Mice.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Mice.png index 601f77ee..7ec78f2a 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Mice.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/Mice.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults1.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults1.png index bee8c180..3137184c 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults1.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults2.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults2.png index cd8426fd..18034aa8 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults2.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults2.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults3.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults3.png new file mode 100644 index 00000000..d6065fc2 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwlResults3.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwls.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwls.png index 83b4b085..6964fa68 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwls.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceAndOwls.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceFlows.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceFlows.png index a910ea82..eaa381b2 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceFlows.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/MiceFlows.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/NewModel.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/NewModel.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/OwlBirthsLoopStructure.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/OwlBirthsLoopStructure.png new file mode 100644 index 00000000..26e13cd5 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/OwlBirthsLoopStructure.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png new file mode 100644 index 00000000..3a0da397 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/SymbolsView.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/SymbolsView.png index 74e6e0b5..e49faeca 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/SymbolsView.png and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/SymbolsView.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ValuesView.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ValuesView.png new file mode 100644 index 00000000..00ad3f7f Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/ValuesView.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/newChart.png b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/newChart.png new file mode 100644 index 00000000..9d92fcfc Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/BasicTutorialImages/newChart.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/BasicWorkbench.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/BasicWorkbench.png index f5a7ebb5..1ff45779 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/BasicWorkbench.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/BasicWorkbench.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/CompareTrend.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/CompareTrend.png index 35e63c2f..5466a5fd 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/CompareTrend.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/CompareTrend.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/ExampleFunction.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/ExampleFunction.png index 707ab4ed..37d9e095 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/ExampleFunction.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/ExampleFunction.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelProperties.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelProperties.png index 0c181522..b94d39aa 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelProperties.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelProperties.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelStructure.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelStructure.png index 131e9204..234df3e8 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelStructure.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/ModelStructure.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewChart.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewChart.png index 76b84c07..9d92fcfc 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewChart.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewChart.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewEnumeration.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewEnumeration.png index 40ecc979..ea2f8b55 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewEnumeration.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewEnumeration.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunction.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunction.png index 84517e28..16a43271 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunction.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunction.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunctionLibrary.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunctionLibrary.png index ca099d12..aaaabca4 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunctionLibrary.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewFunctionLibrary.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModel.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModel.png new file mode 100644 index 00000000..1280c002 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModel.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModule.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModule.png new file mode 100644 index 00000000..ce5535c0 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/Images/NewModule.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/PreferencesNew.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/PreferencesNew.png new file mode 100644 index 00000000..1c4271d6 Binary files /dev/null and b/bundles/org.simantics.sysdyn.wiki/Site/Images/PreferencesNew.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/Trend.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/Trend.png index 256e66af..3346ea1c 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/Trend.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/Trend.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/Values.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/Values.png index f55734e3..80ccb976 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/Values.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/Values.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup1.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup1.png index 08df607b..e9a7f3db 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup1.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup1.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup2.png b/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup2.png index 3f69912f..7c20b0b8 100644 Binary files a/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup2.png and b/bundles/org.simantics.sysdyn.wiki/Site/Images/WithLookup2.png differ diff --git a/bundles/org.simantics.sysdyn.wiki/Site/sysdyn.html b/bundles/org.simantics.sysdyn.wiki/Site/sysdyn.html index 0f3f54ac..97a86ee7 100644 --- a/bundles/org.simantics.sysdyn.wiki/Site/sysdyn.html +++ b/bundles/org.simantics.sysdyn.wiki/Site/sysdyn.html @@ -1,33 +1,33 @@ -Simantics System Dynamics

Simantics System Dynamics

Contents

What is Simantics System Dynamics

-

Simantics System Dynamics is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through some changes in the future. New features will be added and old ones improved according to the needs of the modellers.

This documentation introduces you to the current version of Simantics System Dynamics. Documentation includes the basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, install the software and try our basic and advanced tutorials!

Introduction to System Dynamics Simulation

+Simantics System Dynamics

Simantics System Dynamics

Contents

What is Simantics System Dynamics

+

Simantics System Dynamics is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through changes in the future. New features will be added and old ones improved according to the needs of modellers.

This documentation introduces you to the current version of Simantics System Dynamics. The documentation includes basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, install the software and try our basic and advanced tutorials!

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. Simantics System Dynamics is a free modelling tool for system dynamics modeling and simulation. See installation instructions.

Model

System dynamics model is generally understood as the model configuration. In this tool, the model contains also other components: Experiments are the way to simulate the model. 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. Module types allow user to create reusable component types which can be instantiated as Modules. The Modules folder contains all the different module types in your model and you can create new module types there. The Functions folder contains built-in and user-defined functions.


Model structure

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, Delay and WithLookup. Auxiliary is the default type. Parameters are static 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 and Delay are special variables. WithLookup has an expression and a lookup table. The expression defines what value is taken from the defined table. Delay variable delays an equation a given time with a given delay order.

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. Dependencies that are used for a stock initial value only are colored grey by default, in contrast to the regular blue dependency arrows.

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. Alternatively, the equation that is integrated can be defined manually by user. A stock must be given an initial value. 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.

Shadow

A shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model.

Loop

A loop element is a graphical component for highlighting selected feedback loops in a model.

Comment

A comment element is a string of text on diagram.

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. Note that due to the reserved words in Modelica, variable names such as Carbon in Atmosphere cannot be used (in is a reserved word). Capitalizing the reserved (in --> In) word can be used to sidestep the problem.

Connections

You should usually try to avoid overlapping dependency arrows. Organizing the variables on the diagram and using shadow variables can be used for that purpose. 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. Annotations are important, for communicating the behavior of the model.

Installation Instructions

-

System dynamics tool is provided with the Simantics platform.

  1. Download installer from the tool's download page

  2. Install the program to a directory without spaces (limitation inherited from OpenModelica).

  3. Run the application through the launcher generated by the installer

    (default: Simantics\Simantics-1.8.0-Sysdyn-32\Simantics-1.8.0-Sysdyn-32)

OpenModelica is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install OpenModelica. In addition to OpenModelica, a development version of a purpose-built Modelica solver is embedded in the tool.

Workbench

+

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, Delay and WithLookup. Auxiliary is the default type. Parameters are static 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 and Delay are special variables. WithLookup has an expression and a lookup table. The expression defines what value is taken from the defined table. Delay variable delays an equation a given time with a given delay order.

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. Dependencies that are used for a stock initial value only are colored grey by default, in contrast to the regular blue dependency arrows.

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. Alternatively, the equation that is integrated can be defined manually by user. A stock must be given an initial value. 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.

Shadow

Shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model.

Loop

Loop element is a graphical component for highlighting selected feedback loops in a model.

Comment

Comment element is a string of text on diagram.

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. Note that due to the reserved words in Modelica, variable names such as Carbon in Atmosphere cannot be used (in is a reserved word). Capitalizing the reserved (in → In) word can be used to sidestep the problem.

Connections

You should usually try to avoid overlapping dependency arrows. Organizing the variables on the diagram and using shadow variables can be used for that purpose. 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. Annotations are important for communicating the behavior of the model.

Installation Instructions

+

System dynamics tool is provided with the Simantics platform.

  1. Download installer from the tool's download page

  2. Install the program to a directory without spaces or special characters (limitation inherited from OpenModelica).

  3. Run the application through the launcher generated by the installer

OpenModelica is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install the latest official 64bit release of OpenModelica. In addition to OpenModelica, a development version of a purpose-built Modelica solver is embedded in the tool.

If you plan on creating large models or using a long simulation time with a small step size, it is advised that you give the tool more memory by increasing the numerical value of property -Xmx in the file Simantics-Sysdyn.ini.

Workbench


-

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

Symbols view (stacked with the model browser) is used for dragging elements to diagrams.

Search

Search view (stacked with the model browser) is used for searching elements in all models. Search can be launched also from the search field in the bottom right corner or by Ctrl+F.

3 Properties

Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, Indexes, and Additional information.

Console

Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica.

Issues

Issue view (stacked with the property view) shows the errors and warnings in all models.

Profiles

Profiles view (stacked with the property view) allows enabling/disabling some visual diagram effects.

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.

Structure

The structure view (stacked with the trend view) can be used for analyzing the varaible dependencies, loops, and the structure of the model.

Values

The values view (stacked with the trend view) shows the values of the selected value over time. For the values to be shown, a simulation has to be run.

5 Save and save as...

Save buttons can be used to export the selected model as .sysdyn file. The buttons save that model which is selected in the model browser or, if the focus is on the diagram, the model that is currently open on the diagram.

6 Diagram tool mode

With the diagram tool mode, you can select how the elements on the diagram are edited. The Lock mode prohibits editing diagram elements, the pointer mode allows moving and editing diagram elements, and with the dependency and flow modes arrows can be drawn using only mouse1 and mouse2.

7 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.

8 Perspectives

Perspectives allow changing between different layouts of the views. On start-up, only the default perspective is open. Try adding the two predefined perspectives by clicking the Open Perspective button:
-

9 Chart Panel

Chart panel is able to house multiple charts at the same time. Charts are added to the panel by dragging from model browser.

TIP! If you accidentally close a view, you can reopen them from Window->Show View->Other...

TIP! Try dragging the views to different positions (e.g. the property view to the right pane).

Global Preferences

Global preferences of Simantics System Dynamics are located under Window -> Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below.

-
-
CategoryDescription
General -> KeysAll keyboard shortcuts available.
ModelicaThe location of OpenModelica solver on file system.
SolverSolver to be used for simulation. OpenModelica or internal custom solver (experimental) can be selected.
Sysdyn DiagramsSysdyn Diagrams allows customize default colors and fonts of diagram elements.

Modelling

+

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

Symbols view (stacked with the model browser) is used for dragging elements to diagrams.

3 Properties (MouseBirths in the image above)

Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, indices, and Additional information.

Console

Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica.

Issues

Issue view (stacked with the property view) shows the errors and warnings in all models.

Profiles

Profiles view (stacked with the property view) allows enabling/disabling some visual diagram effects.

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.

Structure

The structure view (stacked with the trend view) can be used for analyzing the variable dependencies, loops, and the structure of the model.

Values

The values view (stacked with the trend view) shows the values of the selected value over time. For the values to be shown, a simulation has to be run.

5 Save and save as...

Save buttons can be used to export the selected model as .sysdyn file. The buttons save that model which is selected in the model browser or, if the focus is on the diagram, the model that is currently open on the diagram.

6 Diagram tool mode

With the diagram tool mode, you can select how the elements on the diagram are edited. The Lock mode prohibits editing diagram elements, the pointer mode allows moving and editing diagram elements, and with the dependency and flow modes arrows can be drawn using only mouse1 and mouse2.

7 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.

8 Perspectives

Perspectives allow changing between different layouts of the views. On start-up, only the default perspective is open. Try adding the two predefined perspectives by clicking the Open Perspective button:
+

9 Chart Panel

Chart panel is able to house multiple charts at the same time. Charts are added to the panel by dragging from model browser.

TIP! If you accidentally close a view, you can reopen them from Window→Show View→Other...

TIP! Try dragging the views to different positions (e.g. the property view to the right pane).

Global Preferences

Global preferences of Simantics System Dynamics are located under Window → Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below.

+
+
CategoryDescription
General → KeysAll keyboard shortcuts available.
ModelicaThe location of OpenModelica solver on file system.
SolverSolver to be used for simulation. OpenModelica or internal custom solver (experimental) can be selected.
Sysdyn DiagramsSysdyn Diagrams allows customize default colors and fonts of diagram elements.

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.

-
-

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 -> SD Model.

-
-

Creating a new module type

Create a new module type by right-clicking on the Modules-folder and selecting New -> Module type. 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 respective module type!

Populate variables

You can drag variables to a diagram from symbol view. You can also populate variables using shortcut keys. Variables can be divided into multiple lines by resizing the variable on diagram.

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. Dependencies and flows can also be created without Alt key by selecting dependency or flow mode on the toolbar.

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
+    
+

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 → SD Model.

+
+

Creating a new module type

Create a new module type by right-clicking on the Modules-folder and selecting New → Module type. 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 respective module type!

Populate variables

You can drag variables to a diagram from symbol view. You can also populate variables using shortcut keys. Variables can be divided into multiple lines by resizing the variable on diagram.

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. Dependencies and flows can also be created without Alt key by selecting dependency or flow mode on the toolbar.

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 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 the Inputs tab stacked under Module Properties you can select which variables you connect to inputs inside the module. In the Outputs tab you can 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->Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database.

Import model

Right-click on the model browser and select Import->Model. Browse to your .sysdyn file and select open. The model is added to your model browser.

Export module

To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export->Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database.

Import module

Right-click the Modules folder of a model and select Import->Module. Browse to your .sysdynModule file and select open. The module is added to your model.

Model Properties

Model properties can be viewed by selecting either the model or its configuration on the model browser.

+ANY VARIABLE -----> MODULE +

This is just the visual configuration, but you need those connections to really connect variables in the module's properties.

In the Inputs tab stacked under Module Properties you can select which variables you connect to inputs inside the module. In the Outputs tab you can 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 send their values outside the module. To make a variable output its values, from the properties view make sure the Is Output checkbox is ticked.

Configure variables

Select a single variable from diagram or model browser. The properties of the variables are shown in the properties view where you can also 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→Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database.

Import model

Select File→Import Model, browse to your .sysdyn file and select open. The model is added to your model browser.

Export module

To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export→Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database.

Import module

Right-click the Modules folder of a model and select Import→Module. Browse to your .sysdynModule file and select open. The module is added to your model.

Model Properties

Model properties can be viewed by selecting either the model or its configuration on the model browser.


-
PropertyDescription
NameThe name of the model
Start timeThe start time of the simulation.
Stop timeThe stop time of the simulation.
Step lengthThe length of the simulation step.
Output intervalInterval of witch the simulation result is presented. If the field is left empty, all steps of the output are presented.
MethodThe simulation solver (only OpenModelica).
Validate unitsUnit validation on/off. If unit validation is enabled, the unit of the simulation time is selected from the pull-down menu.
Unit equivalentsDefine if different forms of predefined units are considered equal (e.g. dollars = dollar = $) in unit validation.
ToleranceIntegrator error tolerance (only OpenModelica)
Variable filterDefine which variables are presented (only OpenModelica)

Special Variables

Auxiliary and valve variables have two special types: WithLookup and Delay. These types are selected from Type drop down menu in the variable's properties. The variable types offer more specific functionalities than normal variables, but the same functionality could be achieved using normal variables.

WithLookup

WithLookup variable has two equation fields, WithLookup and Lookup table. Lookup table has a table from which the value of the variable is interpolated using the value of WithLookup field.

+
PropertyDescription
NameThe name of the model
Start timeThe start time of the simulation.
Stop timeThe stop time of the simulation.
Step lengthThe length of the simulation step.
Output intervalInterval of witch the simulation result is presented. If the field is left empty, all steps of the output are presented.
MethodThe simulation solver (only OpenModelica).
Validate unitsUnit validation on/off. If unit validation is enabled, the unit of the simulation time is selected from the pull-down menu.
Unit equivalentsDefine if different forms of predefined units are considered equal (e.g. dollars = dollar = $) in unit validation.
ToleranceIntegrator error tolerance (only OpenModelica)
Variable filterDefine which variables are presented (only OpenModelica)

Special Variables

Auxiliary and valve variables have two special types: WithLookup and Delay. These types are selected from Type drop down menu in the variable's properties. The variable types offer more specific functionalities than normal variables, but the same functionality could be achieved using normal variables.

WithLookup

WithLookup variable has two equation fields, WithLookup and Lookup table. Lookup table has a table from which the value of the variable is interpolated using the value of WithLookup field.


-

You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clickin on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click.

+

You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clicking on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click.


Delay

Delay variables build equations for Nth order delays. Users can set the equation for the value that is to be delayed, the time and order of the delay and a possible start value. If start value is empty, the start value is set automatically.


@@ -56,25 +56,25 @@ equation end Delay3_delayClass;

The above definitions can be seen as a line of stocks and valves. The first valve, delay0, is given the value of the delayed expression. Delay3 is given the value of the valve that is coming from the last stock.

Equations:

Delay3_delayClass_instance.delay0 = Step1;
 Delay3 = Delay3_delayClass_instance.delay3;
-

Shortcut and Control Keys

Shortcut keys for configuring a model on diagram.

KeyAction
EscCancel operations (e.g. connection and rename).
Shift + AHover Auxiliary at the cursor position, populate with left mouse button.
Shift + SHover Stock at the cursor position, populate with left mouse button.
Shift + CHover Cloud at the cursor position, populate with left mouse button.
Shift + VHover Valve at the cursor position, populate with left mouse button.
Shift + IHover Input at the cursor position, populate with left mouse button.
Shift + GHover Shadow (Ghost) variable at the cursor position, populate with left mouse button.
Alt + left mouse buttonStart an arrow from a variable. End to another variable by clicking left mouse button.
Alt + right mouse buttonStart 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.
DeleteRemove selected variables
F2Rename selected variable
Ctrl + left mouse buttonSelect multiple variables
Mouse wheel or + or -Diagram zoom
drag(mouse3)Diagram pan
drag(shift + any mouse button)Diagram pan
↓, ←, ↑, → (arrow keys)Diagram pan
Ctrl + CCopy selected elements
Ctrl + XCut selected elements
Ctrl + VPaste copied or cut elements
Ctrl + FFind element in current diagram or all models
GShow / hide grid
RShow / hide ruler
1Fit diagram contents to screen
Ctrl + SpaceContent assist in equation editor

Other shortcut keys can be found selecting Window -> Preferences from the main menu. Keys are located in General -> Keys.

Unit Validation

Unit validation is useful for finding errors in the model. With unit validation, the consistency of the measurement units of variables is checked. For unit validation, the units of all variables in the model must be defined. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.

Common error sources of unit validation include the following. The respective issues are shown in the picture below.

+

Shortcut and Control Keys

Shortcut keys for configuring a model on diagram.

KeyAction
EscCancel operations (e.g. connection and rename).
Shift + AHover Auxiliary at the cursor position, populate with left mouse button.
Shift + SHover Stock at the cursor position, populate with left mouse button.
Shift + CHover Cloud at the cursor position, populate with left mouse button.
Shift + VHover Valve at the cursor position, populate with left mouse button.
Shift + IHover Input at the cursor position, populate with left mouse button.
Shift + GHover Shadow (Ghost) variable at the cursor position, populate with left mouse button.
Alt + left mouse buttonStart an arrow from a variable. End to another variable by clicking left mouse button.
Alt + right mouse buttonStart 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.
DeleteRemove selected variables
F2Rename selected variable
Ctrl + left mouse buttonSelect multiple variables
Mouse wheel or + or -Diagram zoom
drag(mouse3)Diagram pan
drag(shift + right mouse button)Diagram pan
↓, ←, ↑, → (arrow keys)Diagram pan
Ctrl + CCopy selected elements
Ctrl + XCut selected elements
Ctrl + VPaste copied or cut elements
Ctrl + FFind element in current diagram or all models
GShow / hide grid
RShow / hide ruler
1Fit diagram contents to screen
Ctrl + SpaceContent assist in equation editor

Other shortcut keys can be found selecting Window → Preferences from the main menu. Keys are located in General → Keys.

Unit Validation

Unit validation is useful for finding errors in the model. Unit validation checks the consistency of units. To use this feature you need to define units for every variable used in the model. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.

Common error sources of unit validation include the following. The respective issues are shown in the picture below.


  • The equation of a variable yields a different unit than that defined for the variable.

  • Two variables which have different units are added (+), subtracted (-), or compared (>, <, =, ...).

  • The output unit of a function is used in an inconsistent manner. (The unit validation for the output unit of a function behaves equivalently to the unit of a variable.)

  • A function is called with an argument of a prohibited unit.

  • A variable has an empty unit.

  • A variable has a misspelled unit.

Unit validation is enabled for a model by selecting the model or its configuration on the model browser and enabling "Validate units" on the properties tab. The unit warnings are shown on Issues view and, supposing the respective profile has been enabled, on the diagram as well. Warnings from unit validation do not prevent simulation.

For models that have stocks (i.e., integration), the simulation time unit must be selected from the pull-down menu next to the "Validate units" checkbox in Model Properties tab.

Unit validation can also cope with certain different forms of units, e.g., you can write dollars, dollar, or $ and the validator considers these equal. This functionality can be disabled from Model Properties tab checkbox "Unit equivalents".

As there may be cases for which the unit validation is for some reason not working as desired, the unitCast() function can be used in the equation of a variable to cast the unit of any expression within the equation to a wildcard. E.g., if expression

    Aux1 + time
 

yields a warning, it can be fixed be changing the expression to

    unitCast(Aux1) + time
-

, in which case the unit of the expression is that of time, or to

    Aux1 + unitCast(time)
-

, in which case the unit of the expression is that of Aux1.

Diagram Profiles

Diagram profiles allow selecting which visual effects are enabled. Currently the following profiles can be used:

Default

Issue warnings

When enabled, an error or a warning symbol is attached to diagram elements in which there are errors or warnings (usually in the equations).

Shadow variable visualizations

When enabled, the original and all the shadow variables are highlighted when one is selected.

Simulation Playback

Playback Colors

When enabled, colors of the elements on diagram change during a playback experiment.

Visual model elements

-

The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool offers are comment symbols which do not affect simulation but help the understandability of models.

Fonts and colors

Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window -> Preferences -> Sysdyn Diagrams.

Dependency properties

Dependency arrow properties can be changed on the property view:

Polarity

Polarity sign can be used to indicate whether the dependency increases or decreases the variable it is pointing to. The polarities serve no function for simulation, however, they are used in loop type automatic determination.

Location

Location of the polarity mark

Arrowhead

Toggle for showing arrowhead

Delay mark

Delay mark is a visual cue for helping understandability of the dynamics of the model when there are (information) delays. A delay mark is usually added to the dependency arrow when the effect the tail of the dependency has on the head of the dependency is delayed.

Line thickness

Thickness of the arrow

Loops

A loop element is a graphical component for highlighting feedback loops in a model. Usually the most interesting feedback loops that affect the behaviour of the model most are marked with a loop symbol.

Loop Items

The loop of variables which the loop symbol refers can be selected for visualization purposes.

Comment

Comment inside the loop. Usually characters 'B' and 'R' are used to denote balancing and reinforcing loops, respectfully. A feedback loop is reinforcing if and only if it has an even number of negative dependencies. Selecting 'Auto' determines automatically the type of the loop.

Direction of Rotation

Direction to which the loop rotates on diagram.

Comments

Comments are just strings of text.

Simulation

-

Experiments

There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics.

Experiments are created from the context menu of experiments folder in a model.

+

in which case the unit of the expression is that of time, or to

    Aux1 + unitCast(time)
+

in which case the unit of the expression is that of Aux1.

Diagram Profiles

Diagram profiles allow selecting which visual effects are enabled. Currently the following profiles can be used:

Default

Issue warnings

When enabled, an error or a warning symbol is attached to diagram elements in which there are errors or warnings (usually in the equations).

Shadow variable visualizations

When enabled, the original and all the shadow variables are highlighted when one is selected.

Simulation Playback

Playback Colors

When enabled, colors of the elements on diagram change during a playback experiment.

Debugging a model

If you find yourself with a model that doesn't simulate or has bizarre behavior, there are several places to look for clues for what went wrong. Firstly, if you got an error message and can't infer the problem straight from the message, look at the issues view if it can tell you what is wrong in different words. If you know how to read Modelica code, right click Configuration under the broken model and choose Open With → Modelica Code Viewer. The tool works by generating Modelica code from the graphical model and then solving it. Therefore, if something is broken it means that there is a problem with the generated Modelica code (or, very rarely, a bug in the solver you are using). You can also refer to the list below, if you still find yourself stuck.

Some of the most common errors include:

  • In a model that uses modules, you forget to connect inputs and/or outputs in the module properties

  • You forgot to add an enumeration to a variable, i.e. trying to put a vector to a scalar variable (or vice versa)

  • You increased the enumeration indices you are using, but forget to update a variable that depend on it

  • You wrote a custom Modelica function, but it is broken

  • You are comparing two numbers for equality while using OpenModelica solver (forbidden, allowed by the internal solver)

  • You have a variable that refers to itself in the equation, making the solver unable find an initial value

If you are using OpenModelica solver it can be very useful to google error messages printed in the console of the tool.

Visual model elements

+

The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool has comment symbols which do not affect simulation but help the understandability of models.

Fonts and colors

Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window → Preferences → Sysdyn Diagrams.

Dependency properties

Dependency arrow properties can be changed on the property view:

Polarity

Polarity sign can be used to indicate whether the dependency increases or decreases the variable it is pointing to. The polarities serve no function for simulation, however, they are used in loop type automatic determination.

Location

Location of the polarity mark

Arrowhead

Toggle for showing arrowhead

Delay mark

Delay mark is a visual cue for helping understandability of the dynamics of the model when there are (information) delays. A delay mark is usually added to the dependency arrow when the effect the tail of the dependency has on the head of the dependency is delayed.

Line thickness

Thickness of the arrow

Loops

A loop element is a graphical component for highlighting feedback loops in a model. Usually the most interesting feedback loops that affect the behaviour of the model most are marked with a loop symbol.

Loop Items

The loop of variables which the loop symbol refers can be selected for visualization purposes.

Comment

Comment inside the loop. Usually characters 'B' and 'R' are used to denote balancing and reinforcing loops, respectfully. A feedback loop is reinforcing if and only if it has an even number of negative dependencies. Selecting 'Auto' determines automatically the type of the loop.

Direction of Rotation

Direction to which the loop rotates on diagram.

Comments

Comments are just strings of text.

Simulation

+

Experiments

There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics. Currently some of the experiment and solver combinations are still in development.

Experiments are created from the context menu of experiments folder in a model.


-

Double-click on an experiment activates it and displays experiment type specific controls in the main tool bar.

Normal simulation

Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run.

Game simulation

Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended.

Simulation playback

Simulation playback works essentially as the basic experiment, but it offers some additional visualization options.

Sensitivity analysis simulation

Sensitivity analysis allows running multivariate Monte Carlo simulations with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters.

+

Double-click on an experiment activates it and displays experiment type specific controls in the main tool bar.

Normal simulation

Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run. Works on both the internal and OpenModelica solvers.

Game simulation

Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended. Works on the internal solver, OpenModelica version still in development.

Simulation playback

Simulation playback works essentially as the basic experiment, but it offers some additional visualization options. Works on both solvers.

Sensitivity analysis simulation

Sensitivity analysis allows running multivariate Monte Carlo simulations with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters. Works on OpenModelica solver, internal solver implementation still in development.


-
General-
NameThe name of the sensitivity analysis experiment. Displayed in e.g. model browser.
Number of runsThe total amount of individual simulation runs
MethodThe method of how the parameter values are selected from the distribution(s). Selecting "Random" yields pseudo-random values, i.e., randomly selected from the distribution(s). Selecting "Halton" yields a quasi-random Halton sequence of values selected deterministically to represent the distribution(s) better than a pseudo-random series.
SeedThe seed number for pseudo-random generator
Add parameterAdds a new parameter to be varied
RemoveRemoves a parameter
Parameter properties-
VariableThe full path of the variable of which value is varied. This field has content assistant, which shows the possible variables as you type.
RangeUsed with multidimensional values to select which dimensions are varied.
DistributionProbability distribution for the varied parameter. "Normal" is for truncated normal distribution and "Uniform" for uniform distribution. With "Interval" the values have equal intervals between each other and are selected in increasing order. In multivariate sensitivity analyses, it is recommended to select either "Normal" or "Uniform".
Distribution properties-
Min valueMinimum value of the distribution
Max valueMaximum value of the distribution
MeanMean of the normal distribution
Standard deviationStandard deviation of the normal distribution

Solvers

Simantics System Dynamics allows using the multiple solvers provided by OpenModelica, like Euler, Runge-Kutta, DASSL, etc. OpenModelica is currently the main simulation environment behind the tool and all functionalities are supported with OpenModelica.

Alternatively to OpenModelica, an internal custom Modelica solver is included in Simantics System Dynamics. The custom solver is currently at an experimental state, and thus all functionalities of the tool are not yet supported, e.g., only the basic experiment can be run with it. The advantage of the custom solver is, however, that simulation is usually a lot faster than with OpenModelica. Try out yourself which solver suits best for your needs.

The solver can be changed in Windows -> Preferences -> Solver.

Simulation Result and Model Structure Analysis

-

Simulation results can be viewed as trends in the trend view or as plain numbers in the values view. The views display results of variables that are selected in the workbench. Users can also create custom charts.

Model structure can be examined in the Structure view. There are three options: dependency structures of individual variables, the complete hierarchy structure of the model, or the feedback loops which individual variables belong to.

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.

+
General-
NameThe name of the sensitivity analysis experiment. Displayed in e.g. model browser.
Number of runsThe total amount of individual simulation runs
MethodThe method of how the parameter values are selected from the distribution(s). Selecting "Random" yields pseudo-random values, i.e., randomly selected from the distribution(s). Selecting "Halton" yields a quasi-random Halton sequence of values selected deterministically to represent the distribution(s) better than a pseudo-random series.
SeedThe seed number for pseudo-random generator
Add parameterAdds a new parameter to be varied
RemoveRemoves a parameter
Parameter properties-
VariableThe full path of the variable of which value is varied. This field has content assistant, which shows the possible variables as you type.
RangeUsed with multidimensional values to select which dimensions are varied.
DistributionProbability distribution for the varied parameter. "Normal" is for truncated normal distribution and "Uniform" for uniform distribution. With "Interval" the values have equal intervals between each other and are selected in increasing order. In multivariate sensitivity analyses, it is recommended to select either "Normal" or "Uniform".
Distribution properties-
Min valueMinimum value of the distribution
Max valueMaximum value of the distribution
MeanMean of the normal distribution
Standard deviationStandard deviation of the normal distribution

Solvers

Simantics System Dynamics allows using the multiple solvers provided by OpenModelica, like Euler, Runge-Kutta, DASSL, etc. OpenModelica is currently the main simulation environment behind the tool and all functionalities are supported with OpenModelica.

Alternatively to OpenModelica, an internal custom Modelica solver is included in Simantics System Dynamics. The custom solver is currently at an experimental state, and thus all functionalities of the tool are not yet supported, e.g., only the basic experiment can be run with it. The advantage of the custom solver is, however, that simulation is usually a lot faster than with OpenModelica. Try out yourself which solver suits best for your needs.

The solver can be changed in Windows → Preferences → Solver.

Simulation Result and Model Structure Analysis

+

Simulation results can be viewed as trends in the trend view or as plain numbers in the values view. The views display results of variables that are selected in the workbench. Users can also create custom charts.

Model structure can be examined in the Structure view. There are three options: dependency structures of individual variables, the complete hierarchy structure of the model, or the feedback loops which individual variables belong to.

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. You can also export the trend using controls in the upper right corner.


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. Selected values can be copied to other software in csv format.


-

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 Results button:

+

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. This functionality currently only works for the OpenModelica solver, internal solver implementation is in development. You can save your results after simulating by clicking the Save Results button:


-

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.

+

on your experiment controls. The saved results appear to model browser under the active experiment. To show the results on trends and tables, double click on the result to activate it.


Dependencies

Dependencies display 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 configured at the bottom of the view.


@@ -82,49 +82,49 @@ Delay3 = Delay3_delayClass_instance.delay3;

Loops

Loops display all feedback loops which the selected variable belongs to.


-

Custom Charts

+

Custom Charts

Custom charts are user-defined displays of simulation result data. They can be used and re-used in various places. The four types of custom charts (line, sensitivity, bar, and pie charts) provide model developers means for examining and developing their models and communicating the simulation results to others.

Custom charts are created to the Charts folder in model browser.


-

Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts.

Line Chart

Line chart shows the time series of a variable. It is capable of displaying multiple multi-dimensional variables at the same time. Simulation playback mode adds a marker to the chart to display the current time in playback simulation. Below is an example chart and its settings.

+

Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts.

Line Chart

Line chart shows the time series of a variable. It is capable of displaying multiple multi-dimensional variables at the same time. Simulation playback mode adds a marker to the chart to display the current time in playback simulation. Below is an example chart and its settings.



-
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleThe title of the chart. Displayed in the chart
TypeLine chart (default) or area chart
HideOptions to hide chart grid, title or legend
X-axis-
VariableA variable that is used as the x-axis variable. The default variable is time and it needs not to be typed in the field.
LabelOptional other label for the variable than its name
MinMinimum value of the x-axis
MaxMaximum value of the x-axis
HideOptions to hide x-axis label, line, tick marks and tick labels
+
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleThe title of the chart. Displayed in the chart
TypeLine chart (default) or area chart
HideOptions to hide chart grid, title or legend
X-axis-
VariableA variable that is used as the x-axis variable. The default variable is time and it needs not to be typed in the field.
LabelOptional other label for the variable than its name
MinMinimum value of the x-axis
MaxMaximum value of the x-axis
HideOptions to hide x-axis label, line, tick marks and tick labels

-
Variable-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed.
ColorColor for the lines of this variable
Line widthThe width of the lines drawn for this variable

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Sensitivity Chart

Sensitivity chart shows the time series of a variable with confidence bounds. Below is an example chart and its settings. The general settings are defined similarly to those of a line chart explained above.

+
Variable-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed.
ColorColor for the lines of this variable
Line widthThe width of the lines drawn for this variable

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Sensitivity Chart

Sensitivity chart shows the time series of a variable with confidence bounds. Below is an example chart and its settings. The general settings are defined similarly to those of a line chart explained above.



-
Axis and Variables-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
Display medianDisplay the median value of the variable at each time step.
Confidence bounds and colorsThe confidence bounds in percents and colors for them.

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Bar Chart

Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time.

+
Axis and Variables-
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
Display medianDisplay the median value of the variable at each time step.
Confidence bounds and colorsThe confidence bounds in percentages and colors for them.

There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab.

Y-axis-
LabelLabel of the axis
MinMinimum value in the axis
MaxMaximum value in the axis
ColorThe color of the axis lines, ticks and labels
HideOptions to hide parts of the axis: label, axis line, tick marks, tick labels

Bar Chart

Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time.


-
General-
NameThe name of the chart. Name is displayed in model browser.
TitleThe title of the chart. Title is displayed in the chart, if not hidden
TypeNormal or stacked. Normal type displays all variables in separate bars. Stacked mode is able to display one-dimensional array variables in stacks.
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOption for hiding grid, title and Legend. Legend is hidden by default since it only contains the information that the current simulation is displayed.
+
General-
NameThe name of the chart. Name is displayed in model browser.
TitleThe title of the chart. Title is displayed in the chart, if not hidden
TypeNormal or stacked. Normal type displays all variables in separate bars. Stacked mode is able to display one-dimensional array variables in stacks.
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOption for hiding grid, title and Legend. Legend is hidden by default since it only contains the information that the current simulation is displayed.

Charts can be added to model diagrams simply by dragging the chart from model browser to diagram.


-
Variable-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
+
Variable-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.

-
Domain axis-
LabelAn optional label for x axis
Label angleAxis labels can be displayed in an angle. This value determines the angle in degrees.
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels
Range axis-
LabelAn optional label for y axis
MinMinimum value of y axis
MaxMaximum value of y axis
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels

Pie Chart

Pie charts display proportions of variables at a certain time. The time, similar to bar charts, can be configured for the whole chart and individually for each variable. If no time is configured, the value at the latest time step (or the time of simulation playback) is displayed.

+
Domain axis-
LabelAn optional label for x axis
Label angleAxis labels can be displayed in an angle. This value determines the angle in degrees.
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels
Range axis-
LabelAn optional label for y axis
MinMinimum value of y axis
MaxMaximum value of y axis
ColorThe color of the axis line, tick lines and labels
HideOptions for hiding axis label, line, tick marks and tick labels

Pie Chart

Pie charts display proportions of variables at a certain time. The time, similar to bar charts, can be configured for the whole chart and individually for each variable. If no time is configured, the value at the latest time step (or the time of simulation playback) is displayed.


-
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleTitle The title of the chart. Displayed in the chart
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOptions for hiding title, section labels and legend
+
General-
NameThe name of the chart. Displayed in e.g. model browser
TitleTitle The title of the chart. Displayed in the chart
TimeA general time setting for the entire chart. The values at this time are displayed in the chart
HideOptions for hiding title, section labels and legend

-
Variables-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
ColorColor for the sector of this variable
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
ExplodedIf set, the sector(s) of the variable(s) are "exploded" away from the center of the pie chart
+
Variables-
Add / RemoveAdd or remove variables
VariableThe full path of the variable. This field has content assistant, which shows the possible variables as you type.
RangeIf the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions.
LabelOptional label for the variable. If label is empty, the variable name is displayed
ColorColor for the sector of this variable
TimeThe time for which the value of this variable is displayed. If this is empty, a general (or default) value of the time is used.
ExplodedIf set, the sector(s) of the variable(s) are "exploded" away from the center of the pie chart

-

Chart Panel

Chart panel is able to house multiple charts at the same time. Chart panel is a normal view in the workbench, which means it can be resized and located anywhere in the workbench. Eclipse also allows detaching the tab completely from the workbench, which means that the chart panel can be dragged to another screen.

+

Chart Panel

Chart panel is able to house multiple charts at the same time. Chart panel is a normal view in the workbench, which means it can be resized and located anywhere in the workbench. Eclipse also allows detaching the tab completely from the workbench, which means that the chart panel can be dragged to another screen.


Chart panel can be either horizontally or vertically oriented. Different orientations help in configuring the workbench perspective.


-

Charts are added to the panel by dragging from model browser. The order of the charts is easily changed by dragging charts from their header. Charts can be minimized or completely removed from the buttons in their headers.

By default, chart panel is hidden in the upper-right corner of the system dynamics perspective.

Multidimensional Variables

-

Modeling

Models with multidimensional variables look just like any other models. The structure of the models is replicated givin multiple indexes to variables. For users with programming background, notation Variable may be familiar. In system dynamic modeling we need to give names to the indexes. Instead of using numbers to define the indexes, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples):

1 Create the model structure

Model with multidimensional variables looks just like any other model.

+

Charts are added to the panel by dragging from model browser. The order of the charts is easily changed by dragging charts from their header. Charts can be minimized or completely removed from the buttons in their headers.

By default, chart panel is hidden in the upper-right corner of the system dynamics perspective.

Multidimensional Variables

+

Modeling

Models with multidimensional variables look just like any other models. The structure of the models is replicated giving multiple indices to variables. For users with programming background, notation Variable may be familiar. In system dynamic modeling we need to give names to the indices. Instead of using numbers to define the indices, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples):

1 Create the model structure

Model with multidimensional variables looks just like any other model.


-

2 Create Enumerations and define the indexes

Enumerations are created by right-clicking configuration and selecting New->Enumeration.

+

2 Create Enumerations and define the indices

Enumerations are created by right-clicking configuration and selecting New→Enumeration.


-

Define enumeration indexes by adding as many indexes as you want. Rename the indexes by selecting them and then clicking on them again.

+

Define enumeration indices by adding as many indices as you want. Rename the indices by selecting them and then clicking on them again.


-

3 Add Enumerations for variables

Select the variable that you want to be multidimensional. From the Indexes -tab in the property view, move the wanted enumerations to the right. The order of the enumerations does matter.

+

3 Add Enumerations for variables

Select the variable that you want to be multidimensional. From the indices -tab in the property view, move the wanted enumerations to the right. The order of the enumerations does matter.


-

4 Define equations for all possible indexes

Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indexes, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}.

+

4 Define equations for all possible indices

Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indices, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}.


-

Expressions

Values for all cells in the variable matrix can be defined in a single expression.

+

Expressions

Values for all cells in the variable matrix can be defined in a single expression.



@@ -136,7 +136,7 @@ Delay3 = Delay3_delayClass_instance.delay3;

4 Select the new expression


-

Repeat until there is value for each cell. There must be exactly one value for each cell.

Array Slices

Many times it is useful to access a slice of a multidimensional variable. In this chapter, we will use the following example variable:

 enumeration E1 = one, two, three
+

Repeat until there is value for each cell. There must be exactly one value for each cell.

Array Slices

Many times it is useful to access a slice of a multidimensional variable. In this chapter, we will use the following example variable:

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
 

The whole variable can be accessed in three different ways:

  1. Auxiliary

  2. Auxiliary[E1, E2]

  3. Auxiliary[:, :]

The following explains different methods for accessing parts of the variable

 // Single cell
@@ -144,35 +144,35 @@ Delay3 = Delay3_delayClass_instance.delay3;
 
 // Slices
  Auxiliary[one, E2] = {1,2,3}
  Auxiliary[E1, zwei] = {{2},{5},{8}}
- 
+
  // In addition to single cells and the whole enumeration range, a subrange of the enumeration can be used
  Auxiliary[two : three, E2] = {{4,5,6},{7,8,9}}
  Auxiliary[one : two, zwei : drei]  = {{2,3},{5,6}}
-

The syntax for accessing parts of variables can be used in both expression range definitions and in expressions.

Arithmetic Operators

Arithmetic operations are defined in Modelica. Below are examples of different operations.

Addition and substraction

Addition and substraction are calculated elementwise

 {1,2,3} - {0,2,3} = {1,0,0}
+

The syntax for accessing parts of variables can be used in both expression range definitions and in expressions.

Arithmetic Operators

Arithmetic operations are defined in Modelica. Below are examples of different operations.

Addition and substraction

Addition and substraction are calculated elementwise

 {1,2,3} - {0,2,3} = {1,0,0}
  {{2,2},{4,4}} + {{8,8},{1,1}} = {{10,10},{5,5}}
  {1,2,3} - {1,2} = ERROR! Different array sizes
 

Division

Division with a scalar

 {5,10,15} / 5 = {1,2,3}
  5 / {5,10,15} = ERROR! not allowed
 

Division with an array

 {1,2,3} / {1,2,3} = ERROR! not allowed
- 
+
  // Elementwise
  {1,2,3} ./ {1,2,3} = {1,1,1}
 

Multiplication

Multiplication with a scalar

 {1,2,3} * 2 = {2,4,6}
  5 * {1,2,3} = {5,10,15}
 

Matrix multiplication with an array

 {{3,4},{5,6}} * {1,2} = {11,17}
  {{3,4},{5,6}}  * {1,2,3} = ERROR! incompatible array sizes
- 
+
  //Elementwise
  {1,2} .* {1,2} = {1,4}
- 
- Real[3,2] c = {{1,2},{3,4},{5,6}};  
+
+ Real[3,2] c = {{1,2},{3,4},{5,6}};
  Real[2,2] d = {{3,4},{5,6}};
  Real[2,2] cd;
  cd = c[2:3, :] .* d; // Result: {{9,16},{25,36}}
 

Power

Elementwise power of array variable

 {1,2} .^ 2 = {1,4}
-

Builtin Modelica Functions

Modelica has some builtin functions that help using multidimensional variables. This chapter introduces some of the builtin functions.

Dimension and size functions

We will use the same example variable as previously.

 enumeration E1 = one, two, three
+

Built-in Modelica Functions

Modelica has some built-in functions that help using multidimensional variables. You can find the functions under any model inside the folder Functions→Built-in Functions. This chapter introduces some of the built-in functions.

Dimension and size functions

We will use the same example variable as previously.

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
- 
+
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
 

ndims(A)

The number of dimensions in array A

 ndims(Auxiliary) = 2
 

size(A, i)

The size of dimension i in array A

 size(Auxiliary, 2) = 3
@@ -188,7 +188,7 @@ Delay3 = Delay3_delayClass_instance.delay3;
    1 0 0
    0 2 0
    0 0 3
-

linspace(x1,x2,n)

Constracts a Real vector from x1 to x2 with n equally spaced elements.

 linspace(2,5,4) = {2,3,4,5}
+

linspace(x1,x2,n)

Constructs a Real vector from x1 to x2 with n equally spaced elements.

 linspace(2,5,4) = {2,3,4,5}
 

Reduction functions

Reduction functions reduce arrays to scalars.

min(A)

Returns the minimum value in array A.

 Real A = {{1,2},{3,4}}
  min(A) = 1
 

max(A)

Returns the maximum value in array A.

 Real A = {{1,2},{3,4}}
@@ -200,9 +200,9 @@ Delay3 = Delay3_delayClass_instance.delay3;
 

Using functions with iterators

Functions min(A), max(A), sum(A) and product(A) reduce arrays to scalars. When you use multidimensional variables, you will most probably like to reduce less dimensions. This can be achieved using iterators with reduction functions. The result is constructed as an array, if curly brackets {} are used to enclose the expression.

 enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
- 
+
  AuxiliarySum[E1] = {sum( Auxiliary[ i , E2 ] ) for i in E1} // Result: {6, 15, 24}
- 
+
  /* Same as:
  {sum(Auxiliary[one, E2]), sum(Auxiliary[two, E2]), sum(Auxiliary[three, E2])}
  {sum({1,2,3}), sum({4,5,6}), sum({7,8,9})}
@@ -210,37 +210,37 @@ Delay3 = Delay3_delayClass_instance.delay3;
 

One expression can have multiple iterators. The Modelica specification defines the following format, but it is NOT yet supported in OpenModelica:

 {sum(Array[ i, j, E3]) for i in E1, j in E2}  // Dimensions reduced from 3 to 2
 

To use multiple iterators, use the following format (NOTE the reversed order of iterators!):

 {{sum(Array[ i, j, E3]) for j in E2} for i in E1}  // Dimensions reduced from 3 to 2
 

The range doesn't have to be the whole enumeration. Subranges can also be used.

 {sum( Auxiliary[ i , eins : zwei ] ) for i in E1.one : E1.two} // Result: {3, 9}
- 
+
  /* Same as
  {sum(Auxiliary[one, eins : zwei]), sum(Auxiliary[two, eins : zwei])}
  {sum({1,2}), sum({4,5})}
  */
-

Simulation Results

Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables.

+

Simulation Results

Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables.


-

The clutter can be reduced by selecting which enumeration indexes are shown in charts. Select an enumeration and tick the indexes that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model.

+

The clutter can be reduced by selecting which enumeration indices are shown in charts. Select an enumeration and tick the indices that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model.


-

Array Variables in Modules

+

Array Variables in Modules


Replaceable enumeration inside a module

-

You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see Modeling).

When defining a module, modeler may not want to restrict the size of the array variable. In many cases the same module structure could be used for both large and small arrays. For example if the module is a project, a project may have three or even twenty phases. In this case the enumerations inside modules need to be set as replaceable.

In this example, the original enumeration that the modeler used had two indexes. We are using an instance of this module, but we need to use array variables that have three indexes instead of two. We are using two variables and an instance of the module.

+

You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see Modeling).

When defining a module, modeler may not want to restrict the size of the array variable. In many cases the same module structure could be used for both large and small arrays. For example if the module is a project, a project may have three or even twenty phases. In this case the enumerations inside modules need to be set as replaceable.

In this example, the original enumeration that the modeler used had two indices. We are using an instance of this module, but we need to use array variables that have three indices instead of two. We are using two variables and an instance of the module.


Module configuration for replacing enumerations inside the module

-

In the parent configuration, we have used an enumeration with three indexes in the two variables.

+

In the parent configuration, we have used an enumeration with three indices in the two variables.


Enumeration in the parent configuration that will replace the enumeration in the module

-

The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clickin on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model.

+

The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clicking on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model.


Enumeration in the parent configuration that will replace the enumeration in the module

-

When creating replaceable enumerations in modules, modelers need to be very careful. Direct references to single enumeration elements are not allowed, since the enumeration elements will change, if the enumeration is replaced for simulation!

Functions

-

Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models.

Creating Functions

+

When creating replaceable enumerations in modules, modelers need to be very careful. Direct references to single enumeration elements are not allowed, since the enumeration elements will change, if the enumeration is replaced for simulation!

Functions

+

Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models.

Creating Functions


-

You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New->Function.

Functions that can be found from Functions -folder can be used in your variable definitions.

Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function.

Algorithm section defines the actual functionality of the function. In algorithm sections you must use assignments ":=" instead of just plain "=". All the assignments are calculated in the order they are written.

Below is an example of a simple function. For more examples, see the built-in functions provided with the tool and Modelica specifications.

+

You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New→Function.

Functions that can be found from Functions -folder can be used in your variable definitions.

Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function.

Algorithm section defines the actual functionality of the function. In algorithm sections you must use assignments ":=" instead of just plain "=". All the assignments are calculated in the order they are written.

Also, take note that creating new lines in the Modelica code text box is done via shift+enter.

Below is an example of a simple function. For more examples, see the built-in functions provided with the tool and Modelica specifications.


-

Function Libraries

Functions can be collected into libraries. This is a good way of organizing your functions. If function is located in a library, you need to append the library name to the function call (e.g. ExampleFunctionLibrary.ExampleFunction(arg1, arg2)). With libraries, you can also have functions with same names (e.g. library1.func(arg) and library2.func(arg)).

+

Function Libraries

Functions can be collected into libraries. This is a good way of organizing your functions. If function is located in a library, you need to append the library name to the function call (e.g. ExampleFunctionLibrary.ExampleFunction(arg1, arg2)). With libraries, you can also have functions with same names (e.g. library1.func(arg) and library2.func(arg)).


-

There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually.

Create a new function library by right-clicking on Functions folder, Shared functions folder or other module library.

A function library can be exported by right clicking the function library and selecting Export -> Function library. A function library can be imported by right clicking the Functions folder and selecting Import -> Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library.

If you create a shared function library, the library can be added to other models or removed from current model by selecting the Shared Functions -folder and using the properties view.

+

There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually.

Create a new function library by right-clicking on Functions folder, Shared functions folder or other module library.

A function library can be exported by right clicking the function library and selecting Export → Function library. A function library can be imported by right clicking the Functions folder and selecting Import → Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library.

If you create a shared function library, the library can be added to other models or removed from current model by selecting the Shared Functions -folder and using the properties view.


-

External Functions

Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window -> Preferences -> Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code.

Below is a simple example of using a function that returns the sum of two arguments.

 double exampleCFunction(double x, double y)
+

External Functions

Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window → Preferences → Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code.

Below is a simple example of using a function that returns the sum of two arguments.

 double exampleCFunction(double x, double y)
  {
    double res;
    res = x + y;
@@ -264,23 +264,23 @@ Delay3 = Delay3_delayClass_instance.delay3;
    return res;
  }");
  end ExampleExternalFunction;
-

Modelica Functions

Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see builtin functions for arrays.

FunctionDescription
abs(x)Returns the absolute value of x. Expanded into "(if x >= 0 then x else -x)".
acos(x)Inverse cosine.
asin(x)Inverse sine.
atan(x)Inverse tangent.
atan2(x1,x2)four quadrant inverse tangent.
cat(n,A,B,...)General concatenation function that concatenates arrays A,B,... along the nth dimension.
ceil(x)Returns the smallest integer not less than x, the closest integer above x.
cos(x)Cosine.
cosh(x)Hyperbolic cosine.
cross(x,y)Returns the 3-vector cross product of the 3-vectors x and y.
delay(expr, delayTime)Returns the value of expr at the time time-delayTime. The value of expr is returned when time <= time.start + delayTime.
der(x)Time derivative of x. X must be have continuous-time variability.
div(x, y)Returns the algebraic quotient x/y with any fractional part discarted. E.g. div(10,3) = 3.
edge(b)Returns true when the value of the boolean expression b changes. Expanded into (b and not pre(b)).
exp(x)Exponential, base e.
floor(x)Returns the largest integer not greater than x, the closest integer below x.
initial()Returns true at the beginning of the simulation.
integer(x)Returns the largest integer not greater than x as an integer.
log(x)Natural logarithm. (base e, x > 0)
log10(x)Base 10 logarithm. (x > 0)
mod(x, y)Returns the integer modulus of x/y: mod(x,y) = x - floor(x/y) * y.
noEvent(expr)noEvent around an expression causes the expression to NOT generate event. Important: If you want a condition to be checked only on time steps, use noEvent. (e.g. if noEvent(value >= 1) then ... else ...)
pre(x)Returns the preceding value of y from time event that has occured before current time.
rem(x, y)Returns the integer remainder of x/y: rem(x,y) = x - div(x,y) * y.
sample(start, interval)Returns true and triggers time events at times start + i * interval (i=0,1,...).
sign(x)Returns -1 if x is negative, 1 if x is positive. Expanded into "(if x > 0 then 1 else if x < 0 then -1 else 0)".
sin(x)Sine.
sinh(x)Hyperbolic sine.
sqrt(x)Square root of x. The value of x must be greater or equal to 0 or an assertion error occurs.
tan(x)Tangent.
tanh(x)Hyperbolic tangent.
terminal()Returns true at the end of a successful simulation.

Spreadsheets

-

Spreadsheets allow storing and maintaining values in a familiar format. The current spreadsheet implementation is experimental and does not provide much functionality.

Variable Values

Spreadsheets are an easy way to import and manage parameter values. Sheet shells can be referenced to in models with the syntax SheetName(CellReference). Below is an example of getting a value for Auxiliary. The text "Auxiliary" is not necessary in the spreadsheet, but it helps maintaining the sheet.

+

Modelica Functions

Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see Built-in functions for arrays.

FunctionDescription
abs(x)Returns the absolute value of x. Expanded into "(if x >= 0 then x else -x)".
acos(x)Inverse cosine.
asin(x)Inverse sine.
atan(x)Inverse tangent.
atan2(x1,x2)four quadrant inverse tangent.
cat(n,A,B,...)General concatenation function that concatenates arrays A,B,... along the nth dimension.
ceil(x)Returns the smallest integer not less than x, the closest integer above x.
cos(x)Cosine.
cosh(x)Hyperbolic cosine.
cross(x,y)Returns the 3-vector cross product of the 3-vectors x and y.
delay(expr, delayTime)Returns the value of expr at the time time-delayTime. The value of expr is returned when time <= time.start + delayTime.
der(x)Time derivative of x. X must be have continuous-time variability.
div(x, y)Returns the algebraic quotient x/y with any fractional part discarded. E.g. div(10,3) = 3.
edge(b)Returns true when the value of the Boolean expression b changes. Expanded into (b and not pre(b)).
exp(x)Exponential, base e.
floor(x)Returns the largest integer not greater than x, the closest integer below x.
initial()Returns true at the beginning of the simulation.
integer(x)Returns the largest integer not greater than x as an integer.
log(x)Natural logarithm. (base e, x > 0)
log10(x)Base 10 logarithm. (x > 0)
mod(x, y)Returns the integer modulus of x/y: mod(x,y) = x - floor(x/y) * y.
noEvent(expr)noEvent around an expression causes the expression to NOT generate event. Important: If you want a condition to be checked only on time steps, use noEvent. (e.g. if noEvent(value >= 1) then ... else ...)
pre(x)Returns the preceding value of y from time event that has occurred before current time.
rem(x, y)Returns the integer remainder of x/y: rem(x,y) = x - div(x,y) * y.
sample(start, interval)Returns true and triggers time events at times start + i * interval (i=0,1,...).
sign(x)Returns -1 if x is negative, 1 if x is positive. Expanded into "(if x > 0 then 1 else if x < 0 then -1 else 0)".
sin(x)Sine.
sinh(x)Hyperbolic sine.
sqrt(x)Square root of x. The value of x must be greater or equal to 0 or an assertion error occurs.
tan(x)Tangent.
tanh(x)Hyperbolic tangent.
terminal()Returns true at the end of a successful simulation.

Spreadsheets

+

Spreadsheets allow storing and maintaining values in a familiar format. The current spreadsheet implementation is experimental and does not provide much functionality.

Variable Values

Spreadsheets are an easy way to import and manage parameter values. Sheet shells can be referenced to in models with the syntax SheetName(CellReference). Below is an example of getting a value for Auxiliary. The text "Auxiliary" is not necessary in the spreadsheet, but it helps maintaining the sheet.



-

You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indexes are not mandatory, but help reading and maintaining the sheet.

+

You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indices are not mandatory, but help reading and maintaining the sheet.


Reference to a sheet range creates an array variable.


-

ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indexes are ordered as in this example. However, if you wish to present the indexes in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3)))

+

ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indices are ordered as in this example. However, if you wish to present the indices in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3)))


-

History Data

Spreadsheets can be used to store and display external history data e.g. from some statistics. The history data should be arranged as columns or rows and include a time variable. Reference variables need to be given the exactly same name as their counterparts in model.

+

History Data

Spreadsheets can be used to store and display external history data e.g. from some statistics. The history data should be arranged as columns or rows and include a time variable. Reference variables need to be given the exactly same name as their counterparts in model.


History data is used by creating a History dataset to an experiment. The dataset is activated and deactivated in charts by double-clicking the dataset. History data reference is set in the properties of the history dataset.


-
History data properties-
NameName of the history dataset
SheetCombo box for selecting a sheet where the history data is located
OrientationColumns or rows. How the data is arranged in the sheet.
Range startThe upper-left corner cell of the history data range
Range endThe lower-right corner cell of the history data range
Time variableThe name of the time variable in the history data, if it is different than "time"
Variables in rangeThis text field displays the found variables in the given sheet and range

If the history dataset is activated, history data is displayed whenever it is available for a variable that is displayed in a chart.

+
History data properties-
NameName of the history dataset
SheetCombo box for selecting a sheet where the history data is located
OrientationColumns or rows. How the data is arranged in the sheet.
Range startThe upper-left corner cell of the history data range
Range endThe lower-right corner cell of the history data range
Time variableThe name of the time variable in the history data, if it is different than "time"
Variables in rangeThis text field displays the found variables in the given sheet and range

If the history dataset is activated, history data is displayed whenever it is available for a variable that is displayed in a chart.


-

Vensim Model Import

-

The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool Vensim. This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" -> "Vensim Model (.mdl)".

The import process has several known limitations:

  • The Vensim model must be in the .mdl file format, the other Vensim file formats are proprietary and thus not supported.

  • Only variables and connections are imported.

  • Many advanced Vensim features, such as input and output objects (e.g. graphs and parameter value editors) and other diagram customizations, are not supported.

  • Variable value range data is not always imported correctly.

  • Subscripts are automatically converted to enumerations which may sometimes lead into problems as the constructions are not exactly equivalent.

  • Dimensionless units are currently not converted correctly (in Simantics System Dynamics, dimensionless should be indicated with a constant).

  • Non-shadow duplicate variables are sometimes very problematic and may be imported incorrectly, shadow variables should work fine.

  • Only a limited subset of Vensim functions is currently implemented in Simantics System Dynamics, so some equations might require additional work before they can be evaluated correctly.

Sample Models and Molecules

-

There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import->Model.

Simantics | System Dynamics Modelling

+

Vensim Model Import

+

The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool Vensim. This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" → "Vensim Model (.mdl)".

The import process has several known limitations:

  • The Vensim model must be in the .mdl file format, the other Vensim file formats are proprietary and thus not supported.

  • Only variables and connections are imported.

  • Many advanced Vensim features, such as input and output objects (e.g. graphs and parameter value editors) and other diagram customizations, are not supported.

  • Variable value range data is not always imported correctly.

  • Subscripts are automatically converted to enumerations which may sometimes lead into problems as the constructions are not exactly equivalent.

  • Dimensionless units are currently not converted correctly (in Simantics System Dynamics, dimensionless should be indicated with a constant).

  • Non-shadow duplicate variables are sometimes very problematic and may be imported incorrectly, shadow variables should work fine.

  • Only a limited subset of Vensim functions is currently implemented in Simantics System Dynamics, so some equations might require additional work before they can be evaluated correctly.

Sample Models and Molecules

+

There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import→Model.

Simantics | System Dynamics Modelling

Tutorial: Basic System Dynamics Modelling

System dynamics modelling in Simantics is a free modelling tool that is included into the basic installation. This tutorial introduces the basic features of the system dynamics modelling tool.

Tutorial: Advanced System Dynamics Modelling

This tutorial introduces the more advanced features of the system dynamics modelling tool: Modules and Operating interfaces

\ No newline at end of file diff --git a/bundles/org.simantics.sysdyn.wiki/commonltr.css b/bundles/org.simantics.sysdyn.wiki/commonltr.css index 7dbcedbe..013b96ba 100644 --- a/bundles/org.simantics.sysdyn.wiki/commonltr.css +++ b/bundles/org.simantics.sysdyn.wiki/commonltr.css @@ -5,6 +5,35 @@ * * See the accompanying LICENSE file for applicable license. */ +.hazardstatement td, +.hazardstatement th { + padding: 0.5rem; +} + +.hazardstatement th { + text-align: center; + text-transform: uppercase; +} + +.hazardstatement--caution { + background-color: #ffd100; +} + +.hazardstatement--danger { + background-color: #c8102e; + color: #fff; +} + +.hazardstatement--warning { + background-color: #ff8200; +} + +.hazardstatement--attention, .hazardstatement--fastpath, .hazardstatement--important, .hazardstatement--note, .hazardstatement--notice, .hazardstatement--other, .hazardstatement--remember, .hazardstatement--restriction, .hazardstatement--tip { + background-color: #0072ce; + color: #fff; + font-style: italic; +} + .codeblock { font-family: monospace; } @@ -29,25 +58,18 @@ font-family: monospace; } -div.tasklabel { - margin-top: 1em; - margin-bottom: 1em; -} - -h2.tasklabel, -h3.tasklabel, -h4.tasklabel, -h5.tasklabel, -h6.tasklabel { +.tasklabel { font-size: 100%; + margin-bottom: 1em; + margin-top: 1em; } .screen { - padding: 5px 5px 5px 5px; + background-color: #ccc; border: outset; - background-color: #CCCCCC; - margin-top: 2px; margin-bottom: 2px; + margin-top: 2px; + padding: 5px; white-space: pre; } @@ -56,37 +78,37 @@ h6.tasklabel { } .numcharref { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .parameterentity { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .textentity { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlatt { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlelement { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlnsname { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlpi { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } @@ -298,6 +320,12 @@ div.imagejustify { margin-top: 1em; } +.indexterm { + background-color: #fdf; + border: 1pt #000 solid; + margin: 1pt; +} + /* Most link groups are created with
. Ensure they have space before and after. */ .ullinks { list-style-type: none; @@ -578,6 +606,27 @@ table .desc { margin-top: 1em; } +/* flagging styles */ +.flag__style--italics { + font-style: italic; +} + +.flag__style--bold { + font-weight: bold; +} + +.flag__style--underline { + text-decoration: underline; +} + +.flag__style--double-underline { + text-decoration: double-underline; +} + +.flag__style--overline { + text-decoration: overline; +} + /*! * Custom CSS declarations, to be appended to the end of existing declarations */ diff --git a/bundles/org.simantics.sysdyn.wiki/commonrtl.css b/bundles/org.simantics.sysdyn.wiki/commonrtl.css index e18e2c02..acff472d 100644 --- a/bundles/org.simantics.sysdyn.wiki/commonrtl.css +++ b/bundles/org.simantics.sysdyn.wiki/commonrtl.css @@ -12,6 +12,35 @@ * * See the accompanying LICENSE file for applicable license. */ +.hazardstatement td, +.hazardstatement th { + padding: 0.5rem; +} + +.hazardstatement th { + text-align: center; + text-transform: uppercase; +} + +.hazardstatement--caution { + background-color: #ffd100; +} + +.hazardstatement--danger { + background-color: #c8102e; + color: #fff; +} + +.hazardstatement--warning { + background-color: #ff8200; +} + +.hazardstatement--attention, .hazardstatement--fastpath, .hazardstatement--important, .hazardstatement--note, .hazardstatement--notice, .hazardstatement--other, .hazardstatement--remember, .hazardstatement--restriction, .hazardstatement--tip { + background-color: #0072ce; + color: #fff; + font-style: italic; +} + .codeblock { font-family: monospace; } @@ -36,25 +65,18 @@ font-family: monospace; } -div.tasklabel { - margin-top: 1em; - margin-bottom: 1em; -} - -h2.tasklabel, -h3.tasklabel, -h4.tasklabel, -h5.tasklabel, -h6.tasklabel { +.tasklabel { font-size: 100%; + margin-bottom: 1em; + margin-top: 1em; } .screen { - padding: 5px 5px 5px 5px; + background-color: #ccc; border: outset; - background-color: #CCCCCC; - margin-top: 2px; margin-bottom: 2px; + margin-top: 2px; + padding: 5px; white-space: pre; } @@ -63,37 +85,37 @@ h6.tasklabel { } .numcharref { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .parameterentity { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .textentity { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlatt { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlelement { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlnsname { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } .xmlpi { - color: #663399; + color: #639; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; } @@ -305,6 +327,12 @@ div.imagejustify { margin-top: 1em; } +.indexterm { + background-color: #fdf; + border: 1pt #000 solid; + margin: 1pt; +} + /* Most link groups are created with
. Ensure they have space before and after. */ .ullinks { list-style-type: none; @@ -585,6 +613,27 @@ table .desc { margin-top: 1em; } +/* flagging styles */ +.flag__style--italics { + font-style: italic; +} + +.flag__style--bold { + font-weight: bold; +} + +.flag__style--underline { + text-decoration: underline; +} + +.flag__style--double-underline { + text-decoration: double-underline; +} + +.flag__style--overline { + text-decoration: overline; +} + .linklist { margin-bottom: 1em; } diff --git a/bundles/org.simantics.sysdyn.wiki/index.html b/bundles/org.simantics.sysdyn.wiki/index.html index f091448b..aad6e7b2 100644 --- a/bundles/org.simantics.sysdyn.wiki/index.html +++ b/bundles/org.simantics.sysdyn.wiki/index.html @@ -4,11 +4,11 @@ - - - - - + + + + + Simantics System Dynamics diff --git a/dita-docs/Site/AdvancedTutorial.md b/dita-docs/Site/AdvancedTutorial.md index 69159f04..92a2888b 100644 --- a/dita-docs/Site/AdvancedTutorial.md +++ b/dita-docs/Site/AdvancedTutorial.md @@ -1,16 +1,20 @@ # Tutorial: Advanced System Dynamics Modelling
-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. A [basic tutorial](BasicTutorial.md) is also available. This tutorial is part of the [sysdyn documentation](sysdyn.md). +This tutorial goes more in-depth on the advanced features of the Simantics System Dynamic tool. Namely modules, custom Modelica functions, special variables and enumerations (i.e. vector variables). We are going to build a model that simulates how a shared workforce works on several overlapping projects. You can think of the resulting model as a framework on which to build models that, for example, simulate a project portfolio of a company. It is advised that you complete the [basic tutorial](BasicTutorial.md) before starting. If you find yourself stuck, seek help from the [documentation](sysdyn.md). + +* [1 Creating model and modules](#Creating-model-and-modules) +* [2 Initial configuration](#Initial-configuration) +* [3 Workforce module](#Workforce-module) +* [4 Project module](#Project-module) +* [5 Connecting modules](#Connecting-modules) +* [6 Simulating the model](#Simulating-the-model) +* [7 Adding modules](#Adding-modules) ## 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 WorkforceModule and WorkModule. You can rename them by right-clicking on the item on the model browser and selecting Rename. +Start by creating a new model from File→New→SD Model, rename the model to WorkModel. Then create two new modules by right-clicking on the Modules folder under the WorkModel tree and selecting New→Module. Rename the modules to Workforce and Project by selecting them in the Model Browser and using the properties view.
@@ -28,252 +32,263 @@ Name your model WorkModel and modules WorkforceModule and WorkModule. You can re ## Initial configuration
+We will use a top-down approach in creating our model - focusing first on the bigger picture of the model and implementing the internal structure of the modules later. + +Open the model configuration by double-clicking Configuration in your model browser. Drag one Workforce and one Project from your Model Browser to the WorkModel diagram. The modules are automatically named with a suffix number. +
-

Workforce and Work modules

+

Workforce and Project 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. +You can think of modules as user made components that communicate with rest of the model by having some input(s) and output(s). In this model the internal implementation of Workforce module should handle resourcing people to projects according to their needs. The Project module should simulate how the people that are assigned to that specific project are advancing the project. -Drag one WorkforceModule and one WorkModule 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. +While not used in this tutorial, Simantics System Dynamics supports nested modules, i.e. modules inside modules. Modules can also be exported and imported independent of the model. + +Let's consider what kind of information we need to pass between the modules. First of all, the Project needs to tell the Workforce module how much workforce it needs. Create an input variable and name it to RequestedWorkingSpeed to pass this information along. Connect Project1 module to RequestedWorkingSpeed and RequestedWorkingSpeed to Workforce1 with a dependency arrow. + +Input variable is a special type of symbol that acts as an interface between modules and the rest of the model. They are the only symbol type that can be connected directly to module outputs and they also act as the only way of creating inputs inside modules, as we will see later. + +We also need to assign people to work for the project - the Workforce module needs to tell the Project module how well we can respond to the request. Create a new input variable called ResponsedWorkingSpeed and connect it to the modules with dependency arrows.

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 we would like to use in the modules. - -Workforce needs to know, how much work is required and it should 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](sysdyn.md#shortcut-and-control-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. - +Now we have the first version of the top-level model structure completed, we can start configuring 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. +Open the Workforce module by double-clicking it under the Modules folder. -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. +First, create an input variable and name it to RequestedNumberOfPeople, this variable receives the request provided by the Project module. Then, create 3 auxiliary variables and name them NumberOfEmployees, EmployeesAssigned and NumberOfFreeEmployees. Lastly connect the variables as shown in the picture. The unit of these variables is number of people.
- -

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

+ +

Internal structure of the Workforce module

-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. +Now we need to give the symbols equations, these are written below. To configure an equation, select a variable and write (or copy-paste) the corresponding equation to the text field in the Properties view. Connected variables are shown in the Variables list on the right side of the properties view. You can double-click on a variable name to insert it to the equation. -
- -

Auxiliaries in Workforce module

-
+
+NumberOfEmployees
+= 10
 
-Now you have used all the basic components and connections. From now on the instructions will be a more simplified.
+NumberOfFreeEmployees
+= NumberOfEmployees-EmployeesAssigned
 
-Next we will create four Auxiliary variables: TimeToAllocateResources, WorkforceRequired, Productivity and PossibleWorkingSpeed. Place and connect them according to the picture on the right.
+EmployeesAssigned
+= min(RequestedNumberOfPeople, NumberOfEmployees)
+
-To be able to simulate the model, all variables must have valid equations. To configure an equation, select a variable. Variable's properties are shown in the Property view and you can input the required equations in the text fields. 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. +Also, we need to decide what value(s) we want the module to output. Make sure that the Is Output checkbox is ticked on the EmployeesAssigned variable, as this is the variable that tells how many people can be provided for the project. -
-WorkforceStock 
-Initial value: 0
+We are using a built-in function min() for calculating how many employees we are going to assign. You can find a list of these in the Model Browser under WorkModel→Functions→Built-in Functions.
 
-NetResourcing 
-= (WorkforceRequired - WorkforceStock)/TimeToAllocateResources
+On the first iteration of this model, we are going to have 10 fulltime employees that get assigned to a single project according to the request. We are going to expand the structure of this module to handle several projects later on in the tutorial. This module is now ready to be used as a part of the first iteration of the model.
 
-TimeToAllocateResources 
-= 2
+## Work module
+
-Productivity -= 1 +Open Project module by double-clicking it on the Model Browser. -PossibleWorkingSpeed -= WorkforceStock * Productivity -Is Output -
+Create a flow of work with stocks and flows like in the picture. This loop says that there is some initial amount of work that is done at a certain speed, gradually becoming completed work. However, our workers are not perfect, as such errors can occur during work. These errors are first undiscovered, and as they are found they become work that needs to be completed. -Variables can be set as output by selecting Is Output option from the Equation tab. +You will see red exclamation mark next to the symbols due to empty equation fields, these are omitted from the tutorial images for clarity reasons. We will return to fill in these fields later.
- -

RequiredWorkingSpeedInput

+ +

Basic work with errors

-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. +Next let's create variables that control the parameters of a project and handle the request of asking people for work. Create auxiliary variables: StartTime, Deadline, ProjectDuration, TimeToStartTime, TimeToDeadline, RequestedWorkingSpeed, ProjectWorkAmount and NumberOfWorkdaysInProject. Connect the symbols as in the picture and write the following expression to their expression fields. Click the checkbox Is Output on RequestedWorkingSpeed variable to make the module output the value of this variable. + +
+ +

Structure of requesting people to work

+
-WorkForceRequired 
-= RequiredWorkingSpeedInput/Productivity
-
+StartTime += 5 -Now this module is ready to be used as a part of the model. +Deadline += 20 -## Work module -
+ProjectDuration += Deadline-StartTime -
- -

Basic work with errors

-
+TimeToStartTime += max(0, StartTime-time) -Open Work1 module by selecting it from the WorkModel diagram, right-clicking it and selecting Show Module. Alternatively you can double click Work1 on the model browser. +TimeToDeadline += Deadline-time -Create the basic flow of work with stocks and flows like in the picture on the right. +RequestedWorkingSpeed += if WorkToDo > 0 and TimeToStartTime == 0 then NumberOfWorkdaysInProject/ProjectDuration else 0 -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. +ProjectWorkAmount += 500 + +NumberOfWorkdaysInProject += ProjectWorkAmount/7 + + +The project has parameters for starting time, deadline and budgeted hours of work. Based on these we calculate how many people the project needs, assuming that an average worker works for 7 hours per day. The number of people is handled as a floating point integer, meaning that one worker can work on multiple different projects. + +Now let's create an input variable to take in the information of how much workforce we got from our request. Create an input variable and name it ResponseWorkingSpeedInput. We are also going to calculate how many hours a day the workers need to work in order to get the project ready in time and limit the result between 7 and 9 hours a day. Create two auxiliary variables and name them RequiredWorkHoursPerDay and TotalWorkHoursPerDay, connect them to other variables as in the image.
- -

Smoothener for work is done

+ +

Input for responsed working speed

-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. Create variables and connections according to the picture on the right. - -Use the following equations for variables: +Write the following expression to the equation fields of the new auxiliary variables:
-ProjectIsReady 
-Initial value: 0
+RequiredWorkHoursPerDay
+= if ResponseWorkingSpeedInput == 0 then 0 else if TimeToDeadline < 0 then 9 else minmax(WorkToDo/ResponseWorkingSpeedInput/TimeToDeadline, 7, 9)
+
+TotalWorkHoursPerDay
+= RequiredWorkHoursPerDay*ResponseWorkingSpeedInput
 
-ProjectReadyness 
-= (xidz(WorkDone, ProjectWorkAmount, 0.0) - ProjectIsReady) / 0.08
+WorkingSpeed
+= TotalWorkHoursPerDay
 
-xidz is short for function X if devided by zero. This means that the simulation calculates ''WorkDone / ProjectWorkAmount''. If ProjectWorkAmount is zero, the result is the third argument ''0.0''. +Next we focus on completing the structure of the work loop. Create 2 auxiliary variables and name them WorkQuality and ErrorsFoundTime. Also, create two Shadow variables and select WorkQuality and ProjectWorkAmount as the referred variables. Shadow variable is a special type of variable, whose role is to pass along the referred variable value to a place where drawing a dependency arrow from the original symbol would make the graph difficult to read. Place the new symbols as in the image and make the dependency connections.
- -

ProjectWorkAmount input variable

+ +

Completed work loop structure

-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. +Now that the structure of the work loop is completed let's input equations to the variables. -
- -

Variables needed for error handling

-
+
+WorkToDo
+Integral: ErrorsFoundRate - WorkingSpeed
+Initial Value: ProjectWorkAmount
 
-Next we need to define how errors are found. For that we need new variables: WorkQuality and ErrorsFoundTime. Create the variables and connections according to the picture and give variables their equations.
+WorkDone
+Integral: WorkingSpeed - ErrorsFoundRate
+Initial Value: 0
 
-
 ErrorsGenerated
 = (1-WorkQuality) * WorkingSpeed
 
+UndiscoveredErrors
+Integral: ErrorsGenerated - ErrorsFoundRate
+Initial Value: 0
+
 ErrorsFoundRate
-= Errors/ErrorsFoundTime
+= UndiscoveredErrors/ErrorsFoundTime
+
-WorkQuality -= 0.9 +For ErrorsFoundTime we are going to use a special type of auxiliary variable called WithLookup. WithLookup is a variable type where the value is interpolated from a 2-dimensional (Lookup) table using the value determined in the "With Lookup" field. Input the following values. +
 ErrorsFoundTime
 Type: WithLookup
-With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0) 
+With Lookup: xidz(WorkDone, ProjectWorkAmount, 0.0)
 Lookup table: {{0,5},{0.5,3},{1,0.5},{2,0.5}}
 
-WithLookup is a variable type where the value is interpolated from a 2-dimensional table (Lookup table) using the value determined in the "With Lookup" field. Type can be changed from the drop-down menu Type. +This variable makes it so that the less we have completed work the larger the variable value is and vice versa. And as we use this value in ErrorsFoundRate variable to divide the number of undiscovered errors, a practical interpretation would be that when we start working on a project we don't discover errors easily. But, as the project gets more and more completed we start to discover more and more errors made earlier on in the project. + +
+ +

Choosing WithLookup as the auxiliary type

+
+ +Now we are going to create a small feedback structure around WorkQuality. The purpose is to simulate how working overtime for a prolonged period causes fatigue. Create a stock variable called Fatigue and two flows, WorkingOverTime and SlowRecovery. Also create a shadow variable of RequiredWorkingHoursPerDay. Connect the variables as shown in the image.
- -

WorkAllocation and RequiredWorkingSpeed

+ +

Structure around WorkQuality

-To calculate our own need for workforce we need to create and connect WorkCompletionTime input variable and the following auxliary variables: +Input the following equations to the variables:
-RequiredWorkingSpeed 
-= if ProjectIsReady < 1 then xidz(WorkToDo, TimeToDeadline, MaximumWorkingSpeed) else 0
-Is Output
+WorkingOverTime
+= if RequiredWorkHoursPerDay == 0 then 0 else (RequiredWorkHoursPerDay-7)*0.025
 
-MaximumWorkingSpeed 
-= 500
+SlowRecovery
+= if Fatigue >= 0 then 0.03 else 0
 
-TimeToDeadline 
-= max(0, WorkCompletionTime-time)
+Fatigue
+Integral: WorkingOverTime - SlowRecovery
+Initial Value: 0
+
+WorkQuality
+= max(0.95*(1-Fatigue), 0.7)
 
-time is a universal variable that gives the current simulation time. +Now working overtime causes fatigue to build up slowly, and fatigue in return causes work quality to decrease. This in return makes the workers more prone to do errors while working, causing more work to do, increasing the need for overtime work. -We need to decide how the workforce is allocated between all the work modules that are using the same workforce. For that we need to know how much work can be done and how much workforce other works require. +There is only one thing left to do for this module, we are going to create variables that tell when the project was completed. An intuitive approach would be to claim that a project is complete when the value of WorkToDo goes to zero. However, due to the structure of the work loop we are likely to find some errors even after the WorkToDo goes to zero. We solve this by recording the time when WorkToDo is zero (or under) for the first time. -Create two Inputs, RequiredWorkingSpeedTotalInput and PossibleWorkingSpeedInput, and an auxiliary variable WorkAllocation. Connect the variables like int the picture. +Create a ghost variables of WorkToDo and Deadline. Then, create three auxiliary variables called ProjectIsCompleted, ProjectCompletitionTime and DaysLateOnDeadline. Connect the variables as in the image. -
-WorkAllocation
-= xidz(RequiredWorkingSpeed, RequiredWorkingSpeedTotalInput, 0.0) * PossibleWorkingSpeedInput
-
+
+ +

Structure of DaysLateOnDeadline

+
-Finally let's give initial values for all the remaining variables: +The variables use the following equations:
-WorkingSpeed 
-= if ProjectIsReady < 1 then WorkAllocation else 0
-
-WorkToDo 
-Initial value: ProjectWorkAmount
+ProjectIsCompleted
+= if time == 0 then 0 else if WorkToDo > 0 and ProjectIsCompleted == 0 then 0 else 1
 
-WorkDone 
-Initial value: 0
+ProjectCompletitionTime
+= if ProjectIsCompleted == 0 then time else ProjectCompletitionTime
 
-Errors 
-Initial value: 0
+DaysLateOnDeadline
+= ProjectCompletitionTime-Deadline
 
-## Connecting modules -
- -Our modules are complete. Let's get back to the WorkModel Configuration. +You can think of ProjectIsCompleted as a Boolean variable that goes to 1 and stays there when WorkToDo goes to 0 for the first time. ProjectCompletitionTime keeps track of time until the project is completed. -
-Set Work1CompletionTime to 10.
-
+Now the Project module is complete.
- -

Module input connections

+ +

Completed Project module

-Connections between modules are made in the properties of the module. Select Work1 and open tab Inputs from the properties. The table lists all input variables in the module that are available. Clicking on the Refers to output column will open a drop-down menu that shows all available variables that are connected to the module. By selecting a variable, you connect that variable to the input. +## Connecting modules +
+ +Now that our modules are complete, let's get back to the WorkModel Configuration and connect the inputs and outputs of the modules. Select Project1 and then select Outputs tab from the properties view. Select the only available variable as the connection. Do the same in the Inputs tab. And repeat this process for Workforce1 also.
- +

Module input connections

-Work1 need also information on how much working speed is required by all works. Since Work1 is the only work, create a dependency connection from RequiredWorkingSpeed1 to Work1 and in Work1's properties connect it to RequiredWorkingSpeedTotalInput. - -In Outputs tab, make the only possible connection: from RequiredWorkingSpeed to RequiredWorkingSpeed1. - -Workforce module has only one input and one output. Create the only possible connections: -(Inputs) RequiredWorkingSpeedInput -> RequiredWorkingSpeed1 -(Outputs) PossibleWorkingSpeed -> TotalPossibleWorkingSpeed - Now your model is ready for simulation! ## Simulating the model
-To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 24.0 +To make the simulation time longer, select Configuration on the model browser. Give the model Stop time 50.

Experiment activation

-To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button:
+To run simulations, you must activate an experiment. Expand the experiments folder on your model browser. There is one ready-made experiment. Double-click on the experiment and the experiment control buttons appear on the toolbar. To simulate the model, press the play button: + +
-System shows the simulation progress in the progress bar on the lower right corner of the screen. +System shows the simulation progress in the progress bar on the lower right corner of the screen.
@@ -283,7 +298,13 @@ When the progress indicator disappears, the simulation is complete. If the Console view pops up and shows an error "Error: Too few equations, underdetermined system. The model has X equation(s) and Y variable(s)", the simulation has failed. The reason might be that you forgot to assign an equation to some variable or some connection in modules. See through all the variables, write the missing equation and simulate again. -After the simulation is succesfully run, you can select a variable and see its simulation results in the trend view. For example WorkDone variable in Work1 module will give the following graph. +After the simulation has successfully completed, you can select a variable from model browser under Configuration to see its values over time in the trend view. You can also right-click on a module and select Show Module. This brings up a view of the internal structure of the module instance used in the simulation. Selecting a variable from there will show its values in the trend view. + +
+ +
+ +For example, RequiredWorkingHoursPerDay variable in Project1 module should give the following graph. At first assigned workers are working 7 hours per day, but they start working more when the deadline starts closing in. After the project is completed, a few undiscovered errors are found and workers return to correct them.
@@ -292,55 +313,199 @@ After the simulation is succesfully run, you can select a variable and see its s ## Adding modules
+Now that we have a model with one Project module we are going to expand the model to support as many Projects as we want. First, we need to make some restructuring on the top level. Delete the dependency arrow that goes from ResponsedWorkingSpeed to Project1 module, also delete RequestedWorkingSpeed symbol entirely. Now create two new auxiliary variables and name them RequestedWorkingSpeed and WorkforceProject1. Connect the new auxiliaries as in the picture, remember make the connection inside the module properties as well. + +
+ +

Updated model structure

+
+ +Write the following equations inside the new variables: +
+RequestedWorkingSpeed
+= Project1.RequestedWorkingSpeed
+
+WorkforceProject1
+= ResponsedWorkingSpeed
+
+ +Notice that we can access variable values without having dependency arrows connected, we are given a warning next to the symbol as this should be done only when you know exactly what you are doing. Also, note that we can access values inside modules by using a dot notation modulename.variablename. + +Simulate the model once to make sure nothing broke. + +Next create a new Project module and a corresponding auxiliary variable WorkforceProject2, connect the auxiliary variable to the module and make the input connection in the module settings. + +
+ +

Updated model structure

+
+ +Now we need to make the Workforce1 module to work with several projects at the same time, for this we use enumerations. You can think of enumerations as indices of a vector variable. To create an enumeration right-click on Configuration and select New→Enumeration. +
- -

Final configuration with two modules

+ +

Creating a new enumeration

-We created the WorkModule to be reusable. To use two WorkModules in the model, you must do the following. + Select the newly created enumeration under Configuration and rename it to Projects. Then, select the enumeration and from properties view click twice on Add, rename index and index2 to Project1 and Project2 respectively. -Populate a second WorkModule to WorkModel configuration and name it Work2. +
+ +

Creating new indices for Projects enumeration

+
-Create RequiredWorkingSpeed2 input variable and Work2CompletionTime auxiliary variable. +Now we have created the needed enumeration for the top level model. We need to create one for the Workforce module as well. Under the Modules folder in the model browser right-click on Workforce, select New→Enumeration, name it Projects and add a single dummy enumeration. Then make sure the checkbox Can be replaced by parent module is checked. Then select Workforce1 module and from Module Properties overwrite enumeration Projects with Projects. This way we only have to update enumerations in one place when adding new projects to the model. -We need a sum of all working speed requirements to give to the work modules. For this purpose, create an auxiliary variable RequiredWorkingSpeedTotal which sums the requirements. +Now we need to select which variables use the enumerations, i.e. what scalar variables we need to turn into vector variables. In the top-level model select RequestedWorkingSpeed and ResponsedWorkingSpeed by holding down ctrl while left-clicking on the symbols, this should bring up a view that allows you to add enumerations to the selected symbols. From the left select Projects by left-clicking and click on the arrow, Projects enumeration should appear on the right side. -You can also have a different size work. To make Work2 smaller, create an auxiliary variable Work2Amount. +
+ +

Adding enumerations to symbols

+
-Use the following equations: +We need to change the equations of RequestedWorkingSpeed, WorkforceProject1 and WorkforceProject2. RequestedWorkingSpeed needs information from both Project modules and WorkforceProject variables should be scalars. Input the following equations:
-Work2CompletionTime
-= 13
+RequestedWorkingSpeed
+= {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed}
 
-Work2Amount
-= 800
+WorkforceProject1
+= ResponsedWorkingSpeed[Project1]
 
-RequiredWorkingSpeedTotal
-= RequiredWorkingSpeed1 + RequiredWorkingSpeed2
+WorkforceProject2
+= ResponsedWorkingSpeed[Project2]
 
-Update connections to match connections shown in the picture and connect the inputs and outputs to the modules. +Next we need to update the structure of Workforce module so that it handles vector variables. Open the module by right-clicking on Workforce1 and selecting Show Module. + +Select variables EmployeesAssigned and RequestedNumberOfPeople and add the Projects enumeration to them as before. + +Now we are going to create a custom function that allocates people to projects. To create a custom function, in the Model Browser right-click on Functions folder and select new→Function. Now click on the newly created function and rename it to AssignWorkersToProjects. + +
+ +

Creating a new function

+
+ + +Write (or copy-paste) the following Modelica code to the empty text field. When working with custom Modelica functions note that you need to press shift+enter to create new lines.
-Workforce
-RequiredWorkingSpeedInput -> RequiredWorkingSpeedTotal
+public input Real requestedhr[:];
+public input Real totalrequestedhr;
+public input Real availablehr;
+public output Real allocatedhr[size(requestedhr, 1)];
+algorithm
+requestaspercentage := zeros(size(requestedhr, 1));
+nofpeople := zeros(size(requestedhr, 1));
+for i in 1:size(requestedhr, 1) loop
+	requestaspercentage[i] := xidz(requestedhr[i], totalrequestedhr, 0);
+	nofpeople[i] := min(availablehr*requestaspercentage[i], requestedhr[i]);
+	allocatedhr[i] := nofpeople[i];
+end for;
+
+ +To give you a quick rundown of the code logic, we have 3 input variables. First one tells how much workforce each projects wants, the second tells what the total number of requested people is and the third tells how many employees we have. The function outputs a vector that tells how many people it assigned to which project. In case there is more demand than available workforce, we calculate what percentage of the whole demand each project contributes and assign people accordingly. + +Now that our custom Modelica function is ready we are going to use it in the EmployeesAssigned variable. Select EmployeesAssigned and on the right of the properties view select Function tab, double-click on the custom function to make it appear in the equation field. Give the function following parameters: RequestedNumberOfPeople, sum(RequestedNumberOfPeople), NumberOfEmployees. -Work1 Inputs -RequiredWorkingSpeedTotalInput -> RequiredWorkingSpeedTotal +
+ +

Our custom function in variable properties view

+
-Work2 Outputs -RequiredWorkingSpeed -> RequiredWorkingSpeed2 +Finally we need to change the calculation logic of NumberOfFreeEmployees. As EmployeesAssigned is now a vector variable just add sum() function around it in the equation field. -Work2 Inputs +
+NumberOfFreeEmployees
+= NumberOfEmployees-sum(EmployeesAssigned)
 
-
- +Now the Workforce module is completed! + +Finally, we are going to give the projects different parameters. Select Project2 and from the properties view select Parameters tab. By slowly double-clicking on a value you can change the starting time, deadline and work amount of a project. + +
+ +

Parameters of Project2

-When all the connections are made, you can simulate the model again. Now you have model with two work modules. Select variables from both modules in model browser to display them in trend view. +Set the following parameters. -
- +
+Deadline: 40
+ProjectWorkAmount : 900
+StartTime: 0
+
+ +Now we have completed a model with two Project modules, simulate to make sure your model is working. + +By following the steps below you can add a new project module to the model. Our current implementation supports any number of projects. + +
+1. Add a new Project module to the diagram
+2. Add a new auxiliary variable and name it WorkforceProject3
+3. Connect the new auxiliary variable with the module using a dependency arrow and connect it to the module in the input tab
+4. Update the equation field of RequestedWorkingSpeed to {Project1.RequestedWorkingSpeed, Project2.RequestedWorkingSpeed, Project3.RequestedWorkingSpeed}
+5. Choose Project enumeration under configuration and add click add, name the new index to Project3
+6. Write ResponsedWorkingSpeed[Project3] as the equation for the new auxiliary variable
+7. Finally, customize the parameters of Project3 module in the Parameters tab
+
+ +Create a third Project module using the instructions above with the following parameters. + +
+Deadline: 20
+ProjectWorkAmount : 300
+StartTime: 10
+
+ +To make the results of the simulation more readable we can add auxiliary variables that collect information from each of the Project modules. For example, we might be interested the behaviour of WorkQuality, RequiredWorkingHoursPerDay and DaysLateOnDeadline. Create an auxiliary variable for each of these, add Project enumeration to them and input the following equations. + +
+DaysLateOnDeadline
+ = {Project1.DaysLateOnDeadline, Project2.DaysLateOnDeadline, Project3.DaysLateOnDeadline}
+
+ RequiredWorkHoursPerDay
+ = {Project1.RequiredWorkHoursPerDay, Project2.RequiredWorkHoursPerDay, Project3.RequiredWorkHoursPerDay}
+
+ WorkQuality
+ = {Project1.WorkQuality, Project2.WorkQuality, Project3.WorkQuality}
+
+ +Remember to update these variables also if you intend to use more than 3 projects. + +If you now simulate the model the results of RequiredWorkHoursPerDay should look like this. + +
+ +

RequiredWorkHoursPerDay results

+
+ +And WorkQuality should look like this. + +
+ +

WorkQuality results

+ +Reading results from DaysLateOnDeadline variable is hard as the variable keeps track of time before the deadline. To see the results more clearly we are going to create a custom bar chart. Right-click on Charts folder under the WorkModel and select New→Bar Chart, rename the chart to Project deadlines and rename the Title to Days late on deadline. Then choose the tab Variables, click on Add, select Write variable name and write DaysLateOnDeadline to the field. Bar charts automatically use the last time step of the simulation when retrieving variable values. The chart should like this. + +
+ +

DaysLateOnDeadline results

+
+ +Now you have completed the advanced Simantics System Dynamics tutorial. + +There are some features that neither of the tutorials cover that can be found in the [documentation](sysdyn.md). + +If you still want to practice using the tool, here are some ideas on how to further develop the model we just made. + +
+1. The number of employees is currently a static variable, think of ways to simulate the hiring procedure of a company using stocks and flows
+2. Add more projects and think of ways to optimize project scheduling
+3. Add wages to employees and an external workforce that is used in case internal workforce isn't enough, minimize total costs
+
+ +Happy simulating! diff --git a/dita-docs/Site/AdvancedTutorialImages/ActivateExperiment.png b/dita-docs/Site/AdvancedTutorialImages/ActivateExperiment.png index 8843321e..6f1162c4 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/ActivateExperiment.png and b/dita-docs/Site/AdvancedTutorialImages/ActivateExperiment.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png b/dita-docs/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png new file mode 100644 index 00000000..08737377 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/AddEnumerationToSymbols.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/AddEnumerations.png b/dita-docs/Site/AdvancedTutorialImages/AddEnumerations.png new file mode 100644 index 00000000..390ffe27 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/AddEnumerations.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/AddingModules1.png b/dita-docs/Site/AdvancedTutorialImages/AddingModules1.png new file mode 100644 index 00000000..caaddd4a Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/AddingModules1.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/AddingModules2.png b/dita-docs/Site/AdvancedTutorialImages/AddingModules2.png new file mode 100644 index 00000000..49ef6c2f Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/AddingModules2.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/CompletedProjectModule.png b/dita-docs/Site/AdvancedTutorialImages/CompletedProjectModule.png new file mode 100644 index 00000000..9e2021f2 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/CompletedProjectModule.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ConfigurationStart.png b/dita-docs/Site/AdvancedTutorialImages/ConfigurationStart.png index 185d9e27..a4208b65 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/ConfigurationStart.png and b/dita-docs/Site/AdvancedTutorialImages/ConfigurationStart.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png b/dita-docs/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png new file mode 100644 index 00000000..4d47176d Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/CustomFunctionInPropertiesView.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png b/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png new file mode 100644 index 00000000..5d6be548 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineResults.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png b/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png new file mode 100644 index 00000000..a52c45c2 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/DaysLateOnDeadlineStructure.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png b/dita-docs/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png new file mode 100644 index 00000000..51721c42 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/ErrorsFoundTimeWithLookUp.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/FirstSimulation.png b/dita-docs/Site/AdvancedTutorialImages/FirstSimulation.png index e1087cb1..a1cb24b0 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/FirstSimulation.png and b/dita-docs/Site/AdvancedTutorialImages/FirstSimulation.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ModelStructure2.png b/dita-docs/Site/AdvancedTutorialImages/ModelStructure2.png index fcb32883..8698b404 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/ModelStructure2.png and b/dita-docs/Site/AdvancedTutorialImages/ModelStructure2.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ModuleConnections1.png b/dita-docs/Site/AdvancedTutorialImages/ModuleConnections1.png index 34122819..21b27256 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/ModuleConnections1.png and b/dita-docs/Site/AdvancedTutorialImages/ModuleConnections1.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NetResourcing1.png b/dita-docs/Site/AdvancedTutorialImages/NetResourcing1.png index b47e9474..36de92eb 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/NetResourcing1.png and b/dita-docs/Site/AdvancedTutorialImages/NetResourcing1.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NetResourcing2.png b/dita-docs/Site/AdvancedTutorialImages/NetResourcing2.png index 71db6659..b06896f3 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/NetResourcing2.png and b/dita-docs/Site/AdvancedTutorialImages/NetResourcing2.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NewEnumeration.png b/dita-docs/Site/AdvancedTutorialImages/NewEnumeration.png new file mode 100644 index 00000000..ea2f8b55 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/NewEnumeration.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NewFunction.png b/dita-docs/Site/AdvancedTutorialImages/NewFunction.png new file mode 100644 index 00000000..297eb875 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/NewFunction.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NewFunctionLibrary.png b/dita-docs/Site/AdvancedTutorialImages/NewFunctionLibrary.png new file mode 100644 index 00000000..44a316a2 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/NewFunctionLibrary.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NewModel.png b/dita-docs/Site/AdvancedTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/NewModel.png and b/dita-docs/Site/AdvancedTutorialImages/NewModel.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/NewModule.png b/dita-docs/Site/AdvancedTutorialImages/NewModule.png index 1e28ea43..ce5535c0 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/NewModule.png and b/dita-docs/Site/AdvancedTutorialImages/NewModule.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ProjectParameters.png b/dita-docs/Site/AdvancedTutorialImages/ProjectParameters.png new file mode 100644 index 00000000..39e57ceb Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/ProjectParameters.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ProjectRequestPeople.png b/dita-docs/Site/AdvancedTutorialImages/ProjectRequestPeople.png new file mode 100644 index 00000000..b7b51e1f Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/ProjectRequestPeople.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png b/dita-docs/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png new file mode 100644 index 00000000..21d02e3d Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/RequiredWorkHoursPerDayResults.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/RequiredWorkingSpeedInput.png b/dita-docs/Site/AdvancedTutorialImages/RequiredWorkingSpeedInput.png index 25a15725..f587357c 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/RequiredWorkingSpeedInput.png and b/dita-docs/Site/AdvancedTutorialImages/RequiredWorkingSpeedInput.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png b/dita-docs/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png new file mode 100644 index 00000000..169a89ff Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/ResponsedWorkingSpeedInput.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/ShowModule.png b/dita-docs/Site/AdvancedTutorialImages/ShowModule.png new file mode 100644 index 00000000..3d150060 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/ShowModule.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/TwoModules.png b/dita-docs/Site/AdvancedTutorialImages/TwoModules.png index 16fdd64b..c7b560a7 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/TwoModules.png and b/dita-docs/Site/AdvancedTutorialImages/TwoModules.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/WorkLoop.png b/dita-docs/Site/AdvancedTutorialImages/WorkLoop.png new file mode 100644 index 00000000..e04da74b Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/WorkLoop.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/WorkQualityResults.png b/dita-docs/Site/AdvancedTutorialImages/WorkQualityResults.png new file mode 100644 index 00000000..b0610507 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/WorkQualityResults.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/WorkQualityStructure.png b/dita-docs/Site/AdvancedTutorialImages/WorkQualityStructure.png new file mode 100644 index 00000000..5fb9a3f5 Binary files /dev/null and b/dita-docs/Site/AdvancedTutorialImages/WorkQualityStructure.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/WorkStocks.png b/dita-docs/Site/AdvancedTutorialImages/WorkStocks.png index 7c787f9a..fe11f2e4 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/WorkStocks.png and b/dita-docs/Site/AdvancedTutorialImages/WorkStocks.png differ diff --git a/dita-docs/Site/AdvancedTutorialImages/WorkforceAuxiliaries.png b/dita-docs/Site/AdvancedTutorialImages/WorkforceAuxiliaries.png index 2044acb1..5bea923b 100644 Binary files a/dita-docs/Site/AdvancedTutorialImages/WorkforceAuxiliaries.png and b/dita-docs/Site/AdvancedTutorialImages/WorkforceAuxiliaries.png differ diff --git a/dita-docs/Site/BasicTutorial.md b/dita-docs/Site/BasicTutorial.md index 279e4430..c8bf8b58 100644 --- a/dita-docs/Site/BasicTutorial.md +++ b/dita-docs/Site/BasicTutorial.md @@ -1,74 +1,75 @@ # Tutorial: Basic System Dynamics Modelling
-* [1 Model](#model) +This tutorial gives an introduction to the Simantics System Dynamic Tool. We will go over how to create, simulate and analyze a simple system dynamic model. After completing this tutorial, if you wish, there is an [advanced tutorial](AdvancedTutorial.md) that goes more in-depth on the advanced features of the tool. It is recommended that you give a quick glance at first few chapters of the [documentation](sysdyn.md) before starting. You should especially familiarize yourself with the [workbench](sysdyn.md#workbench) of the tool to know the terminology used in the tutorials. + +We are going to create the classic prey-predator model. In our case the model will describe how the population sizes of mice (prey) and owls (predator) change over time. The basic idea around the model is to capture the dynamics of two different population sizes. Let's assume a starting scenario where there is a large mice population and a small owl population. Owls start eating mice decreasing their population, and in turn, giving the owl population the opportunity to grow due to good food availability. However, as the mice population is decreasing and the owl population increasing, at some point there won't be enough food for the entire owl population, leading to starvation and consequently to a decrease in owl population size. The decreased owl population size then allows the mice population to regrow, as they have a smaller number of natural predators on the hunt. + +This tutorial is a walkthrough for creating and analyzing such a model. + +* [1 Creating a new model](#model) * [2 Configuring the model structure](#configuring-the-model-structure) * [3 Equations](#equations) * [4 Simulating the model](#simulating-the-model) +* [5 Result analysis](#result-analysis) -This tutorial introduces you to the basic components and concepts of the System dynamics modelling tool for Simantics. After completing this tutorial, you know how to configure and simulate a system dynamics model. An [advanced tutorial](AdvancedTutorial.md) is also available. This tutorial is part of the [sysdyn documentation](sysdyn.md). - -## Model +## Creating a new model
-We are going to create a simple population model. The model consists of the basic components: Auxiliaries, valves, stocks, dependencies and flows. - -Start by creating a new model. Right-click on the model browser and select New -> Model. +Start by creating a new model from File→New→SD Model.

Creating a new model

-Rename the model to Population. Right-click on Model1 and select Rename. - -Expand the model tree and double-click on Configuration. The model configuration diagram opens in a new editor. +Rename the model to Population by slowly clicking twice on the model name in the Model Browser or by clicking the model once and changing the name from the properties view at the bottom of the tool. Then, expand the model tree and open the model diagram by double-clicking the Population model from Model Browser. ## Configuring the model structure
-Our model is now empty. Let's build a population model for mice. +Let's start by building a population model for the mice. -Open Symbols view and expand BasicSymbols. If BasicSymbols are not visible, make sure that you have the diagram open. The contents of the Symbols view depends on the active diagram editor. +Drag the Symbols view from right of the Model Browser to underneath it and expand BasicSymbols for easier use. If BasicSymbols is not visible, make sure that you have the diagram open as the contents of the Symbols view depends on the active diagram editor.

Symbols view

-These are the basic symbols in System dynamics modelling. We will use these to create the model. +These are the basic symbols in System dynamic modelling that will be used to create the model. -Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using [shortcut keys](sysdyn.md#shortcut-and-control-keys) +Drag one stock variable from Symbols view to the diagram. You can zoom and move on the diagram using the middle mouse button. -Select the variable. Properties view on the bottom of the screen shows the properties of the selected variable. Change the name to Mice and press enter. +Select the variable to bring up Properties view on the bottom of the tool. Change the name to Mice and press enter. You should have a red exclamation mark next to the symbol telling that the variable needs to have expressions for Integral and Initial Value fields. These are not shown in the pictures of this tutorial for visual clarity. We will write expressions to these fields later. You can find a collection of warnings and errors related to the model from the Issues tab right of the Properties tab.
-

Stock variable Mice

+

Stock variable Mice with the Properties view open, issues can be found on the third tab from the left

-Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud. Move cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in the middle of the flow. The valve controls the speed of the flow. Flow from Mice is created the same way. Drag one cloud variable from Symbols view to the right hand side of Mice. Hold down Alt and right-click on Mice. Move cursor on top of the cloud and left-click. Rename the valves to MouseBirths and MouseDeaths. +Next we will draw flows in and out of Mice. Drag one cloud variable from Symbols view to the left hand side of Mice. Hold down Alt and right-click on the cloud, then move your cursor on top of Mice and left-click. The system creates a flow from the cloud to Mice and a valve in between. The valve controls the speed of the flow, in this case the birthrate of Mice. We also need a flow going out from Mice to control the death rate. Let's create this using a shortcut. Right-click Mice while holding Alt down, then drag your mouse right of the Mice and press left-click while holding Alt down. Rename the valves to MouseBirths and MouseDeaths.

Flows in and out of Mice

-Of course mice are not alone in the world. There are also owls that hunt mice. Create a similar structure below mice for owls. +Of course mice are not alone in our imaginary world. We also need owls that hunt mice. Create a similar structure for owls by copy-pasting and renaming. You can copy by drag selecting components and using the all familiar Ctrl+C and Ctrl+V.

Owls and mice

-To control the births and deaths, we need auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve to control it. Drag the variables and rename them according to the picture below. +To control births and deaths we use auxiliary variables. Auxiliary variables can be dragged from Symbols view just like Stock variables. We need one variable for each valve. Drag the variables and rename them according to the picture below.

Auxiliaries for valves

-Arrow connections, dependencies, are created almost like flows. The difference is that the connection is started and ended with a left click and the connection can only be made between two existing variables. Connect the auxiliary variables and valves like in the picture below. +Next we need to draw dependency arrows to tell which components of the system have an interaction. Dependency arrows are created by Alt+left-clicking on a symbol and then clicking on another symbol. Connect components like in the picture below.
@@ -78,9 +79,7 @@ Arrow connections, dependencies, are created almost like flows. The difference i ## Equations
-As you can see from the model, we have made some shortcuts in our model to make it more simple. In reality, there are lots of other factors that affect mouse and owl populations. Let's however use this model as an example. - -For the model to be simulated, each variable needs to have an equation. Equations can be configured from the property view, like the names. Input the following equations into the corresponding variables: +Now we need to give each variable an equation, stock variables also need a value for initial population. Like names, equations can be configured from the property view. Input the following equations into the corresponding variables:
 MouseBirths
@@ -108,7 +107,7 @@ OwlDeathRate
 = 0.09
 
-Finally we need initial values for our populations. +Finally input initial population values for Mice and Owls.
 Mice
@@ -121,16 +120,20 @@ Initial Value: 10
 ## Simulating the model
 
+Now the model is configured and ready for simulation. An experiment needs to be activated before a model can be simulated. Expand the Experiments folder of your model and double-click on Experiment to activate it. This adds experiment control buttons to the toolbar. +

Experiment activation

-Now the model is configured and ready for simulation. Switch Symbols view back to Model Browser. Expand the Experiments folder on your model and double-click on Experiment. This activates the experiment. Experiment needs to be active before the model can be simulated. Experiment activations adds experiment control buttons to the toolbar. To simulate the model, press the play button:
+To simulate the model, press the play button: + +
-System shows the simulation progress in the progress bar on the lower right corner of the screen. +System shows the simulation progress in the progress bar on the lower right corner of the screen. As our model is very simple the progress bar will most likely go by faster that you can see it.
@@ -138,22 +141,100 @@ System shows the simulation progress in the progress bar on the lower right corn When the progress indicator disappears, the simulation is complete. -After the simulation has run, you can select variables from the diagram or model browser and their values over the simulation time will be shown on Trend View. You can select multiple variables from the diagram by holding down Ctrl key. Select Mice and Owls. +After the simulation has been completed, you can select variables from the diagram or Model Browser and their values over the simulation time will be shown on Trend view. You can select multiple variables from the diagram by holding down Ctrl key or by drag selecting. Select Mice and Owls.

Results for Mice and Owls

-As you can see, the simulation is complete, but the results do not reveal any interesting behavior. Let's extend the simulation time. +As you can see, the simulation is complete, but the results do not reveal anything interesting. We need to extend the simulation time. -Select Configuration from the model browser. In the properties-view change stop time to 300.0 and simulate again. +Select Configuration from the Model Browser. In the properties view change stop time to 300.0 and simulate again. -After the simualtion is complete, Select Mice and Owls again. +
+ +

Model configuration

+
+ +After the simulation is complete, Select Mice and Owls again.
-

Results for Mice and Owls, Extended simulation time

+

Results for Mice and Owls, extended simulation time

+
+ +Now we can see the wanted behavior. As the mice population reaches a certain point the number of owls start to increase as they have more food. The increase in owl population lowers the mice population, leading to starvation between owls. The lowered owl population in turn allows the mice population grow back, and the cycle continues. In fact this model simulates the behavior of a pair of first-order nonlinear differential equations also known as Lotka-Volterra equations. + +However, we can see that there is something wrong with the results; the peaks of the mice population are not on the same level. We are using a step-size that is too long. On default the step size is calculated by dividing the simulation time to 500 equal steps, meaning that the previous results were obtained using a step size of (300-0)/500=0.6. (For a more bizarre behavior try simulating with a stop time of 950 using the default step size.) + +To combat this we can set the step size manually from the model configuration, the same place where we changed the simulation stop time. Change the step size to 0.01 and output interval to 1. Output interval allows us to manually configure the step size of the results, meaning that we can make the numerical errors arbitrarily small by lowering the simulation step size, while only having to handle a part of the steps used for the simulation. With these new parameters we now get the correct results. + +
+ +

Results for Mice and Owls with a simulation step size of 0.01

+
+ +## Result analysis +
+ +In this chapter we are going to go over how to analyze the resulting model structure, use comment symbols, create and export graphs in form of charts and export the simulated dataset. Let's start with the model structure analysis. + +Often in system dynamics we are interested in how different feedback loops are formed inside of a model. There is a built in tool analyzing these. Open Structure view that is located between Trend and Values views, then select Loops tab. The contents update depending on the active selection, select OwlBirths symbol. + +
+ +

The loop structure of OwlBirths

+
+ +We can see a feedback loop of 3 variables. You could interpret this loop as follows: owl births increase the number of owls, the more owls there are the more mice are going to get eaten, the more mice that end up as food the more owls can breed. + +To make a visual representation of this feedback loop on the diagram we can utilize a comment symbol called Loop. Expand the CommentSymbols from Symbols and drag the symbol between Mice and Owls symbols. Then, from the properties view select Owls→MouseDeaths→OwlBirths from Loop Items and change the Direction of Rotation to counterclockwise. The Comment option is used for telling if the loop is reinforcing (R) or balancing (B). The symbol automatically detects this behavior, but you can also choose this manually or write your own explanation, if you wish. When you make the Loop symbol as your active selection it automatically highlights the symbols that are included in the loop to visualize how it is formed. + +
+ +

Loop comment symbol

+
+ +The other comment symbol, called Comment, is purely for writing text in the diagram. It is useful, for example, when you want to have memos inside the diagram, or when you want to write an explanation for a design choice. + +Let's move on to graphs. There are two ways of creating them, Trend view (that we have used before) and Charts. Trend view allows you to export the graph as .svg and .png file formats from the top-right controls. However, the built in graph tool has much more options for customizing a graph. Let's create a phase-space plot of the model. + +Start by creating a new chart by right-clicking on the folder Charts under your model, then select New→Line Chart. + +
+ +

Creating a new chart

+
+ +Double click the newly made chart to open it and keep the chart selected to access its properties. Name the chart Phase-space plot, tick hide title and hide legend options, type Owls as the x-axis variable and change the label name to Alive owls. + +
+ +

Chart general properties

-Now the simulation reveals the traditional behavior of predator-prey models. Feel free to adjust the parameters and try the simulations again. +Then, select the Axis and Variables tab on the bottom, click on y-axis and rename label to Alive mice, then click Add variable. Select the \ and write Mice as the variable name. + +
+ +

Chart Axis and Variables properties

+
+ +Now you should have a completed phase-space plot of the prey-predator model. To export a graph right click on it and select either Save as→PNG or Print... and select the pdf printer of your choice. Notice that in order to see results on the graph you need to have an active experiment that has finished a simulation. + +
+ +

Completed phase-space plot and export options

+
+ +You might also want to export the simulated data. Currently the easiest way is to copy it to your clipboard. First, select all components by clicking on the diagram and pressing Ctrl+A on the keyboard. Then, select Values view from the bottom left, click on any numerical value to put the field in focus, finally Ctrl+A and Ctrl+C. Now you have all of the numerical data on your clipboard for pasting to the tool of your choosing. + +
+ +

Values view

+
+ +This concludes the basic tutorial. If you wish to learn more about the advanced features of the tool, please refer to the [wiki](sysdyn.md) or the [advanced tutorial](AdvancedTutorial.md). + +Happy simulating! diff --git a/dita-docs/Site/BasicTutorialImages/ActivatePopulationExperiment.png b/dita-docs/Site/BasicTutorialImages/ActivatePopulationExperiment.png index 0eeeb7e6..52b012ad 100644 Binary files a/dita-docs/Site/BasicTutorialImages/ActivatePopulationExperiment.png and b/dita-docs/Site/BasicTutorialImages/ActivatePopulationExperiment.png differ diff --git a/dita-docs/Site/BasicTutorialImages/Auxiliaries.png b/dita-docs/Site/BasicTutorialImages/Auxiliaries.png index 5cec62b8..30d7da36 100644 Binary files a/dita-docs/Site/BasicTutorialImages/Auxiliaries.png and b/dita-docs/Site/BasicTutorialImages/Auxiliaries.png differ diff --git a/dita-docs/Site/BasicTutorialImages/ChartAxisAndVariables.png b/dita-docs/Site/BasicTutorialImages/ChartAxisAndVariables.png new file mode 100644 index 00000000..a65d0a99 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/ChartAxisAndVariables.png differ diff --git a/dita-docs/Site/BasicTutorialImages/ChartProperties1.png b/dita-docs/Site/BasicTutorialImages/ChartProperties1.png new file mode 100644 index 00000000..4c8f0890 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/ChartProperties1.png differ diff --git a/dita-docs/Site/BasicTutorialImages/Configuration1.png b/dita-docs/Site/BasicTutorialImages/Configuration1.png new file mode 100644 index 00000000..0c5e42f6 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/Configuration1.png differ diff --git a/dita-docs/Site/BasicTutorialImages/Dependency_connections.png b/dita-docs/Site/BasicTutorialImages/Dependency_connections.png index eeb22288..dbbb05f2 100644 Binary files a/dita-docs/Site/BasicTutorialImages/Dependency_connections.png and b/dita-docs/Site/BasicTutorialImages/Dependency_connections.png differ diff --git a/dita-docs/Site/BasicTutorialImages/LoopCommentSymbol.png b/dita-docs/Site/BasicTutorialImages/LoopCommentSymbol.png new file mode 100644 index 00000000..d7ed191b Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/LoopCommentSymbol.png differ diff --git a/dita-docs/Site/BasicTutorialImages/Mice.png b/dita-docs/Site/BasicTutorialImages/Mice.png index 601f77ee..7ec78f2a 100644 Binary files a/dita-docs/Site/BasicTutorialImages/Mice.png and b/dita-docs/Site/BasicTutorialImages/Mice.png differ diff --git a/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults1.png b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults1.png index bee8c180..3137184c 100644 Binary files a/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults1.png and b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults1.png differ diff --git a/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults2.png b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults2.png index cd8426fd..18034aa8 100644 Binary files a/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults2.png and b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults2.png differ diff --git a/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults3.png b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults3.png new file mode 100644 index 00000000..d6065fc2 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/MiceAndOwlResults3.png differ diff --git a/dita-docs/Site/BasicTutorialImages/MiceAndOwls.png b/dita-docs/Site/BasicTutorialImages/MiceAndOwls.png index 83b4b085..6964fa68 100644 Binary files a/dita-docs/Site/BasicTutorialImages/MiceAndOwls.png and b/dita-docs/Site/BasicTutorialImages/MiceAndOwls.png differ diff --git a/dita-docs/Site/BasicTutorialImages/MiceFlows.png b/dita-docs/Site/BasicTutorialImages/MiceFlows.png index a910ea82..eaa381b2 100644 Binary files a/dita-docs/Site/BasicTutorialImages/MiceFlows.png and b/dita-docs/Site/BasicTutorialImages/MiceFlows.png differ diff --git a/dita-docs/Site/BasicTutorialImages/NewModel.png b/dita-docs/Site/BasicTutorialImages/NewModel.png index 609a635c..1280c002 100644 Binary files a/dita-docs/Site/BasicTutorialImages/NewModel.png and b/dita-docs/Site/BasicTutorialImages/NewModel.png differ diff --git a/dita-docs/Site/BasicTutorialImages/OwlBirthsLoopStructure.png b/dita-docs/Site/BasicTutorialImages/OwlBirthsLoopStructure.png new file mode 100644 index 00000000..26e13cd5 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/OwlBirthsLoopStructure.png differ diff --git a/dita-docs/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png b/dita-docs/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png new file mode 100644 index 00000000..3a0da397 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/PhaseSpacePlotAndExport.png differ diff --git a/dita-docs/Site/BasicTutorialImages/PropertiesViewWholeTool.png b/dita-docs/Site/BasicTutorialImages/PropertiesViewWholeTool.png new file mode 100644 index 00000000..1a76c5a0 Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/PropertiesViewWholeTool.png differ diff --git a/dita-docs/Site/BasicTutorialImages/SymbolsView.png b/dita-docs/Site/BasicTutorialImages/SymbolsView.png index 74e6e0b5..e49faeca 100644 Binary files a/dita-docs/Site/BasicTutorialImages/SymbolsView.png and b/dita-docs/Site/BasicTutorialImages/SymbolsView.png differ diff --git a/dita-docs/Site/BasicTutorialImages/ValuesView.png b/dita-docs/Site/BasicTutorialImages/ValuesView.png new file mode 100644 index 00000000..00ad3f7f Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/ValuesView.png differ diff --git a/dita-docs/Site/BasicTutorialImages/newChart.png b/dita-docs/Site/BasicTutorialImages/newChart.png new file mode 100644 index 00000000..9d92fcfc Binary files /dev/null and b/dita-docs/Site/BasicTutorialImages/newChart.png differ diff --git a/dita-docs/Site/Images/BasicWorkbench.png b/dita-docs/Site/Images/BasicWorkbench.png index f5a7ebb5..1ff45779 100644 Binary files a/dita-docs/Site/Images/BasicWorkbench.png and b/dita-docs/Site/Images/BasicWorkbench.png differ diff --git a/dita-docs/Site/Images/Basic_1.png b/dita-docs/Site/Images/Basic_1.png deleted file mode 100644 index f3dc3b3c..00000000 Binary files a/dita-docs/Site/Images/Basic_1.png and /dev/null differ diff --git a/dita-docs/Site/Images/Basic_2.png b/dita-docs/Site/Images/Basic_2.png deleted file mode 100644 index d52d24b5..00000000 Binary files a/dita-docs/Site/Images/Basic_2.png and /dev/null differ diff --git a/dita-docs/Site/Images/CompareTrend.png b/dita-docs/Site/Images/CompareTrend.png index 35e63c2f..5466a5fd 100644 Binary files a/dita-docs/Site/Images/CompareTrend.png and b/dita-docs/Site/Images/CompareTrend.png differ diff --git a/dita-docs/Site/Images/ExampleFunction.png b/dita-docs/Site/Images/ExampleFunction.png index 707ab4ed..37d9e095 100644 Binary files a/dita-docs/Site/Images/ExampleFunction.png and b/dita-docs/Site/Images/ExampleFunction.png differ diff --git a/dita-docs/Site/Images/ModelProperties.png b/dita-docs/Site/Images/ModelProperties.png index 0c181522..b94d39aa 100644 Binary files a/dita-docs/Site/Images/ModelProperties.png and b/dita-docs/Site/Images/ModelProperties.png differ diff --git a/dita-docs/Site/Images/ModelStructure.png b/dita-docs/Site/Images/ModelStructure.png index 131e9204..234df3e8 100644 Binary files a/dita-docs/Site/Images/ModelStructure.png and b/dita-docs/Site/Images/ModelStructure.png differ diff --git a/dita-docs/Site/Images/NewChart.png b/dita-docs/Site/Images/NewChart.png index 76b84c07..9d92fcfc 100644 Binary files a/dita-docs/Site/Images/NewChart.png and b/dita-docs/Site/Images/NewChart.png differ diff --git a/dita-docs/Site/Images/NewEnumeration.png b/dita-docs/Site/Images/NewEnumeration.png index 40ecc979..ea2f8b55 100644 Binary files a/dita-docs/Site/Images/NewEnumeration.png and b/dita-docs/Site/Images/NewEnumeration.png differ diff --git a/dita-docs/Site/Images/NewFunction.png b/dita-docs/Site/Images/NewFunction.png index 84517e28..16a43271 100644 Binary files a/dita-docs/Site/Images/NewFunction.png and b/dita-docs/Site/Images/NewFunction.png differ diff --git a/dita-docs/Site/Images/NewFunctionLibrary.png b/dita-docs/Site/Images/NewFunctionLibrary.png index ca099d12..aaaabca4 100644 Binary files a/dita-docs/Site/Images/NewFunctionLibrary.png and b/dita-docs/Site/Images/NewFunctionLibrary.png differ diff --git a/dita-docs/Site/Images/NewModel.png b/dita-docs/Site/Images/NewModel.png new file mode 100644 index 00000000..1280c002 Binary files /dev/null and b/dita-docs/Site/Images/NewModel.png differ diff --git a/dita-docs/Site/Images/NewModule.png b/dita-docs/Site/Images/NewModule.png new file mode 100644 index 00000000..ce5535c0 Binary files /dev/null and b/dita-docs/Site/Images/NewModule.png differ diff --git a/dita-docs/Site/Images/PreferencesNew.png b/dita-docs/Site/Images/PreferencesNew.png new file mode 100644 index 00000000..1c4271d6 Binary files /dev/null and b/dita-docs/Site/Images/PreferencesNew.png differ diff --git a/dita-docs/Site/Images/Trend.png b/dita-docs/Site/Images/Trend.png index 256e66af..3346ea1c 100644 Binary files a/dita-docs/Site/Images/Trend.png and b/dita-docs/Site/Images/Trend.png differ diff --git a/dita-docs/Site/Images/Values.png b/dita-docs/Site/Images/Values.png index f55734e3..80ccb976 100644 Binary files a/dita-docs/Site/Images/Values.png and b/dita-docs/Site/Images/Values.png differ diff --git a/dita-docs/Site/Images/WithLookup1.png b/dita-docs/Site/Images/WithLookup1.png index 08df607b..e9a7f3db 100644 Binary files a/dita-docs/Site/Images/WithLookup1.png and b/dita-docs/Site/Images/WithLookup1.png differ diff --git a/dita-docs/Site/Images/WithLookup2.png b/dita-docs/Site/Images/WithLookup2.png index 3f69912f..7c20b0b8 100644 Binary files a/dita-docs/Site/Images/WithLookup2.png and b/dita-docs/Site/Images/WithLookup2.png differ diff --git a/dita-docs/Site/sysdyn.md b/dita-docs/Site/sysdyn.md index 7e028b34..42cd103d 100644 --- a/dita-docs/Site/sysdyn.md +++ b/dita-docs/Site/sysdyn.md @@ -20,6 +20,7 @@ * [5.4 Shortcut and Control Keys](#shortcut-and-control-keys) * [5.5 Unit Validation](#unit-validation) * [5.6 Diagram Profiles](#diagram-profiles) + * [5.7 Debugging a model](#debugging-a-model) * [6 Visual model elements](#visual-model-elements) * [6.1 Fonts and colors](#fonts-and-colors) * [6.2 Dependency properties](#dependency-properties) @@ -40,7 +41,7 @@ * [10.2 Expressions](#expressions) * [10.3 Array Slices](#array-slices) * [10.4 Arithmetic Operators](#arithmetic-operators) - * [10.5 Builtin Modelica Functions](#builtin-modelica-functions) + * [10.5 Built-in Modelica Functions](#Built-in-modelica-functions) * [10.6 Simulation Results](#simulation-results) * [10.7 Array Variables in Modules](#array-variables-in-modules) * [11 Functions](#functions) @@ -57,9 +58,9 @@ # What is Simantics System Dynamics
-*Simantics System Dynamics* is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through some changes in the future. New features will be added and old ones improved according to the needs of the modellers. +*Simantics System Dynamics* is currently the only open source modelling and simulating tool for Simantics. Simantics System Dynamics is under development and will go through changes in the future. New features will be added and old ones improved according to the needs of modellers. -This documentation introduces you to the current version of Simantics System Dynamics. Documentation includes the basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, [install](#installation-instructions) the software and try our [basic](BasicTutorial.md) and [advanced](AdvancedTutorial.md) tutorials! +This documentation introduces you to the current version of Simantics System Dynamics. The documentation includes basic modelling principles and a guide on how to model system dynamics models with Simantics System Dynamics. If you like to get to know the tool better and try modelling and simulating yourself, [install](#installation-instructions) the software and try our [basic](BasicTutorial.md) and [advanced](AdvancedTutorial.md) tutorials! # Introduction to System Dynamics Simulation
@@ -120,15 +121,15 @@ Input variables are the way of getting values from other modules. Inputs look li **Shadow** -A shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model. +Shadow variable is a reference to a variable defined elsewhere on the diagram. The referred variable can be an auxiliary, a valve, a stock, or an input. Dependency and flow arrows can be drawn out of a shadow variable, but no arrows can be drawn into a shadow variable. Shadow variables are used to improve the readability of the model. **Loop** -A loop element is a graphical component for highlighting selected feedback loops in a model. +Loop element is a graphical component for highlighting selected feedback loops in a model. **Comment** -A comment element is a string of text on diagram. +Comment element is a string of text on diagram. ## Modeling Principles @@ -136,7 +137,7 @@ System dynamics modelling is much more than just mathematical formulas and nice **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. Note that due to the reserved words in Modelica, variable names such as *Carbon in Atmosphere* cannot be used (*in* is a reserved word). Capitalizing the reserved (*in* --> *In*) word can be used to sidestep the problem. +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. Note that due to the reserved words in Modelica, variable names such as *Carbon in Atmosphere* cannot be used (*in* is a reserved word). Capitalizing the reserved (*in* → *In*) word can be used to sidestep the problem. **Connections** @@ -144,7 +145,7 @@ You should usually try to avoid overlapping dependency arrows. Organizing the va **Graphical annotations** -System dynamics contains usually annotations for loops, polarities, delays and so on. Annotations are important, for communicating the behavior of the model. +System dynamics contains usually annotations for loops, polarities, delays and so on. Annotations are important for communicating the behavior of the model. # Installation Instructions
@@ -152,12 +153,12 @@ System dynamics contains usually annotations for loops, polarities, delays and s System dynamics tool is provided with the Simantics platform. 1. [Download installer from the tool's download page](http://sysdyn.simantics.org/) -2. Install the program to a directory without spaces (limitation inherited from OpenModelica). +2. Install the program to a directory without spaces or special characters (limitation inherited from OpenModelica). 3. Run the application through the launcher generated by the installer - (default: Simantics\Simantics-1.8.0-Sysdyn-32\Simantics-1.8.0-Sysdyn-32) +[OpenModelica](http://www.openmodelica.org/) is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install the latest official 64bit release of [OpenModelica](https://www.openmodelica.org/download/download-windows). In addition to OpenModelica, a development version of a [purpose-built Modelica solver](#solvers) is embedded in the tool. -[OpenModelica](http://www.openmodelica.org/) is used to build and simulate the models. Simantics platform has integrated OpenModelica 1.9.0 beta4 for Windows environments. For other versions and other environments you need to install [OpenModelica](https://www.openmodelica.org/download/download-windows). In addition to OpenModelica, a development version of a [purpose-built Modelica solver](#solvers) is embedded in the tool. +If you plan on creating large models or using a long simulation time with a small step size, it is advised that you give the tool more memory by increasing the numerical value of property -Xmx in the file Simantics-Sysdyn.ini. # Workbench
@@ -168,7 +169,7 @@ System dynamics tool is provided with the Simantics platform. 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. +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** @@ -176,35 +177,31 @@ Model browser shows the structure of your model and all items related to it. **Symbols** -Symbols view (stacked with the model browser) is used for dragging elements to diagrams. +Symbols view (stacked with the model browser) is used for dragging elements to diagrams. -**Search** +3 **Properties (MouseBirths in the image above)** -Search view (stacked with the model browser) is used for searching elements in all models. Search can be launched also from the search field in the bottom right corner or by Ctrl+F. - -3 **Properties** - -Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, Indexes, and Additional information. +Property view shows the selected variable's properties. Property view has a different layout depending on the type of the selected component. The view can also have different tabs depending on the component type. Basic tabs for variables are Equation, indices, and Additional information. **Console** -Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica. +Console view (stacked with the property view) shows console messages from the simulator. Console can be used for debugging models simulated using OpenModelica. **Issues** -Issue view (stacked with the property view) shows the errors and warnings in all models. +Issue view (stacked with the property view) shows the errors and warnings in all models. **Profiles** [Profiles](#diagram-profiles) view (stacked with the property view) allows enabling/disabling some visual diagram effects. -**Trend** +4 **Trend** -[Trend](#simulation-result-and-model-structure-analysis) 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. +[Trend](#simulation-result-and-model-structure-analysis) 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. **Structure** -The [structure](#simulation-result-and-model-structure-analysis) view (stacked with the trend view) can be used for analyzing the varaible dependencies, loops, and the structure of the model. +The [structure](#simulation-result-and-model-structure-analysis) view (stacked with the trend view) can be used for analyzing the variable dependencies, loops, and the structure of the model. **Values** @@ -232,21 +229,21 @@ Perspectives allow changing between different layouts of the views. On start-up, [Chart panel](#chart-panel) is able to house multiple [charts](#custom-charts) at the same time. Charts are added to the panel by dragging from model browser. -**TIP!** If you accidentally close a view, you can reopen them from Window->Show View->Other... +**TIP!** If you accidentally close a view, you can reopen them from Window→Show View→Other... **TIP!** Try dragging the views to different positions (e.g. the property view to the right pane). ## Global Preferences -Global preferences of Simantics System Dynamics are located under Window -> Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below. +Global preferences of Simantics System Dynamics are located under Window → Preferences. Feel free to browse the contents yourself. A few notable items on the list are described below.
- +
**Category** | **Description** --- | --- -**General -> Keys** | All [keyboard shortcuts](#shortcut-and-control-keys) available. +**General → Keys** | All [keyboard shortcuts](#shortcut-and-control-keys) available. **Modelica** | The location of OpenModelica solver on file system. **Solver** | [Solver](#solvers) to be used for simulation. OpenModelica or internal custom solver (experimental) can be selected. **Sysdyn Diagrams** | Sysdyn Diagrams allows customize default colors and fonts of diagram elements. @@ -259,24 +256,24 @@ Global preferences of Simantics System Dynamics are located under Window -> Pref 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.
- +
**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 -> SD Model. +Start a new model by right-clicking the model browser and selecting New → Model or from the main menu File → New → SD Model.
- +
**Creating a new module type** -Create a new module type by right-clicking on the Modules-folder and selecting New -> Module type. This creates a new module type that you can populate to your other modules and the model configuration. +Create a new module type by right-clicking on the Modules-folder and selecting New → Module type. 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. +Model configuration can be opened by double clicking Configuration in the model browser. **Configuring modules** @@ -300,44 +297,44 @@ There are some restrictions on what connections can be made, but don't worry, th **Connections between modules** -**Outside the module** +**Outside the module** -You can connect variables to variables in modules like this: +You can connect variables to modules like this:
 MODULE -----> INPUT
 or
-ANY VARIABLE -----> MODULE 
+ANY VARIABLE -----> MODULE
 
This is just the visual configuration, but you need those connections to really connect variables in the module's properties. In the *Inputs* tab stacked under *Module Properties* you can select which variables you connect to inputs inside the module. In the *Outputs* tab you can select which variables you lift from the module to inputs outside it. -**Inside the module** +**Inside the module** -Input variables get values from outside 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 +Output variables send their values outside the module. To make a variable output its values, from the properties view make sure the Is Output checkbox is ticked. **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. +Select a single variable from diagram or model browser. The properties of the variables are shown in the properties view where you can also 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->Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database. +To export your model to a file, select your model from the model browser, right-click and from the context menu choose Export→Model. 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, for example, to create different versions of a model, create backups or to transport a model to another database. **Import model** -Right-click on the model browser and select Import->Model. Browse to your .sysdyn file and select open. The model is added to your model browser. +Select File→Import Model, browse to your .sysdyn file and select open. The model is added to your model browser. **Export module** -To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export->Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database. +To export a module to a file, select the module from the model browser, right-click and from the context menu choose Export→Module. Select the folder where to export your model, give the file a name and press Save. Module export can be used, for example, to transport a module to another model or another database. **Import module** -Right-click the Modules folder of a model and select Import->Module. Browse to your .sysdynModule file and select open. The module is added to your model. +Right-click the Modules folder of a model and select Import→Module. Browse to your .sysdynModule file and select open. The module is added to your model. ## Model Properties @@ -364,33 +361,33 @@ Model properties can be viewed by selecting either the model or its configuratio Auxiliary and valve variables have two special types: WithLookup and Delay. These types are selected from Type drop down menu in the variable's properties. The variable types offer more specific functionalities than normal variables, but the same functionality could be achieved using normal variables. -### WithLookup +### WithLookup WithLookup variable has two equation fields, WithLookup and Lookup table. Lookup table has a table from which the value of the variable is interpolated using the value of WithLookup field.
-You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clickin on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click. +You do not need to manually input the Lookup table. WithLookup variable type offers an additional Lookup table tab in the property view. In this view you can add and modify points in the lookup table. Points can be added either by clicking on the chart or by using the input fields and Add button. Points can be modified by dragging them on the chart or modifying values in the table. Points are removed by clicking them with right mouse click.
### Delay -Delay variables build equations for Nth order delays. Users can set the equation for the value that is to be delayed, the time and order of the delay and a possible start value. If start value is empty, the start value is set automatically. +Delay variables build equations for Nth order delays. Users can set the equation for the value that is to be delayed, the time and order of the delay and a possible start value. If start value is empty, the start value is set automatically.
-Different order delays have slightly different curves when a step change is triggered. The example picture below shows a step change from 0 to 1 at time 1 with four different delays: 1st, 2nd, 3rd and 10th order delays. +Different order delays have slightly different curves when a step change is triggered. The example picture below shows a step change from 0 to 1 at time 1 with four different delays: 1st, 2nd, 3rd and 10th order delays.
-For further information on how the delays work, you can look at the equations that are created by the delay variable. Below is a third order delay. Delay3 is the actual variable that is seen by users. DelayClass has as many level (LV) variables as the order of the delay is. +For further information on how the delays work, you can look at the equations that are created by the delay variable. Below is a third order delay. Delay3 is the actual variable that is seen by users. DelayClass has as many level (LV) variables as the order of the delay is. Definitions:
@@ -417,7 +414,7 @@ equation
 end Delay3_delayClass;
 
-The above definitions can be seen as a line of stocks and valves. The first valve, delay0, is given the value of the delayed expression. Delay3 is given the value of the valve that is coming from the last stock. +The above definitions can be seen as a line of stocks and valves. The first valve, delay0, is given the value of the delayed expression. Delay3 is given the value of the valve that is coming from the last stock. Equations:
@@ -430,7 +427,7 @@ Delay3 = Delay3_delayClass_instance.delay3;
 Shortcut keys for configuring a model on diagram.
 
 Key | Action
---- | --- 
+--- | ---
 Esc	| Cancel operations (e.g. connection and rename).
 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.
@@ -445,7 +442,7 @@ F2 | Rename selected variable
 Ctrl + left mouse button | Select multiple variables
 Mouse wheel or + or - | Diagram zoom
 drag(mouse3) | Diagram pan
-drag(shift + any mouse button) | Diagram pan
+drag(shift + right mouse button) | Diagram pan
 ↓, ←, ↑, → (arrow keys) | Diagram pan
 Ctrl + C | Copy selected elements
 Ctrl + X | Cut selected elements
@@ -456,13 +453,13 @@ R | Show / hide ruler
 1 | Fit diagram contents to screen
 Ctrl + Space | Content assist in equation editor
 
-Other shortcut keys can be found selecting Window -> Preferences from the main menu. Keys are located in General -> Keys.
+Other shortcut keys can be found selecting Window → Preferences from the main menu. Keys are located in General → Keys.
 
 ## Unit Validation
 
-Unit validation is useful for finding errors in the model. With unit validation, the consistency of the measurement units of variables is checked. For unit validation, the units of all variables in the model must be defined. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.
+Unit validation is useful for finding errors in the model. Unit validation checks the consistency of units. To use this feature you need to define units for every variable used in the model. If a variable is dimensionless, use 1 as the unit. In certain constructs, a dimensionless variable can be used as "a wild card", e.g., adding a dimensionless variable with a dimensioned one is OK.
 
-Common error sources of unit validation include the following. The respective issues are shown in the picture below. 
+Common error sources of unit validation include the following. The respective issues are shown in the picture below.
 
 
@@ -489,11 +486,11 @@ yields a warning, it can be fixed be changing the expression to
     unitCast(Aux1) + time
 
-, in which case the unit of the expression is that of time, or to +in which case the unit of the expression is that of time, or to
     Aux1 + unitCast(time)
 
-, in which case the unit of the expression is that of Aux1. +in which case the unit of the expression is that of Aux1. ## Diagram Profiles @@ -501,28 +498,41 @@ Diagram profiles allow selecting which visual effects are enabled. Currently the **Default** -**Issue warnings** +**Issue warnings** When enabled, an error or a warning symbol is attached to diagram elements in which there are errors or warnings (usually in the equations). -**Shadow variable visualizations** +**Shadow variable visualizations** When enabled, the original and all the shadow variables are highlighted when one is selected. **Simulation Playback** -**Playback Colors** +**Playback Colors** When enabled, colors of the elements on diagram change during a playback experiment. +## Debugging a model +If you find yourself with a model that doesn't simulate or has bizarre behavior, there are several places to look for clues for what went wrong. Firstly, if you got an error message and can't infer the problem straight from the message, look at the issues view if it can tell you what is wrong in different words. If you know how to read Modelica code, right click Configuration under the broken model and choose Open With → Modelica Code Viewer. The tool works by generating Modelica code from the graphical model and then solving it. Therefore, if something is broken it means that there is a problem with the generated Modelica code (or, very rarely, a bug in the solver you are using). You can also refer to the list below, if you still find yourself stuck. + +Some of the most common errors include: +* In a model that uses modules, you forget to connect inputs and/or outputs in the module properties +* You forgot to add an enumeration to a variable, i.e. trying to put a vector to a scalar variable (or vice versa) +* You increased the enumeration indices you are using, but forget to update a variable that depend on it +* You wrote a custom Modelica function, but it is broken +* You are comparing two numbers for equality while using OpenModelica solver (forbidden, allowed by the internal solver) +* You have a variable that refers to itself in the equation, making the solver unable find an initial value + +If you are using OpenModelica solver it can be very useful to google error messages printed in the console of the tool. + # Visual model elements
-The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool offers are comment symbols which do not affect simulation but help the understandability of models. +The visual appearance of the elements on diagram can be modified in various ways. In addition, the tool has comment symbols which do not affect simulation but help the understandability of models. ## Fonts and colors -Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window -> Preferences -> Sysdyn Diagrams. +Fonts and colors of diagram elements can be changed by right-clicking the element and selecting Font... The default fonts and colors for each diagram element type can be changed in Window → Preferences → Sysdyn Diagrams. ## Dependency properties @@ -574,9 +584,9 @@ Comments are just strings of text. ## Experiments -There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics. +There are three different ways for simulating a model. Different simulations are represented as different types of experiments in Simantics System Dynamics. Currently some of the experiment and solver combinations are still in development. -Experiments are created from the context menu of experiments folder in a model. +Experiments are created from the context menu of experiments folder in a model.
@@ -586,19 +596,19 @@ Double-click on an experiment activates it and displays experiment type specific **Normal simulation** -Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run. +Experiment is the basic simulation type. It simulates a model from start time to end time and results can be viewed after the simulation has been run. Works on both the internal and OpenModelica solvers. **Game simulation** -Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended. +Game simulations allow simulating an arbitrary number of steps, changing parameter values and continuing simulation with the new values from where it previously ended. Works on the internal solver, OpenModelica version still in development. **Simulation playback** -Simulation playback works essentially as the basic experiment, but it offers some additional visualization options. +Simulation playback works essentially as the basic experiment, but it offers some additional visualization options. Works on both solvers. **Sensitivity analysis simulation** -Sensitivity analysis allows running [multivariate](http://en.wikipedia.org/wiki/Multivariate_analysis) [Monte Carlo simulations](http://en.wikipedia.org/wiki/Monte_Carlo_method) with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters. +Sensitivity analysis allows running [multivariate](http://en.wikipedia.org/wiki/Multivariate_analysis) [Monte Carlo simulations](http://en.wikipedia.org/wiki/Monte_Carlo_method) with different parameter value sets and to visualize how much the simulation result depends on changes in the selected parameters. Works on OpenModelica solver, internal solver implementation still in development.
@@ -628,7 +638,7 @@ Simantics System Dynamics allows using the multiple solvers provided by OpenMode Alternatively to OpenModelica, an internal custom Modelica solver is included in Simantics System Dynamics. The custom solver is currently at an experimental state, and thus all functionalities of the tool are not yet supported, e.g., only the basic experiment can be run with it. The advantage of the custom solver is, however, that simulation is usually a lot faster than with OpenModelica. Try out yourself which solver suits best for your needs. -The solver can be changed in Windows -> Preferences -> Solver. +The solver can be changed in Windows → Preferences → Solver. # Simulation Result and Model Structure Analysis
@@ -639,7 +649,7 @@ Model structure can be examined in the Structure view. There are three options: **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. +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. You can also export the trend using controls in the upper right corner.
@@ -655,13 +665,13 @@ Shows you the values of the selected variable(s) in a table form. If the value h **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 Results button: +You can compare different results of the same model by saving simulation results and displaying the saved results side by side with other results. This functionality currently only works for the OpenModelica solver, internal solver implementation is in development. You can save your results after simulating by clicking the Save Results button:
-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. +on your experiment controls. The saved results appear to model browser under the active experiment. To show the results on trends and tables, double click on the result to activate it.
@@ -694,7 +704,7 @@ Loops display all feedback loops which the selected variable belongs to. # Custom Charts
-Custom charts are user-defined displays of simulation result data. They can be used and re-used in various places. The four types of custom charts (line, sensitivity, bar, and pie charts) provide model developers means for examining and developing their models and communicating the simulation results to others. +Custom charts are user-defined displays of simulation result data. They can be used and re-used in various places. The four types of custom charts (line, sensitivity, bar, and pie charts) provide model developers means for examining and developing their models and communicating the simulation results to others. Custom charts are created to the Charts folder in model browser. @@ -702,7 +712,7 @@ Custom charts are created to the Charts folder in model browser.
-Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts. +Charts are configured the same way as variables: first select the chart from model browser and then configure it in the property view. Charts can be viewed in the same active trend view as any variable by selecting the chart from model browser. In addition to trend view, charts can be populated directly to the model diagram by dragging them from the model browser. Charts can also be added to a separate chart panel which can contain multiple charts. ## Line Chart @@ -769,7 +779,7 @@ Sensitivity chart shows the time series of a variable with confidence bounds. Be Variable | The full path of the variable. This field has content assistant, which shows the possible variables as you type. Range | If the variable has multiple dimensions, this field allows to select, which dimensions are displayed. It is also possible to sum the variables in the dimensions. Display median | Display the median value of the variable at each time step. -Confidence bounds and colors | The confidence bounds in percents and colors for them. +Confidence bounds and colors | The confidence bounds in percentages and colors for them. There are also configuration options for y-axis. They are displayed when an axis is selected in the Axis and variables tab. @@ -783,7 +793,7 @@ Hide | Options to hide parts of the axis: label, axis line, tick marks, tick lab ## Bar Chart -Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time. +Bar charts display variables in a certain point in time. The point can be defined for the complete chart in chart's general settings and individually for each variable in variable's settings. If no time is defined, the last simulation step is shown in game or normal simulation mode. Playback mode displays the current playback time.
@@ -888,7 +898,7 @@ By default, chart panel is hidden in the upper-right corner of the system dynami ## Modeling -Models with multidimensional variables look just like any other models. The structure of the models is replicated givin multiple indexes to variables. For users with programming background, notation Variable[] may be familiar. In system dynamic modeling we need to give names to the indexes. Instead of using numbers to define the indexes, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples): +Models with multidimensional variables look just like any other models. The structure of the models is replicated giving multiple indices to variables. For users with programming background, notation Variable[] may be familiar. In system dynamic modeling we need to give names to the indices. Instead of using numbers to define the indices, like in normal programming, we use enumerations. The steps to create a model with multidimensional variables are as follows (with examples): 1 **Create the model structure** @@ -898,15 +908,15 @@ Model with multidimensional variables looks just like any other model.
-2 **Create Enumerations and define the indexes** +2 **Create Enumerations and define the indices** -Enumerations are created by right-clicking configuration and selecting New->Enumeration. +Enumerations are created by right-clicking configuration and selecting New→Enumeration.
-Define enumeration indexes by adding as many indexes as you want. Rename the indexes by selecting them and then clicking on them again. +Define enumeration indices by adding as many indices as you want. Rename the indices by selecting them and then clicking on them again.
@@ -914,15 +924,15 @@ Define enumeration indexes by adding as many indexes as you want. Rename the ind 3 **Add Enumerations for variables** -Select the variable that you want to be multidimensional. From the Indexes -tab in the property view, move the wanted enumerations to the right. The order of the enumerations does matter. +Select the variable that you want to be multidimensional. From the indices -tab in the property view, move the wanted enumerations to the right. The order of the enumerations **does** matter.
-4 **Define equations for all possible indexes** +4 **Define equations for all possible indices** -Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indexes, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}. +Multidimensional variable can be thought as a multidimensional table. Each cell of the table needs to have an expression or a value. A cell cannot have multiple definitions. All cells can be defined in one expression like in the following example. E1 and E2 have both three indices, so the resulting definition can be {{1,2,3},{4,5,6},{7,8,9}}.
@@ -930,7 +940,7 @@ Multidimensional variable can be thought as a multidimensional table. Each cell ## Expressions -Values for all cells in the variable matrix can be defined in a single expression. +Values for all cells in the variable matrix can be defined in a single expression.
@@ -940,7 +950,7 @@ Values for all cells in the variable matrix can be defined in a single expressio
-In many situations, it is however more clear to define separate expressions for each cell or blocks. +In many situations, it is however more clear to define separate expressions for each cell or blocks. 1 **Define range for the expression** @@ -993,7 +1003,7 @@ The following explains different methods for accessing parts of the variable // Slices Auxiliary[one, E2] = {1,2,3} Auxiliary[E1, zwei] = {{2},{5},{8}} - + // In addition to single cells and the whole enumeration range, a subrange of the enumeration can be used Auxiliary[two : three, E2] = {{4,5,6},{7,8,9}} Auxiliary[one : two, zwei : drei] = {{2,3},{5,6}} @@ -1028,7 +1038,7 @@ Division with an array
  {1,2,3} / {1,2,3} = ERROR! not allowed
- 
+
  // Elementwise
  {1,2,3} ./ {1,2,3} = {1,1,1}
 
@@ -1047,11 +1057,11 @@ Matrix multiplication with an array
  {{3,4},{5,6}} * {1,2} = {11,17}
  {{3,4},{5,6}}  * {1,2,3} = ERROR! incompatible array sizes
- 
+
  //Elementwise
  {1,2} .* {1,2} = {1,4}
- 
- Real[3,2] c = {{1,2},{3,4},{5,6}};  
+
+ Real[3,2] c = {{1,2},{3,4},{5,6}};
  Real[2,2] d = {{3,4},{5,6}};
  Real[2,2] cd;
  cd = c[2:3, :] .* d; // Result: {{9,16},{25,36}}
@@ -1064,9 +1074,9 @@ Elementwise power of array variable
  {1,2} .^ 2 = {1,4}
 
-## Builtin Modelica Functions +## Built-in Modelica Functions -Modelica has some builtin functions that help using multidimensional variables. This chapter introduces some of the builtin functions. +Modelica has some built-in functions that help using multidimensional variables. You can find the functions under any model inside the folder Functions→Built-in Functions. This chapter introduces some of the built-in functions. **Dimension and size functions** @@ -1074,7 +1084,7 @@ We will use the same example variable as previously.
  enumeration E1 = one, two, three
  enumeration E2 = eins, zwei, drei
- 
+
  Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}}
 
@@ -1105,14 +1115,14 @@ In addition to normal array constructing, a special construction functions can b **zeros(n1,n2,n3,...)** -An array full of zeros with dimensions n1 x n2 x n2 x ... +An array full of zeros with dimensions n1 x n2 x n2 x ...
  zeros(2, 2) = {{0,0}, {0,0}}
 
**ones(n1,n2,n3,...)** -An array full of ones with dimensions n1 x n2 x n2 x ... +An array full of ones with dimensions n1 x n2 x n2 x ...
  ones(2, 2) = {{1,1}, {1,1}}
 
@@ -1146,7 +1156,7 @@ Constructs a square matrix with elements of vector v on the diagonal and all oth **linspace(x1,x2,n)** -Constracts a Real vector from x1 to x2 with n equally spaced elements. +Constructs a Real vector from x1 to x2 with n equally spaced elements.
  linspace(2,5,4) = {2,3,4,5}
 
@@ -1194,9 +1204,9 @@ Functions min(A), max(A), sum(A) and product(A) reduce arrays to scalars. When y enumeration E1 = one, two, three enumeration E2 = eins, zwei, drei Auxiliary[E1, E2] = {{1,2,3},{4,5,6},{7,8,9}} - + AuxiliarySum[E1] = {sum( Auxiliary[ i , E2 ] ) for i in E1} // Result: {6, 15, 24} - + /* Same as: {sum(Auxiliary[one, E2]), sum(Auxiliary[two, E2]), sum(Auxiliary[three, E2])} {sum({1,2,3}), sum({4,5,6}), sum({7,8,9})} @@ -1216,7 +1226,7 @@ To use multiple iterators, use the following format (NOTE the reversed order of The range doesn't have to be the whole enumeration. Subranges can also be used.
  {sum( Auxiliary[ i , eins : zwei ] ) for i in E1.one : E1.two} // Result: {3, 9}
- 
+
  /* Same as
  {sum(Auxiliary[one, eins : zwei]), sum(Auxiliary[two, eins : zwei])}
  {sum({1,2}), sum({4,5})}
@@ -1225,13 +1235,13 @@ The range doesn't have to be the whole enumeration. Subranges can also be used.
 
 ## Simulation Results
 
-Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables. 
+Multidimensional variables provide multiple results for the same variable. One result for each index. The trend view clutters very quickly when you add dimensions to the variables.
 
 
-The clutter can be reduced by selecting which enumeration indexes are shown in charts. Select an enumeration and tick the indexes that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model. +The clutter can be reduced by selecting which enumeration indices are shown in charts. Select an enumeration and tick the indices that you want to show. The same settings apply to each variable that uses the enumeration. This way you can follow an interesting index throughout the model.
@@ -1244,25 +1254,25 @@ The clutter can be reduced by selecting which enumeration indexes are shown in c

Replaceable enumeration inside a module

-You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see [Modeling](#modeling)). +You can also use array variables inside modules. Enumeration need to be defined separately for each module type and added to all necessary variables, also inputs and outputs (see [Modeling](#modeling)). When defining a module, modeler may not want to restrict the size of the array variable. In many cases the same module structure could be used for both large and small arrays. For example if the module is a project, a project may have three or even twenty phases. In this case the enumerations inside modules need to be set as replaceable. -In this example, the original enumeration that the modeler used had two indexes. We are using an instance of this module, but we need to use array variables that have three indexes instead of two. We are using two variables and an instance of the module. +In this example, the original enumeration that the modeler used had two indices. We are using an instance of this module, but we need to use array variables that have three indices instead of two. We are using two variables and an instance of the module.

Module configuration for replacing enumerations inside the module

-In the parent configuration, we have used an enumeration with three indexes in the two variables. +In the parent configuration, we have used an enumeration with three indices in the two variables.

Enumeration in the parent configuration that will replace the enumeration in the module

-The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clickin on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model. +The replacement can be defined in the properties of the module instance. When the module instance is selected, a table with all the replaceable enumerations is shown. By clicking on the cell next to the enumeration, a drop-down box is shown with all the enumerations in the parent module. If an enumeration is selected, it will replace the enumeration inside the module during simulation. The replacement will not, however, show elsewhere in the model.
@@ -1274,7 +1284,7 @@ When creating replaceable enumerations in modules, modelers need to be very care # Functions
-Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models. +Modelica provides a convenient way to use functions in your models. You can create your own functions, export and import complete function libraries and share function libraries to be used in all of your models. ## Creating Functions @@ -1282,14 +1292,16 @@ Modelica provides a convenient way to use functions in your models. You can crea
-You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New->Function. +You can create new functions to the Functions -folder in your model or to function library folders. Right-click on the folder and select New→Function. Functions that can be found from Functions -folder can be used in your variable definitions. -Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function. +Functions are defined using Modelica language. The variables used in the function are defined in the declaration section. Function needs an output and an arbitrary number of inputs. Modelica specification enables use of multiple outputs, but this feature is not supported. The inputs are given in the same order as they are used in calling the function. Algorithm section defines the actual functionality of the function. In algorithm sections you must use assignments ":=" instead of just plain "=". All the assignments are calculated in the order they are written. +Also, take note that creating new lines in the Modelica code text box is done via shift+enter. + Below is an example of a simple function. For more examples, see the built-in functions provided with the tool and [Modelica specifications](https://www.modelica.org/documents/).
@@ -1304,11 +1316,11 @@ Functions can be collected into libraries. This is a good way of organizing your
-There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually. +There are three types of function libraries: normal function library, built-in function library and shared function library. Normal function libraries can be created to a model and are available only in that model. Built-in libraries are available in all models and calls to built-in functions should not include the library name. Shared functions are available to all models in your workspace, but you need to enable them to each model individually. Create a new function library by right-clicking on Functions folder, Shared functions folder or other module library. -A function library can be exported by right clicking the function library and selecting Export -> Function library. A function library can be imported by right clicking the Functions folder and selecting Import -> Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library. +A function library can be exported by right clicking the function library and selecting Export → Function library. A function library can be imported by right clicking the Functions folder and selecting Import → Function library. Functions themselves cannot be exported or imported. To export a function, add it into a function library and export that function library. If you create a shared function library, the library can be added to other models or removed from current model by selecting the Shared Functions -folder and using the properties view. @@ -1318,9 +1330,9 @@ If you create a shared function library, the library can be added to other model ## External Functions -Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window -> Preferences -> Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code. +Modelica allows you to use external functions that are programmed using C language. To use this feature, you need to have the Sysdyn version with OpenModelica included and OpenModelica set as the solver in the Preferences (Window → Preferences → Solver). The installation package with OpenModelica has also MinGW C compiler included that allows to build object files from C source code. -Below is a simple example of using a function that returns the sum of two arguments. +Below is a simple example of using a function that returns the sum of two arguments.
  double exampleCFunction(double x, double y)
@@ -1367,7 +1379,7 @@ Small external C function can also be written directly to the function code in S
 
 ## Modelica Functions
 
-Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see [builtin functions for arrays](#builtin-modelica-functions).
+Modelica has built-in functions that can be used anywhere and are not visible in function libraries. This section covers a large number of those functions. For functions related to array variables, see see [Built-in functions for arrays](#Built-in-modelica-functions).
 
 **Function** | **Description**
 --- | ---
@@ -1383,17 +1395,17 @@ cosh(x) | Hyperbolic cosine.
 cross(x,y) | Returns the 3-vector cross product of the 3-vectors x and y.
 delay(expr, delayTime) | Returns the value of expr at the time time-delayTime. The value of expr is returned when time <= time.start + delayTime.
 der(x) | Time derivative of x. X must be have continuous-time variability.
-div(x, y) | Returns the algebraic quotient x/y with any fractional part discarted. E.g. div(10,3) = 3.
-edge(b) | Returns true when the value of the boolean expression b changes. Expanded into (b and not pre(b)).
+div(x, y) | Returns the algebraic quotient x/y with any fractional part discarded. E.g. div(10,3) = 3.
+edge(b) | Returns true when the value of the Boolean expression b changes. Expanded into (b and not pre(b)).
 exp(x) | Exponential, base e.
 floor(x) | Returns the largest integer not greater than x, the closest integer below x.
-initial() | Returns true at the beginning of the simulation. 
+initial() | Returns true at the beginning of the simulation.
 integer(x) | Returns the largest integer not greater than x as an integer.
 log(x) | Natural logarithm. (base e, x > 0)
 log10(x) | Base 10 logarithm. (x > 0)
 mod(x, y) | Returns the integer modulus of x/y: mod(x,y) = x - floor(x/y) * y.
 noEvent(expr) | noEvent around an expression causes the expression to NOT generate event. **Important:** If you want a condition to be checked only on time steps, use noEvent. (e.g. if noEvent(value >= 1) then ... else ...)
-pre(x) | Returns the preceding value of y from time event that has occured before current time.
+pre(x) | Returns the preceding value of y from time event that has occurred before current time.
 rem(x, y) | Returns the integer remainder of x/y: rem(x,y) = x - div(x,y) * y.
 sample(start, interval) | Returns true and triggers time events at times start + i * interval (i=0,1,...).
 sign(x) | Returns -1 if x is negative, 1 if x is positive. Expanded into "(if x > 0 then 1 else if x < 0 then -1 else 0)".
@@ -1418,7 +1430,7 @@ Spreadsheets are an easy way to import and manage parameter values. Sheet shells
     
 
-You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indexes are not mandatory, but help reading and maintaining the sheet. +You can also refer to sheets with array variables. Reference is simple with one and two dimensional array variables. Below is an example of a sheet with values for two different variables. The names of the indices are not mandatory, but help reading and maintaining the sheet.
@@ -1430,7 +1442,7 @@ Reference to a sheet range creates an array variable.
-ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indexes are ordered as in this example. However, if you wish to present the indexes in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3))) +ArrayTest2 has two dimensions. Reference to a larger range creates a two-dimensional variable. By default, the indices are ordered as in this example. However, if you wish to present the indices in a different order in the spreadsheet, you can transpose the sheet reference (e.g. transpose(ArrayTestSheet(E2:G3)))
@@ -1443,7 +1455,7 @@ Spreadsheets can be used to store and display external history data e.g. from so
-History data is used by creating a History dataset to an experiment. The dataset is activated and deactivated in charts by double-clicking the dataset. History data reference is set in the properties of the history dataset. +History data is used by creating a History dataset to an experiment. The dataset is activated and deactivated in charts by double-clicking the dataset. History data reference is set in the properties of the history dataset.
@@ -1469,7 +1481,7 @@ If the history dataset is activated, history data is displayed whenever it is av # Vensim Model Import
-The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool [Vensim](http://vensim.com/). This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" -> "Vensim Model (.mdl)". +The tool also has a limited support for importing system dynamics models created with the simulation and modelling tool [Vensim](http://vensim.com/). This functionality is used similarly to the regular model import, so by right-clicking the browser and selecting "Import" → "Vensim Model (.mdl)". The import process has several known limitations: @@ -1485,13 +1497,13 @@ The import process has several known limitations: # Sample Models and Molecules
-There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import->Model. +There are some sample models located in the sampleModels folder found in the installation folder. The sample models can be imported by right-clicking on the model browser and select Import→Model. [Simantics](https://www.simantics.org/end_user_wiki/index.php/Introduction_to_Simantics) | *System Dynamics Modelling*
- + [**Tutorial: Basic System Dynamics Modelling**](BasicTutorial.md) System dynamics modelling in Simantics is a free modelling tool that is included into the basic installation. This tutorial introduces the basic features of the system dynamics modelling tool.