Handling of Modelica Model’s Parameter Values in Dymola

Written by: Raees B. K. Parambu – project Engineer


This article is designed to guide the user in handling or organising the parameter values of the top-level experimental models in their models. This blog post may be useful for those newcomers who wish to get an insight into different ways of storing and propagating parameter values to top-level experimental models in Dymola.


Dymola (DYnamic MOdelling LAboratory) is a systems engineering tool for modelling of multi engineering & physical complex systems based on Modelica (an open source equation-based object-oriented modelling language). In Dymola, before clicking on the simulation button, it is necessary to check all the parameter values, excitation signal(s) and other boundary conditions (B.C.s) are provided to the top-level of an experimental model in order to run the simulation process successfully. In this blog post, a top-level experimental model means a model which is capable of being used for numerical experiments through which to perform the analysis of simulation results. In this blog post, such a top-level experimental model from now onwards is simply called a top-level model unless stated otherwise. The focus of this blog post is how to handle or propagate the parameter values of the top-level models using three different methods. In the following sections, these three methods are presented and illustrated with a specific example from Modelica Standard Library (MSL).


Depending on the model’s application, complexity and reusability, the method of handling of top-level model parameter values may also vary. Among others, there are at least three different methods one can use in their modelling work. These methods can be classified as listed below:

  1. Direct storage
  2. Using a Modelica class ‘Record’
  3. Using a replaceable model

The next section of this blog will demonstrate an example of each method with the aid of MSL.


  1. Direct storage

This is the simplest and most commonly used method by both new and experienced Dymola users. This method can be very helpful for directly storing parameter values at the top-level of the model and is widely used by several models in MSL.

For the illustration purpose of this method, a simple example is chosen from MSL Electrical Library.

MSL path: Modelica.Electrical.Analog.Examples.Rectifier


Figure 1a: Diagram layer of a MSL rectifier model.

Figure 1a shows that there are multiple electrical components in this rectifier model. Each of these components in the model is parameterised with variable names. Details about the parameter names and values are shown in Figure 1b. In addition to this, an excitation signal such as a signal current load is connected to the right-hand side of the rectifier circuit, and a B.C. of Ground1 is also connected to ground this model. According to the definition provided in the introduction section of this blog, this model is considered to be a top-level experimental model in Dymola. As also aforementioned in the introduction section, before simulating this model it is obligatory to check all the parameters values are provided at the top-level of this model. Failure to do so will result in a simulation error with appropriate error message.


Figure 1b: Modelica Text layer of MSL Rectifier model.

By looking at the Modelica text layer of the rectifier model, it is evident that this model has all the required parameter values stored at its top-level. Such a model can be simulated and carry out further numerical analysis. However, this is beyond the scope of this blog post. The next section is dedicated to Method 2.

     2. Using a Modelica class ‘Record’

This is the second most common method used by Dymola users. This technique is very useful for storing and passing parameter values to the top-level of the model using one of the Modelica classes called ‘Record’. One such example from MSL is provided below:

MSL path: Modelica.Electrical.Machines.Examples.DCMachines.DCPM_Start

Figure 2a-

Figure 2a: Diagram layer of MSL DCPM_Start model and 2b its Record dialog box.

The diagram layer of a DC machine available in MSL is shown in Figure 2a. In this figure, in addition to other components, a Modelica record named as dcpmData is included. By double clicking on it, a new dialog window will open, which is shown on the left. Figure 2b shows that there are multiple tabs on the top of this dialog. This is one of the capabilities of Modelica Record class and can be used to structure all the top-level model parameter values in a well-organised manner. By using this record option, one can store as well as propagate corresponding parameter values to the top-level the model.


Figure 2c: Modelica Text layer of DCPM_Start model.

The text layer DCPM_Start is shown in Figure 2c, where certain texts are highlighted. The blue coloured one is the record class with parameter values stored in it. The orange highlights show how the top-level parameter values are passed from the dcpmData record to corresponding component variables and parameters at the top-level. Compared to Method 1, Method 2 is capable of handling a slightly large set of parameter values in a more structured and organised manner. In Figure 2c, it is also worth mentioning that a few global parameters are provided at the top of the Modelica text layer of this model. This includes Va, tStart, tRamp, etc..

     3. Using a replaceable model

As compared to the first two methods, this is an intermediate method which uses a Modelica class called ‘model’ with a ‘replacable’ attribute. By using this method user is not only able to provide the parameter values at the top-level of this model but is also aided in replacing the behaviour of the model by selecting the desired sub-component model from a drop-down menu. For illustrating Method 3, an example, BranchingDynamicPipes from MSL Fluid library is used.

MSL Path: Modelica.Fluid.Examples.BranchingDynamicPipes

For demonstration purposes, please duplicate this model in the Dymola package browser. This can be done by selecting BranchingDynamicPipes model in the Dymola package browser, and enter Ctrl+Shift+D, then click OK.


Figure 3a: Diagram layer of MSL BranchingDynamicPipes model.

Figure 3a shows Diagram layer of BranchingDynamicPipes model available in MSL. This model includes multiple fluid components such as pipes, Boundary_pT, system, etc..

The partial Modelica text layer of this model is shown in Figure 3b.


Figure 3b: Partial Modelica Text layer of MSL BranchingDynamicPipes model.

A minor modification is needed to be done in order to show how the parameter values are provided at the top-level of the model using a replacable model option. This modification can be done by double clicking on pipe1 in the Diagram layer of this model. This will open a parameter dialog box which is shown in Figure 3c.


Figure 3c: Parameter dialog box of pipe1 and the expanded view of the Pressure loss Model option in BranchingDynamicPipes.

In Figure 3c, at the bottom of the General tab, there is an option to choose a Pressure loss model from a list. This example chooses the first option of NominalLaminarFlow…, from the list. Followed by pressing the record button on the right of FlowModel parameter field. This will then open another parameter dialog box corresponding to this replaceable model as illustrated in Figure 3d.


Figure 3d: Parameter dialog box of optional Pressure loss Model in BranchingDynamicPipes.

Figure 3d shows that there are two empty parameter fields. In order to run this model successfully, a user must provide parameters values in these two fields. For the demonstration purpose, please choose an arbitrary value of 1 for each field, and then click OK twice to get out of both parameter dialog boxes.


Figure 3f: Partial Modelica Text layer of modified BranchingDynamicPipes model.

By comparing Figure 3f with Figure 3b, we notice that extra lines of code are added into Modelica text layer corresponding to the changes made in the Diagram layer of this model. The three highlighted lines in the code are showing where and what modifications have been made. Also, shows the arbitrary value provided during the modifications. Please note that dp_nominal value of 1 is provided during the modification, but a dp_nominal value of 1000000 is visible on the text layer. This is because an internal unit conversion is done automatically by Dymola in order to match with MSL standard unit. In this case, the value of 1bar set in the dialog has been scaled to the default units for dp_nominal which is in Pascal. This example shows how parameter values in a replaceable model can be provided and viewed from the top-level of a model.


This blog post presented three different ways of handling or managing the parameter values especially at the top-level of the Modelica models in Dymola. Depending on the model complexity, reusability and applications, Dymola users can adopt any of this methods in their modelling work. However, it is highly recommended that new Dymola users start with Method 1 or 2 in their work. Later they can choose Method 3 for developing a general purpose Modelica model(s).

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion


Got a question? Just fill in this form and send it to us and we'll get back to you shortly.


© Copyright 2010-2017 Claytex Services Ltd All Rights Reserved. | Designed by CMA Marketing

Log in with your credentials

Forgot your details?