Post · 16 min read· pp. 262–272

Global Constraints

Global constraints apply to more than one component at once and are stored under a unique name in n.global_constraints. Several pre-defined types of global constraints are available (type). For instance, for defining emission limits, transmission expansion limits, or technology capacity expansion limits using the sense and constant attributes.

By default, global constraints span across all investment periods. For models with multiple investment periods, global constraints can be limited to affect only single investment period (e.g. an emission limit for a specific year) by specifying the in the attribute investment_period. The shadow price of each global constraint is stored in the attribute mu. Flow-based rows store theirs per snapshot in mu_ram instead.

Naming Convention

Global constraints carry the name scheme GlobalConstraint-{name} in the Linopy model. All flow_based rows share the one constraint GlobalConstraint-ram, indexed by name. Their net positions and the balance of the net positions are FlowBased-net_position and FlowBased-balance.

Primary Energy

The primary energy constraints (type="primary_energy") are used to limit byproducts of primary energy consumption of a carrier (e.g. CO2 emissions) in generators, storage units and stores. They depend on the generator efficiency and carrier-specific attributes (e.g. co2_emissions).

Suppose there is a global constraint defined for CO2 emissions (carrier_attribute) with sense "<=" (sense) and a limit Γ\Gamma (constant). Emissions can come from generators whose energy carriers have CO2 emissions, and from stores and storage units whose storage medium releases or absorbs CO2 when it is converted. A store or storage unit contributes the net energy withdrawn from it (discharging minus charging): its energy level at the start (t=−1t=-1) minus its level at the end (t=∣T∣−1t=|T|-1) of the counted snapshots, plus its net inflow inflow−spill\textrm{inflow} - \textrm{spill}. This follows from the sum of the storage energy balance over the counted snapshots and includes standing losses. For a constraint with an investment_period, the start level is the level that the storage carries into that period. With investment periods, the level change and the net inflow of each period are weighted by the years of the period. The level term is zero for storage that is cyclic within the counted snapshots.

If the specific emissions of carrier ss is ρs\rho_s (n.carriers.co2_emissions) and the generator with carrier ss at node nn and snapshot tt has efficiency ηn,s,t\eta_{n,s,t} then the CO2 constraint is

∑n,s,twtg⋅ηn,s,t−1⋅gn,s,t⋅ρs+∑n,s(en,s,t=−1−en,s,t=∣T∣−1)⋅ρs+∑n,s(socn,s,t=−1−socn,s,t=∣T∣−1)⋅ρs+∑n,s,twts(inflown,s,t−spilln,s,t)⋅ρs≤Γ↔μ\begin{gather*}\sum_{n,s,t} w_t^g \cdot \eta_{n,s,t}^{-1} \cdot g_{n,s,t}\cdot \rho_s + \sum_{n,s}\left(e_{n,s,t=-1} - e_{n,s,t=|T|-1}\right) \cdot \rho_s\\ + \sum_{n,s}\left(soc_{n,s,t=-1} - soc_{n,s,t=|T|-1}\right) \cdot \rho_s\\ + \sum_{n,s,t} w_t^s \left(\textrm{inflow}_{n,s,t} - \textrm{spill}_{n,s,t}\right) \cdot \rho_s \leq \Gamma \quad \leftrightarrow \quad \mu\end{gather*}

The first sum is over generators; the second sum is over stores; the third over storage units; the fourth over stores and storage units. The shadow price μ\mu would represent the CO2 price in this case.

This global constraint is added in the function define_primary_energy_limit().

Mapping symbols to component attributes

