Open and run in Colab (interactive) Edit on Gitlab

CO2 Emissions

Try this yourself (requires google account)

Wind farm layout optimization usually maximizes energy production (AEP) or minimizes LCOE/NPV. This notebook adds CO2 emissions as an explicit part of the picture, split into three domains that respond differently to the offshore wind farm’s design:

  1. Simplified LCA (life cycle assessment) engineering model - the CO2 emitted manufacturing the turbines and the inter-array cables. This is a fast mass x material-carbon-intensity-factor approximation for one impact category (CO2e) and the manufacturing phase only (no use-phase, end-of-life, transport or installation emissions) - not a full ISO 14040/14044 LCA study.

  2. O&M (operations & maintenance) - the CO2 emitted by vessels burning fuel while servicing the turbines over the plant’s lifetime.

  3. CO2 displacement - the fossil-fuel-based generation avoided elsewhere in the grid because this wind farm is producing electricity instead.

The underlying models:

  • The LCA engineering model’s mass/material approach defaults to the INNWIND-based method.

  • The O&M vessel-emissions formula follows the standard International Maritime Organization (IMO) fuel-based method

  • The CO2 displacement metric follows the avoided-emissions principle

Install TOPFARM if needed

[1]:
# Install TopFarm if needed
import importlib
if not importlib.util.find_spec("topfarm"):
    %pip install git+https://gitlab.windenergy.dtu.dk/TOPFARM/TopFarm2.git

Imports

[2]:
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt

from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussian
from py_wake.examples.data.iea37._iea37 import IEA37_WindTurbines, IEA37Site

from topfarm import TopFarmGroup, TopFarmProblem
from topfarm.constraint_components.boundary import CircleBoundaryConstraint
from topfarm.constraint_components.spacing import SpacingConstraint
from topfarm.cost_models.cost_model_wrappers import CostModelComponent
from topfarm.cost_models.py_wake_wrapper import PyWakeAEPCostModelComponent
from topfarm.cost_models.electrical.optiwindnet_wrapper import WFNComponent
from topfarm.easy_drivers import EasyScipyOptimizeDriver
from topfarm.plotting import NoPlot

from topfarm.cost_models.co2_emissions.lca import LCACostModelComponent, turbine_manufacturing_co2_dtu
from topfarm.cost_models.co2_emissions.om import OMCO2CostModelComponent
from topfarm.cost_models.co2_emissions.displacement import CO2DisplacementComponent, co2_displaced
from topfarm.cost_models.co2_emissions.metrics import carbon_intensity, carbon_payback_years
/builds/TOPFARM/TopFarm2/.pixi/envs/default/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Site, turbines and fixed infrastructure

A small IEA Wind Task 37 case study (16 turbines) and a port location is fixed 15 km away, used by the O&M CO2 model.

[3]:
n_wt = 16
site = IEA37Site(n_wt)
windTurbines = IEA37_WindTurbines()
wfm = IEA37SimpleBastankhahGaussian(site, windTurbines)

rated_power_kw = windTurbines.power(20) / 1000.0  # W -> kW
rotor_diameter_m = windTurbines.diameter()
hub_height_m = windTurbines.hub_height()
RADIUS = 1300.1

x_init, y_init = site.initial_position.T
xs_init, ys_init = 0.0, 0.0  # fixed substation position
port_xy = (-15000.0, 0.0)  # fixed port location, 15 km from the site
LIFETIME = 25  # years
GRID_EF = 300.0  # g CO2 / kWh, an illustrative grid emission factor

cables = np.array([(4, 2000)])  # [turbines per cable string, price per meter]
/builds/TOPFARM/TopFarm2/.pixi/envs/default/lib/python3.13/site-packages/py_wake/deficit_models/gaussian.py:279: UserWarning: The IEA37SimpleBastankhahGaussian model is not representative of the setup used in the literature. For this, use py_wake.literature.iea37_case_study1.IEA37CaseStudy1 instead
  DeprecatedModel.__init__(self, 'py_wake.literature.iea37_case_study1.IEA37CaseStudy1')

CO2 cost-model components

