First time here? Check our help page!
5

How to delete an object from the idf file in an energyplus measure?

I know this is very easy in an openstudio measure, but how do I delete an object from the idf file using an energyplus measure?

Also, is there any documentation for writing energyplus measures similar to the openstudio documentation?

https://openstudio-sdk-documentation....

mldichter's avatar
2.6k
mldichter
asked 2018-01-31 14:06:09 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2018-01-31 15:02:21 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

4

Per Eric's comment below, the best way to do this is using the remove call of a Workspace Object. API documentation for the Workspace object here. You can get an instance of an object in your Workspace with the getObjectByTypeAndName or related method call. Be careful about removing workspace objects - you may end up deleting an object needed by another object.

For a tutorial on writing EnergyPlus measures, see the EnergyPlus Measures section in the OpenStudio Measure Writer's Reference Guide provides an example.

mdahlhausen's avatar
9.5k
mdahlhausen
answered 2018-01-31 17:31:23 -0500, updated 2021-07-21 10:27:29 -0500
edit flag offensive 0 remove flag delete link

Comments

@mdahlhausen I wasn't able to find the string getObjectByTypeAndName anywhere on that webpage by using Ctrl-f on the webpage. There only appears to be instructions on creating new objects and modifying fields on existing objects in an energyplus model.

Ctrl-f on getObject does result in 6 found places on that webpage though, but all 6 instances are the front of getObjectsByType on the webpage.

mldichter's avatar mldichter (2018-01-31 17:44:18 -0500) edit

That's strange, it's right here.

ericringold's avatar ericringold (2018-02-01 09:33:18 -0500) edit

Also WorkspaceObject has the method remove that works just fine.

ericringold's avatar ericringold (2018-02-01 09:55:19 -0500) edit

@Eric Ringold Yes. Your "here" link leads to a webpage with documentation on the workspace class. The "EnergyPlus Measures section" link from @mdahlhausen led to a short tutorial on writing measures, one section of which is writing energyplus measures. This is absolutely everything I need. Thanks!

mldichter's avatar mldichter (2018-02-01 09:57:24 -0500) edit

@mdahlhausen Please change your first sentence to reference @Eric Ringold's link, then I'll accept your answer.

mldichter's avatar mldichter (2018-02-01 09:59:03 -0500) edit
add a comment see more comments
2

For example, removing all EMS sensor objects:

ems_sensors = workspace.getObjectsByType("EnergyManagementSystem:Sensor".to_IddObjectType)

ems_sensors.each do |obj|
  obj.remove
end
ericmartinpe's avatar
2.1k
ericmartinpe
answered 2021-07-20 11:52:05 -0500
edit flag offensive 0 remove flag delete link

Comments

looks like this code snippet might be useful for our "Clean ResStock for Ideal Air Loads" measure @Eric

sashadf1's avatar sashadf1 (2021-07-20 16:40:37 -0500) edit
add a comment see more comments
0

Additional methods for removing EMS objects:

model.getEnergyManagementSystemActuators(&:remove)
model.getEnergyManagementSystemConstructionIndexVariables(&:remove)
model.getEnergyManagementSystemCurveOrTableIndexVariables(&:remove)
model.getEnergyManagementSystemGlobalVariables(&:remove)
model.getEnergyManagementSystemInternalVariables(&:remove)
model.getEnergyManagementSystemMeteredOutputVariables(&:remove)
model.getEnergyManagementSystemOutputVariables(&:remove)
model.getEnergyManagementSystemPrograms(&:remove)
model.getEnergyManagementSystemProgramCallingManagers(&:remove)
model.getEnergyManagementSystemSensors(&:remove)
model.getEnergyManagementSystemSubroutines(&:remove)
model.getEnergyManagementSystemTrendVariables(&:remove)

Credit to @Scott Horowitz from NREL.

You could also extend the solution provided by @Eric Martin to multiple EMS objects.

# remove EMS objects model.getEnergyManagementSystemSensors.each do |ems_obj| ems_obj.remove end model.getEnergyManagementSystemActuators.each do |ems_obj| ems_obj.remove end model.getEnergyManagementSystemGlobalVariables.each do |ems_obj| ems_obj.remove end

etc... for other EMS objects

sashadf1's avatar
1.1k
sashadf1
answered 2021-07-21 16:00:31 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments