How natlabrockies/openstudio works
Purpose and entry points
OpenStudio is a cross-platform C++ SDK for whole-building energy modeling, EnergyPlus simulation, and Radiance daylight analysis. Primary user-facing entry point is the openstudio CLI at src/cli/main.cpp, which dispatches run/update/measure-management commands. The SDK exposes native and generated APIs to C++, Ruby, Python, and C#.
Build and distribution
CMake defines the native build graph and platform packaging; Conan supplies locked third-party dependencies. Core build roots are CMakeLists.txt, conanfile.py, and src/lib/CMakeLists.txt. CI builds Windows, macOS, and Linux variants through GitHub Actions. The repository packages an SDK/CLI rather than a web service.
Core model domain
The central abstraction is an in-memory, object-oriented building model: geometry, constructions, schedules, HVAC, plant equipment, loads, controls, and simulation settings. src/model/Model.hpp and src/model/ModelObject.hpp establish the object graph; concrete domain objects such as src/model/Building.hpp and src/model/AirLoopHVAC.hpp compose it. This model is the main boundary between authoring APIs and downstream translators/workflows.
Schema, workspace, and persistence
Energy-model object definitions and generic IDF workspaces underpin model serialization and translation. src/utilities/idd/IddFile.hpp represents IDD schemas; src/utilities/idf/Workspace.hpp and src/utilities/idf/IdfFile.hpp manage IDF-like object graphs/files. Version migration is a separate boundary: src/osversion/VersionTranslator.hpp upgrades older OpenStudio model formats before normal model processing.
Translation and simulation adapters
The EnergyPlus adapter converts the OpenStudio model to EnergyPlus input and can reconstruct supported models from EnergyPlus workspaces. Its orchestration boundaries are src/energyplus/ForwardTranslator.hpp, src/energyplus/ReverseTranslator.hpp, and src/energyplus/GeometryTranslator.hpp; per-object mapping is decomposed under src/energyplus/ForwardTranslator/. Other format/engine adapters include gbXML (src/gbxml/ForwardTranslator.hpp), Radiance (src/radiance/ForwardTranslator.hpp), CONTAM airflow (src/airflow/contam/ForwardTranslator.hpp), ISO model (src/isomodel/ForwardTranslator.hpp), and glTF (src/gltf/GltfForwardTranslator.hpp).
Workflow execution pipeline
An OpenStudio Workflow (.osw) is parsed into workflow steps and executed by the CLI. src/workflow/OSWorkflow.hpp coordinates staged execution: initialization, model measures, translation, EnergyPlus measures/simulation, reporting measures, post-processing, and cleanup (src/workflow/RunInitialization.cpp, src/workflow/RunTranslator.cpp, src/workflow/RunEnergyPlus.cpp). Inputs include .osm, .osw, weather files, measures, and EnergyPlus resources; outputs include translated simulation inputs, logs, result artifacts, and EnergyPlus SQLite results accessed through src/utilities/sql/SqlFile.hpp.
Extensibility and language runtimes
Measures are plug-ins that mutate models, generated EnergyPlus inputs, or reports through a runner/argument/output contract in src/measure/OSMeasure.hpp, src/measure/OSRunner.hpp, and src/measure/OSArgument.hpp. Embedded Ruby and Python engines execute measure code (ruby/engine/RubyEngine.hpp, python/engine/PythonEngine.hpp). SWIG-facing interface files and modules provide SDK bindings: ruby/module/openstudio_rb.cpp, python/module/openstudio.py, and csharp/openstudio_csharp.cpp.
Shared services and external dependencies
src/utilities provides cross-cutting filesystem, logging, JSON/XML, geometry, units, weather/CSV/workflow parsing, and BCL component support. The major external execution/services boundary is EnergyPlus; Radiance is an advanced daylight engine. BCL supports local and remote component catalogs via src/utilities/bcl/LocalBCL.hpp and src/utilities/bcl/RemoteBCL.hpp. Resources and reference inputs bundled for workflows/translators reside under resources/energyplus, resources/model, and resources/workflow.
Main entry points: RunEnergyPlus.cpp Workflow stages · Model.hpp OpenStudio Model · OSMeasure.hpp Measure plug-in contract · ForwardTranslator.hpp EnergyPlus translators
Components 19
Build & distribution
- CMake build graph
CMakeLists.txt - Conan dependencies
conanfile.py
SDK model & persistence
- OpenStudio Model · Central in-memory building-model boundary.
src/model/Model.hpp - Domain model objects · Building, HVAC, geometry, schedules, loads, and controls.
src/model/AirLoopHVAC.hpp - Version translator
src/osversion/VersionTranslator.hpp - IDD schemas
src/utilities/idd/IddFile.hpp - IDF workspace & files
src/utilities/idf/Workspace.hpp
Workflow & simulation
- openstudio CLI
src/cli/main.cpp - OSWorkflow coordinator · Runs staged .osw execution.
src/workflow/OSWorkflow.hpp - Workflow stages · Initialization, translation, EnergyPlus execution, and cleanup.
src/workflow/RunEnergyPlus.cpp - EnergyPlus translators · Forward, reverse, and geometry translation.
src/energyplus/ForwardTranslator.hpp - EnergyPlus
- Simulation SQL results
src/utilities/sql/SqlFile.hpp - Other engine translators · gbXML, Radiance, CONTAM, ISO model, and glTF.
src/radiance/ForwardTranslator.hpp - Bundled resources · EnergyPlus, model, and workflow resources.
resources/energyplus
Extensions & bindings
- Measure plug-in contract · Measures mutate models, inputs, or reports.
src/measure/OSMeasure.hpp - Ruby & Python engines
ruby/engine/RubyEngine.hpp - Language bindings · C++, Ruby, Python, and C# access the native SDK.
ruby/module/openstudio_rb.cpp - BCL component catalogs · Local and remote measure/component catalogs.
src/utilities/bcl/RemoteBCL.hpp
Connections 23
- CMake build graph → Conan dependencies: resolves dependencies
- CMake build graph → openstudio CLI: builds
- CMake build graph → Language bindings: builds generated APIs
- openstudio CLI → OSWorkflow coordinator: runs .osw
- openstudio CLI → Version translator: updates models
- OSWorkflow coordinator → Workflow stages: coordinates
- Workflow stages → OpenStudio Model: loads and modifies
- Workflow stages → Measure plug-in contract: executes
- Workflow stages → EnergyPlus translators: translates
- Workflow stages → Simulation SQL results: collects results
- OpenStudio Model → Domain model objects: contains
- Version translator → OpenStudio Model: upgrades into
- OpenStudio Model → EnergyPlus translators: exports
- OpenStudio Model → Other engine translators: exports
- IDD schemas → IDF workspace & files: defines objects
- IDF workspace & files → EnergyPlus translators: simulation input/output boundary
- EnergyPlus translators → EnergyPlus: generates input and invokes
- EnergyPlus → Simulation SQL results: produces
- Measure plug-in contract → OpenStudio Model: model measures mutate
- Measure plug-in contract → Ruby & Python engines: executes through
- Ruby & Python engines → Language bindings: uses SDK APIs
- BCL component catalogs → Measure plug-in contract: supplies components
- Bundled resources → Workflow stages: provides reference inputs