SymbolAttributeType
gn,s,tg_{n,s,t}n.generators_t.pDecision Variable
en,s,te_{n,s,t}n.stores_t.eDecision Variable
socn,s,tsoc_{n,s,t}n.storage_units_t.socDecision Variable
spilln,s,t\textrm{spill}_{n,s,t}n.{stores,storage_units}_t.spillDecision Variable
μ\mun.global_constraints.muDual Variable
wtgw_t^gn.snapshot_weightings.generatorsParameter
wtsw_t^sn.snapshot_weightings.storesParameter
inflown,s,t\textrm{inflow}_{n,s,t}n.{stores,storage_units}_t.inflowParameter
ηn,s,t\eta_{n,s,t}n.generators.efficiencyParameter
ρs\rho_sn.carriers.co2_emissionsParameter
Γ\Gamman.global_constraints.constantParameter

Operational Limit

The operational constraints can limit the net production of a carrier taking into account generator, storage units and stores (type="operational_limit"). For example, this can be used to limit the usage of gas in the system to a certain amount Γ\Gamma (constant in MWh). With sense "<=" (sense), the constraint would be given by

∑n,s,twtg⋅gn,s,t+∑n,s(en,s,t=−1−en,s,t=∣T∣−1)+∑n,s(socn,s,t=−1−socn,s,t=∣T∣−1)+∑n,s,twts(inflown,s,t−spilln,s,t)≤Γ↔μ\begin{gather*}\sum_{n,s,t} w_t^g \cdot g_{n,s,t}+ \sum_{n,s}\left(e_{n,s,t=-1} - e_{n,s,t=|T|-1}\right) \\ + \sum_{n,s}\left(soc_{n,s,t=-1} - soc_{n,s,t=|T|-1}\right) \\ + \sum_{n,s,t} w_t^s \left(\textrm{inflow}_{n,s,t} - \textrm{spill}_{n,s,t}\right) \leq \Gamma \quad \leftrightarrow \quad \mu\end{gather*}

The first sum is over generators; the second sum is over stores; the third over storage units; the fourth over stores and storage units. Structurally, it is similar to the primary energy limit, but without the consideration of specific emissions and efficiencies. The shadow price μ\mu (in currency/MWh) would represent the reduction in system costs if the operational limit were relaxed by one unit.

This global constraint is added in the function define_operational_limit().

Mapping symbols to component attributes

SymbolAttributeType
gn,s,tg_{n,s,t}n.generators_t.pDecision Variable
en,s,te_{n,s,t}n.stores_t.eDecision Variable
socn,s,tsoc_{n,s,t}n.storage_units_t.socDecision Variable
spilln,s,t\textrm{spill}_{n,s,t}n.{stores,storage_units}_t.spillDecision Variable
μ\mun.global_constraints.muDual Variable
wtgw_t^gn.snapshot_weightings.generatorsParameter
wtsw_t^sn.snapshot_weightings.storesParameter
inflown,s,t\textrm{inflow}_{n,s,t}n.{stores,storage_units}_t.inflowParameter
Γ\Gamman.global_constraints.constantParameter

Volume Limit on Transmission Expansion

This global constraint can be used to limit the expansion volume in MWkm of transmission lines and links (type="transmission_volume_expansion_limit"). The carrier_attribute specifies the subset of carriers to consider. These can be individual carriers or concatenated by commas, e.g. "AC", "DC", "AC,DC", or a Link carrier such as "H2 pipeline". With sense="<=", the constraint is defined as

∑l∈LcarriersdlFl≤Γ↔μ\sum_{l\in L_{\textrm{carriers}}} d_{l} F_{l} \leq \Gamma \quad \leftrightarrow \quad \mu

where LcarriersL_{\textrm{carriers}} is the set of lines and links with the specified carriers, Γ\Gamma is the maximum allowed volume expansion in MWkm, dld_{l} is the distance of line or link ll in km and FlF_{l} is the capacity of line or link ll in MW. The shadow price μ\mu represents the marginal benefit of expanding the transmission capacity in currency/MWkm/a.

This global constraint is added in the function define_transmission_volume_expansion_limit().

Mapping symbols to component attributes

SymbolAttributeType
FlF_ln.{lines,links}.p_nom_optDecision Variable
μ\mun.global_constraints.muDual Variable
dld_ln.{lines,links}.lengthParameter
Γ\Gamman.global_constraints.constantParameter

