Skip to content

Commit

Permalink
Fix group naming of automated input/output groups
Browse files Browse the repository at this point in the history
Otherwise, this leads to busses without flows
  • Loading branch information
henhuy committed Jun 6, 2024
1 parent 24b6358 commit e2fa122
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions oemof_industry/mimo_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def __init__(
if node in self.emission_factors
}

self.input_groups = self._unify_groups(inputs)
self.output_groups = self._unify_groups(outputs, exclude=emissions)
self.input_groups = self._unify_groups(inputs, "in")
self.output_groups = self._unify_groups(outputs, "out", exclude=emissions)

inputs = reduce(operator.ior, self.input_groups.values(), {})
# Add emissions to outputs (as they are excluded from output groups before)
Expand Down Expand Up @@ -287,6 +287,7 @@ def _init_group(
@staticmethod
def _unify_groups(
flows: Union[Dict[Bus, Flow], Dict[str, Dict[Bus, Flow]]],
direction: str,
exclude: Iterable[str] = None,
) -> Dict[str, Dict[Bus, Flow]]:
"""
Expand All @@ -301,6 +302,8 @@ def _unify_groups(
1. a dict of groups, containing buses with related flows
2. a dict of buses and related flows (as in default converter)
3. a mix of option 1 and 2
direction : str
To differentiate between input and output flows.
exclude: Iterable[str]
List of nodes to exclude from grouping
(needed to exclude emission buses from grouping)
Expand All @@ -316,7 +319,7 @@ def _unify_groups(
if exclude and key in exclude:
continue
if isinstance(key, Bus):
new_group = f"group_{group_counter}"
new_group = f"{direction}_group_{group_counter}"
group_dict[new_group] = {key: flow}
group_counter += 1
else:
Expand Down

0 comments on commit e2fa122

Please sign in to comment.