uesgraphs.examples package

Submodules

uesgraphs.examples.e10_networks_example module

Example Network Generator for UESGraphs

This module provides functionality to generate example district heating networks. It includes predefined network topologies that can be used for testing, demonstration, and validation purposes.

Main Features:

  • Generation of two example networks: ‘Pinola’ and ‘IBPSA’

  • Coordinate transformation for Modelica compatibility

  • Time series data generation for temperatures and heat inputs

  • Network topology creation with detailed pipe specifications

Example Networks:

  1. IBPSA Network: - Based on the PlugFlowAIT model from the IBPSA Library - Contains 1 supply building, 3 demand buildings, and 2 heating network nodes - Includes realistic pipe parameters and thermal properties - Reference: doi: 10.1016/j.enconman.2017.08.072

  2. Pinola Network: - Hybrid network combining IBPSA model and Larock 424 example - Features 2 supply buildings, 3 demand buildings, and 3 heating network nodes - Complete with pipe specifications and thermal parameters

Functions:

make_network_ibpsa(dir_dest):

Creates the IBPSA example network with predefined topology

make_network_pinola(dir_dest):

Creates the Pinola example network with predefined topology

convert_positions(ues_network, width_set):

Transforms network coordinates for Modelica compatibility

get_temperature_ground():

Returns ground temperature time series data

get_temperature_supply():

Returns supply temperature time series data

get_input_heat():

Returns heat input time series data for demand buildings

Notes:

  • All networks are exported with complete metadata for simulation purposes

  • Time series data uses 900-second time steps

  • Coordinates are automatically adjusted for Modelica model generation

  • Network parameters are based on realistic district heating system values

uesgraphs.examples.e10_networks_example.main()[source]
uesgraphs.examples.e10_networks_example.convert_positions(ues_network, width_set=4000)[source]

Translate node positions onto a Modelica-ready canvas

Parameters:
  • ues_network (uesgraphs.uesgraph.UESGraph object) – An uesgraphs representation of the cooling network

  • width_set (float) – Width of the Modelica-ready canvas after translation

Returns:

ues_network – An uesgraphs representation of the cooling network

Return type:

uesgraphs.uesgraph.UESGraph object

uesgraphs.examples.e10_networks_example.make_network_ibpsa(dir_dest)[source]

Creates a graph corresponding to the PlugFlowAIT model in IBPSA

The Modelica IBPSA Library (and thus AixLib, too) contains a benchmark network that was also used in the following paper: doi: 10.1016/j.enconman.2017.08.072

The model is at AixLib.Fluid.FixedResistances.Validation.PlugFlowPipes.PlugFlowAIT

This function returns the UESGraph representing the network

Parameters:

dir_dest (str) – Path where a nodes.json export of the network will be stored

Returns:

graph_network – Graph of the network

Return type:

uesgraphs.uesgraph.UESGraph

uesgraphs.examples.e10_networks_example.make_network_pinola(dir_dest)[source]

Creates a graph of the “Pinola” network

The Modelica IBPSA Library (and thus AixLib, too) contains a benchmark network that was also used in the following paper: doi: 10.1016/j.enconman.2017.08.072

The model is at AixLib.Fluid.FixedResistances.Validation.PlugFlowPipes.PlugFlowAIT

This function returns the UESGraph representing a network that is a mix between the IBPSA model and the Larock 424 example

Parameters:

dir_dest (str) – Path where a nodes.json export of the network will be stored

Returns:

graph_network – Graph of the network

Return type:

uesgraphs.uesgraph.UESGraph

uesgraphs.examples.e10_networks_example.get_temperature_ground()[source]

Returns a time series of ground temperature from IBPSA example

uesgraphs.examples.e10_networks_example.get_temperature_supply()[source]

Returns a time series of supply temperature from IBPSA example

uesgraphs.examples.e10_networks_example.get_input_heat()[source]

Return the map for heat input

uesgraphs.examples.e11_model_generation_example module

Modelica Model Generation using UESGraphs

This module demonstrates the automated generation of Modelica models for district heating networks. The generated models can be directly simulated in Dymola, but require exactly AixLib version 2.1.0. Other versions are not compatible and will cause simulation errors.

Model Variants:

