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

New measure crashed

asked 2018-05-01 02:16:29 -0600

rtsuchiya's avatar

updated 2018-05-01 06:40:53 -0600

Dear All,

I am very new to writing measures by myself.

Currently, to add natural ventilation calculation to my model, I am preparing the method based on existing one. I didn't change much but I cannot solve a problem.

I would like any tips from you to solve this.

Error message is like; "undifined method 'getSchedules' for #-----"

image description

The code of my measure is (only the part seemed to be related to this problem):

   def arguments(model)
   args = OpenStudio::Ruleset::OSArgumentVector.new

(omitted)

#populate choice argument for schedules in the model
sch_handles = OpenStudio::StringVector.new
sch_display_names = OpenStudio::StringVector.new

#putting schedule names into hash
sch_hash = {}
sch_hash << "autocalculate"
    sch_hash << "user defined"
    model.getSchedules.each do |sch|
  sch_hash[sch.name.to_s] = sch
end

#looping through sorted hash of schedules
sch_hash.sort.map do |sch_name, sch|
  if not sch.scheduleTypeLimits.empty?
      sch_handles << sch.handle.to_s
      sch_display_names << sch_name
  end
end

#add empty handle to string vector with schedules
sch_handles << OpenStudio::toUUID("").to_s

#make an argument for cooling schedule
vent_sch = OpenStudio::Ruleset::OSArgument::makeChoiceArgument("vent_sch", sch_handles, sch_display_names, true)
vent_sch.setDisplayName("Opening Area Fraction Schedule Name")
vent_sch.setDefaultValue("Always On Discrete 1 WindStack")
args << vent_sch

I am very happy if you would give me any tips about this problem.

Thank you.

edit retag flag offensive close merge delete

Comments

can you list the full error message?

mdahlhausen's avatar mdahlhausen  ( 2018-05-01 10:59:03 -0600 )edit

Not only the message shown in the picture? Would you tell me where to check?

rtsuchiya's avatar rtsuchiya  ( 2018-05-01 21:27:27 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
4

answered 2018-05-01 04:19:52 -0600

Avi's avatar

I believe that you are using OS API in E+ measure. You can read about E+ measures here.

You can look at code examples of E+ measures dealing with Schedules to get idea of what it is like. Generally speaking E+ measures is very much reading editing and writing back lines in the .idf file.

edit flag offensive delete link more

Comments

Thank you very much for your comment.

I didn't understand well about the difference between E+ measures and OS measures. For E+ measures, is it impossible to use "choose" command based on the current dataset?

Anyway I will learn more about E+ measures.

rtsuchiya's avatar rtsuchiya  ( 2018-05-01 21:39:48 -0600 )edit
3

answered 2018-05-02 11:18:45 -0600

updated 2018-05-02 11:20:01 -0600

Expanding on @Avi's answer.

The ruby object called model in your code is actually an OpenStudio::Workspace object, not an OpenStudio::Model object. Your measure is an EnergyPlus measure, which means the measure will act on a workspace, not a model, which is your model definition after everything has been converted into an EnergyPlus-readable format. Typically, you define EnergyPlus measure arguments by passing in a workspace, e.g. def arguments(workspace). You can name that variable anything you want, e.g. def arguments(flowers_and_sunshine), and it will still be passed in as a OpenStudio::Workpace object. You can't use OpenStudio::Model methods with an OpenStudio::Workspace object.

So what do you do?

You need to use the .getObjectsByType() method in the workspace object to access schedule objects. Here is some example measure code to do that.

edit flag offensive delete link more

Comments

Thank you for your help (, and I am sorry for my late response). I tried your example and that worked. Actually I just modified the measure "Add Vent Wind and Stack Open Area", so I should have tried this at first.

Anyway, thank you very much.

rtsuchiya's avatar rtsuchiya  ( 2018-06-26 01:45:34 -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: 2018-05-01 02:16:29 -0600

Seen: 227 times

Last updated: May 02 '18