Post · 5 min read· pp. 467–471

Global Constraints

The GlobalConstraint components describe constraints in the optimisation problem that apply to multiple components at once. Constraints of type="flow_based" form a flow-based domain.

attributetypeunitdefaultdescriptionstatus
namestringnannanUnique nameInput (required)
typestringnanprimary_energyType of constraint (e.g. "primary energy", "tech_capacity_expansion_limit", "operational_limit", "transmission_volume_expansion_limit", "transmission_expansion_cost_limit", "flow_based"). A flow_based row stores its zonal PTDF as one attribute ptdf_<zone> per zone (static or series), where the zone is a bus or a corridor link.Input (optional)
investment_periodfloatnannanInvestment period for which the constraint is applied. If not specified, the constraint is applied to all investment periods together. For type="flow_based", the period in whose snapshots the CNEC applies (default: all).Input (optional)
busstringnannanBus to which the global constraint applies. Only relevant for `type="tech_expansion_limit". If not specified, the constraint applies to all buses.Input (optional)
carrier_attributestringnanco2_emissionsIf the global constraint is connected with a carrier, name the associated carrier attribute. This must appear as a column in n.carriers.Input (optional)
sensestringnan==Constraint sense; must be one of <=, == or >=. Must be <= for type="flow_based".Input (optional)
constantfloatnan0Constant for right-hand-side of constraint for optimisation period. For a CO2 constraint, this would be tonnes of CO2. Ignored for type="flow_based".Input (optional)
scalingfloatnan1Row scaling factor of the global constraint in the optimisation. Coefficients and right-hand side are multiplied by it in the solver. The shadow price mu is reported in original units.Input (optional)
ramstatic or seriesMWnanRemaining available margin of a flow_based CNEC, the right-hand side of its domain constraint. NaN drops the CNEC in that snapshot. Only read for type="flow_based".Input (optional)
domainstringnannanName of the flow-based domain of a flow_based CNEC, e.g. "Core". Each named domain gets its own zero-sum balance of net positions. Empty: all zones share one balance.Input (optional)
mufloatcurrency/constant0Shadow price of global constraintOutput
mu_ramstatic or seriescurrency/MW0Shadow price of the flow-based domain constraint per snapshot. Only set for type="flow_based".Output

Flow-Based Domain

A flow-based market-coupling domain is a set of global constraints of type="flow_based", one row per critical network element (CNEC), each with sense="<=" and the remaining available margin (RAM) in ram (constant is ignored for these rows). The concept and the constraints are explained on the optimisation page; this section covers how to enter the data. See also the example notebook.

Zonal PTDF

The zonal PTDF is a CNEC x zone matrix. Each zone column is stored as an ordinary attribute ptdf_<zone> of the rows, so a domain is added like any other global constraint, and n.c.global_constraints.zonal_ptdf assembles the matrix back:

text
>>> n = pypsa.Network()
>>> n.add("Bus", ["DE", "FR", "BE"])
>>> zonal_ptdf = pd.DataFrame(  # one CNEC per row, one zone per column
...     {"DE": [0.4, -0.3], "FR": [-0.2, 0.5], "BE": [0.1, 0.2]},
...     index=["cnec_1", "cnec_2"],
... )
>>> ram = pd.Series([1000.0, 800.0], index=zonal_ptdf.index)
>>> n.add(
...     "GlobalConstraint",
...     zonal_ptdf.index,
...     type="flow_based",
...     sense="<=",
...     ram=ram,
...     **zonal_ptdf.add_prefix("ptdf_"),
... )
>>> n.c.global_constraints.zonal_ptdf
bus      DE   FR   BE
name
cnec_1  0.4 -0.2  0.1
cnec_2 -0.3  0.5  0.2

add_flow_based does the same in one call, n.c.global_constraints.add_flow_based(zonal_ptdf, ram), and also takes the time-varying layout: zonal_ptdf with a (snapshot, CNEC) MultiIndex (zones as columns) and ram as a snapshot x CNEC frame. Static and time-varying zone columns may be mixed; in the raw form a time-varying column is a snapshot x CNEC frame, e.g. ptdf_DE=.... ram may likewise be static or time-varying (n.global_constraints_t.ram). With multiple investment periods, investment_period ties a row to one period; rows without it apply in all periods.

A NaN in a time-varying ram drops that CNEC in that snapshot. This suits presolved domains, whose set of CNECs changes from hour to hour.

A column may name a Link instead of a zone bus: an HVDC corridor into the region (AHC) or between two zones (EvFB). The column is the CNEC's sensitivity to the link flow (bus0 -> bus1) with the zone net positions held fixed; see the optimisation page for its definition and how it relates to published hub sensitivities.

text
>>> n.add("Bus", ["NO2", "NL"])
>>> n.add("Link", "BE-DE", bus0="BE", bus1="DE", p_nom=1000, p_min_pu=-1)  # EvFB
>>> n.add("Link", "NO2-NL", bus0="NO2", bus1="NL", p_nom=700, p_min_pu=-1)  # AHC
>>> zonal_ptdf["BE-DE"] = [0.3, -0.1]
>>> zonal_ptdf["NO2-NL"] = [0.05, 0.1]
>>> n.c.global_constraints.add_flow_based(zonal_ptdf, ram, overwrite=True)
>>> n.c.global_constraints.zonal_ptdf.columns.tolist()
['DE', 'FR', 'BE', 'BE-DE', 'NO2-NL']

Cross-zone branches

The domain replaces the grid between zones. The network must not contain a Line, Transformer or Link between two zone buses, except a Link that is a domain column.

Several domains side by side

Europe couples more than one flow-based domain, e.g. Core and Nordic. Name the domain of each row with domain, e.g. add_flow_based(zonal_ptdf, ram, domain="Nordic"). Each named domain gets its own zero-sum balance of net positions. Its zones are the zone columns its rows set (not NaN), so a zone must be set in the rows of exactly one domain. A Link between zones of two domains is a column of both. Name the domain of every flow_based row or of none; without names, all zones share one balance.

diagram 2026-11-04

diagram 2025-10-09