Claytex logo
Blog

Claytex tech blog

If you have a question that isn’t answered here then why not ask us about it in the Dymola LinkedIn group.

Creating and using subsystems

A subsystem in Dymola is a model that is used inside other models and is usually used to define models that correspond to physical parts.  Making use of subsystems is important as it reduces the work required to build new models by increasing the reuse of existing models and reducing the future maintenance effort. The [...] read more
 

Dymola-Simulink interface

Interfacing Dymola and Simulink is quite straight forward. In this example I will look at exporting a simple driven pendulum model from Dymola to Simulink as an s-function. First, create a copy of the example model  Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum model and call it DrivenPendulum. To setup the model for use in Simulink we have to define the [...] read more
 

Modelica XML Reader Released

Claytex have released a new Modelica package that can read XML documents to load parameter values in to a Dymola model.  The XML Reader is a set of Modelica classes for reading parameter values from an XML document directly into a Modelica model.  The values are read from the XML document during model intialisation which [...] read more
 

The difference between class duplication and class extension

Duplicate or Extend? What is the difference? There is a fundamental difference between duplicating a class and extending a class (Blocks, Models, Functions, Types, Enumerations are all types of Class). Duplicating: When we duplicate a class we effectively create a separate instance or copy of that class. Any changes to the original class or duplicate [...] read more
 

State Selection: Overview and Definitions

In most cases state selection should not concern the user and should be done automatically by Dymola. There are a number of times however when it is useful for the model developer to be able to influence the state selection. Using knowledge of the system being modelled, the state selection can be used: To improve [...] read more
 

Adding additional Units? Utilising Type definitions

What is a type class? Often in a physical modelling environment, the parameters and variables used equate to physical quantities defined as a number and unit declaration. In Modelica this unit quantity is defined using a ‘type’ class: type Density = Real ( final quantity="Density", final unit="kg/m3", min=0); The Modelica Standard Library includes definitions of the units [...] read more
 

Useful Keyboard Shortcuts and Commands

The following list of Keyboard Shortcuts and Commands are used on a daily basis. Note, this list is not exhaustive, see Dymola User Manuals for more information. Shortcuts: Check Syntax and Format = Ctrl + L Check Model = F8 Code Completion = Ctrl + Space Duplicate = Ctrl + D Edit Function Call (text [...] read more
 

How can I make my models run faster?

Improving model efficiency and lowering run times: There are 4 common causes of slow-running models: Poor initialisation values Large number of events during simulation Large number of non-linear systems of equations in model Large numbers of numerical jacobians in model Poor Initialisation Poor initialisation values can lead to slow model initialisation and large amounts of [...] read more
 

Exporting models for co-simulation in other tools

With the release of Dymola 2012 it is now possible to compile models to the FMI standard for co-simulation.  This means that a model built in Dymola can be compiled with an open standard interface and coupled to other simulation and integration tools.  Dymola uses the SUNDIALS suite of numerical solvers for co-simulation and these [...] read more
 

How to simulate a model multiple times with different parameter values

Here are 2 examples of how you can simulate a model multiple times using different parameters values in Dymola, also referred to as batch running, and often used to run sensitivity sweeps. For the purpose of these examples a simple test model, Test1.mo, will be used.  The Modelica text for Test1 is shown below; parameter [...] read more
 

Resizing the Diagram layer

Resizing the Diagram layer By increasing the size of the diagram layer we gain more space to layout graphical model diagrams.  To change the size of the diagram follow these steps: Select the class whose diagram layer you wish to resize by double clicking on it in the package browser In Modelling mode, select Attributes [...] read more
 

How to restart a simulation from a given state

How to restart a simulation from a given state Often it is useful to be able to repeatedly restart a simulation from a given state.  This is useful when we have a model that needs to simulate for a significant amount of time to reach a stable operating point from which we are interested in [...] read more
 

Changing the default font size in Dymola

To change the default font size in Dymola Locate the dymodraw.ini file in your Dymola installation insert directory Open dymodraw.ini in note pad or similar editor and change/add the string: Dymola5basefontsize 12 for example for font size = 12 This will affect the font size in menus and windows within Dymola from the moment Dymola [...] read more
 

Creating Models to easily Include / Remove Effects

Modelica supports a concept called conditional components which provides a convenient mechanism to include or remove effects from a model through the change of a single parameter.  This means that the same models can be reused for different types of studies where different effects have to be considered. The ability to tune the model complexity [...] read more
 

Setting parameters in multiple classes quickly

In Dymola you can set parameters with identical names in multiple class instances with a single editing procedure. Say we wanted to modify the axis of rotation n in the four revolutes shown below. - Click on each instance of the revolute whilst keeping the shift button pressed down - Right click on any of [...] read more
 

How to reference data files within a Modelica package

How to reference data files within a Modelica package When creating your own libraries you may want to reference data files that are used within your model.  However when another user installs your library they might install it in a different location so any links referencing the data files have to be done in such [...] read more
 

How to write messages to the simulation log

How to write messages to the simulation log Outputting data and messages to the simulation log is a useful way for the model to communicate results or operation with the user.  There are a number of ways that this can be done. The assert function The assert function can be used to generate an error [...] read more
 

Control of model parameters

Component orientated modelling provides a convienent method of clicking on components to bring up a dialog of parameters to control that components behaviour. As model size and component count increases however, it is often more desirable to collate information from several different places so that data can be controlled in a central place. Often you [...] read more
 

Getting started: running and plotting results

To run a model: Make sure you have selected the model you wish to run in the package browser, do this by double clicking on the model. The name of the selected model will appear in the title bar at the top of the Dymola window. The next step is to select the simulation window [...] read more
 

Glossary of terms

This is a glossary of terms used when talking about Dymola and Modelica. Class All of the following are defined as a Modelica Class: Record – used to define data structures Block – fixed causality normally used within control systems Types – can be used to extend built-in types. These are also used when creating [...] read more