Skip to content

Commit fa12be3

Browse files
committed
Update coupler.py
1 parent c4b921f commit fa12be3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/pownet/coupler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def get_reop_iter(self):
5454
def reoperate(
5555
self,
5656
step_k: int,
57+
max_reop_iter: int = 100,
5758
) -> None:
5859
"""Reoperate the reservoirs based on the daily dispatch of the power system model.
5960
Note that we don't reoperate on the first day of the simulation period.
@@ -106,9 +107,8 @@ def reoperate(
106107

107108
# Set the tolerance for convergence to 5%
108109
reop_tol = {
109-
(idx): 0.05 * hydropower_dispatch[unit, day]
110-
for idx in max_deviation
111-
for day in days_in_step
110+
(unit, day): 0.05 * hydropower_dispatch[unit, day]
111+
for unit, day in max_deviation.keys()
112112
}
113113

114114
if all(
@@ -121,11 +121,11 @@ def reoperate(
121121
f"PowNet: Day {step_k + 1} - Reservoirs converged at iteration {reop_k}"
122122
)
123123

124-
logger.info("Max deviation:", max_deviation)
124+
logger.info("Max deviations:", max_deviation)
125125

126-
if reop_k > 50:
126+
if reop_k > max_reop_iter:
127127
raise ValueError(
128-
"Reservoirs reoperation did not converge after 100 iterations"
128+
f"Reservoirs reoperation did not converge after {max_reop_iter} iterations"
129129
)
130130

131131
# To reoptimize PowNet with the new hydropower capacity,

0 commit comments

Comments
 (0)