WFNComponent (using OptiWindNet’s fast EWRouter heuristic by default, which routes a feasible cable layout in milliseconds) supplies the cable network length that LCACostModelComponent needs for the cable manufacturing CO2 estimate. OMCO2CostModelComponent and CO2DisplacementComponent complete the three CO2 domains.

[4]:
aep_comp = PyWakeAEPCostModelComponent(wfm, n_wt, objective=False, output_key="aep")

cable_comp = WFNComponent(
    turbines_pos=np.column_stack([x_init, y_init]),
    substations_pos=np.array([[xs_init, ys_init]]),
    cables=cables,
)

lca_comp = LCACostModelComponent(n_wt, rated_power_kw, rotor_diameter_m)
om_comp = OMCO2CostModelComponent(n_wt, port_xy=port_xy, lifetime_years=LIFETIME)
displacement_comp = CO2DisplacementComponent(n_wt, displacement_factor=GRID_EF, lifetime_years=LIFETIME)

breakdown_group = TopFarmGroup([aep_comp, cable_comp, lca_comp, om_comp, displacement_comp])

breakdown_problem = TopFarmProblem(
    design_vars=dict(zip("xy", site.initial_position.T)),
    n_wt=n_wt,
    cost_comp=breakdown_group,
    driver=EasyScipyOptimizeDriver(maxiter=1, disp=False),
    constraints=[SpacingConstraint(260), CircleBoundaryConstraint([0, 0], RADIUS)],
    plot_comp=NoPlot(),
)

Baseline breakdown - three separate quantities

[5]:
breakdown_problem.evaluate()

aep_gwh = breakdown_problem["aep"][0]
lca_co2 = breakdown_problem["lca_co2"][0]
om_co2_lifetime = breakdown_problem["om_co2_lifetime"][0]
om_co2_annual = breakdown_problem["om_co2_annual"][0]
co2_displaced_lifetime = breakdown_problem["co2_displaced"][0]

print(f"AEP:                {aep_gwh:10.1f} GWh/year")
print(f"LCA (manufacturing):{lca_co2:10.1f} t CO2e")
print(f"O&M ({LIFETIME} years):     {om_co2_lifetime:10.1f} t CO2e")
print(f"Displaced ({LIFETIME} years):{co2_displaced_lifetime:10.1f} t CO2e")

fig, ax = plt.subplots()
ax.bar(["LCA\n(manufacturing)", f"O&M\n({LIFETIME} yr)", f"Displaced\n({LIFETIME} yr)"],
      [lca_co2, om_co2_lifetime, co2_displaced_lifetime])
ax.set_ylabel("t CO2e")
ax.set_title("CO2 breakdown - kept as three separate quantities")
plt.show()
AEP:                     373.2 GWh/year
LCA (manufacturing):   19026.2 t CO2e
O&M (25 years):        26242.1 t CO2e
Displaced (25 years): 2799049.8 t CO2e
../_images/notebooks_co2_emissions_14_1.png

Two metrics are useful for reporting alongside the breakdown above: the lifecycle carbon intensity of the electricity produced, and the carbon payback time - how long it takes for displaced emissions to offset the one-off manufacturing footprint.

[6]:
ci = carbon_intensity(lca_co2, om_co2_lifetime, co2_displaced_lifetime, aep_gwh, LIFETIME)
payback = carbon_payback_years(lca_co2, om_co2_annual, aep_gwh, GRID_EF)
print(f"carbon intensity:    {ci:10.1f} g CO2/kWh (negative = net avoided emissions)")
print(f"carbon payback time: {payback:10.2f} years (out of a {LIFETIME}-year lifetime)")
carbon intensity:        -295.1 g CO2/kWh (negative = net avoided emissions)
carbon payback time:       0.17 years (out of a 25-year lifetime)

Trade-off demo: AEP-only vs. a combined CO2 objective

A gradient-based driver needs a single scalar objective. The three CO2 quantities are combined into one for this purpose: lca_co2 + om_co2_lifetime - co2_displaced. This weighting is illustrative, not a universal metric.

[7]:
def co2_objective_func(lca_co2, om_co2_lifetime, co2_displaced, **kwargs):
    return lca_co2 + om_co2_lifetime - co2_displaced


