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

How do you write an energyplus measure to add more fields in a custom meter

asked 2021-08-10 21:26:44 -0500

becker1212 gravatar image

updated 2021-08-11 12:04:21 -0500

Hello I am trying to write an energyplus measure that will add more fields to the end of an already existing custom meter. The custom meters I am looking to add to have a varying number of fields, so the measure will also need to be able to insert the fields at the correct index.

The goal is to write an energyplus measure to take the following object:

Meter:Custom,
  unit 1:ElectricityCooling,              !- Name
  Electricity,                            !- Fuel Type
  res ac cooling coil,                    !- Key Name 1
  Cooling Coil Electric Energy,           !- Output Variable or Meter Name 1
  res ac unitary system,                  !- Key Name 2
  Unitary System Cooling Ancillary Electric Energy, !- Output Variable or Meter Name 2

and add the following fields:

  res ac cooling coil,                    !- Key Name 3
  Cooling Coil Crankcase Heater Electric Energy; !- Output Variable or Meter Name 3

So that the final object will be:

Meter:Custom,
  unit 1:ElectricityCooling,              !- Name
  Electricity,                            !- Fuel Type
  res ac cooling coil,                    !- Key Name 1
  Cooling Coil Electric Energy,           !- Output Variable or Meter Name 1
  res ac unitary system,                  !- Key Name 2
  Unitary System Cooling Ancillary Electric Energy, !- Output Variable or Meter Name 2
  res ac cooling coil,                    !- Key Name 3
  Cooling Coil Crankcase Heater Electric Energy; !- Output Variable or Meter Name 3

My initial thought was that "insertExtensibleGroup" might be helpful but I am unsure how to actually use this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-08-11 22:50:13 -0500

You would probably be better off using pushExtensibleGroup. Meter:Custom is extensible with 2 fields per extensible group so you would need to do something like:

# find the meter you want to modify in the Idf then:
new_grp = OpenStudio::StringVector.new
new_grp  << "res ac cooling coil"
new_grp  << "Cooling Coil Crankcase Heater Electric Energy"
meter.pushExtensibleGroup(new_grp)
edit flag offensive delete link more

Comments

Hello, thanks for the help. That doesnt seem to be working for me, but I suspect it might be because I'm not grabbing the meter properly. Can you tell me if you see anything wrong with the following lines?

custom_meter = workspace.getObjectByTypeAndName("Meter:Custom".to_IddObjectType,"unit 1:ElectricityCooling" )
new_grp = OpenStudio::StringVector.new
new_grp << "res ac cooling coil"
new_grp << "Cooling Coil Crankcase Heater Electric Energy"
custom_meter.pushExtensibleGroup(new_grp)
becker1212 gravatar image becker1212  ( 2021-08-17 17:40:06 -0500 )edit

workspace.getObjectByTypeAndName returns an OptionalWorkspaceObject. Optional objects are one of the hardest things to get up to speed with in OpenStudio. You can test if they are empty? and if they are not you can get the value. Calling get on an empty optional will cause a crash.

macumber gravatar image macumber  ( 2021-08-21 23:29:42 -0500 )edit

Try this:

custom_meter = workspace.getObjectByTypeAndName("Meter:Custom".to_IddObjectType,"unit 1:ElectricityCooling" )
if not custom_meter.empty?
  custom_meter = custom_meter.get
  new_grp = OpenStudio::StringVector.new
  new_grp << "res ac cooling coil"
  new_grp << "Cooling Coil Crankcase Heater Electric Energy"
  custom_meter.pushExtensibleGroup(new_grp)
end
macumber gravatar image macumber  ( 2021-08-21 23:30:38 -0500 )edit

Your Answer

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

Add Answer

 

Question Tools

1 follower

Stats

Asked: 2021-08-10 21:26:44 -0500

Seen: 208 times

Last updated: Aug 11