Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Creating a Model with BuildingMOTIF

BuildingMOTIF is a Python SDK for creating, manipulating, and validating semantic building models. Here, we will demonstrate how to create a simple ASHRAE 223P model using BuildingMOTIF.

We will create a model that includes a simple HVAC system with a VAV terminal unit serving a zone. This will use BuildingMOTIF Templates, which are reusable components that encapsulate common patterns in building modeling.

Setting up BuildingMOTIF

Downloading the NREL 223P templates library
!git clone --filter=blob:none --no-checkout https://github.com/NREL/BuildingMOTIF
!pushd BuildingMOTIF && git sparse-checkout init --cone
!pushd BuildingMOTIF && git sparse-checkout set libraries/ashrae/223p/nrel-templates
!pushd BuildingMOTIF && git checkout

The following code sets up a temporary (in-memory) BuildingMOTIF instance, loads the necessary libraries, and creates an (empty) model to hold our building data.

/home/runner/work/docs.open223.info/docs.open223.info/.venv/lib/python3.12/site-packages/pyshacl/extras/__init__.py:46: Warning: Extra "js" is not satisfied because requirement pyduktape2 is not installed.
  warn(Warning(f"Extra \"{extra_name}\" is not satisfied because requirement {req} is not installed."))

Building the Model

Now, we load the templates into a ModelBuilder context, which allows us to use the templates to create our model.

We will create a reheat VAV terminal unit serving a physical space

When we are done, compile the “builder” into the model

Model has 191 triples
/home/runner/work/docs.open223.info/docs.open223.info/.venv/lib/python3.12/site-packages/buildingmotif/dataclasses/template.py:483: UserWarning: Parameters "dmp-in-mapsto, rhc-valve-in, dmp-in, rhc-water-in, dmp-command, rhc-return-water-temp, rhc-water-in-mapsto, rhc, air-in, rhc-air-out-mapsto, rhc-water-out-mapsto, dmp, sup-air-flow, sup-air-pressure, air-in-mapsto, rhc-valve-feedback, rhc-valve-in-mapsto, air-out-mapsto, sup-air-temp, dmp-out, rhc-air-in, rhc-supply-water-temp-sensor, dmp-out-mapsto, rhc-supply-water-temp, rhc-valve-command, rhc-return-water-temp-sensor, rhc-valve-out-mapsto, sup-air-pressure-sensor, rhc-valve-out, rhc-air-out, rhc-air-in-mapsto, rhc-water-out, rhc-valve, c0, dmp-feedback" were not provided during evaluation
  warnings.warn(
/home/runner/work/docs.open223.info/docs.open223.info/.venv/lib/python3.12/site-packages/buildingmotif/dataclasses/template.py:483: UserWarning: Parameters "in3-mapsto, in4-mapsto, in3, out2, out, out-mapsto, humidity-sensor, temp, exhaust-air-flow, temp-sensor, sup-flow-sensor, in-mapsto, physical-space, exh-flow-sensor, in2, in2-mapsto, relative-humidity, out2-mapsto, in4, supply-air-flow" were not provided during evaluation
  warnings.warn(

The model is now ready and contains the VAV terminal unit and the physical space it serves:

223P model generated from templates
print(model.graph.serialize())

Compiling the Model

The generated model is the “pre-inference” model, as described in Model Inference. To apply inference rules to this model, we will need to load the 223P ontology and apply the inference rules as described in that document.

Compiled model has 103352 triples
223P model with all inferred triples
print(compiled_model.graph.serialize())