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

Cant run IdfObject.load

asked 2018-02-17 20:09:25 -0600

SteveF gravatar image

updated 2018-03-11 10:52:47 -0600

I'm trying to run IdfObject.load code from the Reporting section of the Measure Writers Guide but not having any success. I am expecting it to produce a similar result to the Add Output Variable measure on BCL, ie append lines to the in.idf file in my model directory.

I am using OS 2.3.0 on Windows 10. I've got version numbers in the description field in the measure so I can tell from the GUI what version of the code I am running (not always obvious) and I have tried running as both an Energyplus measure (which seems logical as I am trying to modify the idf file) using the Workspace object and as an OpenStudio measure using the model object as the Add Output Variable measure does.

The codebelow is fromthe Energy Plus measure version:

```

#start the measure
class AddAllMonthly < OpenStudio::Ruleset::WorkspaceUserScript
#V1 initial dev, use workspace instead of model in class definition.  Measure failed to run using Model in class definition
#V2 V1 ran but no output or messages.  Add Workspace into def and super statements.  No improvement
#V3 change variable 'steve' back to  as per meaasure writing guide.  Runs, no change to idf
#V4 check with Workspace in class definition and nothing in method or super definition as per downloaded code
#     Runs, no info messages or changes to idf



   #define the name that a user will see, this method may be deprecated as
      #the display name in PAT comes from the name field in measure.xml
      def name
        return "addAllMonthly"
      end



  # human readable description
  def description
    return "V4 test using Energy plus measure and using Workspace object"
  end

  # human readable description of modeling approach
  def modeler_description
    return ""
  end


  #code copied from Measure writing guide
  def energyPlusOutputRequests(runner, user_arguments)
    super(runner, user_arguments)

runner.registerInfo("Started Output requests method")  #line added for debugging

result = OpenStudio::IdfObjectVector.new

# use the built-in error checking
if !runner.validateUserArguments(arguments(), user_arguments)
  #runner.registerInfo("Error check")  #line added for debugging v8
  return result
end

result << OpenStudio::IdfObject.load("Output:Variable,,Site Outdoor Air Drybulb Temperature,Timestep;").get
result << OpenStudio::IdfObject.load("Output:Variable,,Site Outdoor Air Humidity Ratio,Timestep;").get
result << OpenStudio::IdfObject.load("Output:Variable,,Site Outdoor Air Relative Humidity,Timestep;").get
result << OpenStudio::IdfObject.load("Output:Variable,,Zone Air Temperature,Timestep;").get
result << OpenStudio::IdfObject.load("Output:Variable,,Zone Air Humidity Ratio,Timestep;").get
result << OpenStudio::IdfObject.load("Output:Variable,,Zone Air Relative Humidity,Timestep;").get
    return result

    runner.registerInfo("Completed Output requests method")  #line added for debugging
    end #end the OutputRequests method

end #end the measure

#this allows the measure to be use by the application
AddAllMonthly.new.registerWithApplication

```

Any help/pointers would be greatly appreciated

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-03-10 03:18:05 -0600

SteveF gravatar image

Solved it. The key is that I was looking at the reporting section of the measure writers guide. If You use the GUI to create a new measure and select a reporting measure this will give a template with the required include statements and the correct scope definitions (query my terminology on the last, I'm not Ruby competent). Drop the required code in and the idf file is updated as required.

This is not particularly intuitive though; I needed to modify the idf which I thought should happen prior to running the energy plus simulation. The documentation says that reporting measures are run last in the workflow.

edit flag offensive delete link more

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

Stats

Asked: 2018-02-17 20:09:25 -0600

Seen: 93 times

Last updated: Feb 17 '18