For each network (Pinola and IBPSA), three model variants are generated:

  1. Open Loop with Variable Supply Temperature (suffix: _open_loop_dT_var) - High temperature network (80°C supply / 50°C return) - Table-based ground temperature - Direct heating substations

  2. Variable Ground Temperature Model (suffix: _t_ground_var) - Same as variant 1 but uses Kusuda ground temperature model - More detailed soil temperature calculation

  3. Low Temperature Network (suffix: _low_temp_network) - Low temperature regime (20°C supply / 10°C return) - Heat pump substations (Carnot-based) - Includes substation parameters (COP, nominal temperatures)

Functions:

model_generation_pinola(dir_source, dir_dest):

Generates three variants of Modelica models for the Pinola network

model_generation_ibpsa(dir_source, dir_dest):

Generates three variants of Modelica models for the IBPSA network

create_dirs(dir_project):

Creates standardized directory structure for model files and results

Model Parameters:

  • Simulation time: 603900 seconds

  • Time step: 900 seconds

  • Nominal pressure: 5e5 Pa

  • Heat pump COP (nominal): 4.5

  • Network pressure difference: 4e5 Pa (supply-return)

Components Used:

  • Supply: AixLib.Fluid.DistrictHeatingCooling.Supplies.OpenLoop.SourceIdeal

  • Demand: AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.VarTSupplyDp

    AixLib.Fluid.DistrictHeatingCooling.Demands.OpenLoop.HeatPumpCarnot

  • Pipes: AixLib.Fluid.DistrictHeatingCooling.Pipes.PlugFlowPipeEmbedded

  • Medium: AixLib.Media.Specialized.Water.ConstantProperties_pT

Notes:

  • All models use plug flow pipe models with embedded heat losses

  • Ground coupling can be either table-based or using the Kusuda model

  • Directory structure is automatically created for inputs, models, and results

  • Models are exported in Modelica format (.mo files)

  • Direct simulation in Dymola is possible, but strictly requires AixLib v2.1.0

uesgraphs.examples.e11_model_generation_example.main()[source]
uesgraphs.examples.e11_model_generation_example.model_generation_pinola(dir_source, dir_dest)[source]

Run example model generation for Pinola network

Parameters:
  • dir_source (str) – Source directory with nodes.json

  • dir_dest (str) – Directory to store generated models

uesgraphs.examples.e11_model_generation_example.model_generation_ibpsa(dir_source, dir_dest)[source]

Run example model generation for Ibpsa network

Parameters:
  • dir_source (str) – Source directory with nodes.json

  • dir_dest (str) – Directory to store generated models

uesgraphs.examples.e11_model_generation_example.create_dirs(dir_project)[source]

Creates input, model, result and visualization directories

Parameters:

dir_project (str) – Base directory of the example where the directories will be created

Returns:

  • dir_input (str) – Directory for input files

  • dir_model (str) – Directory for model files

  • dir_result (str) – Directory for result files

  • dir_visualization (str) – Directory for plots

uesgraphs.examples.e12_template_generation_example module

Comprehensive Mako Template Generation for UESGraphs Modelica Components

This module demonstrates three different approaches to generating Mako templates for AixLib component types, providing a complete learning experience from manual step-by-step generation to automated production workflows.

Template Generation Methods:

  1. Manual Method: Step-by-step individual template generation - Educational approach showing internal workings - Individual UESTemplates instantiation for each model - Custom save paths and immediate testing - Full visibility into the generation process

  2. Bulk Method: Efficient batch generation - Single generate_bulk() call for multiple models - Organized error handling and reporting - Suitable for moderate-scale template generation

  3. Configuration-Driven Method: Production-ready automation - Uses JSON configuration files - Environment variable integration - Rigorous mode for automated overwriting - Ideal for CI/CD and automated workflows

Component Types:

  1. Demand Models: - Variable supply temperature models - Heat pump models with Carnot cycle - Closed-loop DHC substation models - Templates include parameters for temperature differences and nominal conditions

  2. Pipe Models: - Static pipe model - Plug flow pipe models (standard and embedded) - Plug flow pipe with zeta value - DHC pipe models - Templates include thermal and geometric parameters

  3. Supply Models: - Ideal source models for open-loop systems - DHC supply models with heater/cooler/storage - Templates include pressure and temperature parameters

