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

Running EnergyPlus in Python as a plugin

asked 2020-10-12 16:08:38 -0500

sajithwjay gravatar image

updated 2020-10-13 18:51:51 -0500

To run energyplus I am using the code given in this link,

import sys
sys.path.insert(0,'C:\EnergyPlusV9-4-0') #sys.path.insert(0, '/path/to/EnergyPlusInstallRoot')
from pyenergyplus.plugin import EnergyPlusPlugin
class DummyPlugin(EnergyPlusPlugin):
    def on_end_of_zone_timestep_before_zone_reporting(self):
        return 0

The code runs without an issue. But my concern has been how touse this effectively to run a EMS in an IDF. It would be great to have an example which has successfully run an EP idf using the above technique.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-12 17:14:39 -0500

updated 2020-10-12 17:18:32 -0500

There are 17 example files that are installed with EnergyPlus that show you how to do this.

(py38)julien@ExampleFiles$ cd /usr/local/EnergyPlus-9-4-0/ExampleFiles/
(py38)julien@ExampleFiles$ ls PythonPlugin*.idf  | wc -l
(py38)julien@ExampleFiles$ ls *.py | wc -l
(py38)julien@ExampleFiles$ ls PythonPlugin*
PythonPluginAirflowNetworkOpeningControlByHumidity.idf   PythonPluginPlantLoopOverrideControl.idf
PythonPluginConstantVolumePurchasedAir.idf                   PythonPluginPlantOperation_largeOff.idf
PythonPluginCurveOverride_PackagedTerminalHeatPump.idf   PythonPluginReplaceTraditionalManagers_LargeOffice.idf
PythonPluginCustomOutputVariable.idf                               PythonPluginTestMathAndKill.idf
PythonPluginCustomSchedule.idf                                           PythonPluginThermochromicWindow.idf
PythonPluginCustomTrendVariable.idf                                 PythonPluginUserDefined5ZoneAirCooled.idf
PythonPluginDemandManager_LargeOffice.idf                     PythonPluginUserDefinedWindACAuto.idf
PythonPluginDiscreteAirSystemSizes.idf                           PythonPluginWindowShadeControl.idf

It works out of the box too.

(py38)julien@~$ mkdir tmp && cd tmp
(py38)julien@tmp$ cp /usr/local/EnergyPlus-9-4-0/ExampleFiles/PythonPluginCustomSchedule.* .
(py38)julien@tmp$ ls
(py38)julien@tmp$ cp /usr/local/EnergyPlus-9-4-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw .
(py38)julien@tmp$ energyplus --version
EnergyPlus, Version 9.4.0-998c4b761e
(py38)julien@tmp$ energyplus -w USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw -d out PythonPluginCustomSchedule.idf 
EnergyPlus Starting
EnergyPlus, Version 9.4.0-998c4b761e, YMD=2020.10.13 00:16
Initializing Response Factors
EnergyPlus Run Time=00hr 00min  1.25sec
EnergyPlus Completed Successfully.
edit flag offensive delete link more


Update: I was able to run the examples from the command prompt. :)

sajithwjay gravatar image sajithwjay  ( 2020-10-16 18:22:31 -0500 )edit

If running these with EP-Launch (or any other way besides CLI), you need to add a PythonPlugin:SearchPaths object with the path to your Python script (no quotes around the path, even if it contains spaces). Add Input File Directory to Search Path doesn't seem to work, even if your IDF and .py files are in the same folder.

ericmartinpe gravatar image ericmartinpe  ( 2021-08-02 15:14:33 -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



Asked: 2020-10-12 16:08:38 -0500

Seen: 473 times

Last updated: Oct 12 '20