Skip to content

Commit b4b5def

Browse files
committed
Fix weighting to allow different timeseries
1 parent c3d0bce commit b4b5def

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

switch_model/generators/extensions/hydro_simple.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,6 @@ def define_components(mod):
117117
doc="Set of timepoints in each hydro timeseries"
118118
)
119119

120-
mod.hydro_ts_duration = Param(
121-
mod.HYDRO_TS,
122-
initialize=lambda m, hts: sum(m.tp_duration_hrs[tp] for tp in m.TPS_IN_HTS[hts]),
123-
doc="Total duration in hours of each hydro timeseries."
124-
)
125-
126120
mod.HYDRO_GEN_TS_RAW = Set(
127121
dimen=2,
128122
input_file='hydro_timeseries.csv',
@@ -180,7 +174,9 @@ def define_components(mod):
180174
rule=lambda m, g, hts:
181175
Constraint.Skip if m.hydro_avg_flow_mw[g, hts] == 0 else
182176
enforce_hydro_avg_flow_scaling_factor *
183-
sum(m.DispatchGen[g, t] * m.tp_duration_hrs[t] for t in m.TPS_IN_HTS[hts]) / m.hydro_ts_duration[hts]
177+
# Compute the weighted average of the dispatch
178+
sum(m.DispatchGen[g, t] * m.tp_weight[t] for t in m.TPS_IN_HTS[hts])
179+
/ sum(m.tp_weight[tp] for tp in m.TPS_IN_HTS[hts])
184180
== m.hydro_avg_flow_mw[g, hts] * enforce_hydro_avg_flow_scaling_factor
185181
)
186182

0 commit comments

Comments
 (0)