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

Space and thermalzone in SDK

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

ngkhanh's avatar

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

Hello,

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

Thanks

edit retag flag offensive close merge delete

Comments

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
2

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 ?

Thank

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

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

Comments

1

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
  puts space.name.to_s
end
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
end
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 #{space.name}")
          if not space.DefaultScheduleSet.empty?    
          end
End

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

Careers

Question Tools

1 follower

Stats

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

Seen: 308 times

Last updated: Jan 01 '16