Conference article

Framework for dynamic optimization of district heating systems using Optimica Compiler Toolkit

Gerald Schweiger
AEE INTEC, 8200 Gleisdorf, Austria

Håkan Runvik
Modelon AB, SE-223 70 Lund, Sweden

Fredrik Magnusson
Lund University, SE-221 00 Lund, Sweden / Modelon AB, SE-223 70 Lund, Sweden

Per-Ola Larsson
Modelon AB, SE-223 70 Lund, Sweden

Stéphane Velut
Modelon AB, SE-223 70 Lund, Sweden

Download article

Published in: Proceedings of the 12th International Modelica Conference, Prague, Czech Republic, May 15-17, 2017

Linköping Electronic Conference Proceedings 132:13, p. 131-139

Show more +

Published: 2017-07-04

ISBN: 978-91-7685-575-1

ISSN: 1650-3686 (print), 1650-3740 (online)


Recent studies show that district heating infrastructures should play an important role in future sustainable energy systems. Tools for dynamic optimization are required to increase the efficiency of existing systems and design new ones. This paper presents a novel framework to represent, simplify, simulate and optimize district heating systems. The framework is implemented in Python and is based on Optimica Compiler Toolkit as well as Modelon’s Thermal Power Library. The high-level description of optimization problems using Optimica allows flexible optimization formulations including constraints on physically relevant variables such as supply temperature, flow rate and pressures. The benefit of new algorithms for symbolic elimination in Optimica Compiler Toolkit is also investigated. The framework is applied on a test case, which is based on a planned city district located in Graz, Austria. The results demonstrate the generality of the representation as well as the accuracy of the simplification for dynamic optimization of temperature supply and pressure control.


District heating, dynamic optimization, symbolic elimination


Johan Åkesson. Optimica—an extension of Modelica supporting dynamic optimization. In Proceedings of the 6th International Modelica Conference, pages 57–66, 2008.

Johan Åkesson, Karl-Erik Årzén, Magnus Gäfvert, Tove Bergdahl, and Hubertus Tummescheit. Modeling and optimization with Optimica and—languages and tools for solving large-scale dynamic optimization problems. Computers & Chemical Engineering, 34:1737–1749, 2010.

Jonas Allegrini, Kristina Orehounig, Georgios Mavromatidis, Florian Ruesch, Viktor Dorer, and Ralph Evins. A review of modelling approaches and tools for the simulation of districtscale energy systems. Renewable and Sustainable Energy Reviews, 52:1391–1404, 2015. URL

Joel Andersson. A General-Purpose Software Framework for Dynamic Optimization. Ph.D. thesis, Arenberg Doctoral School, KU Leuven, Belgium, 2013.

Ali Baharev, Hermann Schichl, and Arnold Neumaier. Decomposition methods for solving sparse nonlinear systems of equations. Submitted for publication. Available online:, 2016.

John T. Betts, Stephen L. Campbell, and Karmethia C. Thompson. Solving optimal control problems with control delays using direct transcription. Applied Numerical Mathematics, 108:185–203, 2016.

Lorenz T. Biegler. Nonlinear Programming: Concepts, Algorithms, and Applications to Chemical Processes. MOSSIAM, Philadelphia, PA, 2010.

Iain S. Duff, Albert. Erisman, and John K. Reid. Direct Methods for Sparse Matrices. Clarendon Press, Oxford, United Kingdom, 1986.

Andreas Griewank and Andrea Walther. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation. SIAM, Philadelphia, PA, 2nd edition, 2008.

Stefan Grosswindhager, Andreas Voigt, Martin Kozek, and A Varying-coefficient Models. Predictive Control of District Heating Network using Fuzzy DMC. In International Conference on Modelling, Identification and Control, 2012.

Aric A. Hagberg, Daniel A. Schult, and Pieter J. Swart. Exploring network structure, dynamics, and function using NetworkX. Proceedings of the 7th Python in Science Conference (SciPy 2008), (SciPy):11–15, 2008.

Helge V Larsen, Benny Bøhm, and Michael Wigbels. A comparison of aggregated models for simulation and operational optimisation of district heating networks. Energy Conversion and Management, 45:1119–1139, 2004.

Björn Lennernäs. A CasADi based toolchain for M.Sc. thesis, Department of Automatic Control, Lund University, Sweden, 2013.

Achim Loewen. Entwicklung eines Verfahrens zur Aggregation komplexer Fernwärmenetze. Ph.D. thesis, Fraunhofer UMSICHT, Germany, 2001.

Henrik Lund, Sven Werner, Robin Wiltshire, Svend Svendsen, Jan Eric Thorsen, Frede Hvelplund, and Brian Vad Mathiesen. 4th Generation District Heating (4GDH): Integrating smart thermal grids into future sustainable energy systems. Energy, 68:1–11, 2014. URL

Fredrik Magnusson and Johan Åkesson. Dynamic optimization in Processes, 3(2):471–496, 2015.

Fredrik Magnusson and Johan Åkesson. Symbolic elimination in dynamic optimization based on block-triangular ordering. Optimization Methods and Software, 2016. Accepted for publication.

Patrik Meijer. Tearing differential algebraic equations. M.Sc. thesis, Centre for Mathematical Sciences, Lund University, Sweden, 2011.

Modelica Association. Modelica R - A Unified Object-Oriented Language for Systems Modeling Language Specification Version 3.3 Revision 1. 2014. URL

Modelon. OPTIMICA Compiler Toolkit, 2016. URL

Dave Olsthoorn, Fariborz Haghighat, and Parham A Mirzaei. Integration of storage and renewable energy into district heating systems : A review of modelling and optimization. Solar Energy, 136:49–64, 2016. URL

Kristina Orehounig, Ralph Evins, and Viktor Dorer. Integration of decentralized energy systems in neighbourhoods using the energy hub approach. Applied Energy, 154:277–289, 2015. URL

Jonatan Rantzer. Robust production planning for district heating networks. M.Sc. thesis, Centre for Mathematical Sciences, Lund University, Sweden, 2015.

Håkan Runvik, Per-Ola Larsson, Stéphane Velut, Jonas Funquist, Markus Bohlin, Andreas Nilsson, and Sara Modarrez Razavi. Production Planning for Distributed District Heating Networks with In 11th International Modelica Conference, pages 217–223, 2015.

Gerald Schweiger, Per-Ola Larsson, Fredrik Magnusson, Patrick Lauenburg, and Stéphane Velut. District heating and cooling systems – framework for modelica-based simulation and dynamic optimization. Energy, 2017a. ISSN 0360-5442. doi: URL

Gerald Schweiger, Jonatan Rantzer, Karin Ericsson, and Patrick Lauenburg. The potential of power-to-heat in Swedish district heating systems. Energy, 2017b. ISSN 0360-5442. doi: URL

Stéphane Velut, Per-Ola Larsson, JohanWindahl, Linn Saarinen, and Katarina Boman. Short-term production planning for district heating networks with In Proceedings of the 10th International Modelica Conference, pages 959–968, 2014.

Andreas Wächter and Lorenz T. Biegler. On the implementation of a primal-dual interior point filter line search algorithm for large-scale nonlinear programming. Mathematical Programming, 106:25–57, 2006.

Citations in Crossref