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

Revision history [back]

Using Eppy, you can list all the fenestration names for Input Data File (IDF) parsed to the python script. Add the EMS program as string in python script. Append the EMS program into IDF by adding new fenestration name into while iterating the fenestration names using "for" loop. The following sample code explains in detail-

  1. from eppy import modeleditor
  2. from eppy.modeleditor import IDF
  3. iddFn = [Assign ur IDD file name with path]
  4. idfFn = [Assign ur IDF file name with path]
  5. idf = IDF(idfFn)
  6. fenNamesList = [x.Name for x in idf.idfobjects[''FENESTRATIONSURFACE:DETAILED"]
  7. emsProgramLine2 = "[Mathematical operation],"
  8. emsProgramLine3 = "[if clause],"
  9. emsProgramLastLine = "[last line of program];"
  10. programNames = []
  11. i = 0
  12. for fenName in fenNamesList:
  13. i += 1
  14. idf1.newidfobject(''FENESTRATIONSURFACE:DETAILED")
  15. program = idf.idfobjects[''ENERGYMANAGEMENTSYSTEM:PROGRAM"][-1]
  16. program.Name = 'p'+str(i)
  17. program.Program_Line_1 = [ according my code i want to assign fenName in line1 of ems program)
  18. program.Program_Line_2 = emsProgramLine2
  19. program.Program_A4 = emsProgramLine3 [and this continues based on the ems logic to be scripted
  20. idf.saveas('emsProgramAppended.idf')

In May of 2020, Python Plugin was added to EP version 9.3 by NREL, where you can script the logic in Python directly and assign the file as function for EP runtime simulation. This avoids the use of Erl and you can use or call complex mathematical models in python. Please go through the documentation to learn python plugin if you are interested (https://nrel.github.io/EnergyPlus/api/python/).