Plumb#
Plumb lets you describe water treatment plants and building systems in plain, typed Python — and export standards-compliant RDF graphs for WaTr, ASHRAE 223P, and Brick.
Why Plumb?#
An ontology defines a shared vocabulary of equipment, substances, and relationships so analytics, controls, and digital twins can read the same plant description. Writing those descriptions directly as RDF triples is tedious: every single pipe requires connection points on both ends, matching fluid types, inverse links, and exact class names — and you only discover mistakes after running an external validator.
With Plumb, you state what the plant is in Python. Plumb checks types as you write, fills in connection points and pipes using the ontology’s own rules, validates the result, and draws a flow sheet.
Here is a small drinking-water plant modeled, instrumented, saved, and drawn in a dozen lines:
from plumb import Model, connect, flowsheet
from plumb.qudt import quantity_kinds, units
from plumb.watr import Pump
from plumb.watr.drinking_water import (
ClarificationStage,
CoagulationStage,
RapidSandFiltrationStage,
)
with Model("urn:example:plant#") as model:
intake = Pump("intake-pump")
coagulation = CoagulationStage("coagulation")
clarifier = ClarificationStage("clarifier")
sand_filter = RapidSandFiltrationStage("sand-filter")
raw_water = connect(intake, coagulation.inlet, name="raw-water")
connect(coagulation.outlet, clarifier.inlet, name="coagulated-water")
settled = connect(clarifier.clarified_water, sand_filter.inlet, name="settled-water")
raw_water.quantity("raw-turbidity", 18.0, unit=units.NTU, kind=quantity_kinds.Turbidity)
settled.sensor("settled-turbidity", kind=quantity_kinds.Turbidity, unit=units.NTU)
model.save("plant.ttl")
flowsheet(model)
Notice what you did not have to write: you never created a Pipe, never
instantiated inlet or outlet connection points for the pump, and never wrote
a single line of Turtle or SPARQL.
Install#
Plumb requires Python 3.12 or newer.
From a checkout of the repository, install with uv:
uv sync
To install into another project:
pip install git+https://github.com/gtfierro/plumb
The WaTr, ASHRAE 223P (S223), Brick, QUDT, and bundled domain packages all
ship with Plumb. To render flow sheets with flowsheet(), install
Graphviz so dot is on your PATH.
Where to go next#
This book is organized into four sections by what you want to do:
Tutorials — learn by building complete systems step by step, with every term explained as it comes up:
Build your first plant model — models, equipment, connections, ambiguity, domain packages, validation, and flow sheets.
Add measurements, sensors, and controls — physical quantities with QUDT units, reusable property sets, sensors, and actuators.
Model a building HVAC system (S223) — rooms, equipment inside equipment, port mapping (
maps_to), and walking across containers.
How-to guides — jump straight to a task when you already know what you want to accomplish:
Explanation — understand how Plumb works under the hood:
Reference — look up exact signatures, compiler rules, and generated classes: