Model parameterisation tips to help usability

As Modelica is an object oriented language, most models in Dymola are composed of several subsystems, spread over several levels. Navigating down the hierarchy of a model from the top level in order to find the one parameter we are looking for can seem like looking for a needle in a haystack.

Fortunately, there are some rules and tips one can follow to make parameterisation more intuitive. This blog post gives a quick overview of how to declare parameters in a multi-level model and how to parameterise this model.

As an example, let’s duplicate the model Modelica.Mechanics.MultiBody.Examples.Loops.EngineV6_analytic from the Modelica Standard Library (MSL).

Example model from MSL. parameterisation

Figure 1: Example model from MSL.

 If I want to modify the value of the engine cylinder bore for instance, what I could do (and what many people unfortunately tend to do) is to select ‘Show Component’ on the engine.

Inside the engine model. parameterisation

Figure 2: Inside the engine model.

Then ‘Show Component’ on cylinder1, and after double-clicking on gasForce, I can change the chamber diameter (i.e. cylinder bore).

Propagation of cylinder diameter. parameterisation

Figure 3: Inside the first cylinder.

However it is not recommended for several reasons:

  • The model in this example is fairly simple, but in a more complicated model with more components on the diagram layer and more levels, it might be difficult to locate the exact component where the parameter is if we start from the top level.
  • The engine in this example has 6 cylinders, which means I would have to make sure I modify the value of the bore in all the other cylinders as well, which can be tedious in case I want to run several experiments with different bore values every time.
  • Even if this is not the case here, the parameter bore could be used in other components as well (piston diameter for instance) and it is not always easy to identify all the components that are using a specific parameter.
  • If I want to reuse the same cylinder model – with the same bore – in another model, I would have to re-apply the modifier.
  • If I hand over the model to a colleague with a top level modifier for bore, if the person applies a modifier with a different value from another level (say from the cylinder level), it will be overridden and will have no effect. Indeed, higher level modifiers always have the priority over lower levels ones.

Let’s now have a look at a better way of parameterising this model.

The first thing that we need to think about is: at which level should we expect to have to parameterise the engine cylinder bore? The answer is probably at the cylinder model level since it is an intrinsic characteristic of this component. So what we need to do is to duplicate the cylinder model (Modelica.Mechanics.MultiBody.Examples.Loops.Utilities.Cylinder_analytic_CAD) or to select it in our library in case we have already developed the models ourselves. If we right-click on the diagram layer of this model and select Parameters, we can notice that there is no parameter “bore” or “diameter”. We will have to propagate it. Let’s double-click on the gasForce component, then click on the little black arrow next to “diameter” and click “Propagate d”.

Propagation of cylinder diameter. parameterisation

Figure 4: Propagation of cylinder diameter.

We can now parameterise our cylinder model. Let’s right-click on the diagram layer and select Parameters. Set a value of 0.088 for bore (by default the name of the parameter we just propagated is “d”).We modify the value of the cylinder bore

Figure 5: We modify the value of the cylinder bore.

In this way, we could create several cylinder variants with different parameterisation by just extending from the cylinder model.

We can now make sure we use this cylinder model in our engine using change class. If we want to use a different value for bore (or any other parameter) we should select the cylinder model in the package browser and make the parameter change there.

We have seen in this post that parameterisation of a model is a two-stage process. The first one is to make sure, when creating a model, to propagate all the parameters needed but only what is really needed (gearbox bearing diameter does not need to be at the top level of a vehicle model for example…). The second stage is to parameterise the subsystems and components directly rather than from the top level (i.e. when parameterising a model, one should never use “Show Component”).

Written by: Romain Gillot – Powertrain Modelling Engineer


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-2018 Claytex Services Ltd All Rights Reserved. | Designed by CMA Marketing

Log in with your credentials

Forgot your details?