co2_objective_comp = CostModelComponent(
    input_keys=[("lca_co2", 0.0), ("om_co2_lifetime", 0.0), ("co2_displaced", 0.0)],
    n_wt=n_wt,
    cost_function=co2_objective_func,
    output_keys=[("co2_objective", 0.0)],
    objective=True,
    maximize=False,
)

MAXITER = 15

aep_only_problem = TopFarmProblem(
    design_vars=dict(zip("xy", site.initial_position.T)),
    n_wt=n_wt,
    cost_comp=PyWakeAEPCostModelComponent(wfm, n_wt, objective=True, output_key="aep"),
    driver=EasyScipyOptimizeDriver(maxiter=MAXITER, disp=False),
    constraints=[SpacingConstraint(260), CircleBoundaryConstraint([0, 0], RADIUS)],
    plot_comp=NoPlot(),
)
_, aep_state, _ = aep_only_problem.optimize()

co2_problem = TopFarmProblem(
    design_vars=dict(zip("xy", site.initial_position.T)),
    n_wt=n_wt,
    cost_comp=TopFarmGroup([aep_comp, cable_comp, lca_comp, om_comp, displacement_comp, co2_objective_comp]),
    driver=EasyScipyOptimizeDriver(maxiter=MAXITER, disp=False),
    constraints=[SpacingConstraint(260), CircleBoundaryConstraint([0, 0], RADIUS)],
    plot_comp=NoPlot(),
)
_, co2_state, _ = co2_problem.optimize()
Optimization FAILED.
Iteration limit reached
-----------------------------------
Optimization FAILED.
Iteration limit reached
-----------------------------------
[8]:
def summarize(label, x, y):
    breakdown_problem.evaluate(state={"x": x, "y": y})
    return dict(
        label=label,
        aep=breakdown_problem["aep"][0],
        lca_co2=breakdown_problem["lca_co2"][0],
        om_co2_lifetime=breakdown_problem["om_co2_lifetime"][0],
        co2_displaced=breakdown_problem["co2_displaced"][0],
    )


rows = [
    summarize("AEP-optimal", aep_state["x"], aep_state["y"]),
    summarize("CO2-optimal", co2_state["x"], co2_state["y"]),
]
print(f"{'layout':14s}{'AEP[GWh]':>12s}{'LCA[t]':>12s}{'OM[t]':>12s}{'Displaced[t]':>14s}")
for r in rows:
    print(f"{r['label']:14s}{r['aep']:12.1f}{r['lca_co2']:12.1f}{r['om_co2_lifetime']:12.1f}{r['co2_displaced']:14.1f}")
layout            AEP[GWh]      LCA[t]       OM[t]  Displaced[t]
AEP-optimal          373.2     19026.2     26242.1     2799049.8
CO2-optimal          373.2     19026.2     26242.1     2799049.8

The two layouts end up with essentially the same AEP and CO2 breakdown (their exact turbine coordinates differ - this circular, symmetric site has many equally good local optima). CO2 displaced over a multi-decade lifetime scales with AEP and dwarfs the layout-sensitive part of the LCA (cable length) and O&M (distance to port) terms for a farm this size, so maximizing AEP and minimizing this combined CO2 objective pull in almost the same direction - consistent with the well-known wind energy LCA result that turbines pay back their embodied carbon within months (see the payback time above).

Exercises

  • Detailed manufacturing CO2: swap the default INNWIND-based turbine CO2 function for the DTU offshore cost model’s own bill-of-materials estimate and compare.

[9]:
lca_comp_dtu = LCACostModelComponent(
    n_wt, rated_power_kw, rotor_diameter_m,
    turbine_co2_function=turbine_manufacturing_co2_dtu,
    turbine_co2_kwargs=dict(hub_height_m=hub_height_m),
)
dtu_problem = TopFarmProblem(
    design_vars=dict(zip("xy", site.initial_position.T)),
    n_wt=n_wt,
    cost_comp=TopFarmGroup([aep_comp, cable_comp, lca_comp_dtu]),
    driver=EasyScipyOptimizeDriver(maxiter=1, disp=False),
    constraints=[SpacingConstraint(260), CircleBoundaryConstraint([0, 0], RADIUS)],
    plot_comp=NoPlot(),
)
dtu_problem.evaluate()
print("turbine manufacturing CO2, INNWIND (default):     ", breakdown_problem["turbine_co2"][0])
print("turbine manufacturing CO2, DTU cost model (detailed):", dtu_problem["turbine_co2"][0])
turbine manufacturing CO2, INNWIND (default):      18577.21695754672
turbine manufacturing CO2, DTU cost model (detailed): 22040.207753251507
  • Grid emission factor: a cleaner grid reduces the CO2 displaced per unit of energy produced. Try a range of factors, from a hydro/nuclear-heavy grid to a coal-heavy one.