Cost Limit on Transmission Expansion

This global constraint can be used to limit the total investment cost in currency/a of transmission lines and links (type="transmission_expansion_cost_limit"). The carrier_attribute specifies the subset of carriers to consider. These can be individual carriers or concatenated by commas, e.g. "AC", "DC", "AC,DC", or a Link carrier such as "H2 pipeline". With sense="<=", the constraint is defined as

∑l∈LcarriersclFl≤Γ↔μ\sum_{l\in L_{\textrm{carriers}}} c_{l} F_{l} \leq \Gamma \quad \leftrightarrow \quad \mu

where LcarriersL_{\textrm{carriers}} is the set of lines and links with the specified carriers, clc_{l} is the capital cost of line or link ll in currency/MW/a, FlF_{l} is the capacity of line or link ll in MW and Γ\Gamma is the maximum allowed cost of line expansion in currency/a. The shadow price mumu represents how much the total system cost could be reduced if the spending limit was increased by one currency/a.

This global constraint is added in the function define_transmission_expansion_cost_limit().

Mapping symbols to component attributes

SymbolAttributeType
FlF_ln.{lines,links}.p_nom_optDecision Variable
μ\mun.global_constraints.muDual Variable
clc_ln.{lines,links}.capital_costParameter
Γ\Gamman.global_constraints.constantParameter

Expansion Limit

This global constraint can be used to limit the total capacity of components of a carrier (type=tech_capacity_expansion_limit). This global constraint can be specific to an investment period by setting the investment_period attribute and specific to a bus by setting the bus attribute. This constraint is mainly used for networks with multiple investment periods, where land usage and building rate restrictions need to be applied for a range of active components of a particular carrier (carrier_attribute) in a certain region.

Warning

Currently, only the capacities of extendable components are considered, i.e. generators, storage units and stores with extendable=True. The capacities of non-extendable components are not considered in this constraint.

For example, the capacities of all onshore wind generators (carrier_attribute="onshore wind") at a certain bus (bus="DE") should be smaller (sense="<=") than a hypothetical technical potential of 200 GW for onshore wind in the specific region (constant=200e3). Then the technology capacity expansion constraint across all active components is given by

∑s∣bs<=a<bs+LsGn,s≤Γa∈A↔μ\sum_{s | b_s<=a<b_s+L_s} G_{n,s} \leq \Gamma \quad a \in A \quad \leftrightarrow \quad \mu

where AA are the investment periods, ss are all extendable generators of the specified carrier, bsb_s is the build year of an asset ss with lifetime LsL_s. In this example, the shadow price μ\mu would represent the marginal benefit of expanding the capacity of onshore wind in currency/MW/a.

In general, the constraint would iterate over all investment variables for generators Gn,sG_{n,s}, lines and transformers PlP_{l}, links FlF_{l}, stores En,sE_{n,s} and storage units Hn,sH_{n,s} for the specified carrier and bus. For components connecting two buses, the bus selection is done by bus0.

This global constraint is added in the function define_tech_capacity_expansion_limit().

Mapping symbols to component attributes

SymbolAttributeType
Gn,sG_{n,s}n.generators.p_nom_optDecision Variable
Hn,sH_{n,s}n.storage_units.p_nom_optDecision Variable
En,sE_{n,s}n.stores.e_nom_optDecision Variable
FlF_ln.links.p_nom_optDecision Variable
PlP_ln.{lines,transformers}.s_nom_optDecision Variable
μ\mun.global_constraints.muDual Variable
bsb_sn.{<component>}.build_yearParameter
LsL_sn.{<component>}.lifetimeParameter
aa, AAn.investment_periodsParameter
Γ\Gamman.global_constraints.constantParameter

Growth Limit per Carrier

