I got something working in python with a few blemishes. Python's recommended subprocess was interfering with multiprocessing, so I had to use the ill advised os instead.
rungroup.py
from multiprocessing import Pool
import os
import time
def run_energyplus_cmd(command_string):
print('starting ' + command_string)
start_seconds = time.time()
os.system(command_string + ' >NUL 2>&1') #concatenated string for suppressing energyplus output
elapsed_minutes = int((time.time() - start_seconds)/60*100.0)/100.0 #two decimal places
print(str(elapsed_minutes) + ' min for ' + command_string)
if __name__ == '__main__':
number_of_simultaneous_simulations = 4
#read commands.txt and split lines into array
commands_file = open('commands.txt', 'r')
commands_array = commands_file.read()
commands_file.close()
commands_array = commands_array.splitlines()
#run all commands in parallel up to number_of_simultaneous_simulations at a time
with Pool(number_of_simultaneous_simulations) as p:
p.map(run_energyplus_cmd, commands_array)
#using energyplus on the command line versus EP-Launch had different output
#cmd made <idf_name>out.eio but EP-Launch made <idf_name>.eio output files
#this is to remove all the "out" strings from the output files
folder = 'runs'
for filename in os.listdir(folder):
filename = os.path.join(folder,filename)
if not os.path.isfile(filename): continue
new_filename = filename.replace('out.', '.')
try:
os.rename(filename, new_filename)
except WindowsError:
os.remove(new_filename)
os.rename(filename, new_filename)
Here is my file organization. Folder "runs" contains all my IDFs, "weather files" contained my EPWs, and commands.txt contains the Windows cmd input.
commands.txt
C:/EnergyPlusV9-3-0/energyplus -w
"weather files/CZ03/CZ03.epw" -p run0
-d runs runs/run0.idf C:/EnergyPlusV9-3-0/energyplus -w
"weather files/CZ03/CZ03.epw" -p run1
-d runs runs/run1.idf C:/EnergyPlusV9-3-0/energyplus -w
"weather files/CZ03/CZ03.epw" -p run2
-d runs runs/run2.idf C:/EnergyPlusV9-3-0/energyplus -w
"weather files/CZ03/CZ03.epw" -p run3
-d runs runs/run3.idf C:/EnergyPlusV9-3-0/energyplus -w
"weather files/CZ03/CZ03.epw" -p run4
-d runs runs/run4.idf
Lastly, the output.
C:\Users\<YOUR NAME>\Desktop\multiprocessing>python rungroup.py
starting C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run0 -d runs runs/run0.idf
starting C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run1 -d runs runs/run1.idf
starting C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run2 -d runs runs/run2.idf
starting C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run3 -d runs runs/run3.idf
0.26 min for C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run2 -d runs runs/run2.idf
starting C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run4 -d runs runs/run4.idf
0.27 min for C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run3 -d runs runs/run3.idf
0.27 min for C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run0 -d runs runs/run0.idf
0.27 min for C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run1 -d runs runs/run1.idf
0.16 min for C:/EnergyPlusV9-3-0/energyplus -w "weather files/CZ03/CZ03.epw" -p run4 -d runs runs/run4.idf
C:\Users\<YOUR NAME>\Desktop\multiprocessing>
That should not be happening so you might want to post a bug report here. Have you looked at script-for-multiple-simulations?
Thank you, Joson! Python is a good choice. I've made it.
@Mark Kou I am having this exact problem for EnergyPlus 9.3 on our 16 core Windows Server OS. Unfortunately, I cannot easily use a python script like @JasonGlazer recommended because each IDF is paired with an EPW and the parametric generation pairs runs with some technologies in some climate zones, but not others, like heat pump water heaters in Miami vs New York, so the IDFs and EPWs pairs don't follow a simple pattern. Did you ever submit an issue on github?
@JasonGlazer I am able to reproduce the behavior consistently. The problem goes away if the individual simulations take longer to run, like a run period of one week vs one year. A strange thing I noticed is new simulation terminals take a while to display for the one week run period. I allow my server to run 24 simultaneous IDFs, but there are usually only 2 or 3 simulation terminals, and sometimes zero simulations running. Looks like the interruptions occur when there are no simulations running for half a second (best guess). Does the code use the nonexistence of running simulations to exit?
@mldichter you may be right, EP-Launch does use a timer to manage the queue of simulations and if simulations run for a very short time, that process may get messed up. I do believe the timer is set to 0.5 seconds. I am not sure that is responsible for the issue you are seeing but it is very likely related. Unfortunately, I'm not sure I can change that timer without it creating other issues. I would encourage you to reconsider using Python or another scripting tool to run simulations. You can certainly pair weather files with specific simulations.