Educational Progression:

This example is designed for researchers and developers who want to understand: - How template generation works internally (Manual Method) - How to efficiently generate multiple templates (Bulk Method) - How to set up automated template generation workflows (Config Method)

Requirements:

  • AixLib v2.1.0+ library installation

  • UESGraphs package with systemmodels module

  • Shapely for geometric operations

  • Optional: AIXLIB_LIBRARY_PATH environment variable for automated workflows

Usage:

Run the script and select from four demonstration modes: 1. Manual demonstration - See step-by-step template creation 2. Bulk demonstration - See efficient batch processing 3. Config demonstration - See automated configuration-driven generation 4. All methods - Experience the complete progression

uesgraphs.examples.e12_template_generation_example.get_test_data(model_type: str, model_name: str)[source]

Get sample test data for different model types

uesgraphs.examples.e12_template_generation_example.demonstrate_manual_generation(path_aixlib: str, workspace: str)[source]

Method 1: Manual step-by-step template generation

This approach shows exactly how template generation works internally. Each template is created individually with full control over the process. This is the best method for learning and debugging.

uesgraphs.examples.e12_template_generation_example.demonstrate_bulk_generation(path_aixlib: str, workspace: str)[source]

Method 2: Bulk template generation

This approach uses the generate_bulk() method to efficiently create multiple templates with organized error handling. Good for moderate scale template generation.

uesgraphs.examples.e12_template_generation_example.demonstrate_config_generation(workspace: str)[source]

Method 3: Configuration-driven template generation

This approach uses JSON configuration files and environment variables for fully automated template generation. Ideal for production workflows and CI/CD integration.

uesgraphs.examples.e12_template_generation_example.get_user_choice()[source]

Get user’s choice for demonstration method

uesgraphs.examples.e12_template_generation_example.get_aixlib_path()[source]

Get AixLib library path via file dialog

uesgraphs.examples.e12_template_generation_example.main()[source]

Main function with method selection

uesgraphs.examples.e13_analyze_uesgraphs_example module

uesgraphs.examples.e1_readme_example module

Creating and Visualizing a Simple Heating Network from the readme.md with uesgraphs

uesgraphs.examples.e1_readme_example.main()[source]
uesgraphs.examples.e1_readme_example.example_readme()[source]

The example given in the README.md file

uesgraphs.examples.e1_readme_example.workspace_example(name_workspace=None)[source]

Creates a local workspace with given name

If no name is given, the general workspace directory will be used

Parameters:

name_workspace (str) – Name of the local workspace to be created

Returns:

workspace – Full path to the new workspace

Return type:

str

uesgraphs.examples.e2_simple_dhc_example module

Creating and Visualizing a more sophisticated Network with uesgraphs including heating and cooling

uesgraphs.examples.e2_simple_dhc_example.main()[source]
uesgraphs.examples.e2_simple_dhc_example.simple_dhc_model()[source]

Initializes an UESGraph object, adds 2 heating and cooling networks each

Returns:

example_district – An UESGraph containing 4 buildings connected to 2 heating supplies and 2 cooling supplies via 2 heating and cooling networks each

Return type:

uesgraphs.uesgraph.UESGraph object

uesgraphs.examples.e3_add_network_example module

Extend the e2_simple_dhc model for an electric grid and visualize

uesgraphs.examples.e3_add_network_example.main()[source]
uesgraphs.examples.e3_add_network_example.add_more_networks(example_district)[source]

Adds an electric grid to the simple_dhc_model example

Parameters:

example_district (uesgraphs.uesgraph.UESGraph object) – An UESGraph containing 4 buildings connected to 2 heating supplies and 2 cooling supplies via 2 heating and cooling networks each from simple_dhc_model()

Returns:

example_district – An UESGraph containing 8 buildings and various supplies and networks to illustrate UESGraph use

Return type:

uesgraphs.uesgraph.UESGraph object

uesgraphs.examples.e4_save_uesgraphs_example module

“”Write example district heating cooling network to JSON file.

uesgraphs.examples.e4_save_uesgraphs_example.main()[source]
uesgraphs.examples.e4_save_uesgraphs_example.to_json()[source]

