Ontologies, WaTr vocabulary, and domain extensions#
Plumb compiles standard ontologies (ASHRAE 223P, WaTr, Brick) and smaller domain extensions into Python packages that interoperate cleanly. This page explains how those layers relate, how the WaTr vocabulary separates equipment concepts, and when to write a domain extension of your own.
The WaTr vocabulary mental model#
plumb.watr is compiled from WaTr
v0.3.0.rc1.
WaTr separates four questions about every unit operation so you never have
to guess where a concept belongs:
Question |
Attribute |
Example |
|---|---|---|
What physical unit is it? |
Python class ( |
|
What physical/chemical operation does it perform? |
|
|
What is that operation trying to achieve? |
|
|
What is its role in this plant? |
|
|
A SedimentationTank and a GravityThickener both perform
Process_Settling, but their objectives differ (clarifying water vs.
thickening sludge), and a unit’s role depends on how you deploy it.
Processes and objectives are ontology classes used directly as values; roles
are enumeration values under enums.values.
Class defaults vs. SHACL rules#
When an equipment class always performs a process or objective, both Python
constructors and WaTr’s ClassDefaultsRule know about it:
Python constructors fill in the most specific class default unless you supply that term or a narrower subclass.
SHACL inference (
validate()orModel.from_graph(..., infer=True)) runsClassDefaultsRuleandProcessObjectiveRule(for example, inferring disinfection fromProcess_Chlorination).Model.from_graph()withoutinfer=Truekeeps loaded graphs exactly as written without injecting defaults.
Media and mixtures#
WaTr defines freshwater as containing H₂O, and seawater, brackish water, and
brine as containing H₂O and NaCl. Fluid_Sludge is a Mix_Fluid of water
and solids — it is not a subclass of Fluid_Water, so a water-only port
rejects a sludge connection. Bundled SHACL shapes also check constituent
percentages (CompositionPercentageShape) and infer a single missing
percentage (CompositionComplementRule).
Domain extensions: Python vs. SHACL#
A domain extension (such as plumb.watr.drinking_water,
plumb.watr.asm2d, plumb.watr.seawater_ro, or plumb.s223.hvac) is a
small ontology layered on top of WaTr or S223. It uses SHACL to specialize
generic equipment classes with named ports, required processes/roles, and
compiled PropertySchema value sets.
Decide how much structure you need based on how widely it will be reused:
Goal |
Best tool |
|---|---|
Model one plant quickly |
Base classes, |
Reuse a group of quantities in one script or notebook |
A Python |
Reuse named equipment layouts across many models |
A compiled domain extension with named ports |
Enforce rules in SHACL validation or share definitions with non-Python RDF tools |
A compiled domain extension |
Worked example: plumb.watr.drinking_water#
plumb.watr.drinking_water is compiled from ontology/drinking-water.ttl.
Each stage subclasses a WaTr unit and fixes its process, objective, and
exact connection points:
Stage |
WaTr parent |
Named points |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Because ClarificationStage subclasses SedimentationTank in both Python
and RDF, queries for SedimentationTank automatically find it, and every
SHACL sh:name becomes a typed attribute on the instance:
from plumb import Model
from plumb.watr import SedimentationTank
from plumb.watr.drinking_water import ClarificationStage
with Model("urn:example:extension#"):
clarifier = ClarificationStage("clarifier")
print("is a SedimentationTank:", isinstance(clarifier, SedimentationTank))
print("processes:", list(clarifier.has_process))
print("sludge port:", clarifier.sludge)
is a SedimentationTank: True
processes: [<class 'plumb.watr.Process_Settling'>]
sludge port: <PointRef clarifier.sludge>
To build your own extension, follow Write and compile a domain package and consult the Compiler and extension reference.