pownet.optim_model.constraints package
Submodules
pownet.optim_model.constraints.energy_storage_constr module
energy_storage_constr.py: Constraints for energy storage units.
- pownet.optim_model.constraints.energy_storage_constr.add_c_link_ess_charge(model, pcharge, ucharge, timesteps, units, max_charge)[source]
Link the charging indicator to the continuous charging variable. The charging variable is limited by the maximum charging capacity of the unit.
- Parameters:
model (gp.Model) – The Gurobi model.
pcharge (gp.tupledict) – Continuous charging variable.
ucharge (gp.tupledict) – Binary charging indicator.
timesteps (range) – Range of time steps.
units (list) – List of energy storage units.
max_charge (dict[str, float]) – Maximum charging capacity for each unit.
- Returns:
The added constraints.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.energy_storage_constr.add_c_link_ess_discharge(model, pdischarge, udischarge, timesteps, units, max_discharge)[source]
Link the discharging indicator to the continuous discharging variable. The discharging variable is limited by the maximum discharging capacity of the unit.
- Parameters:
model (gp.Model) – The Gurobi model.
pdischarge (gp.tupledict) – Continuous discharging variable.
udischarge (gp.tupledict) – Binary discharging indicator.
timesteps (range) – Range of time steps.
units (list) – List of energy storage units.
max_discharge (dict[str, float]) – Maximum discharging capacity for each unit.
- Returns:
The added constraints.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.energy_storage_constr.add_c_link_ess_state(model, ucharge, udischarge, timesteps, units)[source]
Link the charging and discharging indicators to ensure that only one can be active at a time.
- Parameters:
model (gp.Model) – The Gurobi model.
ucharge (gp.tupledict) – Binary charging indicator.
udischarge (gp.tupledict) – Binary discharging indicator.
timesteps (range) – Range of time steps.
units (list) – List of energy storage units.
- Returns:
The added constraints.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.energy_storage_constr.add_c_unit_ess_balance(model, pcharge, pdischarge, charge_state, units, sim_horizon, charge_efficiency, discharge_efficiency, self_discharge_rate)[source]
Balance for energy storage units at the second time step and onwards. The balance equation ensures that the charge state at time t is equal to the charge state at time t-1, adjusted for the charging and discharging variables, as well as the self-discharge rate.
- Parameters:
model (gp.Model) – The Gurobi model.
pcharge (gp.tupledict) – Continuous charging variable.
pdischarge (gp.tupledict) – Continuous discharging variable.
charge_state (gp.tupledict) – Charge state variable.
units (list) – List of energy storage units.
sim_horizon (int) – Simulation horizon.
charge_efficiency (dict[str, float]) – Charging efficiency for each unit.
discharge_efficiency (dict[str, float]) – Discharging efficiency for each unit.
self_discharge_rate (dict[str, float]) – Self-discharge rate for each unit.
- Returns:
The added constraints.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.energy_storage_constr.add_c_unit_ess_balance_init(model, pcharge, pdischarge, charge_state, units, charge_state_init, charge_efficiency, discharge_efficiency, self_discharge_rate)[source]
Initial balance for energy storage units at the first time step.
- Parameters:
model (gp.Model) – The Gurobi model.
pcharge (gp.tupledict) – Continuous charging variable.
pdischarge (gp.tupledict) – Continuous discharging variable.
charge_state (gp.tupledict) – Charge state variable.
units (list) – List of energy storage units.
charge_state_init (dict[str, float]) – Initial charge state for each unit.
charge_efficiency (dict[str, float]) – Charging efficiency for each unit.
discharge_efficiency (dict[str, float]) – Discharging efficiency for each unit.
self_discharge_rate (dict[str, float]) – Self-discharge rate for each unit.
- Returns:
The added constraints.
- Return type:
gp.tupledict
pownet.optim_model.constraints.nondispatch_constr module
nondispatch_constr.py: Constraints for non-dispatchable units.
- pownet.optim_model.constraints.nondispatch_constr.add_c_hourly_unit_ub(model, pdispatch, unit_type, timesteps, units, contracted_capacity_dict)[source]
Add constraints to define the hourly availability of non-dispatchable units. This is limited by the contracted_capacity
- Parameters:
model (gp.Model) – The optimization model.
pdispatch (gp.tupledict) – The dispatch variable.
unit_type (str) – The type of unit (“wind”, “solar”, “hydro”, “import”).
timesteps (range) – The range of timesteps.
units (list) – The list of units.
contracted_capacity_dict (dict[str, float]) – The contracted capacity of the unit.
- Returns:
The constraints linking the dispatch variable and the unit status variable.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.nondispatch_constr.add_c_hydro_limit_daily(model, phydro, step_k, sim_horizon, hydro_units, hydro_capacity)[source]
Add constraints to limit hydropower by the daily amount. The sum of dispatch variables for each hydro unit over a 24-hour period must be less than or equal to the daily capacity.
- Parameters:
model (gp.Model) – The optimization model
phydro (gp.tupledict) – The power output of hydro units
step_k (int) – The current iteration
sim_horizon (int) – The simulation horizon
hydro_units (list) – The list of hydro units
hydro_capacity (pd.DataFrame) – The daily capacity of the hydro unit
- Returns:
The constraints for the daily hydro limit
- Return type:
gp.tupledict
- Raises:
ValueError – If the simulation horizon is not divisible by 24
- pownet.optim_model.constraints.nondispatch_constr.add_c_hydro_limit_daily_dict(model, phydro, step_k, sim_horizon, hydro_units, hydro_capacity_dict)[source]
Add constraints to limit hydropower by the daily amount. The sum of dispatch variables for each hydro unit over a 24-hour period must be less than or equal to the daily capacity.
- Parameters:
model (gp.Model) – The optimization model
phydro (gp.tupledict) – The power output of hydro units
step_k (int) – The current iteration
sim_horizon (int) – The simulation horizon
hydro_units (list) – The list of hydro units
hydro_capacity_dict (
dict[tuple[str,int],float]) – The daily capacity of the hydro unit
- Returns:
The constraints for the daily hydro limit
- Return type:
gp.tupledict
- Raises:
ValueError – If the simulation horizon is not divisible by 24
- pownet.optim_model.constraints.nondispatch_constr.add_c_hydro_limit_weekly(model, phydro, step_k, sim_horizon, hydro_units, hydro_capacity, hydro_capacity_min)[source]
Defines the weekly limit (lower and upper bounds) of hydro generation. Assumes that a certain amount of water is available for hydropower generation each day.
- Parameters:
model (gp.Model) – The optimization model
phydro (gp.tupledict) – The power output of hydro units
step_k (int) – The current iteration
sim_horizon (int) – The simulation horizon
hydro_units (list) – The list of hydro units
hydro_capacity (pd.DataFrame) – The capacity of the hydro unit
- Returns:
The constraints for the weekly hydro limit
- Return type:
gp.tupledict
- Raises:
ValueError – If the simulation horizon is not divisible by 24
- pownet.optim_model.constraints.nondispatch_constr.add_c_link_unit_pu(model, pdispatch, u, unit_type, timesteps, units, contracted_capacity_dict)[source]
Add constraints to link the dispatch variable and the unit status variable. The dispatch variable is limited by the unit status variable and the maximum dispatch of the unit (contracted capacity).
- Parameters:
model (gp.Model) – The optimization model.
pdispatch (gp.tupledict) – The dispatch variable.
u (gp.tupledict) – The unit status variable.
unit_type (str) – The type of unit (“wind”, “solar”, “hydro”, “import”).
timesteps (range) – The range of timesteps.
units (list) – The list of units.
contracted_capacity_dict (dict[str, float]) – The contracted capacity of the unit.
- Returns:
The constraints linking the dispatch variable and the unit status variable.
- Return type:
gp.tupledict
pownet.optim_model.constraints.system_constr module
system_constr.py: Constraints for the power system
- pownet.optim_model.constraints.system_constr.add_c_angle_diff(model, flow_fwd, flow_bwd, theta, timesteps, step_k, edges, susceptance)[source]
Equation 64a of Kneuven et al (2019) expresses the power flow in a transmission line as a function of the voltage angle difference between the two buses it connects. In DC-OPF, the real power flow on a transmission line is directly proportional to the difference in voltage angles.
Note: If the voltage-angle variable is not implemented, then we can use the Kirchhoff formulation.
- Parameters:
model (gp.Model) – The optimization model
flow_fwd (gp.tupledict) – The power flow from forward k -> s
flow_bwd (gp.tupledict) – The power flow from backward s <- k
theta (gp.tupledict) – The voltage angle
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
edges (list) – The list of edges
susceptance (pd.DataFrame) – The susceptance matrix
- Returns:
The constraints for the angle difference
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_flow_balance(model, pthermal, phydro, psolar, pwind, pimp, pcharge, pdis, pos_pmismatch, neg_pmismatch, flow_fwd, flow_bwd, timesteps, step_k, thermal_units, hydro_units, solar_units, wind_units, import_units, nodes, node_edge, node_generator, ess_charge_units, ess_discharge_units, demand_nodes, demand, gen_loss_factor, line_loss_factor)[source]
Adds power flow balance constraints to the optimization model.
These constraints ensure that for each node and each timestep, the total power flowing into the node equals the total power flowing out of the node. This represents Kirchhoff’s Current Law (KCL) applied to power flow in the network.
The balance considers: - Power generated at the node (adjusted for generation efficiency). - Power flow into and out of the node via transmission lines (adjusted for line losses). - Power consumed by energy storage charging at the node. - Power injected by energy storage discharging at the node. - Power demand at the node. - Power mismatch variables (positive and negative slack).
- Parameters:
model (gp.Model) – The optimization model
pthermal (gp.tupledict) – The power output of thermal units
phydro (gp.tupledict) – The power output of hydro units
psolar (gp.tupledict) – The power output of solar units
pwind (gp.tupledict) – The power output of wind units
pimp (gp.tupledict) – The power output of import units
pcharge (gp.tupledict) – The charge of energy storage units
pdis (gp.tupledict) – The discharge of energy storage units
pos_pmismatch (gp.tupledict) – The positive power mismatch
neg_pmismatch (gp.tupledict) – The negative power mismatch
flow_fwd (gp.tupledict) – The power flow from forward k -> s
flow_bwd (gp.tupledict) – The power flow from backward s <- k
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
hydro_units (list) – The list of hydro units
solar_units (list) – The list of solar units
wind_units (list) – The list of wind units
import_units (list) – The list of import units
nodes (list) – The list of nodes
node_edge (dict) – The edges connected to a node
node_generator (dict) – The generators connected to a node
ess_charge_units (dict) – Storage units to charge from this node
ess_discharge_units (dict) – Storage units to discharge to this node
demand_nodes (list) – The list of demand nodes
demand (pd.DataFrame) – The demand data
gen_loss_factor (float) – The system-wide generation loss factor (applied at generation source)
line_loss_factor (float) – The system-wide line loss factor
- Returns:
The constraints for the power flow balance
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_kirchhoff(model, flow_fwd, flow_bwd, timesteps, step_k, edges, cycle_map, susceptance)[source]
Equation 23b in Horsch et al (2018). This constraint implements the Kirchhoff circuit laws (KCL) directly on the flow variables.
Note: This constraint replaces the voltage-angle difference formulation.
- Parameters:
model (gp.Model) – The optimization model
flow_fwd (gp.tupledict) – The power flow variable
flow_bwd (gp.tupledict) – The power flow variable
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
edges (list) – The list of edges
cycle_map (dict) – The cycle map (created by DataProcessor class)
susceptance (pd.DataFrame) – The susceptance matrix
- Returns:
The constraints for the Kirchhoff circuit laws
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_link_shortfall(model, load_shortfall, p_pmismatch, n_pmismatch, timesteps)[source]
Equation 66 of Kneuven et al (2019). Supply-demand is balanced with an equality constraint. To prevent model infeasibility, we introduce a variable to represent the load shortfall s_n(t), which can be expressed in terms of non-negative variables: the positive and negative power mismatch.
Note: Currently not implemented in the model. The load shortfall is not a variable in the model.
Formula: s_n(t) = s_pos(t) - s_neg(t)
- Parameters:
model (gp.Model) – The optimization model
load_shortfall (gp.tupledict) – The load shortfall
p_pmismatch (gp.tupledict) – The positive power mismatch
n_pmismatch (gp.tupledict) – The negative power mismatch
timesteps (range) – The range of timesteps
- Returns:
The constraints for the load shortfall
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_ref_node(model, theta, timesteps, max_demand_node)[source]
Equation 64d of Kneuven et al (2019). Set the voltage angle at the reference node to zero. The reference node is typically the node with the highest demand.
- Parameters:
model (gp.Model) – The optimization model
theta (gp.tupledict) – The voltage angle
timesteps (range) – The range of timesteps
max_demand_node (str) – The node with the highest demand
- Returns:
The constraints for the reference node
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_reserve_req_1(model, spin, charge_state, spin_shortfall, timesteps, step_k, thermal_units, storage_units, spin_requirement)[source]
Equation 68 of Kneuven et al (2019) based on Morales-España et al. (2013). System-wide spinning reserve requirement. The spinning reserve is the sum of the spinning reserve of all thermal units.
NOTE: This formulation is suitable when we implement the spinning-reserve variable (spin). Only one reserve_requirement is constraint is needed.
- Parameters:
model (gp.Model) – The optimization model
spin (gp.tupledict) – The spinning reserve
charge_state (gp.tupledict) – The state of charge of energy storage systems
spin_shortfall (gp.tupledict) – The spinning reserve shortfall
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
storage_units (list) – The list of storage units
spin_requirement (pd.Series) – The spinning reserve requirement at each hour (MW)
- Returns:
The constraints for the spinning reserve requirement
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_reserve_req_2(model, pbar, u, charge_state, spin_shortfall, timesteps, step_k, thermal_units, thermal_min_capacity, storage_units, total_demand, spin_requirement)[source]
Equation 67 of Kneuven et al (2019) based on Carrion and Arroyo (2006) and Ostrowski et al. (2012). The spinning reserve is expressed in terms of the maximum power output of all thermal units. Since the pbar in our implementation is actuallly pbar_tilde in Knueven et al (2019), we substitute pbar with pbar + u*min_capacity.
NOTE: This formulation is suitable when we implement the pbar variable. Only one reserve_requirement is constraint is needed.
- Parameters:
model (gp.Model) – The optimization model
pbar (gp.tupledict) – The maximum power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
spin_shortfall (gp.tupledict) – The spinning reserve shortfall
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
storage_units (list) – The list of storage units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
demand_nodes (list) – The list of demand nodes
total_demand (pd.Series) – The total system demand at each hour (MW)
spin_requirement (pd.Series) – The spinning reserve requirement at each hour (MW)
- Returns:
The constraints for the spinning reserve requirement
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_thermal_curtail_ess(model, pthermal, pthermal_curtail, pcharge, timesteps, step_k, thermal_must_take_units, thermal_derated_capacity, ess_attached)[source]
Adds curtailment constraints for must-take thermal units, considering ESS charging.
For must-take thermal units, the total potential generation (derated capacity) must equal the sum of dispatched power, curtailed power, and power used to charge any attached energy storage systems.
Constraint: pthermal[unit, t] + pthermal_curtail[unit, t] + pcharge_ess[unit, t] == derated_capacity[unit, t]
- Parameters:
model (gp.Model) – The optimization model.
pthermal (gp.tupledict) – Power dispatched from thermal units [unit, t].
pthermal_curtail (gp.tupledict) – Power curtailed from thermal units [unit, t].
pcharge (gp.tupledict) – Power used to charge energy storage systems [ess_unit, t].
timesteps (range) – The range of timesteps for the constraints.
step_k (int) – The current optimization step (for indexing time-series data).
thermal_must_take_units (list) – List of thermal units designated as must-take.
thermal_derated_capacity (pd.DataFrame) – DataFrame of derated capacity for thermal units (index=time, columns=unit).
ess_attached (dict) – Dictionary mapping generation units to lists of attached ESS units {gen_unit: [ess_unit1, ess_unit2, …]}.
- Returns:
Dictionary of added curtailment constraints.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_unit_curtail_ess(model, pdispatch, pcurtail, pcharge, unit_type, timesteps, step_k, units, capacity_df, ess_attached)[source]
Adds generic curtailment constraints for a specified unit type, considering ESS charging.
This function ensures that for each unit of the specified type and each timestep, the total available capacity equals the sum of the power dispatched to the grid, the power curtailed, and the power used to charge any directly attached energy storage systems (ESS).
Constraint for each unit u and time t: pdispatch[u, t] + pcurtail[u, t] + pcharge_ess[u, t] == capacity[u, t]
Where pcharge_ess[u, t] is the sum of pcharge for all ESS units attached to u.
- Parameters:
model (gp.Model) – The Gurobi optimization model.
pdispatch (gp.tupledict) – Decision variables for power dispatched from units [unit, t].
pcurtail (gp.tupledict) – Decision variables for power curtailed from units [unit, t].
pcharge (gp.tupledict) – Decision variables for power charging ESS units [ess_unit, t].
unit_type (str) – A string identifier for the type of unit (e.g., ‘solar’, ‘wind’) used for naming constraints.
timesteps (range) – The range of timesteps to add constraints for.
step_k (int) – The current optimization step (used for indexing time-series data like capacity).
units (list) – A list of unit identifiers (strings) of the specified type.
capacity_df (pd.DataFrame) – DataFrame containing the available capacity of each unit over time (index=time, columns=unit).
ess_attached (Dict[str, List[str]]) – A dictionary mapping generation unit IDs to a list of attached ESS unit IDs. Example: {‘solar_farm_1’: [‘battery_1’, ‘battery_2’]}
- Returns:
A Gurobi tupledict containing the added constraints, indexed by constraint name.
- Return type:
gp.tupledict
- pownet.optim_model.constraints.system_constr.add_c_unit_curtail_ess_daily(model, pdispatch, pcurtail, pcharge, unit_type, sim_horizon, step_k, units, capacity_df, ess_attached)[source]
Adds daily energy balance constraints for specified units, considering ESS charging.
This function aggregates the hourly dispatch, curtailment, and associated ESS charging over a full day (24 hours) and ensures this sum equals the total available energy capacity for that unit on that day. This is useful for constraints or objectives that operate on a daily timescale.
Constraint for each unit u and day d: Sum_{t in day d}(pdispatch[u, t]) + Sum_{t in day d}(pcurtail[u, t]) + Sum_{t in day d}(pcharge_ess[u, t]) == daily_capacity[u, d]
Where pcharge_ess[u, t] is the sum of pcharge for all ESS units attached to u at hour t. The capacity is assumed to be provided as a single value for the entire day.
- Parameters:
model (gp.Model) – The Gurobi optimization model.
pdispatch (gp.tupledict) – Decision variables for hourly power dispatched [unit, t].
pcurtail (gp.tupledict) – Decision variables for hourly power curtailed [unit, t].
pcharge (gp.tupledict) – Decision variables for hourly power charging ESS [ess_unit, t].
unit_type (str) – String identifier for the unit type (e.g., ‘solar’, ‘wind’) used for naming constraints.
sim_horizon (int) – Total simulation horizon in hours. Used to determine the number of full days.
step_k (int) – The starting day index for adding constraints. Assumes days are numbered sequentially (e.g., 1, 2, 3…).
units (list) – List of unit identifiers (strings) of the specified type.
capacity_df (pd.DataFrame) – DataFrame containing the total daily available energy capacity for each unit. Crucially, this DataFrame must be indexed by day number (matching the `day` loop variable) and have units as columns. Example index: [1, 2, 3…], columns: [‘unit1’, ‘unit2’, …].
ess_attached (Dict[str, List[str]]) – Dictionary mapping generation unit IDs to lists of attached ESS unit IDs. Example: {‘solar_farm_1’: [‘battery_1’]}
- Returns:
A Gurobi tupledict containing the added daily constraints, indexed by constraint name.
- Return type:
gp.tupledict
pownet.optim_model.constraints.thermal_unit_constr module
thermal_unit_constr.py: Constraints for thermal units
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_ppbar(model, p, pbar, timesteps, thermal_units)[source]
Equation 17 of Kneuven et al (2019). Since pbar = p + spin, if we do not implement the spin variable, then p <= pbar.
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
pbar (gp.tupledict) – The maximum power output above the minimum capacity
timesteps (range) – The range of timesteps
thermal_units (list) – The list of thermal units
- Returns:
The constraints for the power output above the minimum capacity and the maximum power output above the minimum capacity
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_pthermal(model, pthermal, p, u, timesteps, thermal_units, thermal_min_capacity)[source]
Equation 12 of Kneuven et al (2019). This establishes the power output above the minimum capacity, which is a variable promoted by Morales-Espana et al. (2013).
- Parameters:
model (gp.Model) – The optimization model
pthermal (gp.tupledict) – The power output
p (gp.tupledict) – The power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
timesteps (range) – The range of timesteps
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
- Returns:
The constraints for the power output above the minimum capacity
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_pu_lower(model, pthermal, u, timesteps, thermal_units, thermal_min_capacity)[source]
Equation 18 of Kneuven et al (2019) based on Carrion and Arroyo (2006). Set the lower bound of the dispatched power.
- Parameters:
model (gp.Model) – The optimization model
pthermal (gp.tupledict) – The dispatched power
u (gp.tupledict) – The status of the thermal unit
timesteps (range) – The range of timesteps
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
- Returns:
The constraints for the lower bound of the dispatched power
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_pu_upper(model, pbar, u, timesteps, step_k, thermal_units, thermal_min_capacity, thermal_derated_capacity)[source]
Equation 18 of Knueven et al (2019) based on Carrion and Arroyo (2006). Set the upper bound of the dispatched power.
- Parameters:
model (gp.Model) – The optimization model
pbar (gp.tupledict) – The maximum power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
timesteps (range) – The range of timesteps
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
thermal_derated_capacity (pd.DataFrame) – The derated capacity of the thermal unit
- Returns:
The constraints for the upper bound of the dispatched power
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_spin(model, p, pbar, spin, timesteps, thermal_units)[source]
Equation 14 of Kneuven et al (2019). Establish the relationship among p, pbar, and spin: pbar = p + spin Note that pbar and p are variables defines as MW above the minimum capacity.
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
pbar (gp.tupledict) – The maximum power output above the minimum capacity
spin (gp.tupledict) – The spinning reserve
timesteps (range) – The range of timesteps
thermal_units (list) – The list of thermal units
- Returns:
The constraints for the power output above the minimum capacity
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_uvw(model, u, v, w, sim_horizon, thermal_units)[source]
Equation 2 of Kneuven et al (2019) based on Garver (1962). Three binary variables u (status), v (startup), and w (shutdown) are used to model the status of a thermal unit. Their logical relationship is defined by this equation.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
- Returns:
The constraints for the subsequent time
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_link_uvw_init(model, u, v, w, thermal_units, initial_u)[source]
Equation 2 of Kneuven et al (2019) based on Garver (1962). Three binary variables u (status), v (startup), and w (shutdown) are used to model the status of a thermal unit. Their logical relationship is defined by this equation. The initial condition is also considered here.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
thermal_units (list) – The list of thermal units
initial_u (dict) – The initial status of the thermal unit
- Returns:
The constraints for the initial condition
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_min_down(model, u, w, sim_horizon, thermal_units, TD)[source]
Equation 5 of Kneuven et al (2019) based on Malkin (2003) and Rajan and Takriti (2005). Minimum downtime of thermal units at t>1.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
TD (dict) – The minimum downtime of thermal units
- Returns:
The constraints for the minimum downtime of thermal units at t>1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_min_down_init(model, u, sim_horizon, thermal_units, initial_min_off)[source]
Equation 3b of Kneuven et al (2019). Minimum downtime of thermal units at t=1.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
initial_min_off (dict) – The remaining minimum downtime of the thermal unit from the previous iteration
- Returns:
The constraints for the minimum downtime of thermal units at t=1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_min_up(model, u, v, sim_horizon, thermal_units, TU)[source]
Equation 4 of Kneuven et al (2019) based on Malkin (2003) and Rajan and Takriti (2005). Minimum uptime of thermal units at t>1.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
TU (dict) – The minimum uptime of thermal units
- Returns:
The constraints for the minimum uptime of thermal units at t>1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_min_up_init(model, u, sim_horizon, thermal_units, initial_min_on)[source]
Equation 3a of Kneuven et al (2019). Minimum uptime of thermal units at t=1.
- Parameters:
model (gp.Model) – The optimization model
u (gp.tupledict) – The status of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
initial_min_on (dict) – The remaining minimum uptime of the thermal unit from the previous iteration
- Returns:
The constraints for the minimum uptime of thermal units at t=1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_peak_down_bound(model, p, u, v, w, sim_horizon, step_k, thermal_units, thermal_min_capacity, thermal_derated_capacity, SD, SU, TU)[source]
Shutdown capability based on Gentile et al. (2017) for TU=1 units. Implements Eq. (1) for t=1 and Eq. (4) for t in [2, T-1].
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
sim_horizon (int) – The simulation horizon
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
thermal_derated_capacity (pd.DataFrame) – The derated capacity of the thermal unit
SD (dict) – The shutdown rate of the thermal unit
SU (dict) – The startup rate of the thermal unit
TU (dict) – The minimum uptime of thermal units
- Returns:
The constraints for the peak down bound
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_peak_up_bound(model, p, u, v, w, sim_horizon, step_k, thermal_units, thermal_min_capacity, thermal_derated_capacity, SD, SU, TU)[source]
Startup capability based on Gentile et al. (2017) for TU=1 units. Implements Eq. (5) for t in [2, T-1] and Eq. (3) for t=T. Constraint applies to p (power above minimum output).
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
sim_horizon (int) – The simulation horizon
step_k (int) – The current iteration
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
thermal_derated_capacity (pd.DataFrame) – The derated capacity of the thermal unit
SD (dict) – The shutdown rate of the thermal unit
SU (dict) – The startup rate of the thermal unit
TU (dict) – The minimum uptime of thermal units
- Returns:
The constraints for the peak up bound
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_ramp_down(model, p, u, w, sim_horizon, thermal_units, thermal_min_capacity, RD, SD)[source]
Equation 36 of Kneuven et al (2019) based on Damci-Kurt et al. (2016). Ramp-down constraint at t>1. The equation was modified to be expressed in terms of power output above the minimum capacity.
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
w (gp.tupledict) – The shutdown of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
RD (dict) – The ramp-down rate of the thermal unit
SD (dict) – The shutdown rate of the thermal unit
- Returns:
The constraints for the ramp-down at t>1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_ramp_down_init(model, p, w, thermal_units, initial_p, initial_u, thermal_min_capacity, RD, SD)[source]
Equation 36 of Kneuven et al (2019) based on Damci-Kurt et al. (2016). Ramp-down constraint at t=1. The equation was modified to be expressed in terms of power output above the minimum capacity.
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
w (gp.tupledict) – The shutdown of the thermal unit
thermal_units (list) – The list of thermal units
initial_p (dict) – The initial power output above the minimum capacity
initial_u (dict) – The initial status of the thermal unit
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
RD (dict) – The ramp-down rate of the thermal unit
SD (dict) – The shutdown rate of the thermal unit
- Returns:
The constraints for the ramp-down at t=1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_ramp_up(model, p, pbar, u, v, sim_horizon, thermal_units, thermal_min_capacity, RU, SU)[source]
Equation 35 of Kneuven et al (2019) based on Damci-Kurt et al. (2016). Ramp-up constraint at t>1. The equation was modified to be expressed in terms of power output above the minimum capacity.
- Parameters:
model (gp.Model) – The optimization model
p (gp.tupledict) – The power output above the minimum capacity
pbar (gp.tupledict) – The maximum power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
sim_horizon (int) – The simulation horizon
thermal_units (list) – The list of thermal units
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
RU (dict) – The ramp-up rate of the thermal unit
SU (dict) – The startup rate of the thermal unit
- Returns:
The constraints for the ramp-up at t>1
- Return type:
gp.tupledict
- pownet.optim_model.constraints.thermal_unit_constr.add_c_ramp_up_init(model, pbar, u, v, thermal_units, initial_p, thermal_min_capacity, RU, SU)[source]
Equation 35 of Kneuven et al (2019) based on Damci-Kurt et al. (2016). Ramp-up constraint at t=1. The equation was modified to be expressed in terms of power output above the minimum capacity.
- Parameters:
model (gp.Model) – The optimization model
pbar (gp.tupledict) – The maximum power output above the minimum capacity
u (gp.tupledict) – The status of the thermal unit
v (gp.tupledict) – The startup of the thermal unit
thermal_units (list) – The list of thermal units
initial_p (dict) – The initial power output above the minimum capacity
thermal_min_capacity (dict) – The minimum capacity of the thermal unit
RU (dict) – The ramp-up rate of the thermal unit
SU (dict) – The startup rate of the thermal unit
- Returns:
The constraints for the ramp-up at t=1
- Return type:
gp.tupledict
Module contents
This is the constraint module.