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

How to set ZoneVentilation:DesignFlowRate in workspace object?

asked 2016-02-12 04:12:42 -0600

dani71's avatar

updated 2017-04-16 11:08:25 -0600

I'm trying to change the Schedule Name in the zoneVentilation:DesignFlowRate workspace objects.

To do this I retrieve all the zoneVentilation:DesignFlowRate objects using getObjectsByType. Then I iterate over the array and try to set the Schedule Name using the setString method. Unexpectedly, it returns False and no change is done.

I'm using the example in the Measure Writing Guide, following closely the "Editing EnergyPlus Workspace Objects" section, and I can't find any obvious problem.

What follows is the code I'm testing:

idfFlowRates = workspace.getObjectsByType("ZoneVentilation_DesignFlowRate".to_IddObjectType)
if not idfFlowRates.empty?
    msg("\n __ result __\n")    
    msg("  idfFlowRates[0].class ----------------------> #{idfFlowRates[0].class}\n")    
    msg("  inital value: idfFlowRates[0].getString(1) -> #{idfFlowRates[0].getString(1)}\n")
    result = idfFlowRates[0].setString(1,"Test text")
    msg("  succesfully written? -----------------------> #{result}\n")
    msg("  final value --------------------------------> #{idfFlowRates[0].getString(1)}\n")
else
    msg("array is empty \n")
end

The output of this code is:

__ result __
idfFlowRates[0].class ----------------------> OpenStudio::WorkspaceObject
inital value: idfFlowRates[0].getString(2) -> Always_On
succesfully written? -----------------------> false
final value --------------------------------> Always_On

Do you have any clue about what I may be missing here?

Note: getObjectByType function seems to be working ok because idfFlowRates is an array of WorkspaceObjects. I get the same result using : instead of _.

edit retag flag offensive close merge delete

Comments

1

For reference zone ventilation design flow rate is in the OpenStudio api now. This measure demonstrates how to use it. https://bcl.nrel.gov/node/83272

David Goldwasser's avatar David Goldwasser  ( 2016-02-12 09:37:42 -0600 )edit

Due to this bug: https://github.com/NREL/OpenStudio/is... , this measure doesn't work properly when used with an ideal air loads system, and the idf object ends with an "Always On Discrete" schedule name. We are trying to work around this using an Energy+ measure instead of an OpenStudio one.

dani71's avatar dani71  ( 2016-02-15 03:56:15 -0600 )edit

Solved,

I was using a test name instead a real schedule name. Using an existing schedule name works fine both with : or _ .

Thank you very much for your help.

dani71's avatar dani71  ( 2016-02-17 04:51:51 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
4

answered 2016-02-12 07:55:48 -0600

updated 2016-02-12 09:22:58 -0600

Arguments for the getObjectsByType method require the object name to be passed in verbatim. So replace the _ with :. Here's what I would try:

# get objects
objects = workspace.getObjectsByType('ZoneVentilation:DesignFlowRate'.to_IddObjectType) #array

# DO STUFF
if not objects.empty?

  objects.each do |object|

    puts 'Setting schedule for : #{object.getString(0)}'
    object.setString(2, schedule)

  end

end
edit flag offensive delete link more

Comments

1

"ZoneVentilation:DesignFlowRate".to_IddObjectType.valueName (with a :) and "ZoneVentilation_DesignFlowRate".to_IddObjectType.valueName (with a _) both point to the same ZoneVentilation_DesignFlowRate

Julien Marrec's avatar Julien Marrec  ( 2016-02-15 09:29:51 -0600 )edit
0

answered 2016-02-15 04:26:43 -0600

dani71's avatar

updated 2016-02-15 04:32:17 -0600

Solved,

I was using a test name instead a real schedule name. Using an existing schedule name works fine both with : or _ .

Thank you very much for your help.

edit flag offensive delete link more

Comments

1

This is not an answer, please add this as a comment

Julien Marrec's avatar Julien Marrec  ( 2016-02-15 09:28:59 -0600 )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

Careers

Question Tools

1 follower

Stats

Asked: 2016-02-12 04:12:42 -0600

Seen: 602 times

Last updated: Feb 15 '16