pommes.model.transport
Module related to inter-zone resource transport.
Attributes
Functions
|
Refuse resource names that collide with the transport separator. |
|
Say which resources each transport technology carries on each link. |
|
The links that end in each area, as positions along |
|
Sum |
|
|
|
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 namedbio-methanewould be split intobioandmethane, 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
resourcecoordinate.- 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_resourceis a string per (link, tech) listing the resources that share the pipe, separated byRESOURCE_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_resourceand theresourcecoordinate.- Returns:
mask[link, transport_tech, resource], True where the (link, tech) pair carries the resource.- Return type:
xarray.DataArray
- pommes.model.transport.links_of_area(area: xarray.DataArray, end: xarray.DataArray) xarray.DataArray
The links that end in each area, as positions along
link.endistransport_area_to(ortransport_area_from), overlinkor 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
areacoordinate.end (xarray.DataArray) – The area at that end of each link.
- Returns:
Integer positions over
area, the other dimensions ofendandlink_slot.- Return type:
xarray.DataArray
- pommes.model.transport.flows_of_area(flows, area: xarray.DataArray, end: xarray.DataArray)
Sum
flowsover the links that end in each area.flowsisoperation_transport_power, as a linopy variable or as its values. The same asflows.where(area == end).sum("link"), one term per link of the area instead of one per link of the network.- Parameters:
flows – Over
linkand the dimensions of the flows.area (xarray.DataArray) – The
areacoordinate.end (xarray.DataArray) –
transport_area_tofor the inflows,transport_area_fromfor the outflows.
- Returns:
The sum, over
areain place oflink.
- 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"), aspommes.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:
Note
This function introduces the following elements into the model:
Variables
- Operation
operation_transport_power_capacityRepresents the operational power capacity for transport technologies on each link and operational year.
operation_transport_powerRepresents 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_generationRepresents 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_costsRepresents operational costs associated with transport technologies for each area and operational year.
- Planning
planning_transport_power_capacityRepresents the planned power capacity investments in transport infrastructure.
planning_transport_costsRepresents planning costs associated with transport investments.
Constraints
- Operation
operation_transport_power_max_constraintLimits the total flow, summed over every carried resource, to the available capacity.
- Planning
planning_transport_power_capacity_min_constraintEnforces a lower limit on planned transport power investments.
planning_transport_power_capacity_max_constraintEnforces an upper limit on planned transport power investments.
- Costs
operation_transport_costs_defDefines 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_defDefines 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_resourcestring, separated byRESOURCE_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<U11array leaves"electricity", and the pipe quietly carries one resource instead of two.