[10]:
for grid_ef in [50.0, 300.0, 700.0]:
    co2_disp = co2_displaced(aep_gwh, grid_ef, LIFETIME)
    ci = carbon_intensity(lca_co2, om_co2_lifetime, co2_disp, aep_gwh, LIFETIME)
    print(f"grid_emission_factor={grid_ef:6.1f} gCO2/kWh -> carbon_intensity={ci:8.1f} gCO2/kWh")
grid_emission_factor=  50.0 gCO2/kWh -> carbon_intensity=   -45.1 gCO2/kWh
grid_emission_factor= 300.0 gCO2/kWh -> carbon_intensity=  -295.1 gCO2/kWh
grid_emission_factor= 700.0 gCO2/kWh -> carbon_intensity=  -695.1 gCO2/kWh
  • Port distance: try moving port_xy farther away and re-evaluating breakdown_problem to see the O&M CO2 term grow.

  • Maintenance assumptions: topfarm.cost_models.co2_emissions.om.MAINTENANCE_CATEGORIES and DEFAULT_VESSEL_PARAMS can be overridden with site- or fleet-specific values.

Time-series based CO2 displacement

The displacement figure used above is a single constant grid emission factor applied to annual AEP. Different, more detailed hourly time-series methods exists for the same quantity:

  1. Reverse merit order: given an hourly generation-mix time series for a bidding zone (how much of each fossil fuel type is actually running each hour) and an assumed merit order, work out how much of each fuel is displaced by the farm’s own hourly output. This saturates: once the farm’s output exceeds all the fossil generation still running that hour, no more can be displaced that hour - a real effect a single constant factor cannot capture.

  2. Linear marginal displacement factor (MDF) (following Kainz et al. (2025), An initial study on the environmental value of wind farm control): multiply the farm’s hourly output by a precomputed, farm- independent hourly displacement factor. Simpler (needs only one time series, not a full generation mix), and standard practice in consequential LCA when the farm is a small perturbation on the grid.

Both need an hourly power time series rather than the wind-rose AEP used so far - PyWake computes this just as efficiently by passing chronological wind speed/direction arrays with time=True instead of the usual binned wind rose.

Example datasets:

  • DK2 (East Denmark), 2019: hourly wind speed/direction and hourly generation from three fossil-fuel categories (gas, hard coal, oil) - used for the reverse-merit-order method.

  • Hollandse Kust Noord (HKN), Netherlands, 2023: hourly wind speed/direction, the same year as the Dutch wind MDF series - used for the linear MDF method.

[11]:
from topfarm.examples.data.co2_displacement import (
    load_dk2_wind_and_genmix, load_hkn_wind, load_dutch_wind_mdf,
)
from topfarm.cost_models.co2_emissions.displacement import (
    co2_displaced_reverse_merit_order, CO2DisplacementMeritOrderComponent,
)

Reverse merit order (DK2, Denmark)

[12]:
ws_dk2, wd_dk2, genmix = load_dk2_wind_and_genmix()
sim_res_dk2 = wfm(x_init, y_init, wd=wd_dk2, ws=ws_dk2, time=True)
power_t_dk2_mwh = sim_res_dk2.Power.sum("wt").values / 1e6  # W -> MWh (1-hour timesteps)

# illustrative fossil emission factors [kg CO2eq / MWh] and an assumed reverse merit order
# (most expensive / first displaced -> cheapest / last displaced)
EMISSION_FACTORS = {"Fossil Oil": 700.0, "Fossil Gas": 450.0, "Fossil Hard coal": 900.0}
DISPLACEMENT_ORDER = ["Fossil Oil", "Fossil Gas", "Fossil Hard coal"]

