bim2sim.tasks.hvac package

Submodules

bim2sim.tasks.hvac.check_ifc module

bim2sim.tasks.hvac.connect_elements module

class bim2sim.tasks.hvac.connect_elements.ConnectElements(playground: Playground)

Bases: ITask

Analyses IFC, creates element elements and connects them. Elements are stored in elements dict with GUID as key.

static check_element_ports(elements: dict)

Checks position of all ports for each element.

Args:

elements: dictionary of elements to be checked with GUID as key.

static check_inner_connections(elements: Iterable[ProductBased]) Generator[DecisionBunch, None, None]

Check inner connections of HVACProducts.

Args:
elements: An iterable of elements, where each element is a subclass

of ProductBased.

Yields:

Yields decisions to set inner connections.

static confirm_connections_position(connections: list, eps: float = 1) Tuple[list, list, list]

Checks distance between port positions.

The method uses the ‘port_distance’ function from ‘ConnectElements’ to calculate distances. If distance < eps, the connection is confirmed otherwise rejected.

Args:

connections: list of connections to be checked. eps: distance tolerance for which connections are either confirmed

or rejected. Defaults to 1.

Returns:

tuple of lists of connections (confirmed, unconfirmed, rejected)

static connections_by_boundingbox(open_ports, elements)

Search for open ports in elements bounding boxes.

This is especially useful for vessel like elements with variable number of ports (and bad ifc export) or proxy elements. Missing ports on element side are created on demand.

static connections_by_position(ports: Generator, eps: float = 10) list

Connect ports of elements by computing geometric distance.

The method uses geometric distance between ports to establish connections. If multiple candidates are found for a port, the method prioritizes the closest one.

Args:

ports: A generator of ports to be connected. eps: distance tolerance for which ports are connected. Defaults

to 10.

Returns:

list of tuples of ports that are connected.

static connections_by_relation(ports: list, include_conflicts: bool = False) list

Connect ports of elements by IFC relations.

This method uses IfcRelConnects relations to establish connections between ports. It can include conflicting connections in the output if specified.

Args:

ports: list of ports to be connected include_conflicts: if true, conflicts are included. Defaults to

false.

Returns:

connections: list of tuples of ports that are connected.

static port_distance(port1: Port, port2: Port) array

Calculates distance (delta in x, y, z) of ports.

Args:

port1: the first port. port2: the seconds port.

Returns:

delta: distance between port1 and port2 in x, y, z coordinates.

reads: Tuple[str] = ('elements',)
run(elements: dict) dict

Connect elements based on port information and geometric relations.

This method performs the following steps: 1. Checks the ports of elements. 2. Connects the relevant elements based on relations. 3. Checks the positions of connections and connects ports based on

geometric distance.

  1. Connects remaining unconnected ports by position.

  2. Logs information about the number of connected and unconnected ports.

Args:

elements: dictionary of elements with GUID as key.

Returns:
elements: dictionary of elements with GUID as key, with updated

connections.

touches: Tuple[str] = ('elements',)

bim2sim.tasks.hvac.dead_ends module

class bim2sim.tasks.hvac.dead_ends.DeadEnds(playground)

Bases: ITask

static decide_dead_ends(graph: HvacGraph, pot_dead_ends: list, playground: Playground | None = None, force: bool = False) [{<class 'bim2sim.elements.graphs.hvac_graph.HvacGraph'>}, <class 'int'>]

Decide if potential dead ends are consumers or dead ends.

This method evaluates potential dead end ports and prompts the user for decisions on removal. If force is True, dead ends are removed without confirmation. If playground is provided, the graph is updated and visualized during the process.

Args:

graph: HVAC graph to be analysed. pot_dead_ends: List of potential dead end ports to be evaluated. playground: BIM2SIM Playground instance. Defaults to None. force: If True, then all potential dead ends are removed without

confirmation. Defaults to False.

Yields:

Decision bunch with BoolDecisions for confirming dead ends.

Returns:

