@@ -122,6 +122,7 @@ def __init__(self, inputs: SystemInput) -> None:
122122
123123 self .c_hydro_curtail_ess = gp .tupledict ()
124124 self .c_daily_hydro_curtail_ess = gp .tupledict ()
125+ self .c_weekly_hydro_curtail_ess = gp .tupledict ()
125126 self .c_solar_curtail_ess = gp .tupledict ()
126127 self .c_wind_curtail_ess = gp .tupledict ()
127128 self .c_import_curtail_ess = gp .tupledict ()
@@ -130,11 +131,13 @@ def __init__(self, inputs: SystemInput) -> None:
130131 # and provides indicators if the unit is online
131132 self .c_link_hydro_pu = gp .tupledict ()
132133 self .c_link_daily_hydro_pu = gp .tupledict ()
134+ self .c_link_weekly_hydro_pu = gp .tupledict ()
133135 self .c_link_solar_pu = gp .tupledict ()
134136 self .c_link_wind_pu = gp .tupledict ()
135137 self .c_link_import_pu = gp .tupledict ()
136138
137139 self .c_hydro_limit_daily = gp .tupledict ()
140+ self .c_hydro_limit_weekly = gp .tupledict ()
138141
139142 # Energy storage constraints
140143 self .c_link_ess_charge = gp .tupledict ()
@@ -380,6 +383,12 @@ def _build_rnw_import_storage_objfunc_terms(self, step_k: int) -> gp.LinExpr:
380383 self .inputs .daily_hydro_must_take_units ,
381384 self .inputs .nondispatch_contracts ,
382385 ),
386+ # Weekly hydro
387+ (
388+ self .phydro_curtail ,
389+ self .inputs .weekly_hydro_must_take_units ,
390+ self .inputs .nondispatch_contracts ,
391+ ),
383392 (self .psolar , self .inputs .solar_units , self .inputs .nondispatch_contracts ),
384393 (
385394 self .psolar_curtail ,
@@ -531,6 +540,7 @@ def _add_daily_hydropower_constraints(self, step_k: int) -> None:
531540 sim_horizon = self .inputs .sim_horizon ,
532541 hydro_units = self .inputs .daily_hydro_unit_node .keys (),
533542 hydro_capacity = self .inputs .daily_hydro_capacity ,
543+ hydro_capacity_min = self .inputs .hydro_capacity_min ,
534544 )
535545 # (2) The curtailment is enforced for the day and not the hour.
536546 self .c_daily_hydro_curtail_ess = modeling .add_c_unit_curtail_ess_daily (
@@ -546,10 +556,36 @@ def _add_daily_hydropower_constraints(self, step_k: int) -> None:
546556 ess_attached = self .inputs .ess_daily_hydro_units ,
547557 )
548558
559+ def _add_weekly_hydropower_constraints (self , step_k : int ) -> None :
560+ # (1) Define the weekly upper bound.
561+ self .c_hydro_limit_weekly = modeling .add_c_hydro_limit_weekly (
562+ model = self .model ,
563+ phydro = self .phydro ,
564+ step_k = step_k ,
565+ sim_horizon = self .inputs .sim_horizon ,
566+ hydro_units = self .inputs .weekly_hydro_unit_node .keys (),
567+ hydro_capacity = self .inputs .weekly_hydro_capacity ,
568+ hydro_capacity_min = self .inputs .hydro_capacity_min ,
569+ )
570+ # (2) The curtailment is enforced for the day and not the hour.
571+ # self.c_weekly_hydro_curtail_ess = modeling.add_c_unit_curtail_ess_weekly(
572+ # model=self.model,
573+ # pdispatch=self.phydro,
574+ # pcurtail=self.phydro_curtail,
575+ # pcharge=self.pcharge,
576+ # type="hydro",
577+ # sim_horizon=self.inputs.sim_horizon,
578+ # step_k=step_k,
579+ # units=self.inputs.weekly_hydro_unit_node.keys(),
580+ # capacity_df=self.inputs.weekly_hydro_capacity,
581+ # ess_attached=self.inputs.ess_weekly_hydro_units,
582+ # )
583+
549584 def _add_hydropower_constraints (self , step_k : int ) -> None :
550585
551586 self ._add_hourly_hydropower_constraints (step_k = step_k )
552587 self ._add_daily_hydropower_constraints (step_k = step_k )
588+ self ._add_weekly_hydropower_constraints (step_k = step_k )
553589
554590 # Does not update every step_k for this constraint
555591 self .c_link_daily_hydro_pu = modeling .add_c_link_unit_pu_constant (
@@ -561,6 +597,16 @@ def _add_hydropower_constraints(self, step_k: int) -> None:
561597 contracted_capacity = self .inputs .hydro_contracted_capacity ,
562598 )
563599
600+ # Does not update every step_k for this constraint
601+ self .c_link_weekly_hydro_pu = modeling .add_c_link_unit_pu_constant (
602+ model = self .model ,
603+ pdispatch = self .phydro ,
604+ u = self .uhydro ,
605+ timesteps = self .timesteps ,
606+ units = self .inputs .weekly_hydro_unit_node .keys (),
607+ contracted_capacity = self .inputs .hydro_contracted_capacity ,
608+ )
609+
564610 def _update_hydropower_constraints (self , step_k : int ) -> None :
565611 # Hourly constraints
566612 self .model .remove (self .c_link_hydro_pu )
@@ -571,6 +617,10 @@ def _update_hydropower_constraints(self, step_k: int) -> None:
571617 self .model .remove (self .c_daily_hydro_curtail_ess )
572618 self ._add_daily_hydropower_constraints (step_k = step_k )
573619
620+ self .model .remove (self .c_hydro_limit_weekly )
621+ # self.model.remove(self.c_weekly_hydro_curtail_ess)
622+ self ._add_weekly_hydropower_constraints (step_k = step_k )
623+
574624 def _add_unit_link_pu (self , step_k : int ) -> None :
575625 # Define parameters
576626 unit_params = {
@@ -1127,10 +1177,13 @@ def _update_constraints(self, step_k, init_conds: dict) -> None:
11271177 - c_link_import_pu: Import capacity is a timeseries
11281178
11291179 - c_hydro_limit_daily: Hydropower capacity is a timeseries
1180+ - c_hydro_limit_weekly: Hydropower capacity is a timeseries
11301181
11311182 *Curtailment*
11321183 - c_hydro_curtail_ess: Hydropower capacity is a timeseries
11331184 - c_daily_hydro_curtail_ess: Daily hydropower capacity is a timeseries
1185+ - c_weekly_hydro_curtail_ess: Weekly hydropower capacity is a timeseries
1186+
11341187 - c_solar_curtail_ess: Solar capacity is a timeseries
11351188 - c_wind_curtail_ess: Wind capacity is a timeseries
11361189 - c_import_curtail_ess: Import capacity is a timeseries
@@ -1376,15 +1429,18 @@ def print_added_constraints(self):
13761429 "c_reserve_req" ,
13771430 "c_hydro_curtail_ess" ,
13781431 "c_daily_hydro_curtail_ess" ,
1432+ "c_weekly_hydro_curtail_ess" ,
13791433 "c_solar_curtail_ess" ,
13801434 "c_wind_curtail_ess" ,
13811435 "c_import_curtail_ess" ,
13821436 "c_link_hydro_pu" ,
13831437 "c_link_daily_hydro_pu" ,
1438+ "c_link_weekly_hydro_pu" ,
13841439 "c_link_solar_pu" ,
13851440 "c_link_wind_pu" ,
13861441 "c_link_import_pu" ,
13871442 "c_hydro_limit_daily" ,
1443+ "c_hydro_limit_weekly" ,
13881444 "c_link_ess_charge" ,
13891445 "c_link_discharge" ,
13901446 "c_link_ess_state" ,
0 commit comments