This carrier-specific constraint type implements absolute and relative growth limits per carrier which constrains new installed capacities for each investment period. It can be defined by providing the attributes n.carriers.max_growth and n.carriers.max_relative_growth.

Suppose the absolute growth limit for a specific carrier ss is Γs\Gamma_s (max_growth) and the relative growth limit is γs\gamma_s (max_relative_growth). With the growth limit constraint, for each investment period aa, the new installed capacity Ga,sG_{a,s} of all components with carrier ss is limited by:

Ga,s≤γs⋅Ga−1,s+Γs∀a,s↔μa,sG_{a,s} \leq \gamma_s \cdot G_{a-1,s} + \Gamma_s \quad \forall a, s \quad \leftrightarrow \quad \mu_{a,s}

where Ga,sG_{a,s} represents the sum of all newly built nominal capacities of extendable components with carrier ss in period aa. The relative growth limit γs\gamma_s allows the new capacity in period aa to be proportional to the capacity added in the previous period a−1a-1.

This constraint only applies to networks with multiple investment periods and only considers components that are newly activated in each period. For the constraint to take effect, at least one of the attributes max_growth or max_relative_growth must be set to a finite value for the carrier.

Warning

The relative and abolute growth limits are additive, i.e. the absolute growth limit applies in addition to the relative growth limit.

In general, the constraint would iterate over all investment variables for generators Gn,sG_{n,s}, lines and transformers PlP_{l}, links FlF_{l}, stores En,sE_{n,s} and storage units Hn,sH_{n,s} for the specified carrier. For components connecting two buses, the bus selection is done by bus0.

This global constraint is added in the function define_growth_limit() and carries the name Carrier-growth_limit.

Mapping symbols to component attributes

SymbolAttributeType
Gn,sG_{n,s}n.generators.p_nom_optDecision Variable
Hn,sH_{n,s}n.storage_units.p_nom_optDecision Variable
En,sE_{n,s}n.stores.e_nom_optDecision Variable
FlF_ln.links.p_nom_optDecision Variable
PlP_ln.{lines,transformers}.s_nom_optDecision Variable
γs\gamma_sn.carriers.max_relative_growthParameter
Γs\Gamma_sn.carriers.max_growthParameter

Flow-Based Market Coupling

Flow-based market coupling (FBMC) replaces the transmission grid constraints between market zones by a compact set of linear constraints on the zones' net positions. Instead of resolving every node and line, the market treats each zone as a copper plate and trades against a few linear limits that capture how zonal exchanges load the critical grid elements. This is the capacity-allocation method used in parts of the European day-ahead market, notably the Core region.4 For an introduction to the method and its parameters, see Van den Bergh et al. (2016)[^vandenbergh] and Schönheit et al. (2021)[^schonheit]. The domain of feasible net positions is stored as global constraints of type="flow_based", see the component page.

The net-position variable is FlowBased-net_position, the domain half-spaces are GlobalConstraint-ram, and the zero-sum balance is FlowBased-balance; see also the example notebook.

Net position

The net position NPz,tNP_{z,t} of a market zone zz at snapshot tt is the power it feeds into the flow-based region. It is added as a decision variable and injected directly into the nodal balance of its zone bus,

gz,t−dz,t−NPz,t=0,g_{z,t} - d_{z,t} - NP_{z,t} = 0 ,

so it equals the bus's net injection and is read from n.buses_t.p after solving. The output n.buses_t.net_position holds the generation minus load of each zone bus (0 for other buses), which is the net position itself unless corridor links are present (see below).

Domain constraints

Each critical network element (CNEC) cc is one global constraint row, a monitored grid constraint such as a line under a given outage. It contributes one half-space that bounds a weighted sum of net positions by its remaining available margin RAMc,t\text{RAM}_{c,t}, the headroom left on that element for cross-zonal trade:

∑zPTDFc,z,t NPz,t  ≤  RAMc,t↔μc,t\sum_{z} \text{PTDF}_{c,z,t}\, NP_{z,t} \;\le\; \text{RAM}_{c,t} \quad \leftrightarrow \quad \mu_{c,t}