Tuple containing the updated HVAC graph where dead ends are removed and the number of removed ports.

static identify_dead_ends(graph: HvacGraph) list

Identify potential dead ends in graph.

This method identifies potential dead end ports in the HVAC graph by considering two cases: 1. Ports that are not connected to any other port. 2. Ports that are connected to only one other port.

Args:

graph: HVAC graph to be analysed.

Returns:

pot_dead_ends: List of potential dead ends.

reads: Tuple[str] = ('graph',)
run(graph: HvacGraph) HvacGraph

Analyses graph for dead ends and removes ports due to dead ends.

This task performs the following steps: 1. Identifies potential dead ends in the HVAC graph. 2. Logs the number of identified potential dead ends. 3. Prompts and yields decisions regarding the removal of dead ends and updates the graph accordingly. 4. Logs the number of ports removed due to dead ends. 5. Optionally, plots the HVAC graph in debug mode.

Args:

graph: HVAC graph containing elements and ports.

Returns:

Updated HVAC graph after handling dead ends.

touches: Tuple[str] = ('graph',)

bim2sim.tasks.hvac.expansiontanks module

class bim2sim.tasks.hvac.expansiontanks.ExpansionTanks(playground)

Bases: ITask

static decide_expansion_tanks(graph: HvacGraph, potential_expansion_tanks: set, playground: Playground | None = None, force: bool = False) [<class 'bim2sim.elements.graphs.hvac_graph.HvacGraph'>, <class 'int'>]

Decide and handle the removal of potential expansion tanks.

This method evaluates potential expansion tanks and prompts the user for decisions on removal. If force is True, expansion tanks are removed without confirmation. If playground is provided, the graph is updated and visualized during the process.

Args:

graph: HVAC graph where the expansion tank should be removed. potential_expansion_tanks: set of potential expansion tank elements

to be evaluated.

playground: BIM2SIM Playground instance. Defaults to None. force: If True, forcefully remove expansion tanks without

confirmation. Defaults to False.

Yields:
Decision bunch with BoolDecisions for confirming expansion tank

removal.

Returns:

Tuple containing the updated HVAC graph where expansions tanks are removed and the number of removed expansion tanks.

static identify_expansion_tanks(graph: HvacGraph) set

Identify potential expansion tanks in the HVAC graph.

Expansion tanks are all tanks with only one port.

Args:

graph: HVAC graph to be analysed.

Returns:

set of potential expansion tanks.

reads: Tuple[str] = ('graph',)
run(graph: HvacGraph, force: bool = False) HvacGraph

Analyses graph network for expansion tanks and removes them.

This task performs the following steps: 1. Identifies potential expansion tanks in the HVAC graph. 2. Logs the number of identified potential expansion tanks. 3. Prompts and yields decisions regarding the removal of expansion tanks and updates the graph accordingly. 4. Logs the number of elements removed because they were identified as expansion tanks.

Args:

graph: The HVAC graph containing elements and ports. force: If True, forcefully remove expansion tanks without

confirmation. Defaults to False.

Returns:

The updated HVAC graph after handling expansion tanks.

touches: Tuple[str] = ('graph',)

bim2sim.tasks.hvac.export module

class bim2sim.tasks.hvac.export.Export(playground)

Bases: ITask

Export to Dymola/Modelica

static create_connections(graph: HvacGraph, export_elements: dict) list

Creates a list of connections for the corresponding Modelica model.

This method iterates over the edges of the HVAC graph and creates a list of connections for the corresponding Modelica model. It considers distributors and adjusts port names accordingly.

Args:

graph: the HVAC graph export_elements: the Modelica elements

Returns:
connection_port_names: list of tuple of port names that are

connected.

final = True
reads: Tuple[str] = ('libraries', 'graph')
run(libraries: tuple, graph: HvacGraph)

Export HVAC graph to Modelica code.

