uesgraphs.systemmodels.systemmodelheating

This module includes the UESModel graph to write Modelica code from uesgraphs

Functions

set_up_logger(name[, log_dir, level])

Sets up a configured logger with file handler.

Classes

SystemModelHeating([model_name, ...])

Writes Modelica code for system models from uesgraphs information

uesgraphs.systemmodels.systemmodelheating.set_up_logger(name, log_dir=None, level=40)[source]

Sets up a configured logger with file handler.

Creates a logger with specified name and logging level. Log files are stored in a directory with timestamp in filename. If no directory is specified, the system’s temporary directory is used.

Parameters:
  • name (str) – Name of the logger, also used for filename

  • log_dir (str, optional) – Directory for log files. Defaults to None (uses temp directory)

  • level (int, optional) – Logging level (e.g. logging.ERROR, logging.INFO). Defaults to logging.ERROR

Returns:

Configured logger object

Return type:

logging.Logger

Example

>>> logger = set_up_logger("my_app", "/var/log", logging.INFO)
>>> logger.info("Application started")

Notes

  • Log filename format: {name}_{YYYYMMDD_HHMMSS}.log

  • Log entry format: time - logger_name - [file:line] - level - message

class uesgraphs.systemmodels.systemmodelheating.SystemModelHeating(model_name='Test', network_type='heating', logger=None)[source]

Writes Modelica code for system models from uesgraphs information

While a uesgraph object uses edges to describe pipe connections between nodes, the Modelica model needs a specific node representing the pipe model and connections between connectors of each model. Therefore, UESModel initializes a new graph object from information of an uesgraph object. At the current stage, the uesgraph object should be a subgraph that only contains one network.

Parameters:
  • model_name (str) –

  • model (Name of the) –

  • file (will be used for naming components and output) –

nodelist_pipe

List of all pipe node numbers in the graph

Type:

list

network_type

Type of network to be modeled

Type:

{‘heating’}

stop_time

Stop time for simulation in seconds

Type:

float

timestep

Timestep for simulation in seconds

Type:

float

time

time vector calculated from ‘timestep’ and ‘stop_time’

Type:

list

solver

Solver for use in Dymola

Type:

str

medium

Default is ‘water’

Type:

str

doc_string

A doc string for the Modelica mode

Type:

str

documentation

Currently just a string that will be written to the model documentation

Type:

str

add_ground_around_pipe

For True, the ground around the pipe will be modeled by an RC network. This requires values for RExt, RExtRem, CExt, T_ground_start, and n for each edge to parameterize a model using AixLib.ThermalZones.ReducedOrder.RC.BaseClasses.ExteriorWall for the ground

Type:

boolean

uses

A list of string specifying all used Modelica libraries

Type:

list

control_pressure

Collection of settings for pressure control: building, dp, supply

Type:

dict

__init__(model_name='Test', network_type='heating', logger=None)[source]

Construct SystemModelHeating class.

property time
property doc_string
property medium
import_nodes_from_uesgraph(uesgraph_input, logger=None)[source]

Adds uesgraph_input’s nodes to the model graph

As a first step for the conversion from a uesgraph to a uesmodel graph, this method imports the uesgraph’s nodes to the nodes of this class. The method conserves each node’s attributes, but converts the x and y coordinates from GIS data to coordinates on the canvas for graphical representation of the Modelica model.

Parameters:
  • uesgraph_input (uesgraphs.uesgraph.UESGraph object) – At current stage, this uesgraph should contain only 1 network of 1 type that is indexed in the corrsponding nodelist as ‘default’

  • logger (logging.Logger, optional) – Logger instance for debugging

add_pipe_node(name=None, position=None, logger=None)[source]

Adds a pipe node to the graph

Parameters:
  • name (str, int, or float) – A name for the building represented by this node. If None is given, the newly assigned node number will also be used as name.

  • position (shapely.geometry.Point object) – New node’s position

  • logger (logging.Logger, optional) – Logger instance for debugging

Returns:

node_number – Identifier of the newly created pipe node

Return type:

int

remove_pipe_node(node_number, logger=None)[source]

Removes the specified pipe node from the graph

Parameters:
  • node_number (int) – Identifier of the node in the graph

  • logger (logging.Logger, optional) – Logger instance for debugging

import_pipes_from_uesgraph(uesgraph_input, logger=None)[source]

Adds uesgraph_input’s pipe edges as nodes to uesmodel graph

The second step for conversion of a uesgraph to a uesmodel graph involves the conversion of pipes from edges to nodes of their own. They keep their attributes like length and diameter and in addition are assigned x and y coordinates which locate them in the middle between the nodes they originally connected. Furthermore, new edges are created representing the connection from the pipe model’s ports to the next nodes.

