Skip to content

eag.py

National net-zero electricity constraints implementing EAG §4(2).

constraint_net_zero_electricity(n, snakemake, investment_year)

Add national net-zero electricity production constraints.

Parameters:

Name Type Description Default
n pypsa.Network

The pypsa network to add the constraints to.

required
snakemake

The snakemake workflow object.

required
investment_year int

The current workflow planning horizon.

required
Notes

Implements EAG $ 4 (2) RIS

Source code in mods/constraints/eag.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def constraint_net_zero_electricity(n: pypsa.Network, snakemake, investment_year: int):
    """
    Add national net-zero electricity production constraints.

    Parameters
    ----------
    n
        The pypsa network to add the constraints to.
    snakemake
        The snakemake workflow object.
    investment_year
        The current workflow planning horizon.

    Notes
    -----
    Implements EAG $ 4 (2) [RIS](https://www.ris.bka.gv.at/GeltendeFassung.wxe?Abfrage=Bundesnormen&Gesetzesnummer=20011619&FassungVom=2022-06-22)
    """
    net_zero_constraint = snakemake.config["mods"]["net_zero_electricity"]
    if not net_zero_constraint.get("enable"):
        logger.info(
            "Skipping net-zero electricity constraints because the feature is disabled."
        )
        return

    # the year in the config is an inclusive start year boundary.
    country_years = {
        k: v
        for k, v in net_zero_constraint.items()
        if k not in ("enable", "fuels", "h2_sources")
    }

    # Sub-national regions (e.g. AT11, DEA) and empty-string match-all keys are
    # out of scope per EAG §4(2) spec — constraints operate at country-prefix level.
    for country, start_year in country_years.items():
        if investment_year < int(start_year):
            logger.info(
                f"Skipping net-zero electricity constraint for country "
                f"{country} and investment year {investment_year} "
                f"because the start year {start_year} is not reached."
            )
            continue

        logger.info(
            f"Adding net-zero electricity constraints for "
            f"region {country} and year {investment_year}."
        )
        _add_net_zero_electricity_production_constraint(n, country)
        _add_green_gas_production_constraint(n, country)
        _add_hydrogen_production_constraint(n, country)
        _add_methanol_production_constraint(n, country)