pommes.model.transport

Module related to inter-zone resource transport.

Attributes

RESOURCE_SEPARATOR

TRANSPORT_NET_GENERATION

Functions

check_resource_separator(→ None)

Refuse resource names that collide with the transport separator.

carried_resources(→ xarray.DataArray)

Say which resources each transport technology carries on each link.

links_of_area(→ xarray.DataArray)

The links that end in each area, as positions along link.

flows_of_area(flows, area, end)

Sum flows over the links that end in each area.

_transport_net_generation_mask(→ xarray.DataArray)

add_transport(→ pommes.model.catalogue.PommesModel)

Add transport-related components to the Linopy model.

Module Contents

pommes.model.transport.RESOURCE_SEPARATOR = '-'
pommes.model.transport.check_resource_separator(resources: collections.abc.Iterable[str]) → None

Refuse resource names that collide with the transport separator.

Multi-resource transport encodes the resources sharing one pipe in a single string split on RESOURCE_SEPARATOR. A resource named bio-methane would be split into bio and methane, neither of which is a declared resource: the mask of valid (link, tech, resource) triples would come out empty and the pipe would carry nothing. Nothing else in the model would complain – the run would simply build more local generation and report a plausible, wrong result.

So the convention is enforced rather than documented.

Parameters:

resources (Iterable[str]) – The declared resource names, i.e. the values of the resource coordinate.

Raises:

ValueError – If any resource name contains RESOURCE_SEPARATOR. The message names the offending resources.

Returns:

None

pommes.model.transport.carried_resources(model_parameters: xarray.Dataset) → xarray.DataArray

Say which resources each transport technology carries on each link.

transport_resource is a string per (link, tech) listing the resources that share the pipe, separated by RESOURCE_SEPARATOR. Read here once, for the model and for the pre-analysis (pommes.model.data_validation.pre_analysis), so the two cannot parse it differently.

Parameters:

model_parameters (xarray.Dataset) – Model parameters, carrying transport_resource and the resource coordinate.

Returns:

mask[link, transport_tech, resource], True where the (link, tech) pair carries the resource.

Return type:

xarray.DataArray

The links that end in each area, as positions along link.

end is transport_area_to (or transport_area_from), over link or over (link, transport_tech). Each area keeps as many slots as the area with the most such links, padded with -1: summing the flows of an area over its slots takes one term per link it has, where a sum over every link masked to the area took one per link of the network (#152).

Parameters:
  • area (xarray.DataArray) – The area coordinate.

  • end (xarray.DataArray) – The area at that end of each link.

Returns:

Integer positions over area, the other dimensions of end and link_slot.

Return type:

xarray.DataArray

pommes.model.transport.flows_of_area(flows, area: xarray.DataArray, end: xarray.DataArray)

Sum flows over the links that end in each area.

flows is operation_transport_power, as a linopy variable or as its values. The same as flows.where(area == end).sum("link"), one term per link of the area instead of one per link of the network.

Parameters:
  • flows – Over link and the dimensions of the flows.

  • area (xarray.DataArray) – The area coordinate.

  • end (xarray.DataArray) – transport_area_to for the inflows, transport_area_from for the outflows.

Returns:

The sum, over area in place of link.

pommes.model.transport._transport_net_generation_mask(p: xarray.Dataset) → xarray.DataArray
pommes.model.transport.TRANSPORT_NET_GENERATION
pommes.model.transport.add_transport(model: pommes.model.catalogue.PommesModel, model_parameters: xarray.Dataset, annualised_totex_def: linopy.Constraint, operation_adequacy_constraint: linopy.Constraint, operation_year_normalization: xarray.DataArray | float) → pommes.model.catalogue.PommesModel

Add transport-related components to the Linopy model.

Including variables, constraints, and costs related to energy transport between areas.

Parameters:
  • model (PommesModel) – The Linopy model to which transport-related elements will be added.

  • model_parameters (xarray.Dataset) – Dataset containing energy system parameters, including transport capacity limits, network topology, and costs.

  • annualised_totex_def (linopy.Constraint) – Constraint defining annualised total expenditures (totex), which will be updated with transport-specific costs.

  • operation_adequacy_constraint (linopy.Constraint) – Constraint ensuring operational adequacy, enforcing supply-demand balance, which will be updated with transport-related contributions.

  • operation_year_normalization (xarray.DataArray | float) – The factor scaling the operated hours to a year, operation_year_duration / time_step_duration.sum("hour"), as pommes.model.build_model.build_model() computes it for every module.

Returns:

The updated Linopy model with added transport-related variables, costs, and constraints.

Return type:

PommesModel

Note

This function introduces the following elements into the model:

Variables

  • Operation
    • operation_transport_power_capacity

      Represents the operational power capacity for transport technologies on each link and operational year.

    • operation_transport_power

      Represents the power flow for transport technologies by link, resource, hour, and operational year. A single capacity is shared by every resource the technology carries.

    • operation_transport_net_generation

      Represents the net energy transferred between areas, accounting for inflows and outflows. A derived quantity (TRANSPORT_NET_GENERATION), written as an expression into the adequacy row, not a variable.

    • operation_transport_costs

      Represents operational costs associated with transport technologies for each area and operational year.

  • Planning
    • planning_transport_power_capacity

      Represents the planned power capacity investments in transport infrastructure.

    • planning_transport_costs

      Represents planning costs associated with transport investments.

Constraints

  • Operation
    • operation_transport_power_max_constraint

      Limits the total flow, summed over every carried resource, to the available capacity.

  • Planning
    • planning_transport_power_capacity_min_constraint

      Enforces a lower limit on planned transport power investments.

    • planning_transport_power_capacity_max_constraint

      Enforces an upper limit on planned transport power investments.

  • Costs
    • operation_transport_costs_def

      Defines operational transport costs: the fixed costs of the power capacity and the hurdle costs of the flows, each link’s costs split evenly between its two areas.

    • planning_transport_costs_def

      Defines planning costs for transport investments, considering annuities.

These additions ensure that transport infrastructure operates within technical and economic limits, allowing the model to simulate energy transport flows realistically.

Multi-resource transport:

A transport technology may carry several resources through the same pipe, sharing one capacity. The capacity constraint then reads

Σ_resource operation_transport_power[link, tech, resource, h, y]

≤ operation_transport_power_capacity[link, tech, y]

which stays fully linear – no binary variable, no commitment logic. Nothing prevents the mix from changing hour to hour; a pipe that has to be purged between two resources is not represented by this.

The resources sharing a pipe are listed in the transport_resource string, separated by RESOURCE_SEPARATOR, e.g. "co2_fossil-co2_biogenic". A string without the separator names a single resource and behaves exactly as before.

Warning

Setting this value on an EXISTING array rather than reading it from CSV requires widening the dtype first. NumPy fixed-width strings truncate silently: assigning "electricity-methane" into a <U11 array leaves "electricity", and the pipe quietly carries one resource instead of two.