An open-source Python package for steady-state hydraulic modelling of district heating (DH) networks. The toolkit builds incidence and loop matrices using graph theory and solves mass and energy balances through Newton–Raphson (NR) and Genetic Algorithm (GA) methods. It provides a transparent and reproducible framework for researchers and practitioners to analyse flow and pressure distributions in central hydronic networks of any scale.
District Heating networks are central hydronic systems that distribute thermal energy via supply and return pipelines. Hydraulic modelling is critical to ensure adequate pressure and flow at all substations, evaluate network extensions, integrate new heat sources, and support efficient operation. Key principles:
A pipe-node list is used to construct incidence and loop matrices, providing a mathematical representation of the DH topology. Loop detection algorithms automatically generate the fundamental cycle basis.
Flow distribution is solved by enforcing Kirchhoff-type mass balances at nodes and energy conservation in loops.
- Newton–Raphson (NR): A rapid iterative solver with proven convergence properties, suitable for large-scale networks.
- Genetic Algorithm (GA): A heuristic solver that explores the solution space, useful for non-linear or highly constrained cases.
Scope & Aim: Provides steady-state flow and pressure distribution; as designed as a physical modelling tool (not a black-box), ensuring transparency and extensibility for further research.
Python ≥ 3.8 with (pandas, numpy, scipy, geneticalgorithm, matplotlib)
numpy>=1.24,<2.0
scipy>=1.10
pandas>=1.5
openpyxl>=3.1
geneticalgorithm==1.0.2
matplotlib>=3.7
You are free to use, modify and distribute the code as long as authorship is properly acknowledged. Please reference this repository in derivative works.
Tol, Hİ. Development of a physical hydraulic modelling tool for District Heating systems. Energy and Buildings (2021) 253. https://doi.org/10.1016/j.enbuild.2021.111512
Above all, I give thanks to Allah, The Creator (C.C.), and honor His name Al-‘Alīm (The All-Knowing).
This repository is lovingly dedicated to my parents who have passed away, in remembrance of their guidance and support.
I would also like to thank ChatGPT (by OpenAI) for providing valuable support in updating and improving the Python implementation.