Package: energyplus-wrapper
energy+ wrapperThis little library has been written in order to run energy+ simulation
in linux and windows in a thread-safe way.The main goal is to ensure a stable behavior across platform and
version, and to make the link between the e+ building model tools
written in python and the different analysis and optimization tools.InstallFor now, the package is available on PyPI, and via the github repo.pipinstallgit+https://github.com/locie/energy_plus_wrapperfor the requirements.UsageThere is two main classes in the library: the EPlusRunner and the Simulation.The first one is linked with the EnergyPlus local installation and allow to run
one or many simulation. It also ensure the compatibility between the executable
and the IDF file.The later is generated with therunner.run_oneandrunner.run_many. It
contains the EnergyPlus simulation reports and results.A small utility routineensure_eplus_rootallow to automatically download,
extract and install EnergyPlus (but only for linux for now).fromenergyplus_wrapperimportEPlusRunner,ensure_eplus_rooteplus_root=ensure_eplus_root("http://url/to/eplus/install.sh")# oreplus_root="path/to/energyplus/install/dir"runner=EPlusRunner(eplus_root)simulation=runner.run("my/idf/file.idf","my/weather/file.epw")print(simulation.reports)# be aware that the result is a complex nested dictprint(simulation.time_series)The runner.run is multi-process safe, allowing to run multiple EnergyPlus
simulation at the same time.The methodrunner.run_manyallow to run multiple simulation at the same
time. It usesjoblib.parallelunder the hood : how the simulation are
ran and how many CPU are used can be controlled byjoblib.parallel_backendfromenergyplus_wrapperimportEPlusRunner,ensure_eplus_rooteplus_root=ensure_eplus_root("http://url/to/eplus/install.sh")# oreplus_root="path/to/energyplus/install/dir"runner=EPlusRunner(eplus_root)samples={"sim01":("idf01.idf","weather01.epw"),"sim02":("idf02.idf","weather01.epw"),"sim03":("idf03.idf","weather02.epw"),"sim04":("idf04.idf","weather02.epw")}# run on 4 CPUwithjoblib.parallel_backend("loky",n_jobs=4):sims=runner.run_many(samples)print(sims.keys())run_one,run_manycommon mecanismeppycompatibilityEvery time you need to provide an idf file, you can use aeppy.modeleditor.IDFobject instead (as obtained usingeppy.openidf). This allow dynamic change of the model
without the need to rewrite one file per simulation.backupAccording to thebackup_strategy, the runner can save the
files generated by EnergyPlus in thebackupfolder. It can
save the files'always','on_error', or never (withNone).version checkAccording toversion_mismatch_action, a mismatch between the
e+ executable and the idf file version willraisean error,warnthe user or beignored.custom post-processYou can provide a custom simulation post process. By default,
the fileeplus-table.htmis parsed and put in thesimulation.reportsattribute, and all the csv files generated
by the run are parsed and put insimulation.time_series.For example, you could save all the files generated by the simulation withfrompathimportPathimportzipfilearchive_folder=Path("./archive/").abspath()defsave_and_compress(simulation):withzipfile.ZipFile(archive_folder/f"{simulation.name}.gz","w",zipfile.ZIP_DEFLATED)aszip_handler:forfileinsimulation.working_dir.files("*"):zip_handler.write(file)runner.run_one(idf,wf,custom_process=save_and_compress)