Leveraging Existing Modelica Libraries in Your Simulations

Do you really need detailed knowledge of every component in your system and how to model each component in order to successfully simulate the system? In this blog post I’m going to consider this question, and how the existing Modelica libraries that Dymola supports affect the answer.

One thing I have come to recognise with experience, is that I can’t know everything about everything; even though the engineer in me is always curious to learn more. My knowledge includes a little about a lot of areas, and a greater depth of knowledge in a few areas. This is alright because I work in a team, which collectively has a much wider knowledge than my own. So as long as my team works together to share the knowledge, the outcome should be successful.

“Try to learn something about everything, and everything about something”

Thomas Henry Huxley

I think, this idea also applies when you’re deciding how to approach simulation. To achieve your goal of successfully simulating your system, you probably don’t actually need to know everything about your system and how to model it. Because someone may have already figured out how to model it, and you can leverage that in your work. Dymola supports an existing ecosystem of Modelica libraries, covering a vast range of domains and applications that you can use to supplement your inhouse knowledge.

The Modelica libraries available for Dymola contain knowledge in huge range domains
Figure 1 – The Modelica libraries available for Dymola contain knowledge in huge range domains for you to utilise

Modelica and Dymola Support Collaboration

Dymola uses the Modelica language. Together, Dymola and Modelica support us in sharing our knowledge by:

  • Being object oriented We use objects that represent the physical components that we put together to create more complex systems. It encourages hierarchical modelling, where we can reuse models and easily interchange components in a plug-and-play style.
  • Being multi-domain (multi-physics) – We aren’t limited to creating one type of system. There are existing Modelica libraries in the mechanical, electrical, electronic, magnetic, hydraulic, thermal, control domains plus many others.
  • Being open – You can see the code defining the majority of models in Modelica libraries. So you can understand how they work. This code can also be customised if required.
  • Supporting FMI (Functional Mock-up Interface) – This lets you import models from other tools into Dymola, or export Dymola models for use in other tools. This feature eases the exchange and co-simulation of models.
  • Allowing interfaces with external tools – There are a number of examples where interfaces exist to permit Dymola to work with other tools.

Idea into Practice

We’ve done a lot of modelling and simulation in the automotive industry here at Claytex. Cars are complex systems, covering a wider range of domains. While our libraries cover many of the vehicle subsystems (suspension, engines, powertrain and hydraulics), we recognise the benefits that can be gained by using the expertise contained in third party Modelica libraries to complete the remaining vehicle subsystems.

This is illustrated in our VehicleDemos library, where the Claytex VeSyMA suite and FluidPower libraries are combined with libraries from other developers to create a variety of vehicles.

In the VehicleDemos electric bus example, we wanted to be able to investigate the effect of the heating, ventilation and air conditioning (HVAC) systems on the buses battery performance. We have an electric bus model in the VeSyMA library, but the necessary thermal management and cabin models required models outside our own libraries. So we used the ThermalSystems and TSMobileAC libraries from TLK to provide this HVAC modelling capability.

Diagram layer of the VehicleDemos electric bus (VehicleDemos.Vehicles.RearWheelDrive.BusElectricAC). The bus powertrain and chassis models using VeSyMA, integrated with thermal management and cabin models from ThermalSystems and TSMobileAC
Figure 2 – Diagram layer of the VehicleDemos electric bus (VehicleDemos.Vehicles.RearWheelDrive.BusElectricAC). The bus powertrain and chassis models using VeSyMA, integrated with thermal management and cabin models from ThermalSystems and TSMobileAC
Thermal management model in the VehicleDemos electric bus using components from ThermalSystems and TSMobileAC libraries
Figure 3 – Thermal management model in the VehicleDemos electric bus using components from ThermalSystems and TSMobileAC libraries

To create an electrified car with a higher fidelity electrified powertrain than the existing vehicle in VeSyMA, we need a more detailed electrification model. We were able to create this using the ElectrifiedPowertrains library (EPTL) from Dassault Systemes coupled with the remaining subsystems of our existing VeSyMA vehicle. This vehicle is used to simulate a drive cycle to investigate energy consumption.

Simulation post-processing of the VehicleDemos electric vehicle drive cycle (VehicleDemos.Experiments.VehicleManoeuvres.DriveCycleElectric), showing EPTL based electric powertrain elements
Figure 4 – Simulation post-processing of the VehicleDemos electric vehicle drive cycle (VehicleDemos.Experiments.VehicleManoeuvres.DriveCycleElectric), showing EPTL based electric powertrain elements

One important factor on the ease of being about to combine our libraries with those of other developers, is the hierarchical structuring of our libraries with extensive use of common templates and interfaces. This made it simple for us to replace the subsystems in the VehicleDemos I’ve talked about with the versions built from external libraries. We have a number of blog posts on this key topic, including Dymola Model Inheritance and When to Extend, Duplicate or Create From Scratch.

In addition to the extra functionality in the VehicleDemos library by using the knowledge stored in other developers libraries, we have extended the potential capability of our libraries by interfacing them with specialist external tools such as:

FTire animation
Figure 5 – Interfacing with FTire allows your vehicle model in Dymola to include high fidelity tyre simulation

Some Things to Consider

By making use of existing Modelica libraries and interfaces to external tools you can vastly increase the capability of your libraries. And because you’re not creating everything from scratch you can reach your simulations goals much quicker, which is great. But there are some things to consider first:

  • Library structure – It will be far easier to work with external libraries if you use a hierarchical structure based on interfaces and templates in you models (plug and play approach).
  • Understand the results – While using libraries from other developers allows you to skip having to learn how to best model the system, you still need a good understanding of the system and its behaviour so you can make best use of the simulation.
  • What goes in, comes out A simulation can only ever be as realistic as the data you put into it and this isn’t something you can overlook.
  • End of Life – There are many Modelica libraries out there, both open source and commercial, so when selecting one you need to think about its end of life. You don’t want to start using a library that isn’t being actively supported which could prevent you upgrading to new versions of Dymola because they become incompatible.

Don’t be an Island

By treating our Modelica library as an island entire of itself, we miss the opportunity available to us to expand our modelling capability by using the wider Modelica library community surrounding Dymola. I hope this post has highlighted the gains that can be achieved by looking beyond your own Modelica library, and this means you don’t need to know everything about everything to create your simulation.

Modelica library islands
Figure 6 – There are a range of Modelica libraries available to expand the capability in your own library development, no Modelica library needs to be a separate island.

Please take a look at the collection of libraries we can supply and support here to see which of these Modelica libraries can help you accomplish your simulation goals.

Written by: Hannah Hammond-Scott – Modelica Project Leader

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

CONTACT US

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

Sending

© Copyright 2010-2022 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?