@@ -15,6 +15,7 @@ class HydroUnitBuilder(ComponentBuilder):
1515 Variables
1616 ===========================
1717 - `phydro`: Hydropower output. Unit: MW.
18+ - `uhydro`: Hydropower unit status. Unit: binary (0 or 1).
1819
1920 Fixed objective terms
2021 ===========================
@@ -46,6 +47,10 @@ def __init__(self, model: gp.Model, inputs: SystemInput):
4647
4748 # Constraints
4849 self .c_link_hydro_pu = gp .tupledict ()
50+ self .c_link_weekly_hydro_pu = gp .tupledict ()
51+
52+ self .c_hydro_limit_daily = gp .tupledict ()
53+ self .c_hydro_limit_weekly = gp .tupledict ()
4954
5055 def add_variables (self , step_k : int ) -> None :
5156 """Add variables to the model for hydro units.
@@ -112,6 +117,17 @@ def add_constraints(self, step_k: int, init_conds: dict, **kwargs) -> None:
112117 units = self .inputs .hydro_unit_node .keys (),
113118 capacity_df = self .inputs .hydro_capacity ,
114119 )
120+
121+ # Weekly upper bound
122+ self .c_link_weekly_hydro_pu = nondispatch_constr .add_c_link_unit_pu (
123+ model = self .model ,
124+ pdispatch = self .phydro ,
125+ u = self .uhydro ,
126+ timesteps = self .timesteps ,
127+ units = self .inputs .weekly_hydro_unit_node .keys (),
128+ contracted_capacity = self .inputs .hydro_contracted_capacity ,
129+ )
130+
115131 # Daily upper bound
116132 self .c_hydro_limit_daily = nondispatch_constr .add_c_hydro_limit_daily (
117133 model = self .model ,
@@ -122,6 +138,17 @@ def add_constraints(self, step_k: int, init_conds: dict, **kwargs) -> None:
122138 hydro_capacity = self .inputs .daily_hydro_capacity ,
123139 )
124140
141+ # Weekly lower and upper bounds
142+ self .c_hydro_limit_weekly = nondispatch_constr .add_c_hydro_limit_weekly (
143+ model = self .model ,
144+ phydro = self .phydro ,
145+ step_k = step_k ,
146+ sim_horizon = self .inputs .sim_horizon ,
147+ hydro_units = self .inputs .weekly_hydro_unit_node .keys (),
148+ hydro_capacity = self .inputs .weekly_hydro_capacity ,
149+ hydro_capacity_min = self .inputs .hydro_min_capacity ,
150+ )
151+
125152 def update_variables (self , step_k : int ) -> None :
126153 "Hydropower variables do not have time-dependent lower/upper bounds."
127154 return
@@ -157,6 +184,17 @@ def update_constraints(self, step_k: int, init_conds: dict, **kwargs) -> None:
157184 hydro_capacity = self .inputs .daily_hydro_capacity ,
158185 )
159186
187+ self .model .remove (self .c_hydro_limit_weekly )
188+ self .c_hydro_limit_weekly = nondispatch_constr .add_c_hydro_limit_weekly (
189+ model = self .model ,
190+ phydro = self .phydro ,
191+ step_k = step_k ,
192+ sim_horizon = self .inputs .sim_horizon ,
193+ hydro_units = self .inputs .weekly_hydro_unit_node .keys (),
194+ hydro_capacity = self .inputs .weekly_hydro_capacity ,
195+ hydro_capacity_min = self .inputs .hydro_min_capacity ,
196+ )
197+
160198 def update_daily_hydropower_capacity (
161199 self , step_k : int , new_capacity : dict [(str , int ), float ]
162200 ) -> None :
0 commit comments