Regional self-sufficiency
This constraint enforces that each region (defined by bus location) meets a minimum proportion of its local demand with local generation. It's useful when modeling energy security policies, regional independence targets, or scenarios where long-distance transmission is limited or penalized.
Common use cases:
- Modelling regional energy security and independence policies
- Exploring the cost of reducing inter-regional energy dependencies
- Analysing local renewable energy penetration requirements
Note that in the code block below, n refers to the network object.
python
# Configure self-sufficiency parameters
min_self_sufficiency = 0.8 # 80% of local demand must be met locally
target_buses = [] # Leave empty to apply to all buses, or specify: ["bus1", "bus2"]
# Access generation dispatch variable
gen_p = n.model["Generator-p"]
# Get bus assignments for each generator
bus = n.generators.bus.to_xarray()
# Get all unique buses
if len(target_buses) == 0:
buses_to_constrain = n.buses.index
else:
buses_to_constrain = target_buses
# Apply constraint to each bus
for bus_name in buses_to_constrain:
# Get generators at this bus
generators_at_bus = n.generators[n.generators.bus == bus_name].index
if len(generators_at_bus) == 0:
continue # Skip buses with no generators
# Get loads at this bus
loads_at_bus = n.loads[n.loads.bus == bus_name].index
if len(loads_at_bus) == 0:
continue # Skip buses with no loads
# Total generation at this bus
local_generation = gen_p.sel(Generator=generators_at_bus).sum()
# Total demand at this bus
local_demand = n.loads_t.p_set[loads_at_bus].sum().sum()
# Add constraint: local generation >= self-sufficiency ratio * local demand
n.model.add_constraints(
local_generation >= min_self_sufficiency * local_demand,
name=f"self_sufficiency_{bus_name}"
)
# print statement for your logs
print(f"Added self-sufficiency constraint for {bus_name}: {min_self_sufficiency*100:.0f}% local generation")
