OpenStudio Documentation

repository·develop·Indexed 20 days ago

https://github.com/natlabrockies/openstudio

A cross-platform suite of tools for building energy modeling and daylight analysis, integrating EnergyPlus and Radiance. It provides an SDK accessible via C++, Ruby, Python, and C#. The documentation covers building from source using Conan v2 and CMake Presets, C# package verification via NuGet, Ruby implementation layers, and the use of Nano::Signal for C++11 signals and slots.

Tokens
59.2K
Snippets
148
Records
274
Agent score
71%

What's inside OpenStudio

  1. Overview of OpenStudio

    develop

    OpenStudio is a cross-platform (Windows, Mac, and Linux) software collection designed for whole building energy modeling and advanced daylight analysis. It integrates with EnergyPlus for energy modeling and Radiance for daylight analysis.

    Developers can interact with the OpenStudio SDK through several programming language entry levels:

    • C++
    • Ruby
    • Python
    • C#
  2. Components included in the OpenStudio SDK 3.5.0 installer

    develop

    The OpenStudio SDK installer bundles several core components required for building energy modeling workflows. Note that the PAT (Parametric Analysis Tool) is not included in the SDK and must be installed separately from its own GitHub page.

    OpenStudio SDK 3.5.0 components:
    - EnergyPlus
    - Command Line Interface (CLI)
    - Radiance
    - Ruby API
    - C++ SDK
  3. Identify OpenStudio SDK components and dependencies

    develop

    The OpenStudio SDK 3.1.0 installer includes the following core components:

    • EnergyPlus (specifically version 9.4, which is bundled and required)
    • Command Line Interface (CLI)
    • Radiance (version 5.0.a.12, which is bundled and required)
    • Ruby API (supports Ruby 2.5.5)
    • C++ SDK

    Important Notes:

    • PAT (Parametric Analysis Tool): This is not included in the SDK or the OpenStudio Application installers. You must install it separately from the OpenStudio-PAT GitHub page.
    • EnergyPlus/Radiance: You do not need to install these separately as they are bundled. OpenStudio will use the included versions regardless of other versions installed on your system.
  4. Identify components included in the OpenStudio SDK 3.4.0 installer

    develop

    The OpenStudio SDK 3.4.0 installer bundles several key components. Note that PAT (Parametric Analysis Tool) is not included in the SDK or the OpenStudio Application installers and must be installed separately from the OpenStudio-PAT GitHub page.

    Included components:

    • EnergyPlus (v22.1.0)
    • Command Line Interface (CLI)
    • Radiance (v5.0.a.12)
    • Ruby API
    • C++ SDK
  5. Understand the components of OpenStudio Ruby

    develop

    The OpenStudio Ruby implementation is composed of four distinct layers depending on your integration needs:

    1. interpreter: The base Ruby interpreter with minimal OpenStudio initializations. It is provided via two CMake targets:
      • rubyinterpreter-declarations: An interface library that adds Ruby to the include path (used by standalone bindings).
      • rubyinterpreter: Adds Ruby to include paths and links to the Ruby library (used by the OpenStudio Ruby engine).
    2. bindings: The interface used to initialize OpenStudio API bindings for Ruby (e.g., init_openstudio_model). This is consumed by both the module and engine components.
    3. module: The standard OpenStudio Ruby bindings designed to be loaded into a standalone Ruby interpreter.
    4. engine: A complete package combining the Ruby bindings, the Ruby interpreter, and embedded files. This is specifically designed for use by the OpenStudio CLI to execute Ruby-based workflows.
  6. Understand the OpenStudio C++ Workflow vs. Classic Workflow

    develop

    Since version 3.7.0, OpenStudio uses a re-written C++ workflow by default instead of the older Ruby-based Workflow Gem. This modern workflow supports mixed-language workflows containing both Ruby and Python Measures.

    If your project requires the legacy Ruby-based implementation, you must use the classic subcommand with the OpenStudio CLI. Note that the classic subcommand is slated for future deprecation.

    # To use the legacy Ruby-based workflow
    openstudio classic
  7. Follow OpenStudio Ruby Naming Conventions

    develop

    OpenStudio uses a hybrid naming convention because much of the Ruby API is generated from C++ via SWIG. When writing code for OpenStudio, follow these rules to distinguish between C++-style bindings and pure Ruby code:

    • Top-level Module: Always use OpenStudio.
    • Classes: Use UpperCamelCase (e.g., DetailedGeometry).
    • C++-style Member Functions/Variables: Use lowerCamelCase (e.g., addVertex, timeOfDay). These are typically the SWIG-generated bindings.
    • Pure Ruby Member Functions/Variables: Use snake_case (e.g., add_vertex_ruby, time_of_day_ruby).
    • Enumerations: Use snake_case and symbols (e.g., enum items{:small_items, :big_items}).
    • Getters: Do not start function names with get_ unless the function accepts one or more arguments.
    • Unit Tests:
      • Test cases: UpperCamelCase post-fixed with _test (e.g., GeometryTest).
      • Individual tests: UpperCamelCase prefixed with test_ (e.g., test_vertex_addition).
  8. Understand ScheduleTypeLimits compatibility rules

    develop

    Compatibility between a Schedule and its required ScheduleTypeLimits is determined by the isCompatible function. When checking compatibility (with isStringent set to false), the following rules apply:

    • Unit Type: The units must be identical between the expected limits and the candidate limits.
    • Lower Limits: If a lower limit is expected, the candidate's lower limit must exist and be higher than (or equal to) the expected limit (i.e., the candidate must be more restrictive).
    • Upper Limits: If an upper limit is expected, the candidate's upper limit must exist and be lower than (or equal to) the expected limit (i.e., the candidate must be more restrictive).

    This ensures that a schedule assigned to a field cannot exceed the physical or logical bounds defined for that field.

  9. Apply const-correctness in C++

    develop

    Use const to provide compile-time guarantees and improve code safety:

    • Variables: Use const for any value that should not be modified.
    • Methods: Declare "getter" methods as const if they do not modify object data.
    • Containers: For custom containers, provide both const and non-const versions of accessors (like operator[]) to ensure usability in different contexts.

    Avoid these anti-patterns:

    • Do not overload functions based on the const-ness of input arguments (e.g., void doSomething(const std::vector<int> &p) and void doSomething(std::vector<int> &p)).
    • Do not implement both const and non-const versions of templated types unless strictly necessary.
    • Avoid unnecessary const overloads for methods that return pointers (e.g., prefer std::shared_ptr<Data> Class::getData() const over providing both const and non-const versions).
    class MyType
    {
     public:
      int value() const; // const getter
      void setValue(int t_value); // non-const setter
     private:
      int m_value;
    };
  10. How HVAC component connections work in OpenStudio

    develop

    OpenStudio uses a connection model that differs significantly from EnergyPlus. While EnergyPlus connects components using shared unique node names, OpenStudio uses explicit OS:Connection objects to join Ports between components.

    Key Concepts:

    • Ports: Every HVAC component has inlets and outlets called Ports. These are identified by an index (e.g., port "5", port "6").
    • OS:Connection: An object that references a Source Object and its Outlet Port, and a Target Object and its Inlet Port. This allows for arbitrary connections between any two components.
    • OS:Node: In OpenStudio, a Node is a component type itself within the HVAC topology, rather than just a name. While most connections involve an intermediate OS:Node, it is not strictly required; components can be connected directly via an OS:Connection.
    // EnergyPlus (Node-based)
    Coil:Heating:Fuel, ..., Node 19, Node 20, ...;
    Fan:ConstantVolume, ..., Node 20, Node 12, ...;
    
    // OpenStudio (Connection-based)
    OS:Connection,
      {connection-handle}, !- Handle
      {connection-name}, !- Name
      {source-handle},   !- Source Object
      6,                 !- Outlet Port
      {target-handle},   !- Target Object
      2;                 !- Inlet Port
  11. Understand OpenStudio's Git workflow

    develop

    OpenStudio follows a specific branching model:

    1. Feature Branches: All development work must be completed in feature branches created from the develop branch.
    2. Iteration Branches: Biweekly iterations are branched from develop to iteration.
    3. Master Branch: Releases are branched from iteration to master.

    Important: Do not make commits or development work directly to iteration or master unless you are an authorized maintainer.