The sensitivities PTDFc,z,t\text{PTDF}_{c,z,t} are the zonal power transfer distribution factors (attributes ptdf_<zone>, see the component page); both they and the RAM (ram) may be static or vary by snapshot, and the constraint broadcasts over tt either way. A row with an investment_period only applies in that period's snapshots, and a row with a NaN ram is dropped in that snapshot. The shadow price μc,t\mu_{c,t} is written to n.global_constraints_t.mu_ram. A zero-sum balance closes the copper plate across the zones of each domain DD,

∑z∈DNPz,t=0.\sum_{z \in D} NP_{z,t} = 0.

By default all zones form one domain. Rows that name their domain, e.g. Core and Nordic, give one balance per named domain. A link between two domains then acts as an AHC corridor in each. The rows of one domain see neither the zones nor the hubs of the other (PTDF\text{PTDF} and hh are 0 there), so the EvFB and AHC formulas below give the same column.

The net-position variable is added in define_flow_based_variables() and these constraints in define_flow_based_constraints(); the net-position injection is added in define_nodal_balance_constraints() via flow_based_balance_terms().

A domain column may name a Link instead of a zone Bus. This extends the domain to controllable corridors, such as HVDC links;[^estermann] PyPSA tells the two cases apart by the link's ends:

  • Advanced hybrid coupling (AHC): one end is a zone, the other a bus outside the flow-based region.
  • Evolved flow-based (EvFB): both ends are flow-based zones.

The link stays in the nodal balances of its buses like any other link, so a zone's net position now includes the corridor inflow,

NPz,t=gz,t−dz,t+∑ℓaz,ℓ fℓ,t,NP_{z,t} = g_{z,t} - d_{z,t} + \sum_{\ell} a_{z,\ell}\, f_{\ell,t},

with fℓ,tf_{\ell,t} the link flow (Link-p, in the bus0 -> bus1 direction) and az,ℓa_{z,\ell} the link's incidence at zz (−1-1 at bus0, +ηℓ+\eta_\ell at bus1, else 00). Each link adds a term to every CNEC:

∑zPTDFc,z,t NPz,t+∑ℓPTDFc,ℓ,t fℓ,t  ≤  RAMc,t↔μc,t\sum_{z} \text{PTDF}_{c,z,t}\, NP_{z,t} + \sum_{\ell} \text{PTDF}_{c,\ell,t}\, f_{\ell,t} \;\le\; \text{RAM}_{c,t} \quad \leftrightarrow \quad \mu_{c,t}

The link column PTDFc,ℓ\text{PTDF}_{c,\ell} is the sensitivity of CNEC cc to the link flow with all zone net positions held fixed: the loading the corridor causes beyond what its zones' PTDFs already explain. Let hc,ℓ,zh_{c,\ell,z} be the sensitivity of CNEC cc to an injection at the node where link ℓ\ell lands in zone zz (its hub sensitivity). Then

PTDFc,ℓ=hc,ℓ−∑zaz,ℓ PTDFc,z,\text{PTDF}_{c,\ell} = h_{c,\ell} - \sum_{z} a_{z,\ell}\, \text{PTDF}_{c,z},

which is h−PTDFzh - \text{PTDF}_z for an AHC link into zone zz, and (hB−hA)−(PTDFB−PTDFA)(h_B - h_A) - (\text{PTDF}_B - \text{PTDF}_A) for an EvFB link from AA to BB. If the corridor lands where the zone's GSK puts its power anyway, the column is zero. The zero-sum balance is unchanged, ∑zNPz,t=0\sum_z NP_{z,t} = 0, because the corridor imports are already inside the net positions.

Two equivalent net-position conventions

