Cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance
—
Core classes for creating and managing building energy models with hierarchical object relationships and template-based type safety. The model module provides hundreds of building component classes organized in a comprehensive object-oriented framework.
The primary container class for all building model objects, providing template-based access and lifecycle management.
/**
* Primary container class for all building model objects
* Inherits from Workspace and adds building-specific functionality
*/
class Model : public openstudio::Workspace {
public:
// Constructors
Model();
Model(const IdfFile& idfFile);
Model(const Workspace& workspace);
// Template-based object access
template<typename T>
boost::optional<T> getModelObject(const Handle& handle) const;
template<typename T>
std::vector<T> getConcreteModelObjects() const;
template<typename T>
T getUniqueModelObject();
template<typename T>
boost::optional<T> getOptionalUniqueModelObject();
template<typename T>
std::vector<T> getModelObjectsByName(const std::string& name) const;
template<typename T>
boost::optional<T> getModelObjectByName(const std::string& name) const;
// Simulation output connection
boost::optional<SqlFile> sqlFile() const;
bool setSqlFile(const SqlFile& sqlFile);
void resetSqlFile();
// Component operations
ComponentData insertComponent(const Component& component);
void purgeUnusedResourceObjects();
// HVAC system connections
bool connect(ModelObject sourceObject,
unsigned sourcePort,
ModelObject targetObject,
unsigned targetPort);
void disconnect(ModelObject object, unsigned port);
// Autosizing operations
void autosize();
void applySizingValues();
// Cached unique objects (automatically created as needed)
Building building() const;
Site site() const;
SimulationControl simulationControl() const;
WeatherFile weatherFile() const;
Timestep timestep() const;
RunPeriod runPeriod() const;
};Usage Examples:
#include <openstudio/model/Model.hpp>
#include <openstudio/model/Zone.hpp>
#include <openstudio/model/Building.hpp>
// Create new model
Model model;
// Access unique objects (created automatically)
Building building = model.building();
building.setName("Office Building");
// Create and access multiple objects
Zone zone1(model);
Zone zone2(model);
std::vector<Zone> allZones = model.getConcreteModelObjects<Zone>();
// Template-based access with handles
Handle zoneHandle = zone1.handle();
boost::optional<Zone> foundZone = model.getModelObject<Zone>(zoneHandle);
// Access by name
zone1.setName("Main Zone");
boost::optional<Zone> namedZone = model.getModelObjectByName<Zone>("Main Zone");Base class for all building model objects providing common functionality and resource management.
/**
* Base class for all building model objects
* Provides common functionality for hierarchy, resources, and metadata
*/
class ModelObject : public openstudio::WorkspaceObject {
public:
virtual ~ModelObject() = default;
// Object lifecycle
ModelObject clone(Model model) const;
Component createComponent() const;
// Model access
Model model() const;
// Object hierarchy
boost::optional<ParentObject> parent() const;
bool setParent(ParentObject& newParent);
std::vector<ModelObject> children() const;
// Resource management
std::vector<ResourceObject> resources() const;
std::vector<ModelObject> getModelObjectSources() const;
template<typename T>
std::vector<T> getModelObjectSources() const;
template<typename T>
boost::optional<T> getModelObjectTarget(unsigned index) const;
template<typename T>
std::vector<T> getModelObjectTargets() const;
// Simulation output
std::vector<std::string> outputVariableNames() const;
std::vector<OutputVariable> outputVariables() const;
// Economic analysis
std::vector<LifeCycleCost> lifeCycleCosts() const;
boost::optional<LifeCycleCost> createLifeCycleCost(
const std::string& name,
const std::string& category,
double cost);
// Metadata and properties
AdditionalProperties additionalProperties() const;
// EnergyManagementSystem integration
std::vector<std::string> emsActuatorNames() const;
std::vector<std::string> emsInternalVariableNames() const;
};Core geometric objects representing the building envelope and spatial organization.
/**
* Building object - overall building properties
*/
class Building : public ParentObject {
public:
Building(const Model& model);
// Geometric properties
boost::optional<double> northAxis() const;
bool setNorthAxis(double northAxis);
boost::optional<double> nominalFloortoFloorHeight() const;
bool setNominalFloortoFloorHeight(double nominalFloortoFloorHeight);
// Floor area calculations
boost::optional<double> floorArea() const;
boost::optional<double> conditionedFloorArea() const;
// Building stories
std::vector<BuildingStory> buildingStories() const;
// Spaces and zones
std::vector<Space> spaces() const;
std::vector<ThermalZone> thermalZones() const;
};
/**
* BuildingStory - floor/story organization
*/
class BuildingStory : public ParentObject {
public:
BuildingStory(const Model& model);
boost::optional<double> nominalZCoordinate() const;
bool setNominalZCoordinate(double nominalZCoordinate);
boost::optional<double> nominalFloortoFloorHeight() const;
bool setNominalFloortoFloorHeight(double nominalFloortoFloorHeight);
std::vector<Space> spaces() const;
};
/**
* Space - architectural space representation
*/
class Space : public ParentObject {
public:
Space(const Model& model);
// Geometry
boost::optional<double> directionofRelativeNorth() const;
bool setDirectionofRelativeNorth(double directionofRelativeNorth);
boost::optional<double> xOrigin() const;
boost::optional<double> yOrigin() const;
boost::optional<double> zOrigin() const;
bool setXOrigin(double xOrigin);
bool setYOrigin(double yOrigin);
bool setZOrigin(double zOrigin);
// Floor area and volume
boost::optional<double> floorArea() const;
boost::optional<double> volume() const;
// Surfaces and subsurfaces
std::vector<Surface> surfaces() const;
// Thermal zone connection
boost::optional<ThermalZone> thermalZone() const;
bool setThermalZone(ThermalZone& thermalZone);
void resetThermalZone();
// Space type and loads
boost::optional<SpaceType> spaceType() const;
bool setSpaceType(const SpaceType& spaceType);
std::vector<People> people() const;
std::vector<Lights> lights() const;
std::vector<ElectricEquipment> electricEquipment() const;
};
/**
* ThermalZone - thermal zone for HVAC
*/
class ThermalZone : public ParentObject {
public:
ThermalZone(const Model& model);
// Thermostat control
boost::optional<ThermostatSetpointDualSetpoint> thermostatSetpointDualSetpoint() const;
bool setThermostatSetpointDualSetpoint(const ThermostatSetpointDualSetpoint& thermostat);
// Zone equipment
std::vector<ModelObject> equipment() const;
bool addEquipment(const ModelObject& equipment);
bool removeEquipment(const ModelObject& equipment);
// Air loop connections
boost::optional<AirLoopHVAC> airLoopHVAC() const;
// Spaces in zone
std::vector<Space> spaces() const;
// Zone sizing
SizingZone sizingZone() const;
};Objects representing building envelope components and their thermal properties.
/**
* Surface - walls, floors, roofs, internal surfaces
*/
class Surface : public ParentObject {
public:
Surface(const std::vector<Point3d>& vertices, const Model& model);
// Surface properties
std::string surfaceType() const;
bool setSurfaceType(const std::string& surfaceType);
std::string outsideBoundaryCondition() const;
bool setOutsideBoundaryCondition(const std::string& outsideBoundaryCondition);
// Geometry
std::vector<Point3d> vertices() const;
bool setVertices(const std::vector<Point3d>& vertices);
double grossArea() const;
double netArea() const;
boost::optional<double> tilt() const;
boost::optional<double> azimuth() const;
// Construction assignment
boost::optional<ConstructionBase> construction() const;
bool setConstruction(const ConstructionBase& construction);
// Space relationship
boost::optional<Space> space() const;
bool setSpace(Space& space);
// Subsurfaces (windows, doors)
std::vector<SubSurface> subSurfaces() const;
// Adjacent surface
boost::optional<Surface> adjacentSurface() const;
bool setAdjacentSurface(Surface& surface);
};
/**
* SubSurface - windows, doors, skylights
*/
class SubSurface : public ParentObject {
public:
SubSurface(const std::vector<Point3d>& vertices, const Model& model);
std::string subSurfaceType() const;
bool setSubSurfaceType(const std::string& subSurfaceType);
// Geometry
std::vector<Point3d> vertices() const;
bool setVertices(const std::vector<Point3d>& vertices);
double grossArea() const;
// Construction
boost::optional<ConstructionBase> construction() const;
bool setConstruction(const ConstructionBase& construction);
// Surface relationship
boost::optional<Surface> surface() const;
bool setSurface(Surface& surface);
};
/**
* Construction - layered construction assembly
*/
class Construction : public ConstructionBase {
public:
Construction(const Model& model);
// Layer management
std::vector<Material> layers() const;
bool insertLayer(unsigned layerIndex, const Material& material);
bool eraseLayer(unsigned layerIndex);
// Thermal properties
boost::optional<double> thermalConductance() const;
boost::optional<double> heatCapacity() const;
// Reverse construction
Construction reverseConstruction() const;
};Core HVAC system components for air and plant loops.
/**
* AirLoopHVAC - main air handling system
*/
class AirLoopHVAC : public Loop {
public:
AirLoopHVAC(const Model& model);
// System components
Node supplyInletNode() const;
Node supplyOutletNode() const;
Node demandInletNode() const;
Node demandOutletNode() const;
// Outdoor air system
boost::optional<AirLoopHVACOutdoorAirSystem> airLoopHVACOutdoorAirSystem() const;
bool setAirLoopHVACOutdoorAirSystem(const AirLoopHVACOutdoorAirSystem& outdoorAirSystem);
// Thermal zones served
std::vector<ThermalZone> thermalZones() const;
bool addBranchForZone(ThermalZone& thermalZone);
bool removeBranchForZone(ThermalZone& thermalZone);
// Equipment on loop
std::vector<ModelObject> supplyComponents() const;
std::vector<ModelObject> demandComponents() const;
// Sizing
SizingSystem sizingSystem() const;
};
/**
* PlantLoop - hydronic loop system
*/
class PlantLoop : public Loop {
public:
PlantLoop(const Model& model);
// Loop properties
std::string fluidType() const;
bool setFluidType(const std::string& fluidType);
boost::optional<double> maximumLoopTemperature() const;
bool setMaximumLoopTemperature(double maximumLoopTemperature);
boost::optional<double> minimumLoopTemperature() const;
bool setMinimumLoopTemperature(double minimumLoopTemperature);
// Supply and demand sides
std::vector<ModelObject> supplyComponents() const;
std::vector<ModelObject> demandComponents() const;
bool addSupplyBranchForComponent(HVACComponent& hvacComponent);
bool addDemandBranchForComponent(HVACComponent& hvacComponent);
// Sizing
SizingPlant sizingPlant() const;
};
/**
* Coil heating/cooling components
*/
class CoilHeatingWater : public WaterToAirComponent {
public:
CoilHeatingWater(const Model& model, Schedule& availabilitySchedule);
Schedule availabilitySchedule() const;
bool setAvailabilitySchedule(Schedule& schedule);
boost::optional<double> ratedCapacity() const;
bool setRatedCapacity(double ratedCapacity);
void autosizeRatedCapacity();
boost::optional<double> ratedInletWaterTemperature() const;
bool setRatedInletWaterTemperature(double ratedInletWaterTemperature);
};
class CoilCoolingWater : public WaterToAirComponent {
public:
CoilCoolingWater(const Model& model, Schedule& availabilitySchedule);
Schedule availabilitySchedule() const;
bool setAvailabilitySchedule(Schedule& schedule);
boost::optional<double> designWaterFlowRate() const;
bool setDesignWaterFlowRate(double designWaterFlowRate);
void autosizeDesignWaterFlowRate();
boost::optional<double> designAirFlowRate() const;
bool setDesignAirFlowRate(double designAirFlowRate);
void autosizeDesignAirFlowRate();
};Objects for defining time-varying inputs and internal loads.
/**
* Schedule objects for time-varying inputs
*/
class ScheduleConstant : public Schedule {
public:
ScheduleConstant(const Model& model);
double value() const;
bool setValue(double value);
};
class ScheduleRuleset : public Schedule {
public:
ScheduleRuleset(const Model& model);
ScheduleDay defaultDaySchedule() const;
ScheduleDay summerDesignDaySchedule() const;
ScheduleDay winterDesignDaySchedule() const;
std::vector<ScheduleRule> scheduleRules() const;
ScheduleRule setWeekendRule(const ScheduleDay& scheduleDay);
ScheduleRule setWeekdayRule(const ScheduleDay& scheduleDay);
};
/**
* Internal load objects
*/
class People : public SpaceLoadInstance {
public:
People(const PeopleDefinition& definition);
PeopleDefinition peopleDefinition() const;
bool setPeopleDefinition(const PeopleDefinition& definition);
std::string numberofPeopleCalculationMethod() const;
boost::optional<double> numberofPeople() const;
bool setNumberofPeople(double numberofPeople);
boost::optional<double> peopleperSpaceFloorArea() const;
bool setPeopleperSpaceFloorArea(double peopleperSpaceFloorArea);
};
class Lights : public SpaceLoadInstance {
public:
Lights(const LightsDefinition& definition);
LightsDefinition lightsDefinition() const;
bool setLightsDefinition(const LightsDefinition& definition);
std::string designLevelCalculationMethod() const;
boost::optional<double> lightingLevel() const;
bool setLightingLevel(double lightingLevel);
boost::optional<double> wattsperSpaceFloorArea() const;
bool setWattsperSpaceFloorArea(double wattsperSpaceFloorArea);
};
class ElectricEquipment : public SpaceLoadInstance {
public:
ElectricEquipment(const ElectricEquipmentDefinition& definition);
ElectricEquipmentDefinition electricEquipmentDefinition() const;
bool setElectricEquipmentDefinition(const ElectricEquipmentDefinition& definition);
std::string designLevelCalculationMethod() const;
boost::optional<double> designLevel() const;
bool setDesignLevel(double designLevel);
boost::optional<double> wattsperSpaceFloorArea() const;
bool setWattsperSpaceFloorArea(double wattsperSpaceFloorArea);
};#include <openstudio/model/Model.hpp>
#include <openstudio/model/Space.hpp>
#include <openstudio/model/Surface.hpp>
#include <openstudio/utilities/geometry/Point3d.hpp>
Model model;
// Create a space
Space space(model);
space.setName("Office Space");
// Define vertices for a rectangular floor
std::vector<Point3d> vertices;
vertices.push_back(Point3d(0, 0, 0));
vertices.push_back(Point3d(10, 0, 0));
vertices.push_back(Point3d(10, 10, 0));
vertices.push_back(Point3d(0, 10, 0));
// Create floor surface
Surface floor(vertices, model);
floor.setSurfaceType("Floor");
floor.setSpace(space);
// Create walls with different heights
std::vector<Point3d> wallVertices;
wallVertices.push_back(Point3d(0, 0, 0));
wallVertices.push_back(Point3d(0, 0, 3));
wallVertices.push_back(Point3d(10, 0, 3));
wallVertices.push_back(Point3d(10, 0, 0));
Surface wall(wallVertices, model);
wall.setSurfaceType("Wall");
wall.setSpace(space);#include <openstudio/model/Model.hpp>
#include <openstudio/model/AirLoopHVAC.hpp>
#include <openstudio/model/ThermalZone.hpp>
Model model;
// Create thermal zones
ThermalZone zone1(model);
ThermalZone zone2(model);
// Create air loop
AirLoopHVAC airLoop(model);
airLoop.setName("VAV System");
// Connect zones to air loop
airLoop.addBranchForZone(zone1);
airLoop.addBranchForZone(zone2);
// Add heating coil to supply side
Schedule alwaysOn = model.alwaysOnDiscreteSchedule();
CoilHeatingWater heatingCoil(model, alwaysOn);
airLoop.supplyComponents();// Get all zones in the model
std::vector<ThermalZone> allZones = model.getConcreteModelObjects<ThermalZone>();
// Filter zones by name pattern
std::vector<ThermalZone> officeZones;
for (const auto& zone : allZones) {
if (zone.name() && zone.name()->find("Office") != std::string::npos) {
officeZones.push_back(zone);
}
}
// Get all surfaces in a space
if (!model.getConcreteModelObjects<Space>().empty()) {
Space space = model.getConcreteModelObjects<Space>()[0];
std::vector<Surface> surfaces = space.surfaces();
// Count different surface types
int walls = 0, floors = 0, ceilings = 0;
for (const auto& surface : surfaces) {
if (surface.surfaceType() == "Wall") walls++;
else if (surface.surfaceType() == "Floor") floors++;
else if (surface.surfaceType() == "RoofCeiling") ceilings++;
}
}Install with Tessl CLI
npx tessl i tessl/pypi-openstudio