displaced_t_meritorder = co2_displaced_reverse_merit_order(
    power_t_dk2_mwh, genmix, EMISSION_FACTORS, DISPLACEMENT_ORDER)
annual_displaced_meritorder = displaced_t_meritorder.sum()

saturated_hours = (power_t_dk2_mwh > sum(genmix[f] for f in DISPLACEMENT_ORDER)).mean()
print(f"annual AEP (DK2 wind year):        {power_t_dk2_mwh.sum() / 1000:8.1f} GWh")
print(f"annual displaced (reverse merit order): {annual_displaced_meritorder:8.1f} t CO2e")
print(f"hours where farm output alone exceeds all fossil generation running: {saturated_hours:.1%}")
annual AEP (DK2 wind year):           224.2 GWh
annual displaced (reverse merit order): 129154.1 t CO2e
hours where farm output alone exceeds all fossil generation running: 4.6%

How much did that saturation effect actually matter? Compare against a naive constant factor built from the same generation-mix data (its generation-weighted average emission factor), applied without any hourly resolution:

[13]:
naive_ef_dk2 = (sum(EMISSION_FACTORS[f] * genmix[f].sum() for f in DISPLACEMENT_ORDER)
               / sum(genmix[f].sum() for f in DISPLACEMENT_ORDER))
naive_displaced_dk2 = power_t_dk2_mwh.sum() * naive_ef_dk2 / 1000.0
print(f"naive constant-factor displaced:   {naive_displaced_dk2:8.1f} t CO2e")
print(f"reverse-merit-order displaced:     {annual_displaced_meritorder:8.1f} t CO2e")
print(f"naive method overestimates by:     {100 * (naive_displaced_dk2 / annual_displaced_meritorder - 1):8.1f} %")

fig, ax = plt.subplots()
ax.plot(displaced_t_meritorder[: 24 * 14])
ax.set_xlabel("hour (first two weeks of the year)")
ax.set_ylabel("t CO2e displaced")
ax.set_title("DK2: hourly displaced CO2 (reverse merit order)")
plt.show()
naive constant-factor displaced:   164288.4 t CO2e
reverse-merit-order displaced:     129154.1 t CO2e
naive method overestimates by:         27.2 %
../_images/notebooks_co2_emissions_35_1.png

Linear marginal displacement factor (Netherlands)

[14]:
ws_nl, wd_nl = load_hkn_wind()
mdf_nl = load_dutch_wind_mdf()
sim_res_nl = wfm(x_init, y_init, wd=wd_nl, ws=ws_nl, time=True)
power_t_nl_gwh = sim_res_nl.Power.sum("wt").values / 1e9

annual_displaced_mdf = co2_displaced(power_t_nl_gwh, mdf_nl)
naive_displaced_nl = power_t_nl_gwh.sum() * mdf_nl.mean()

print(f"annual AEP (NL wind year):           {power_t_nl_gwh.sum():8.1f} GWh")
print(f"annual displaced (hourly MDF):       {annual_displaced_mdf:8.1f} t CO2e")
print(f"naive constant-average-MDF displaced:{naive_displaced_nl:8.1f} t CO2e")

fig, axes = plt.subplots(2, 1, sharex=True, figsize=(7, 5))
axes[0].plot(power_t_nl_gwh[: 24 * 14])
axes[0].set_ylabel("power [GWh]")
axes[1].plot(mdf_nl[: 24 * 14], color="C1")
axes[1].set_ylabel("MDF [kg CO2/MWh]")
axes[1].set_xlabel("hour (first two weeks of the year)")
fig.suptitle("NL: power output and marginal displacement factor")
plt.show()
annual AEP (NL wind year):              221.6 GWh
annual displaced (hourly MDF):        44309.7 t CO2e
naive constant-average-MDF displaced: 46113.0 t CO2e
../_images/notebooks_co2_emissions_37_1.png

Unlike the reverse-merit-order case, the naive constant-average-MDF estimate is close to the fully hourly-resolved one here - because the linear MDF method has no saturation effect to miss, hourly resolution mainly matters when the farm’s own output is correlated with the displacement factor (e.g. if curtailment or wake steering could shift output towards high-MDF hours - the kind of “smart yaw” decision Kainz et al.’s own EMS-integrated version targets).