Skip to content

Commit

Permalink
add create function for multiple heat exchangers (#503)
Browse files Browse the repository at this point in the history
* enable multiple creation of heat exchanger

* adapted changelog and added doc for multiple heat exchanger
  • Loading branch information
SimonRubenDrauz authored Jan 31, 2023
1 parent fd76539 commit 01377f9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Change Log

[upcoming release] - 2023-..-..
-------------------------------
- [ADDED] multiple creation of heat exchanger
- [ADDED] support Python 3.11 (now included in test pipeline)

[0.8.3] - 2023-01-09
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ Create Function

.. _create_heat_exchanger:

For creating a single heat exchanger unit:

.. autofunction:: pandapipes.create_heat_exchanger

For creating multiple heat exchangers at once:

.. autofunction:: pandapipes.create_heat_exchangers


Component Table Data
====================

Expand Down
56 changes: 55 additions & 1 deletion pandapipes/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def create_source(net, junction, mdot_kg_per_s, scaling=1., name=None, index=Non

return index


def create_mass_storage(net, junction, mdot_kg_per_s, init_m_stored_kg=0, min_m_stored_kg=0.,
max_m_stored_kg=np.inf, scaling=1., name=None, index=None,
in_service=True, type="mass_storage", **kwargs):
Expand Down Expand Up @@ -1502,7 +1503,7 @@ def create_pressure_controls(net, from_junctions, to_junctions, controlled_junct
_set_multiple_entries(net, "press_control", index, **entries, **kwargs)

controlled_elsewhere = (controlled_junctions != from_junctions) \
& (controlled_junctions != to_junctions)
& (controlled_junctions != to_junctions)
if np.any(controlled_elsewhere):
controllers_warn = index[controlled_elsewhere]
logger.warning("The pressure controllers %s control the pressure at junctions that they are"
Expand Down Expand Up @@ -1572,6 +1573,59 @@ def create_flow_controls(net, from_junctions, to_junctions, controlled_mdot_kg_p
return index


def create_heat_exchangers(net, from_junctions, to_junctions, diameter_m, qext_w, loss_coefficient=0,
name=None, index=None, in_service=True, type="heat_exchanger", **kwargs):
"""
Convenience function for creating many heat exchangers at once. Parameters 'from_junctions'\
and 'to_junctions' must be arrays of equal length. Other parameters may be either arrays of the\
same length or single values.
:param net: The net for which the heat exchangers should be created
:type net: pandapipesNet
:param from_junctions: ID of the junctions on one side the heat exchangers will be\
connected with
:type from_junctions: Iterable(int)
:param to_junctions: ID of the junctions on the other side the heat exchangers will be\
connected with
:type to_junctions: Iterable(int)
:param diameter_m: The heat exchangers inner diameter in [m]
:type diameter_m: Iterable(float) or float
:param qext_w: External heat flux in [W]. If positive, heat is derived from the network. If
negative, heat is being fed into the network from a heat source.
:type qext_w: Iterable(float) or float
:param loss_coefficient: An additional pressure loss coefficient, introduced by e.g. bends
:type loss_coefficient: Iterable(float) or float
:param name: The name of the heat exchangers
:type name: str, default None
:param index: Force a specified ID if it is available. If None, the index one higher than the\
highest already existing index is selected.
:type index: Iterable(str) or str, default None
:param in_service: True if the heat exchangers are in service or False if they are out of service
:type in_service: Iterable(bool) or bool, default True
:param type: Not used yet
:type type: Iterable(str) or str, default "heat exchanger"
:param kwargs: Additional keyword arguments will be added as further columns to the\
net["heat_exchanger"] table
:return: index - The unique IDs of the created heat exchangers
:rtype: Iterable(int), default None
:Example:
>>> create_heat_exchangers(net, from_junctions=[0,1], to_junctions=[2,3],
>>> diameter_m=40e-3, qext_w=2000)
"""
add_new_component(net, HeatExchanger)

index = _get_multiple_index_with_check(net, "heat_exchanger", index, len(from_junctions))
_check_branches(net, from_junctions, to_junctions, "heat_exchanger")

entries = {"name": name, "from_junction": from_junctions, "to_junction": to_junctions,
"diameter_m": diameter_m, "qext_w": qext_w, "loss_coefficient": loss_coefficient,
"in_service": bool(in_service), "type": type}
_set_multiple_entries(net, "heat_exchanger", index, **entries, **kwargs)

return index


def create_fluid_from_lib(net, name, overwrite=True):
"""
Creates a fluid from library (if there is an entry) and sets net["fluid"] to this value.
Expand Down

0 comments on commit 01377f9

Please sign in to comment.