Gas Gathering Network¶
In this tutorial you will gather natural gas from three wells into a header, compress it and send it down an 8 km export line to a sales point held at 90 bar. Two of the wells are set by their wellhead pressure, so the network finds how much gas each one delivers. The third is set by its rate, so the network finds the pressure it needs. You will then give the compressor more pressure increase and watch the wells respond.
What you will learn
- How to set a boundary by its pressure or by its flow, and what the network computes in each case
- How the compositional flow model flashes the gas along every pipe
- How check valves keep a weak well from taking gas back
- How the header pressure decides the rate of each well, and how the compressor moves it
- How the heat of compression changes the gas in the export line
Prerequisites
- Completed Water Distribution Network
- DWSIM 10.3.0 or later
- The Pipe Network is part of the Patreon edition (Premium+).
Process Overview¶
Three gas wells, W1, W2 and W3, produce a lean natural gas into short flowlines. Each well has a check valve at the wellhead. The flowlines join at a header, and a 300 m suction line takes the gas to the compressor K-101, which adds 35 bar. An 8 km export line, rising 30 m on its way, delivers the gas to the sales point, where the buyer holds the pressure at 90 bar.
W1 and W2 flow on their own pressure: the wellhead pressures are 72 and 68 bar. W3 is a well under rate control, which produces 5 kg/s. The question is how much gas the field sends to sales, and what the compressor does to it.
graph LR
W1["W1<br/>72 bar"] --> C1["CHK-W1"] --> F1["FL-W1<br/>600 m"] --> H(("HDR"))
W2["W2<br/>68 bar"] --> C2["CHK-W2"] --> F2["FL-W2<br/>900 m"] --> H
W3["W3<br/>5 kg/s"] --> C3["CHK-W3"] --> F3["FL-W3<br/>1200 m"] --> H
H --> S["SUCTION<br/>300 m"] --> K["K-101<br/>+35 bar"] --> E["EXPORT<br/>8 km, +30 m"] --> SA["SALES<br/>90 bar"]
Key Design Parameters¶
| Parameter | Value |
|---|---|
| Compounds | Methane 86, ethane 6, propane 3, n-butane 1, nitrogen 2, carbon dioxide 2 (mole %) |
| Property package | Peng-Robinson |
| Flow model of the network | Compositional |
| W1, W2 | wellhead pressure 72 and 68 bar |
| W3 | 5 kg/s |
| Flowlines | 4 in (102.3 mm inner), 600, 900 and 1200 m |
| Suction line | 8 in (202.7 mm inner), 300 m |
| K-101 | pressure increase 35 bar, adiabatic efficiency 75 % |
| Export line | 8 in, 8000 m, rising 30 m |
| SALES | 90 bar |
| Gas temperature at the wells | 45 °C |
Step-by-Step in the Classic UI¶
1. Set up¶
File > New Chemical Process Model: add Methane, Ethane, Propane, N-butane, Nitrogen and Carbon dioxide, and choose Peng-Robinson as the property package.
Add a Pipe Network to the flowsheet, name it GAS-1, open its editor and click Open Network Designer. In the designer, open Settings and set Flow Model to Compositional (multiphase). In this model each pipe flashes the gas along its length with the property package, so the density, the viscosity and the phases follow the pressure and the temperature. The incompressible model of the water tutorial would hold one density for the whole network, which doesn't suit a gas that loses 10 % of its pressure in the export line.


2. The wells¶
Drag three Source blocks and name them W1, W2 and W3. A source is the boundary where fluid enters the network, and it is set in one of two ways:
W1andW2: Specified VariablePressure, 72 and 68 bar. The network holds the pressure and computes the flow.W3: Specified VariableMass Flow, 18000 kg/h (5 kg/s). The network holds the flow and computes the pressure the well needs.