Parameters:
  • uesgraph_input (uesgraphs.uesgraph.UESGraph object) – At current stage, this uesgraph should contain only 1 network of 1 type that is indexed in the corresponding nodelist as ‘default’

  • logger (logging.Logger, optional) – Logger instance for debugging

import_from_uesgraph(uesgraph_input, logger=None)[source]

Imports nodes and edges from uesgraph and transform edges to nodes which will later be pipes in modelica

Parameters:
  • uesgraph_input (uesgraphs.uesgraph.UESGraph object) – At current stage, this uesgraph should contain only 1 network of 1 type that is indexed in the corresponding nodelist as ‘default’

  • logger (logging.Logger, optional) – Logger instance for debugging

set_connection(remove_network_nodes=True, logger=None)[source]

Sets connections between supplies, pipes and buildings

To connect supplies, pipes, and buildings, each edge of the model graph is assigned four attributes (‘con1’, ‘con2’, ‘con1R’, ‘con2R’) that characterize the connected node (supply, pipe, building) and the used port of the node (port_a, port_b). In case the node is a supply, a pipe, or a building, the attribute (con1, con2, con1R, con2R) contains the corresponding Modelica-Code. In case the node is a network-node the attribute only contains the number of the node, since network-nodes can be connected to more then one node. The connections of the network-nodes is written later on in method ‘write_network_model()’.

For remove_network_nodes is True, ports depend on type of node:

pipe network building supply

con1 a/b node # a b con1R a/b node # b a con2 a/b node # a b con2R a/b node # b a

Parameters:
  • remove_network_nodes (boolean) – If True, all connections at network nodes will be clustered onto connecting ports. If False, network nodes will get their own representation in the conncetion network.

  • logger (logging.Logger, optional) – Logger instance for debugging

write_medium_definition()[source]

Write the rendered Modelica code for the Medium definition

Returns:

mo_medium – Rendered Modelica code for the medium definition

Return type:

str

write_supply_definitions()[source]

Write the rendered Modelica code for the supply model definitions

Returns:

mo_supplies – Rendered Modelica code for the supply definitions

Return type:

str

write_t_ground_definitions()[source]

Write the rendered Modelica code for the ground temperature def

Returns:

mo_t_ground – Rendered Modelica code for the ground temperature definition

Return type:

str

write_demand_definitions()[source]

Write the rendered Modelica code for the demand model definitions

Returns:

mo_demands – Rendered Modelica code for the demand definitions

Return type:

str

write_pipe_definitions()[source]

Write the rendered Modelica code for the pipe model definitions

Returns:

mo_pipes – Rendered Modelica code for the pipe definitions

Return type:

str

write_annotations()[source]

Write the rendered Modelica code for annotations

Returns:

mo_ann – Rendered Modelica code for the annotations

Return type:

str

write_input_connections()[source]

Write the rendered Modelica code for the input connections

Returns:

mo_con – Rendered Modelica code for the input connections

Return type:

str

write_network_connections()[source]

Write the rendered Modelica code for the network connections

Returns:

mo_con – Rendered Modelica code for the network connections

Return type:

str

write_network_model(save_at)[source]

Writes a network model to Modelica code file

Parameters:

save_at (str) – Path where to create the subfolders, in which the Modelica files are saved

write_modelica_package(save_at)[source]

Writes a system model and inputs to Modelica package

Parameters:

save_at (str) – Path where to create the subfolders, in which the Modelica files are saved

write_modelica_system(save_at)[source]

Writes a system model with inputs

Parameters:

save_at (str) – Path where to store the generated model

write_input_txt(save_as, name_variable, time, values, digits, description='')[source]

Writes a time series to input text file for Resources directory

Parameters:
  • save_as (str) – File to store input data to

  • name_variable (str) – Name of the variable to be referenced in model

  • time (list) – Time vector as float in seconds

  • values (list) – The input values corresponding to the the time steps

  • digits (int) – Number of digits to round to in output table

  • description (str) – Optional description to describe the input data

set_control_pressure(name_supply, dp, name_building='max_distance', p_max=1000000.0, k=None, ti=None)[source]

Set a pressure control to provide a given dp at a building

Parameters:
  • name_supply (str) – Name of supply to control the pressure in the network

  • dp (float) – Pressure difference to be held at reference building

  • name_building (str) – Name of the reference building for the network. For default ‘max_distance’, the building with the greatest distance from the supply unit will be chosen

  • p_max (float) – Maximum pressure allowed for the pressure controller

  • k (int) – gain of controller

  • ti (int) – time constant for integrator block

write_output_connector(name, unit, annotation)[source]

Write Modelica code for modular output connector

Parameters:
  • name (str) – Name of of the output connector

  • unit (str) – Unit of the output value

  • annotation (boolean) – If ‘true’ annotations will be added to the connector

Returns:

mo – Rendered Modelica code

Return type:

str