3

How to update IDF version with Python on Window?

I would like to update IDF files through python on Windows. I know EnergyPlus includes the IDFVersionUpdater.exe GUI which lets you update one or multiple IDFs files as described here: https://unmethours.com/question/27275....

However I am looking to build a workflow that will automate the IDF update process, in addition to running the IDF and processing the energyPlus results.

I found an example library that does this for Linux and MacOS. I am looking to replicate this functionally on windows. https://pypi.org/project/idf-updater/

phillk3's avatar
33
phillk3
asked 2022-04-25 14:00:21 -0500, updated 2022-04-25 19:30:33 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

4

The IDFVersionUpdater GUI simply calls the each individual fortran utilities called TransitionV-X-X-X-to-Y-Y-Y, eg Transition-V9-6-0-to-V22-1-0. You'll find those in the PreProcess/IDFVersionUpdater folder. You can just have python do a system call to these utilities which take one argument, and that is the path to the IDF file to translate.

For it to work you should change the current directory to the EnergyPlus PreProcess/IDFVersionUpdater folder, and that folder should not be write protected (on Windows it shouldn't by default, as it installs to C:\EnergyPlusV-X-Y-Z if I recall correctly, and not in Program Files, but worst case just copy the entire PreProcess\IDFVersionUpdater folder somewhere else)

A minimal example would be something like that:

In [1]: import subprocess
   ...: from pathlib import Path

In [2]: idfs = list(Path('.').resolve().glob('*.idf'))
   ...: idfs
Out[2]:
[PosixPath('/media/DataExt4/tmp/1ZoneUncontroller.idf'),
 PosixPath('/media/DataExt4/tmp/idf2.idf')]

In [3]: TRANSITION_CLI_DIR = Path('C:\EnergyPlusV22-1-0\PreProcess\IDFVersionUpdater\')

In [4]: transition_exe = TRANSITION_CLI_DIR / 'Transition-V9-6-0-to-V22-1-0'

In [5]: subprocess.check_output([transition_exe, idfs[0]], cwd=TRANSITION_CLI_DIR)
Out[5]: b' Transition Starting\n Conversion 9.6 => 22.1\n Processing Old IDD -- V9-6-0-Energy+.idd\n Processing New IDD -- V22-1-0-Energy+.idd\n Will create new full IDFs\n Will create new IDF lines with units where applicable\n Will create new IDF lines leaving blank incoming fields as blank (no default fill)\n F\n Processing IDF -- /media/DataExt4/tmp/1ZoneUncontrolled.idf\n Processing IDF -- Processing idf objects . . .\n Processing IDF -- Processing idf objects complete.\n'

Side note, the library you linked to (idf-updater) may work with windows as well, the pypi description just says it was "Built for Linux and MacOS as windows has the IDFVersionUpdater.exe", not that it doesn't work on windows.

Julien Marrec's avatar
29.7k
Julien Marrec
answered 2022-04-26 02:28:18 -0500, updated 2022-04-26 02:30:20 -0500
edit flag offensive 0 remove flag delete link

Comments

1

Julien - thanks a bunch. I was able to get a script up and running with your suggestions. Much appreciated!

phillk3's avatar phillk3 (2022-04-27 19:17:36 -0500) edit
add a comment see more comments