After each source place a Node, a Valve and a second Node (N-W1, CHK-W1, NC-W1, and the same for W2 and W3). In each valve tick Non-Return (Check Valve). A check valve lets the gas through in one direction only, so if the header ever rose above the pressure of a weak well, the valve would shut instead of letting gas flow back into the well.
3. The flowlines, the header and the suction line¶
Drag three Pipe Segment blocks for the flowlines (FL-W1, FL-W2, FL-W3) and one for the suction line (SUCTION). Open the Profile tab of each pipe and give it one straight section of carbon steel:
| Pipe | Length (m) | Elevation (m) | Inner diameter (mm) |
|---|---|---|---|
| FL-W1 | 600 | 0 | 102.3 |
| FL-W2 | 900 | 0 | 102.3 |
| FL-W3 | 1200 | 0 | 102.3 |
| SUCTION | 300 | 0 | 202.7 |

The Pipe Segment is the multiphase pipe of DWSIM. Its Hydraulic tab chooses the pressure drop correlation (Beggs and Brill by default), which also covers a gas that drops some condensate on its way.
Place a Node named HDR where the three flowlines meet.
4. The compressor and the export line¶
Drag a Compressor and name it K-101. Set Calculation Mode to Pressure Variation, Pressure Increase to 35 bar and Adiabatic Efficiency to 75 %. In a network the compressor adds a fixed pressure: its suction pressure comes out of the network, and the discharge is the suction plus 35 bar.

Drag a Pipe Segment for the export line (EXPORT, 8000 m long, 30 m of elevation, 202.7 mm), a Sink named SALES with Specified Variable Pressure at 90 bar, and the nodes N-SUC, N-DIS and N-END.
5. Connect and attach the streams¶
Connect the blocks:
W1→N-W1→CHK-W1→NC-W1→FL-W1→HDR, and the same for W2 and W3HDR→SUCTION→N-SUC→K-101→N-DIS→EXPORT→N-END→SALES
On the flowsheet, add a material stream for each well (gas-W1, gas-W2, gas-W3) with the gas composition at 45 °C and connect it to an inlet port of GAS-1. Add a stream sales-gas on an outlet port for the sales point. Then choose each stream in the Associated Stream list of its source or sink. The network takes the composition and the temperature of each well from its stream.
6. Solve¶
Click Solve. The compositional model iterates between the flows and the gas states, so a solve takes a few seconds.
| Well | Specified | Mass flow (kg/s) | Wellhead pressure (bar) |
|---|---|---|---|
| W1 | pressure | 7.23 | 72.00 |
| W2 | pressure | 3.57 | 68.00 |
| W3 | mass flow | 5.00 | 71.74 |
| Total | 15.81 |
| Point | Pressure (bar) | Temperature (°C) |
|---|---|---|
| Header HDR | 65.51 | 42.7 |
| Compressor suction | 65.04 | 42.5 |
| Compressor discharge | 100.04 | 82.5 |
| Sales point | 90.00 | 79.6 |
K-101 needs 1150 kW. The export line loses 10.04 bar from the compressor to the sales point.

