4

Running EnergyPlus in Python as a plugin

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,

sajithwjay's avatar
445
sajithwjay
asked 2020-10-12 16:08:38 -0500
__AmirRoth__'s avatar
4.4k
__AmirRoth__
updated 2020-10-13 18:51:51 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

3

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.
Julien Marrec's avatar
29.7k
Julien Marrec
answered 2020-10-12 17:14:39 -0500, updated 2020-10-12 17:18:32 -0500
edit flag offensive 0 remove flag delete link

Comments

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

sajithwjay's avatar 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's avatar ericmartinpe (2021-08-02 15:14:33 -0500) edit
add a comment see more comments