Skip to content

Commit 0f12ab4

Browse files
committed
feat: check capacities are non-negative
1 parent 781602e commit 0f12ab4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/pownet/input.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,23 @@ def check_data(self):
925925
raise ValueError(
926926
f"PowNet: Weekly hydropower timeseries must be of length {self.num_sim_days}."
927927
)
928+
929+
##################################
930+
# Capacities are non-negative
931+
##################################
932+
933+
attrs_to_check = [
934+
"solar_capacity",
935+
"wind_capacity",
936+
"import_capacity",
937+
"hydro_capacity",
938+
"susceptance",
939+
"line_capacity",
940+
]
941+
for attr in attrs_to_check:
942+
temp_df = getattr(self, attr)
943+
if (not temp_df.empty) and (temp_df < 0).any().any():
944+
raise ValueError(f"PowNet: {attr} must be non-negative.")
928945

929946
##################################
930947
# The derated capacities of thermal units must be above its minimum capacity

0 commit comments

Comments
 (0)