This method performs the following steps: 1. Initializes the Modelica instance factory with the specified libraries. 2. Creates Modelica instances for each HVAC element in the graph. 3. Collects and exports parameters for each Modelica instance. 4. Creates connections between Modelica instances based on the HVAC graph. 5. Creates a Modelica model with the exported elements and connections. 6. Saves the Modelica model to the specified export path.

Args:

libraries: Tuple of libraries to be used in Modelica. graph: The HVAC graph to be exported.

touches: Tuple[str] = ('modelica_model',)

bim2sim.tasks.hvac.fixports module

class bim2sim.tasks.hvac.fixports.FixPorts(playground)

Bases: ITask

Remove invalid ports from ifc.

entities_with_unusual_number_of_ports(ifc: file) set
static get_product_position(entity: entity_instance)
get_unconnected_ports(ifc: file) list
ports_with_same_parent_and_same_position(ifc: file) set
reads: Tuple[str] = ('ifc',)
run(ifc: file) tuple

Run tasks.

touches: Tuple[str] = ('ifc',)
unconnected_ports_on_same_position(ifc: file) set

Analyse IFC file for unconnected ports on the same position.

Args:

ifc: the IFC file that is inspected

Returns:

to_remove: set of ports to be removed

bim2sim.tasks.hvac.load_standardlibrary module

class bim2sim.tasks.hvac.load_standardlibrary.LoadLibrariesStandardLibrary(playground)

Bases: ITask

Load AixLib library for export

run(**kwargs)

Run tasks.

touches: Tuple[str] = ('libraries',)

bim2sim.tasks.hvac.make_graph module

class bim2sim.tasks.hvac.make_graph.MakeGraph(playground)

Bases: ITask

reads: Tuple[str] = ('elements',)
run(elements: dict)

Create an HVACGraph from IFC elements.

This task creates an HVACGraph from IFC elements (excluding materials). It logs the creation of the graph and returns the graph.

Args:

elements: Dictionary of IFC elements.

Returns:

The created HVAC graph.

touches: Tuple[str] = ('graph',)

bim2sim.tasks.hvac.obsolete module

This module holds currently not used tasks related to hvac

class bim2sim.tasks.hvac.obsolete.DetectCycles(playground)

Bases: ITask

Detect cycles in graph

reads: Tuple[str] = ('graph',)
run(graph: HvacGraph) tuple

Run tasks.

touches: Tuple[str] = ('cycles',)
class bim2sim.tasks.hvac.obsolete.Enrich(playground: Playground)

Bases: ITask

enrich_instance(instance, json_data)
static load_element_class(instance, dataclass)

this function fills a data class object, with the information found in the enrichment data, based on the class, parameter and parameter value.

static load_element_ifc(element, ele_ifc, enrich_parameter, parameter_value, dataclass)

this function fills a data class object, with the information found in the enrichment data, based on the ifc type and year.

run(elements)

Run tasks.

bim2sim.tasks.hvac.reduce module

class bim2sim.tasks.hvac.reduce.Reduce(playground)

Bases: ITask

reads: Tuple[str] = ('graph',)
run(graph: ~bim2sim.elements.graphs.hvac_graph.HvacGraph) -> (<class 'bim2sim.elements.graphs.hvac_graph.HvacGraph'>)

Apply aggregations to reduce number of elements in the HVAC graph.

This task applies aggregations to the HVAC graph based on the specified aggregation classes. It logs information about the number of elements before and after applying aggregations, as well as the statistics for each aggregation class. The task also updates the graph and logs relevant information. If the code is running in debug mode, it plots the graph using different options.

Args:

graph: The HVAC graph.

Returns:

The updated HVAC graph.

static set_flow_sides(graph: HvacGraph)

Set flow sides for ports in HVAC graph based on known flow sides.

This function iteratively sets flow sides for ports in the HVAC graph. It uses a recursive method (recurse_set_unknown_sides) to determine the flow side for each unset port. The function may prompt the user for decisions in case of conflicts or unknown sides.

Args:

graph: The HVAC graph.

Yields:
DecisionBunch: A collection of decisions may be yielded during the

task.

touches: Tuple[str] = ('graph',)