Skip to content

Linear capacity ramp

This constraint enforces a gradual increase in the capacity share of a specific carrier (e.g., nuclear, solar, wind) over multiple investment periods. It's useful when you need to model realistic technology deployment scenarios with phased capacity buildout rather than sudden jumps.

Common use cases:

  • Modelling realistic renewable energy transition scenarios with gradual capacity expansion
  • Enforcing policy-driven technology deployment targets (e.g., X% solar by year Y)
  • Exploring the impact of technology learning curves and supply chain constraints on capacity growth

Note that in the code block below, n refers to the network object.

python
# Configure your capacity share parameters
carrier_name = "nuclear"  # Change to your desired carrier (e.g., "solar", "wind", "gas")
start_share = 0.05  # Starting share (5%)
end_share = 0.25  # Target share (25%)
start_year = 2025
end_year = 2050

# Access capacity variables
p_nom_opt = n.model["Generator-p_nom_opt"]
is_target_carrier = n.generators.carrier == carrier_name
target_generators = n.generators[is_target_carrier].index

for period in n.investment_periods:
    # Skip if outside your desired range
    if period < start_year or period > end_year:
        continue
    
    # Linear interpolation for carrier capacity share
    frac = start_share + (end_share - start_share) * ((period - start_year) / (end_year - start_year))
    
    # Handle period-indexed capacity variables
    try:
        period_capacity = p_nom_opt.sel(period=period)
        total_capacity = period_capacity.sum()
        
        if len(target_generators) > 0:
            target_capacity = period_capacity.sel(Generator=target_generators).sum()
        else:
            target_capacity = 0
            
    except (KeyError, ValueError):
        # Fallback: capacity variables not period-indexed
        total_capacity = p_nom_opt.sum()
        if len(target_generators) > 0:
            target_capacity = p_nom_opt.sel(Generator=target_generators).sum()
        else:
            target_capacity = 0
    
    # Add the constraint
    n.model.add_constraints(
        target_capacity >= frac * total_capacity,
        name=f"{carrier_name}_capacity_ramp_{period}"
    )
    
    # print statement for your logs
    print(f"Added {carrier_name} capacity ramp for {period}: {frac*100:.1f}% of total capacity")

© Copyright 2025 Bayesian Energy