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

Running EnergyPlus in Python as a plugin

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

sajithwjay's avatar

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

To run energyplus I am using the code given in this link, https://bigladdersoftware.com/epx/doc...

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.

Regards,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

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

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

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
17
(py38)julien@ExampleFiles$ ls *.py | wc -l
17
(py38)julien@ExampleFiles$ ls PythonPlugin*
PythonPluginAirflowNetworkOpeningControlByHumidity.idf  PythonPluginLrgOff_GridStorageSmoothing.py
PythonPluginAirflowNetworkOpeningControlByHumidity.py   PythonPluginPlantLoopOverrideControl.idf
PythonPluginConstantVolumePurchasedAir.idf              PythonPluginPlantLoopOverrideControl.py
PythonPluginConstantVolumePurchasedAir.py               PythonPluginPlantOperation_largeOff.idf
PythonPluginCurveOverride_PackagedTerminalHeatPump.idf  PythonPluginPlantOperation_largeOff.py
PythonPluginCurveOverride_PackagedTerminalHeatPump.py   PythonPluginReplaceTraditionalManagers_LargeOffice.idf
PythonPluginCustomOutputVariable.idf                    PythonPluginReplaceTraditionalManagers_LargeOffice.py
PythonPluginCustomOutputVariable.py                     PythonPluginTestMathAndKill.idf
PythonPluginCustomSchedule.idf                          PythonPluginTestMathAndKill.py
PythonPluginCustomSchedule.py                           PythonPluginThermochromicWindow.idf
PythonPluginCustomTrendVariable.idf                     PythonPluginThermochromicWindow.py
PythonPluginCustomTrendVariable.py                      PythonPluginUserDefined5ZoneAirCooled.idf
PythonPluginDemandManager_LargeOffice.idf               PythonPluginUserDefined5ZoneAirCooled.py
PythonPluginDemandManager_LargeOffice.py                PythonPluginUserDefinedWindACAuto.idf
PythonPluginDiscreteAirSystemSizes.idf                  PythonPluginUserDefinedWindACAuto.py
PythonPluginDiscreteAirSystemSizes.py                   PythonPluginWindowShadeControl.idf
PythonPluginLrgOff_GridStorageSmoothing.idf             PythonPluginWindowShadeControl.py

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
PythonPluginCustomSchedule.idf  PythonPluginCustomSchedule.py
(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

Comments

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

sajithwjay's avatar sajithwjay  ( 2020-10-16 18:22:31 -0600 )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's avatar ericmartinpe  ( 2021-08-02 15:14:33 -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

4 followers

Stats

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

Seen: 970 times

Last updated: Oct 12 '20