Water Distribution Network¶
In this tutorial you will build the water network of a small town: a water tower, a well with a booster pump and a looped grid that delivers to four districts. You will solve it at the average demand, see how the flow divides around the loop, and then run the peak hour, when the end of one branch falls below the minimum service pressure. A larger pipe on that branch fixes it.
What you will learn
- How the Pipe Network block hosts a whole network inside one flowsheet object, and how its designer works
- How reservoirs, nodes, water pipes, pumps and sinks fit together, and why every boundary needs a stream
- How the network divides the flow in a loop, and how to read the direction of each flow
- How to check the service pressure at the junctions and find the pipe that limits it
Prerequisites
- Completed Your First Simulation
- DWSIM 10.3.0 or later
- The Pipe Network is part of the Patreon edition (Premium+).
Process Overview¶
A town takes its water from two places. A well at ground level feeds a booster pump, which sends the water through a 250 mm main to the grid. A water tower stands 30 m above the grid with 5 m of water in it, and it is connected to the other side of the grid by a 200 mm line. The grid is a loop of four junctions, J1 to J4, with a branch from J3 to a fifth junction, J5. Four districts draw water at J1, J2, J4 and J5.
During the day the pump and the tower share the demand. The grid has to hold at least 15 m of water (about 1.5 bar gauge) at every junction, so that the top floors of the houses still get water.
graph LR
W["Well"] --> PU["PU-1<br/>booster pump"] --> M["P-MAIN<br/>DN 250, 600 m"] --> J2
T["Water tower<br/>30 m + 5 m"] --> PT["P-TANK<br/>DN 200, 400 m"] --> J1
J1 --- J2
J2 --- J3
J3 --- J4
J4 --- J1
J3 --> B1["B1<br/>DN 100, 300 m"] --> J5
Key Design Parameters¶
| Parameter | Value |
|---|---|
| Compound | Water |
| Property package | Steam Tables (IAPWS-IF97) |
| Water tower TANK | base 30 m above the grid, 5 m of water |
| Well WELL | base at the grid level, 2 m of water |
| Pump PU-1 | head curve from 48 m at zero flow to 22 m at 80 L/s |
| Pipes | Hazen-Williams, C = 120 (ductile iron, a few years old) |
| Demands | D1 15 kg/s at J1, D2 10 kg/s at J2, D3 20 kg/s at J4, D4 8 kg/s at J5 (53 kg/s in all) |
| Minimum service pressure | 15 m of water at every junction |
| Pipe | From, to | Length (m) | Inner diameter (mm) |
|---|---|---|---|
| P-TANK | tower, J1 | 400 | 202.7 (DN 200) |
| P-MAIN | pump, J2 | 600 | 254.5 (DN 250) |
| L1 | J1, J2 | 500 | 202.7 (DN 200) |
| L2 | J2, J3 | 450 | 154.1 (DN 150) |
| L3 | J3, J4 | 500 | 154.1 (DN 150) |
| L4 | J4, J1 | 450 | 154.1 (DN 150) |
| B1 | J3, J5 | 300 | 102.3 (DN 100) |
The grid is flat, so the junctions sit at the same elevation as the base of the well. The pressures in this tutorial are gauge pressures and heads in metres of water above the grid.
Step-by-Step in the Classic UI¶
1. Set up¶
File > New Chemical Process Model: add Water and choose Steam Tables (IAPWS-IF97) as the property package. Use a unit system with bar, kg/h and m, or switch the units to your taste. The editors of the network show their values in the units of the flowsheet.
2. Add the Pipe Network and open its designer¶
Drag a Pipe Network from the object palette onto the flowsheet and name it NET-1. Double-click it and click Open Network Designer.
The designer is a window of its own, with the canvas in the middle and the Equipment palette on the right. You build the network on this canvas the way you build a flowsheet: drag a block from the palette, then double-click it to edit its properties in the panel on the left.

Nodes between the blocks
In a pipe network, pipes, pumps and valves are branches, and they always join two nodes. A boundary block (a reservoir, a source or a sink) also connects to a node, never straight to a pipe. The network solver writes one mass balance per node and one pressure-flow relation per branch, and it solves them all at once.
3. Place the two supplies¶
Drag two Reservoir blocks onto the canvas and name them TANK and WELL. In the editor of each one set the base elevation and the liquid level:
TANK: base elevation 30 m, liquid level 5 mWELL: base elevation 0 m, liquid level 2 m
A reservoir holds the head of its free surface: the base elevation plus the level, at the pressure of its surface (the atmosphere here). The water tower therefore holds 35 m of head and the well 2 m.