Published domains use one of two conventions for corridors. Both describe the same feasible set and give the same CNEC flows; they only split each flow differently between the zone terms and the link terms.

  • PyPSA: the net position includes the corridor flow. The zone PTDF already spreads that flow as if the GSK placed it, so the link column keeps only the correction from the GSK to the landing node. ERAA publishes its AHC columns in this form (PTDF*_AHC = PTDF_AHC - PTDF_SZ).
  • Virtual hub: the net position is generation minus load, NPz=gz−dzNP_z = g_z - d_z. Each corridor end acts as a hub with its raw hub sensitivity hh, and the hub flows join the zero-sum balance. The Core methodology,4 JAO and TSO files use this form, and so do ERAA's EvFB columns.

The conversion is one rule: what PyPSA adds to the net positions, it takes out of the link column,

NPz=(gz−dz)+∑ℓaz,ℓ fℓ⟺PTDFc,ℓ=hc,ℓ−∑zaz,ℓ PTDFc,z.NP_z = (g_z - d_z) + \sum_\ell a_{z,\ell}\, f_\ell \qquad \Longleftrightarrow \qquad \text{PTDF}_{c,\ell} = h_{c,\ell} - \sum_z a_{z,\ell}\, \text{PTDF}_{c,z} .

PyPSAVirtual hub
zone net positiongz−dz+∑ℓaz,ℓfℓg_z - d_z + \sum_\ell a_{z,\ell} f_\ell (n.buses_t.p)gz−dzg_z - d_z (n.buses_t.net_position)
AHC column, X→AX \to AhA−PTDFAh_A - \text{PTDF}_AhAh_A
EvFB column, A→BA \to B(hB−hA)−(PTDFB−PTDFA)(h_B - h_A) - (\text{PTDF}_B - \text{PTDF}_A)hB−hAh_B - h_A
zero-sum balance∑zNPz=0\sum_z NP_z = 0∑zNPz+∑hubsf=0\sum_z NP_z + \sum_{\text{hubs}} f = 0

PyPSA uses the first form because the link then needs no special treatment in the nodal balance. After solving, n.buses_t.net_position reports the virtual-hub net position gz−dzg_z - d_z of each zone bus, i.e. n.buses_t.p without the flows of its corridor links.

These terms are built in define_flow_based_constraints().

Mapping symbols to component attributes

SymbolAttributeType
NPz,tNP_{z,t}n.buses_t.p (variable FlowBased-net_position)Decision Variable
gz,t−dz,tg_{z,t} - d_{z,t}n.buses_t.net_positionOutput
fℓ,tf_{\ell,t}n.links_t.p0Decision Variable
μc,t\mu_{c,t}n.global_constraints_t.mu_ramDual Variable
PTDFc,z,t\text{PTDF}_{c,z,t}n.c.global_constraints.zonal_ptdfParameter
RAMc,t\text{RAM}_{c,t}n.global_constraints.ram, n.global_constraints_t.ramParameter
hc,ℓh_{c,\ell}hub sensitivity of a published corridor columnData
ηℓ\eta_\elln.links.efficiencyParameter

[^vandenbergh]: K. Van den Bergh, J. Boury and E. Delarue (2016), The Flow-Based Market Coupling in Central Western Europe: Concepts and definitions, The Electricity Journal, 29(1), 24-29, doi:10.1016/j.tej.2015.12.004. [^schonheit]: D. Schönheit, M. Kenis, L. Lorenz, D. Möst, E. Delarue and K. Bruninx (2021), Toward a fundamental understanding of flow-based market coupling for cross-border electricity trading, Advances in Applied Energy, 2, 100027, doi:10.1016/j.adapen.2021.100027. [^estermann]: A. Estermann, M. Schrade and L. Anderson (eds.) (2025), European Electricity Market Coupling: A Practitioner's Guide, Springer, doi:10.1007/978-3-031-86315-8. 4.

ACER (2019), Day-ahead capacity calculation methodology of the Core capacity calculation region, in accordance with Commission Regulation (EU) 2015/1222 (CACM).

diagram 2026-11-13

diagram 2025-10-09