7. Read the network¶
Start from the sales point and walk back. The buyer holds 90 bar at the end of the export line, and the line loses 10.04 bar, so the compressor has to deliver 100.04 bar. It adds 35 bar, so its suction sits at 65.04 bar, and the header, 0.47 bar upstream, at 65.51 bar. Every well has to push its gas into that header.
W1 has 72 bar at the wellhead, 6.5 bar above the header, and it delivers 7.23 kg/s. W2 has only 68 bar, 2.5 bar above the header, and its longer flowline takes most of that difference, so it delivers 3.57 kg/s. W3 is held at 5 kg/s, and the network says its wellhead has to be at 71.74 bar to push that rate through 1200 m of flowline.
The compressor heats the gas from 42.5 to 82.5 °C. Hot gas is less dense, so it flows faster in the export line and loses more pressure on its way. With the default thermal settings of the pipe, the gas cools by only 3 °C over the 8 km of the line. An aftercooler after K-101 would cut the export loss, which is why gas compressor stations have one.
8. More compression¶
Raise the Pressure Increase of K-101 to 45 bar and solve again.
| 35 bar | 45 bar | |
|---|---|---|
| W1 (kg/s) | 7.23 | 9.10 |
| W2 (kg/s) | 3.57 | 5.71 |
| W3 (kg/s) | 5.00 | 5.00 |
| W3 wellhead pressure (bar) | 71.74 | 68.14 |
| Total (kg/s) | 15.81 | 19.81 |
| Compressor suction (bar) | 65.04 | 60.73 |
| Compressor discharge (bar) | 100.04 | 105.73 |
| Discharge temperature (°C) | 82.5 | 92.8 |
| K-101 power (kW) | 1150 | 1888 |
| Export line loss (bar) | 10.04 | 15.73 |
The extra 10 bar doesn't raise the sales pressure, which the buyer holds. It lowers the suction and the header instead, by about 4 bar, and the wells answer with more gas. W2, the weak well, gains the most in relative terms (60 %), because the header pressure was close to its own. The field sends 25 % more gas to sales for 64 % more compressor power. Part of the extra pressure is spent in the export line, which now carries more and hotter gas.
Results and Validation¶
Expected results
- Base case: 15.81 kg/s to sales, header at 65.51 bar, W3 needs 71.74 bar at the wellhead.
- K-101: 1150 kW, discharge at 82.5 °C.
- With 45 bar of pressure increase: 19.81 kg/s, suction at 60.73 bar, 1888 kW.
The compressor and the node after it agree. The Results of K-101 give a temperature increase of 39.9 K, and the node N-DIS sits 39.9 K above N-SUC. Before DWSIM 10.3.0 the compositional network passed the suction temperature through the compressor, which left the export line with gas 40 K too cold.
Automating This Tutorial¶
Files in this repository
- Python script:
examples/pipe-networks/02_gas_gathering.py - Pre-built flowsheet:
examples/saved/gas_gathering.dwxmz(the base case, with 35 bar of pressure increase)
The script builds the network, solves it with 35 and 45 bar of pressure increase and prints the tables of this page. It reads the results of the blocks through the property interface of the network ("W1: Mass Flow", "W1: Pressure"), the same names a spreadsheet or a sensitivity analysis uses. It needs DWSIM_PATRON_KEY when DWSIM is not activated on the machine.
import os
import sys
import pythonnet
pythonnet.load("netfx") # DWSIM is a .NET Framework application
import clr # noqa: E402
DWSIM_BIN = os.environ.get("DWSIM_BIN")
if not DWSIM_BIN:
raise SystemExit("Set DWSIM_BIN to the DWSIM installation folder before running.")
for sub in ("", "unitops", "ppacks", "extenders"):
sys.path.append(os.path.join(DWSIM_BIN, sub))
clr.AddReference("DWSIM.Automation")
clr.AddReference("DWSIM.Automation.FluentAPI")
clr.AddReference("DWSIM.UnitOperations")
clr.AddReference("DWSIM.UnitOperations.PipeNetwork")
from DWSIM.Automation.FluentAPI import Flowsheet, License, PropertyPackages, Q # noqa: E402
from DWSIM.UnitOperations.PipeNetwork.Blocks import Compressor, Node, Pipe, Sink, Source, Valve # noqa: E402
from DWSIM.UnitOperations.PipeNetwork.Classes import BoundarySpecification, NodalFlowModel # noqa: E402
from DWSIM.UnitOperations.UnitOperations import Compressor as ClassicCompressor # noqa: E402
from DWSIM.UnitOperations.UnitOperations.Auxiliary.Pipe import PipeEditorStatus, PipeSection # noqa: E402
if not License.IsActivated:
key = os.environ.get("DWSIM_PATRON_KEY")
if not key or not License.CheckLicense(key):
raise SystemExit("The Pipe Network is a DWSIM Plus operation: set DWSIM_PATRON_KEY to your Patreon key.")
GAS = {"Methane": 0.86, "Ethane": 0.06, "Propane": 0.03, "N-butane": 0.01, "Nitrogen": 0.02, "Carbon dioxide": 0.02}
fs = (Flowsheet.Create("GasGathering")
.WithCompounds(*GAS.keys())
.WithPropertyPackage(PropertyPackages.PengRobinson))
net = fs.AddPipeNetwork("GAS-1")
net.Object.NodalFlowModel = NodalFlowModel.Compositional # each pipe flashes the gas along its length
def set_pipe(node, length_m, rise_m, id_inch, increments):
"""One straight carbon steel section: length, elevation change, outer and inner diameter."""
prof = node.As[Pipe]().BaseUnitOperation.Profile
prof.Sections.Clear()
prof.Sections.Add(1, PipeSection(1, "Straight Tube", 1, increments, "Carbon Steel", length_m, rise_m, id_inch + 1.0, id_inch))
prof.Status = PipeEditorStatus.OK
# --- the wells: W1 and W2 at a fixed wellhead pressure, W3 at a fixed rate --------------
WELLS = { # tag: (specification, value, flowline length m)
"W1": ("pressure", 72e5, 600.0),
"W2": ("pressure", 68e5, 900.0),
"W3": ("flow", 5.0, 1200.0), # kg/s
}
hdr = net.AddNode("HDR")
src, chk, fl = {}, {}, {}
for tag, (spec, value, length) in WELLS.items():
src[tag] = net.AddSource(tag)
s = src[tag].As[Source]()
if spec == "pressure":
s.BoundarySpec, s.PressureSpec = BoundarySpecification.Pressure, value
else:
s.BoundarySpec, s.MassFlowSpec = BoundarySpecification.MassFlow, value
nw, nc = net.AddNode("N-" + tag), net.AddNode("NC-" + tag)
chk[tag] = net.AddValve("CHK-" + tag)
chk[tag].As[Valve]().NonReturn = True # a check valve: no backflow into a weak well
fl[tag] = net.AddPipe("FL-" + tag)
set_pipe(fl[tag], length, 0.0, 4.026, 5) # 4 in schedule 40
net.ConnectChain(src[tag], nw, chk[tag], nc, fl[tag], hdr)
# --- compression and export ---------------------------------------------------------
n_suc, n_dis, n_end = net.AddNode("N-SUC"), net.AddNode("N-DIS"), net.AddNode("N-END")
suction = net.AddPipe("SUCTION")
set_pipe(suction, 300.0, 0.0, 7.981, 3) # 8 in
comp = net.AddCompressor("K-101")
k = comp.As[Compressor]().BaseUnitOperation
k.CalcMode = ClassicCompressor.CalculationMode.Delta_P
k.DeltaP = 35e5 # the compressor adds 35 bar
k.AdiabaticEfficiency = 75.0 # in percent
export = net.AddPipe("EXPORT")
set_pipe(export, 8000.0, 30.0, 7.981, 10) # 8 km of 8 in, rising 30 m
sales = net.AddSink("SALES")
sk = sales.As[Sink]()
sk.BoundarySpec, sk.PressureSpec = BoundarySpecification.Pressure, 90e5
net.ConnectChain(hdr, suction, n_suc, comp, n_dis, export, n_end, sales)
def attach(node, tag, p_bar):
"""The flowsheet stream of a boundary: the gas composition at 45 °C (the network sets the flows)."""
ms = net.AttachStream(node, tag)
for name, x in GAS.items():
ms.SetCompoundMolarFlow(name, 300.0 * x) # mol/s, only the proportions matter
ms.At(Q.Celsius(45.0), Q.Bar(p_bar)).Object.Calculate()
for tag in WELLS:
attach(src[tag], "gas-" + tag, 70.0)
attach(sales, "sales-gas", 90.0)
POSITIONS = {
"W1": (20, 40), "N-W1": (100, 50), "CHK-W1": (170, 40), "NC-W1": (250, 50), "FL-W1": (330, 50),
"W2": (20, 180), "N-W2": (100, 190), "CHK-W2": (170, 180), "NC-W2": (250, 190), "FL-W2": (330, 190),
"W3": (20, 320), "N-W3": (100, 330), "CHK-W3": (170, 320), "NC-W3": (250, 330), "FL-W3": (330, 330),
"HDR": (470, 190), "SUCTION": (550, 190), "N-SUC": (650, 190), "K-101": (720, 180), "N-DIS": (810, 190),
"EXPORT": (890, 190), "N-END": (1000, 190), "SALES": (1070, 180),
}
for tag, (x, y) in POSITIONS.items():
go = net.Find(tag).Block.GraphicObject
go.X, go.Y = x, y
def bar(node):
return node.As[Node]().Pressure / 1e5
def report(title):
print(f"\n{title}")
total = 0.0
uo = net.Object # a block's results are read as "<tag>: <property>", in SI units
for tag in WELLS:
w = float(uo.GetPropertyValue(f"{tag}: Mass Flow"))
p = float(uo.GetPropertyValue(f"{tag}: Pressure"))
total += w
print(f" {tag}: {w:5.2f} kg/s at a wellhead pressure of {p / 1e5:6.2f} bar")
print(f" total {total:.2f} kg/s; header {bar(hdr):.2f} bar, compressor suction {bar(n_suc):.2f} bar, "
f"discharge {bar(n_dis):.2f} bar")
t_dis = n_dis.As[Node]().Temperature - 273.15
print(f" K-101 power {k.DeltaQ:.0f} kW, discharge temperature {t_dis:.1f} °C")
print(f" export line: {bar(n_dis) - bar(n_end):.2f} bar from the compressor to the sales point")
return total
fs.Solve()
report("Base case: the compressor adds 35 bar")
# --- what if the compressor adds 45 bar? -------------------------------------------
k.DeltaP = 45e5
fs.Solve()
report("The compressor adds 45 bar")
# back to the base case before saving
k.DeltaP = 35e5
fs.Solve()
Output may vary
Results depend on the LLM's reasoning quality and tool-use accuracy. Always verify the simulation matches your intent before relying on the numbers.
In the DWSIM Assistant, build the following simulation:
- Compounds Methane, Ethane, Propane, N-butane, Nitrogen and Carbon
dioxide (mole fractions 0.86, 0.06, 0.03, 0.01, 0.02, 0.02),
property package Peng-Robinson
- A Pipe Network "GAS-1" with the Compositional flow model:
- sources W1 (72 bar), W2 (68 bar) and W3 (5 kg/s), each followed by
a check valve and a 4 in flowline (600, 900 and 1200 m) into a
header node HDR, with the gas at 45 °C
- a 300 m, 8 in suction line, a compressor K-101 adding 35 bar at
75 % adiabatic efficiency, an 8 km, 8 in export line rising 30 m,
and a sales sink held at 90 bar
- Solve and report the rate and the wellhead pressure of each well,
the header pressure, the compressor power and discharge temperature
and the pressure drop of the export line
- Repeat with a pressure increase of 45 bar and compare
Exercises
- Shut W1 by setting its source to a mass flow of zero. How far does the header pressure fall, and how much more do W2 and W3 have to give?
- Replace the 8 in export line by a 10 in one (254.5 mm). How much more gas does the field deliver with the original 35 bar of pressure increase?
- Set W3 to a wellhead pressure of 66 bar instead of its rate. Does the check valve close, and what does the network report for W3?
- The buyer raises the sales pressure to 95 bar. How much gas does the field lose with 35 bar of pressure increase, and which well loses the most?
Further Reading¶
- M. Mohitpour, H. Golshan and A. Murray. (2007). Pipeline Design and Construction: A Practical Approach, 3rd ed. ASME Press
- E. S. Menon. (2005). Gas Pipeline Hydraulics. CRC Press
- H. D. Beggs and J. P. Brill. (1973). A study of two-phase flow in inclined pipes. Journal of Petroleum Technology, 25(5), 607-617
- DWSIM User Guide: the Pipe Network unit operation
Next Steps¶
You now know how pressure and flow boundaries work, how a header shares the gas among the wells and what a compressor does inside a network. Continue with Flare and Relief Network, where the gas flows the other way, from the relief valves to the flare.