4. Add the pump¶
Drag a Pump next to the well and name it PU-1. In its editor, set Calculation Mode to Defined Curves and click Edit Curves. Enable the head curve and type these points, with the flow in m³/s and the head in m:
| Flow (m³/s) | Head (m) |
|---|---|
| 0.00 | 48 |
| 0.02 | 46 |
| 0.04 | 41 |
| 0.06 | 33 |
| 0.08 | 22 |
The network reads the pump on its curve, so the pump delivers whatever flow puts its head where the grid needs it.

5. Add the junctions and the pipes¶
Drag eight Node blocks onto the canvas: N-TANK, N-WELL and N-PUMP for the supply side, and J1 to J5 for the grid. Then drag seven Water Pipe blocks, name them as in the pipe table and type the length and the diameter of each one in its editor. Tick Use Hazen-Williams and set Hazen-Williams C to 120.
The Water Pipe is the pipe for water networks. It computes the friction loss with Hazen-Williams or with Darcy-Weisbach, and it takes the fittings either as an equivalent length or as a sum of K. The general Pipe Segment of the palette is the one for multiphase and compressible flow, which a water grid doesn't need.

6. Add the demands¶
Drag four Sink blocks and name them D1 to D4. In each one set Specified Variable to Mass Flow and type the demand: 54000 kg/h for D1, 36000 kg/h for D2, 72000 kg/h for D3 and 28800 kg/h for D4 (15, 10, 20 and 8 kg/s).
A sink with a specified flow draws exactly that flow, and the network finds the pressure it arrives at. A sink with a specified pressure would do the opposite.
7. Connect the blocks¶
Connect the blocks by dragging from the outlet of one to the inlet of the next, or right-click a block and use Connect To:
TANK→N-TANK→P-TANK→J1WELL→N-WELL→PU-1→N-PUMP→P-MAIN→J2- the loop:
J1→L1→J2→L2→J3→L3→J4→L4→J1 - the branch:
J3→B1→J5 - the demands:
J1→D1,J2→D2,J4→D3,J5→D4
The direction you draw a pipe in sets the sign of its flow. If the water runs the other way, the network solves it anyway, gives the flow a negative sign and turns the arrow on the pipe around.
8. Give every boundary a stream¶
Each reservoir, source and sink needs a material stream on the main flowsheet. The network reads the temperature and the composition of the water from the stream of a reservoir, and it writes what a sink delivers into the stream of that sink.
On the flowsheet, add a material stream for each reservoir (Tower and Well, water at 20 °C and 1.01325 bar) and connect it to an inlet port of NET-1. Add one stream for each demand (D1-out to D4-out) and connect each one to an outlet port of NET-1. Then, in the designer, choose the stream of each boundary in its Associated Stream list.

9. Solve and read the results¶
Click Solve on the designer toolbar. Double-click a pipe and open its Results tab to see the mass flow, the volumetric flow, the pressure drop and the velocity. Double-click a junction for its pressure. The node pressure is absolute, so subtract 1.013 bar to get the gauge pressure.