Demos the output of an uesgraph to JSON

uesgraphs.examples.e5_add_street_nodes_example module

Usage of street nodes

uesgraphs.examples.e5_add_street_nodes_example.main()[source]
uesgraphs.examples.e5_add_street_nodes_example.street_nodes()[source]

Tests the street nodes implementation

uesgraphs.examples.e6_additional_building_attributes_example module

Demonstration for adding additional attributes to building nodes (only terminal output)

uesgraphs.examples.e6_additional_building_attributes_example.main()[source]
uesgraphs.examples.e6_additional_building_attributes_example.additional_attrib()[source]

Demonstration for adding additional attributes to building nodes

This approach can be used to enhance the functionality of an uesgraph with additional attributes, e.g. assigning a building object to a building node

Additional advise: Nodes and edges of an uesgraph can be treated similar. Important is to understand the given dictionary structure and the idea of also adding additional attributes to edges/nodes/buildings

uesgraphs.examples.e7_plot_uesgraphs_example module

Creating advanced plots of uesgraphs. Its worth to take a look at the different outputs and how they’re generated. The plots are saved in the workspace folder.

uesgraphs.examples.e7_plot_uesgraphs_example.main()[source]
uesgraphs.examples.e7_plot_uesgraphs_example.plot_example_networks()[source]

Plots example networks to demo uesgraphs

uesgraphs.examples.e8_load_uesgraphs_example module

How to load UESGraphs from JSON and OSM files.

uesgraphs.examples.e8_load_uesgraphs_example.main()[source]

Main function.

uesgraphs.examples.e8_load_uesgraphs_example.load_json()[source]

Loads a nodes.json and plots it.

uesgraphs.examples.e8_load_uesgraphs_example.load_osm()[source]

Loads an osm file and plots it.

uesgraphs.examples.e9_generate_ues_from_osm_example module

Generate complex Urban Energy System (UES) Graph from OpenStreetMap (OSM) data.

This script processes OSM data to create and visualize district heating networks. It performs building clustering, street network analysis, and generates various visualization outputs.

Output Files

e9_simple_melaten_osm.png

Basic network visualization without detailed features

e9_example_melaten_osm.png

Network layout including street labels

e9_example_melaten_osm_bldgs.png

Network layout with building identifiers

e9_example_melaten_osm_wo_large_bldgs.png

Network layout after removing large buildings Note: Only building 1121 is removed in this example

e9_simple_melaten_osm_wo_large_bldgs.png

Simplified network view without building 1121

e9_melaten_dhc_network.png

District heating network visualization after: - Street crossing detection - Building clustering - Supply node integration - Network optimization

e9_melaten_dhc_network_detail.png

Detailed view of the final district heating network

Dependencies

  • uesgraphs

  • os

Author

MichaMans

Review

rka-lko

uesgraphs.examples.e9_generate_ues_from_osm_example.main()[source]

Main function.

uesgraphs.examples.e9_generate_ues_from_osm_example.generate_ues()[source]

Loads an osm file and plots it.

uesgraphs.examples.e9_generate_ues_from_osm_example.remove_small_buildings(input_graph, min_area)[source]

Remove all buildings from the graph that have area less than `min_area´.

Parameters:
  • input_graph (uesgraphs.uesgraph.UESGraph object) – An UESGraph that will be analysed for data

  • min_area (float) – Minimum area for a building to remain in the graph

Returns:

input_graph – An UESGraph that will be analysed for data

Return type:

uesgraphs.uesgraph.UESGraph object

uesgraphs.examples.e9_generate_ues_from_osm_example.add_district_heating_buildings(input_graph, supply_id_osm)[source]

Set the given osm id as supply and remaining buildings as demand.

Parameters:
  • input_graph (uesgraphs.uesgraph.UESGraph object) – An UESGraph that will be analysed for data

  • supply_id_osm – The osm id of the building which is used as the supply node

Return type:

None

uesgraphs.examples.e9_generate_ues_from_osm_example.area_list(input_graph)[source]

List the average area of small, medium and large buildings

Small: < 200 m² Medium: 200 m² < 1000 m² Large: > 1000 m²

Parameters:

input_graph (uesgraphs.uesgraph.UESGraph object) – An UESGraph that will be analysed for data