Package Overview
This page sketches the two pillars of EnergyModelsGasNetworks: gas transport based on flow-pressure relationship and quality-tracking pooling.
The detailed documentation on the methodology behind EnergyModelsGasNetworks can be found in Theoretical Background.
Flow–pressure coupling
- Potentials on nodes and links. Defining resources of type
ResourcePressureactivates the flow-pressure constraints (see Internal Constraints) on nodes and links. Potentials can be bounded withFixPressureData,MaxPressureData, orMinPressureData. - Weymouth relationship. For single-component flows, the pressure-flow curve is linearised with the first-order Taylor. The defined cuts will be defined between the minimum and maximum inlet pressures stored in
PressureLinkData. For blended gases, the non-convex surface is outer-approximated with planes generated by PiecewiseAffineApprox. - Optimiser The PWA planes require a MIP-capable solver; set it with
set_optimizer_pwa!(e.g., HiGHS, Xpress, Gurobi) before building the model. The discretisation step of the pressure grid for the approximations can be tuned viaset_step_pressure!. - Binary variables. One binary array —
has_flow— is declared per pressure-carrying link per time period.has_flowenables big-M deactivation of idle links in pressure-balance and capacity constraints; when active (has_flow=1), both the upper and lower bounds onpotential_in[n]bind, forcing equality with the link outlet potential. The array is restricted to links carrying at least oneCompoundResource; Power-only links are excluded.
Pooling and quality tracking
- Pooling formulation. Defining a resource of type
ResourcePoolingstores a blended resource and its subresources. Subresources can be of typeResourceCarrierorResourcePressure. The former activates only the pooling formulation, the latter the pooling formuation and flow-pressure constraints. - Quality limits.
RefBlendData(for nodes) andBlendLinkData(for links) subtypes specify maximum and minimum qualities for subresource at nodes or links. Quality is enforced at pooling nodes and sinks, and component proportions are tracked so they can be reused by the pressure formulation of blended gases. - Node types for blending. Three node types handle mixing of blend subresources:
PoolingNode— for junctions with ≥ 2 outgoing blend links. Uses the standard bilinear pooling formulation (proportion_out × total_flow = component_flow) to ensure all splits share the same composition.BlendingNode— for junctions with exactly 1 outgoing blend link. Uses a linear formulation: component mass balance directly determines the output composition withoutproportion_outvariables or bilinear constraints. Quality bounds (max_h2 × total_flow) remain linear because the quality limits are fixed parameters. Preferred overPoolingNodewhenever the topology allows it — typically pre-sink, post-source, and single-path transit mixing nodes.TransitNode— for pass-through junctions with no injection or extraction and no quality enforcement. The composition is copied linearly from upstream, so aTransitNodesends blend down at most one outgoing link per period (Σ has_flow[l_out, t] ≤ 1). Bidirectional pipelines are supported, since only one direction is active. With several outgoing blend links, every one of them must carry a pressure resource (so that it has ahas_flowbinary); otherwisevalidate_blend_topologyraises anArgumentError. UsePoolingNodeorDiscretizedPoolingNodewhere the blend must split into several pipes at the same time.