Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

Space and thermalzone in SDK

asked 2015-12-25 09:02:22 -0500

ngkhanh's avatar

updated 2015-12-28 09:41:24 -0500


I would like to know how to get name/schedule object name applying to a thermal zone in Measure writing. in SDK , ThemalZones.Space is a standard vector while schedule object are class of Spaces object.

How to get class of parent object while we work with inheritance object. for examples Thermal zone -> Space -> Space Type. Default schedule set and Default Construction set in facility/building story/Space Type and Space


edit retag flag offensive close merge delete


Is this related to this question? What I'm wondering is if you are trying to get HVAC schedules or schedules about internal loads?

David Goldwasser's avatar David Goldwasser  ( 2015-12-28 10:52:41 -0500 )edit

Thank for reply. I make new question in order to clarify about class and inheritance relation of model. You can merge with my previous question but it's better for me when ask in separate question.

ngkhanh's avatar ngkhanh  ( 2015-12-28 11:12:17 -0500 )edit

What i want is get Number of People schedule use for space and apply it to equipment

ngkhanh's avatar ngkhanh  ( 2015-12-29 13:47:36 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-01-01 05:30:28 -0500

ngkhanh's avatar

updated 2016-01-01 07:30:46 -0500

I succeed to get schedule for equipment aviablity schedule. I am really appreciate the effort of OS team for user supporting. Thank a lots. I got schedule as follow : first try loop all thermal zone to get all space. For each space, i start to check if they have instance load assigned directly to this zone so they must have schedule there. i get space.spaceType and find around it. At the end i got schedule and assign it to equipment schedule. i add many info registers to get checking each step. Maybe it's not an efficient way but it really helps me to understand better about Ruby syntax and program structure. However, there are some points which i still want to optimize my measure :

  1. in case have many people loads in one zone or one space, i want to observe all people loads and schedule sets in each zone . The repeated if loop is not good in this case.

a)Is there any better approach for this work ?

b) My approach for central ventilation airloop schedule is making a new schedule which incorporate all Numberofpeople schedule in each zone. For this work in E+, it pretty easy with EMS and constant schedule every time zero people count in the building system is off. In OS , we need to setup schedule before running simulation, so i want to know that whether OS SDK has any method or general configuration for observing schedule.

  1. I try to make QC code for result by checking the the equipment method in thermalzone : link text but because of Model::object properties, im not able to loop through all equipment with zone.equipments.each do |equip|. How should i call a Model::object method ?


 model.getThermalZones.each do |zone|
  runner.registerInfo(" Check #{}")
  zone.spaces.each do |space|
    runner.registerInfo(" Check #{}")
    if not space.defaultScheduleSet.empty?  
        spc_default_schset = space.defaultScheduleSet
        runner.registerInfo(" #{} has schedule set #{} ")
        runner.registerInfo(" #{} has no schedule set")
    if not space.people.empty?
        space_people = space.people.get
        runner.registerInfo(" #{} has people load #{} ")
        if not Space_people.numberofPeopleSchedule.empty?
            runner.registerInfo(" #{} has occupancy schedule")
            space_sch_occ = space_people.numberofPeopleSchedule
            runner.registerInfo(" #{} has no occupancy schedule")
        runner.registerInfo(" #{} has no people load")
    if space.spaceType.is_initialized
        spc_type = space.spaceType.get
        runner.registerInfo(" #{} has space type #{} in zone #{}")
        i = 0
        spc_type.people.each do |spc_type_people|
            i= i+1
            if spc_type_people.numberofPeopleSchedule.is_initialized
                @@schd = spc_type_people.numberofPeopleSchedule.get
                runner.registerInfo("  in zone #{} has #{} has people schedule #{} ") 
                runner.registerInfo("in zone #{} has #{} people load but has no schedule ") 
        if i == 0
        runner.registerInfo("in zone #{} has no people load ") 
edit flag offensive delete link more

answered 2015-12-28 11:01:32 -0500

updated 2015-12-28 12:02:30 -0500

The 'space' object is a child of the 'building'. Building is part of model, but not everything is in it. Exterior lights for example are part of 'facility'.

There 'thermal zones' and 'space types' are just assigned to spaces, it isn't really part of a inheritance with one above the other. Both of these can be assigned to multiple spaces.

Answer Updated: code removed, see comments from @macumber for code example

But many objects like floorArea or numberOfPeople can be called directly from the thermal zone, so you don't always have to drill down.

edit flag offensive delete link more



That isn't quite right, a thermal zone may have zero to many spaces so it returns a vector of spaces. You would typically want to loop through these like this (if the vector is empty then the code in the loop will never execute):

thermal_zone.spaces.each do |space|
  # do stuff with space here
macumber's avatar macumber  ( 2015-12-28 11:12:50 -0500 )edit

The reference from a space to a thermal zone returns an optional thermal zone so this code works like David's example:

thermal_zone = nil
if space.thermalZone.is_initialized
  thermal_zone = space.thermalZone.get
macumber's avatar macumber  ( 2015-12-28 11:14:32 -0500 )edit

Thanks @macumber, I'll remove my code from answer and refer to your comments. That's what I get for not looking at the API :)

David Goldwasser's avatar David Goldwasser  ( 2015-12-28 12:01:32 -0500 )edit

i get error when try this code :

 zone.spaces.each do |space|
          runner.registerInfo("Check #{}")
          if not space.DefaultScheduleSet.empty?    

I got error with space.DefaultScheduleSet method. How i need to solve this error if i delete Space.DefaultScheduleSet , it runs well again

ngkhanh's avatar ngkhanh  ( 2015-12-29 14:42:17 -0500 )edit

Well look at the documentation or source code for the Space class. There is a defaultScheduleSet method but no DefaultScheduleSet method (method names are case sensitive).

macumber's avatar macumber  ( 2015-12-29 15:18:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops


Question Tools

1 follower


Asked: 2015-12-25 09:02:22 -0500

Seen: 314 times

Last updated: Jan 01 '16