Skip to content

Commit 7920059

Browse files
committed
Add all_generators attribute
The SystemInput.all_generators attribute is a set of generators of different types.
1 parent ebdbc37 commit 7920059

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

src/pownet/core/input.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def __init__(
9999
self.hydro_capacity: pd.DataFrame = pd.DataFrame()
100100
self.hydro_timestep: str = ""
101101
self.hydro_unit_node: dict[str, str] = {}
102+
self.using_pownet_hydropower: bool = False
102103

103104
self.solar_capacity: pd.DataFrame = pd.DataFrame()
104105
self.solar_unit_node: dict[str, str] = {}
@@ -127,6 +128,7 @@ def __init__(
127128
self.solar_units: list[str] = []
128129
self.wind_units: list[str] = []
129130
self.import_units: list[str] = []
131+
self.all_generators: set[str] = []
130132

131133
# Generators by node
132134
self.node_generator: dict[str, list[str]] = {}
@@ -320,6 +322,7 @@ def load_data(self):
320322
"pownet_hydropower.csv", fuel_type="hydropower"
321323
)
322324
)
325+
self.using_pownet_hydropower = True
323326

324327
elif os.path.exists(os.path.join(self.model_dir, "hydropower.csv")):
325328
self.hydro_capacity, self.hydro_unit_node = (
@@ -360,6 +363,23 @@ def load_data(self):
360363
self._load_capacity_and_update_fuelmap("import.csv", "import")
361364
)
362365

366+
#################
367+
# All generators
368+
#################
369+
generators = (
370+
list(self.thermal_unit_node.keys())
371+
+ list(self.hydro_unit_node.keys())
372+
+ list(self.solar_unit_node.keys())
373+
+ list(self.wind_unit_node.keys())
374+
+ list(self.import_unit_node.keys())
375+
)
376+
set_generators = set(generators)
377+
if len(generators) != len(set_generators):
378+
raise ValueError(
379+
"PowNet: Generator names cannot repeat across different types."
380+
)
381+
self.all_generators = set_generators
382+
363383
#################
364384
# Transmission
365385
#################
@@ -571,25 +591,10 @@ def check_data(self):
571591
f"PowNet: The number of edges in the node_edge dictionary must be equal to the number of edges. {sum(len(v) for v in self.node_edge.values())} != {2*len(self.edges)}"
572592
)
573593

574-
##################################
575-
# Generator names cannot repeat across different generator types and slack units (demand nodes)
576-
##################################
577-
generators = (
578-
set(self.thermal_units)
579-
| set(self.hydro_units)
580-
| set(self.solar_units)
581-
| set(self.wind_units)
582-
| set(self.import_units)
583-
)
584-
if len(generators) != number_of_generators:
585-
raise ValueError(
586-
"PowNet: Generator names cannot repeat across different types."
587-
)
588-
589594
##################################
590595
# Generator names cannot be the same as the name of demand nodes
591596
##################################
592-
if generators.intersection(self.demand_nodes):
597+
if self.all_generators.intersection(self.demand_nodes):
593598
raise ValueError(
594599
"PowNet: Generator names cannot be the same as the name of demand nodes."
595600
)

0 commit comments

Comments
 (0)