At the average demand the network gives:
| Junction | Pressure (bar g) | Head (m) |
|---|---|---|
| J1 | 3.43 | 35.0 |
| J2 | 3.60 | 36.7 |
| J3 | 3.33 | 34.0 |
| J4 | 3.25 | 33.2 |
| J5 | 2.94 | 30.0 |
| Pipe | Flow (L/s) | Velocity (m/s) | Head loss (m) |
|---|---|---|---|
| P-TANK | 4.1 | 0.13 | 0.05 |
| P-MAIN | 49.0 | 0.96 | 2.66 |
| L1 | -23.5 | 0.73 | 1.72 |
| L2 | 15.6 | 0.83 | 2.74 |
| L3 | 7.5 | 0.40 | 0.80 |
| L4 | -12.5 | 0.67 | 1.83 |
| B1 | 8.0 | 0.98 | 3.94 |
The pump delivers 49.0 L/s at 37.4 m of head, and the tower only 4.1 L/s. This is what happens in a grid with a tower: the pump raises the grid almost to the level of the water in the tower (35 m), so the tower has little head left to push with. At night, when the demand falls, the grid rises above the tower and the tower fills.
Two pipes of the loop carry a negative flow. L1 was drawn from J1 to J2, but its water runs from J2 up to J1, and L4 was drawn from J4 to J1 but runs from J1 to J4. The arrows on the canvas show where the water really goes. Most of the water enters the grid at J2, where the pump main arrives, and it splits there: one part goes up L1 to J1 and on to J4, and the other part goes along L2 to J3, which feeds J4 and the branch.
10. The peak hour¶
At the peak hour every district draws 1.8 times its average. Multiply the four demands by 1.8 (97200, 64800, 129600 and 51840 kg/h) and click Solve again.
| Junction | Average (m) | Peak (m) |
|---|---|---|
| J1 | 35.0 | 31.7 |
| J2 | 36.7 | 32.4 |
| J3 | 34.0 | 26.0 |
| J4 | 33.2 | 24.6 |
| J5 | 30.0 | 14.3 |
The pump moves down its curve to 57.5 L/s at 34.0 m, and the tower now supplies 38.1 L/s, nine times more than before, because the grid has fallen well below its level. Every junction of the loop stays above 24 m. J5 falls to 14.3 m, below the 15 m minimum.
The cause is the branch. B1 carries 14.4 L/s through a DN 100 pipe at 1.75 m/s and loses 11.7 m of head on its 300 m, more than all the pipes of the loop together. The loop is fine. The branch is too small for the peak.
11. Enlarge the branch¶
Open the editor of B1, change the diameter to 154.1 mm (DN 150) and solve again. The velocity in B1 falls to 0.77 m/s, its head loss to 1.59 m, and J5 recovers to 24.4 m. The rest of the network doesn't change, because B1 is a dead end: the flow it carries is the demand at its end, whatever its size.
Results and Validation¶
Expected results
- Average demand: the pump gives 49.0 L/s at 37.4 m of head, the tower 4.1 L/s, and the lowest junction is J5 at 30.0 m.
- Peak hour (1.8 times the average): the pump gives 57.5 L/s at 34.0 m, the tower 38.1 L/s, and J5 falls to 14.3 m, below the 15 m minimum.
- With B1 in DN 150, J5 holds 24.4 m at the peak hour.
You can check one number by hand. B1 is a dead end, so at the average demand it carries exactly the 8 kg/s of D4, which is 0.008014 m³/s at 998.2 kg/m³. The Hazen-Williams formula, h = 10.67 L Q^1.852 / (C^1.852 D^4.871), gives 10.67 × 300 × 0.008014^1.852 / (120^1.852 × 0.1023^4.871) = 3.94 m, the head loss the network reports for B1.
Automating This Tutorial¶
Files in this repository
- Python script:
examples/pipe-networks/01_water_distribution.py - Pre-built flowsheet:
examples/saved/water_distribution.dwxmz(the network of step 9: the average demand, with B1 still in DN 100)
The script builds the network, solves the average demand, the peak hour and the peak hour with B1 enlarged, and prints the tables of this page. 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.PipeNetwork")
from DWSIM.Automation.FluentAPI import Flowsheet, License, PropertyPackages, Q # noqa: E402
from DWSIM.UnitOperations.PipeNetwork.Blocks import Node, Pump, Reservoir, Sink, WaterPipe # noqa: E402
from DWSIM.UnitOperations.PipeNetwork.Classes import BoundarySpecification # noqa: E402
from DWSIM.UnitOperations.UnitOperations import Pump as ClassicPump # 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.")
G = 9.80665
RHO = 998.2 # water at 20 °C, kg/m3, only for the m of water printouts
MIN_HEAD_M = 15.0 # minimum service pressure at the junctions, m of water
# --- build the network --------------------------------------------------------
fs = (Flowsheet.Create("WaterDistribution")
.WithCompound("Water")
.WithPropertyPackage(PropertyPackages.SteamTables))
net = fs.AddPipeNetwork("NET-1")
# supplies: a water tower and a well with a booster pump
tank = net.AddReservoir("TANK")
well = net.AddReservoir("WELL")
n_tank, n_well, n_pump = net.AddNode("N-TANK"), net.AddNode("N-WELL"), net.AddNode("N-PUMP")
pump = net.AddPump("PU-1")
# the grid: four junctions on a loop and a branch to a fifth one
j = {t: net.AddNode(t) for t in ("J1", "J2", "J3", "J4", "J5")}
PIPES = { # tag: (length m, inner diameter m)
"P-TANK": (400.0, 0.2027), "P-MAIN": (600.0, 0.2545),
"L1": (500.0, 0.2027), "L2": (450.0, 0.1541), "L3": (500.0, 0.1541), "L4": (450.0, 0.1541),
"B1": (300.0, 0.1023),
}
p = {t: net.AddWaterPipe(t) for t in PIPES}
DEMANDS = {"D1": ("J1", 15.0), "D2": ("J2", 10.0), "D3": ("J4", 20.0), "D4": ("J5", 8.0)} # kg/s
d = {t: net.AddSink(t) for t in DEMANDS}
r = tank.As[Reservoir]()
r.ElevationM = 30.0 # the bottom of the tower is 30 m above the grid
r.LevelM = 5.0 # 5 m of water in it
r = well.As[Reservoir]()
r.ElevationM = 0.0
r.LevelM = 2.0
pu = pump.As[Pump]().BaseUnitOperation
pu.CalcMode = ClassicPump.CalculationMode.Curves
curve = pu.PumpCurveSet.CurveHead
curve.Enabled = True
curve.xunit, curve.yunit = "m3/s", "m"
curve.X.Clear(); curve.Y.Clear()
for q, h in ((0.0, 48.0), (0.02, 46.0), (0.04, 41.0), (0.06, 33.0), (0.08, 22.0)):
curve.X.Add(q); curve.Y.Add(h)
for tag, (length, diameter) in PIPES.items():
w = p[tag].As[WaterPipe]()
w.LengthM, w.DiameterM = length, diameter
w.UseHazenWilliams, w.HazenWilliamsC = True, 120.0 # ductile iron, a few years old
for tag, (_, flow) in DEMANDS.items():
s = d[tag].As[Sink]()
s.BoundarySpec = BoundarySpecification.MassFlow
s.MassFlowSpec = flow
net.ConnectChain(tank, n_tank, p["P-TANK"], j["J1"])
net.ConnectChain(well, n_well, pump, n_pump, p["P-MAIN"], j["J2"])
net.ConnectChain(j["J1"], p["L1"], j["J2"], p["L2"], j["J3"], p["L3"], j["J4"], p["L4"], j["J1"])
net.ConnectChain(j["J3"], p["B1"], j["J5"])
for tag, (junction, _) in DEMANDS.items():
net.Connect(j[junction], d[tag])
# every boundary needs a flowsheet stream: a feed for each reservoir, a product for each demand
for node, tag in [(tank, "Tower"), (well, "Well")] + [(d[t], t + "-out") for t in DEMANDS]:
s = net.AttachStream(node, tag).SetCompoundMassFlow("Water", 10.0).At(Q.Celsius(20.0), Q.Bar(1.01325))
s.Object.Calculate()
# where each block sits on the designer canvas, in pixels, so the diagram reads like a map
POSITIONS = {
"TANK": (40, 60), "N-TANK": (130, 70), "P-TANK": (250, 70),
"WELL": (40, 330), "N-WELL": (120, 340), "PU-1": (200, 330), "N-PUMP": (290, 340), "P-MAIN": (370, 340),
"J1": (460, 70), "J2": (460, 340), "J3": (780, 340), "J4": (780, 70),
"L1": (460, 205), "L2": (620, 340), "L3": (780, 205), "L4": (620, 70),
"B1": (880, 340), "J5": (980, 340),
"D1": (460, 0), "D2": (460, 420), "D3": (780, 0), "D4": (1060, 340),
}
blocks = {**j, **p, **d, "TANK": tank, "WELL": well, "N-TANK": n_tank, "N-WELL": n_well, "N-PUMP": n_pump, "PU-1": pump}
for tag, (x, y) in POSITIONS.items():
go = blocks[tag].Block.GraphicObject
go.X, go.Y = x, y
def gauge_m(node):
return (node.As[Node]().Pressure - 101325.0) / (RHO * G)
def report(title):
print(f"\n{title}")
print(" junction pressure (bar g) head (m)")
worst = None
for t, n in j.items():
hm = gauge_m(n)
print(f" {t:8s} {(n.As[Node]().Pressure - 101325.0) / 1e5:15.2f} {hm:8.1f}")
worst = hm if worst is None else min(worst, hm)
print(" pipe flow (L/s) velocity (m/s) head loss (m)")
for t in PIPES:
w = p[t].As[WaterPipe]()
print(f" {t:7s} {w.SolvedFlow * 1000:10.1f} {w.Velocity:14.2f} {w.PressureDropResult / (RHO * G):13.2f}")
q_tank = p["P-TANK"].As[WaterPipe]().SolvedFlow * 1000.0
q_pump = p["P-MAIN"].As[WaterPipe]().SolvedFlow * 1000.0
head = (n_pump.As[Node]().Pressure - n_well.As[Node]().Pressure) / (RHO * G)
print(f" tower supplies {q_tank:.1f} L/s, the pump {q_pump:.1f} L/s at {head:.1f} m of head")
print(f" lowest junction head {worst:.1f} m ({'meets' if worst >= MIN_HEAD_M else 'below'} the {MIN_HEAD_M:.0f} m minimum)")
return worst
fs.Solve()
report("Average demand (53 kg/s)")
# --- the peak hour: every demand 1.8 times the average ----------------------------
for tag, (_, flow) in DEMANDS.items():
d[tag].As[Sink]().MassFlowSpec = 1.8 * flow
fs.Solve()
report("Peak hour (1.8 times the average)")
# --- the fix: the branch to J5 goes from DN 100 to DN 150 ----------------------------
p["B1"].As[WaterPipe]().DiameterM = 0.1541
fs.Solve()
report("Peak hour with B1 in DN 150")
# back to the state of step 9 before saving: the average demand, B1 in DN 100
for tag, (_, flow) in DEMANDS.items():
d[tag].As[Sink]().MassFlowSpec = flow
p["B1"].As[WaterPipe]().DiameterM = PIPES["B1"][1]
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:
- Compound Water, property package Steam Tables
- A Pipe Network "NET-1" with:
- a reservoir "TANK" (base elevation 30 m, level 5 m) and a
reservoir "WELL" (base elevation 0 m, level 2 m)
- a pump "PU-1" after the well, on a head curve of
(0, 48), (0.02, 46), (0.04, 41), (0.06, 33), (0.08, 22) in m3/s and m
- water pipes with Hazen-Williams C = 120: P-TANK 400 m DN 200 from
the tower to J1, P-MAIN 600 m DN 250 from the pump to J2, a loop
J1-J2 (L1, 500 m DN 200), J2-J3 (L2, 450 m DN 150), J3-J4
(L3, 500 m DN 150), J4-J1 (L4, 450 m DN 150) and a branch J3-J5
(B1, 300 m DN 100)
- mass flow demands of 15 kg/s at J1, 10 at J2, 20 at J4 and 8 at J5
- Solve and report the gauge pressure of each junction in metres of
water, the flow and velocity of each pipe, and the flows of the
pump and of the tower
- Repeat with every demand 1.8 times larger, then again with B1 in
DN 150, and say which junction falls below 15 m of water
Exercises
- At the average demand, untick Available (in service) in the editor of
PU-1, so that the tower feeds the grid alone. Can it hold 15 m at every junction? Which pipe carries the most water now? - The pipes age and their C falls to 100. Solve the peak hour again with B1 in DN 150. How much head does J5 lose?
- Add a second pipe in parallel to L2 (DN 150, 450 m) and solve the peak hour with the original B1. Does it help J5, and why does it help less than enlarging B1?
- Raise the water tower by 5 m (base elevation 35 m). How does the share of the demand between the pump and the tower change at the average demand?
Further Reading¶
- L. W. Mays (ed.). (2000). Water Distribution Systems Handbook. McGraw-Hill
- T. M. Walski, D. V. Chase, D. A. Savic, W. Grayman, S. Beckwith and E. Koelle. (2003). Advanced Water Distribution Modeling and Management. Haestad Press
- E. Todini and S. Pilati. (1988). A gradient algorithm for the analysis of pipe networks. In Computer Applications in Water Supply, vol. 1, Research Studies Press, 1-20
- DWSIM User Guide: the Pipe Network unit operation
Next Steps¶
You now know how to build a network in the designer, how a loop shares its flow and how to find the pipe that limits the service pressure. Continue with Gas Gathering Network, where the gas changes its density along the pipes and the pressure decides how much each well delivers.