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

# Simultaneously run a number of independent EnergyPlus simulations on multiple cores on Linux via a script.

Dear all,

I would like to run simultaneously a number of independent energyplus simulations on multiple cores on Linux.

There are several sources of information that explain how to do this (1-3 below)

Ref (1) explains that the energyplus executable, a number of files and windows libraries are copied in the directory where energyplus is to be executed using default idf and weather files (in.idf, in.epw).

Ref (2), for example @__AmirRoth__'s reply suggest the following script in order to run multiple energyplus simulations:

for i in glob('*.idf'):
for w in glob('*.epw'):
subprocess.call(["EnergyPlus -p %s -w %s %s" % (i[:-len('.idf')] + '_' + w[:-len('.epw')], w, i)])


My understanding is that the subprocess.call() spawns a new process, which should run independently and in parallel of the previosly spawned similar processes.

Since this solution appears be exactly what I need, but at the same time does not explicitly copy the files and libraries requested in (1), a doubt arises:

• can we execute parallel and independent energyplus simulations in this way (without copying any libraries and files as in (1)) under Linux?

• if it is possible, any experiences shared would be greatly appreciated;

• if not possible, what would be the required files and libraries to be copied under Linux and again, any experiences shared would be greatly appreciated

Thank you.

(2) "Script for multiple simulations" post on this forum: https://unmethours.com/question/4668/...

(3) "How to run EnergyPlus in multi-core cluster(Linux)?" post on this forum https://unmethours.com/question/31609...

P.S. I have asked a more concise question with similar content below Amir Roth's comment in (1), but thought that a separate discussion might be a better idea.

edit retag close merge delete

Sort by » oldest newest most voted

One option is to use the parallel gen in ruby. Example:

# gem for running jobs in parallel
require 'parallel'
num_parallel = 4
puts job
system(job)
end

more

1

Hi Matthew,

My concern is if multiple and independent energyplus runs can be run in Linux via a script as parallel processes (not via Open Studio or Launcher - I have just edited the title of my post adding "script") without copying in the energyplus executable, the idd file and libraries as described in refference (1) from my post.

Are you aware if this is possible?

Thank you.

( 2019-05-02 15:09:03 -0500 )edit

eppy will be able to run energyplus on multiple cores. It is not well documented in the user documentation - see https://eppy.readthedocs.io/en/latest....

You may be able to figure it out from the code and the unit tests

We would be mighty obliged if you can help improve the documentation.

more

My current approach is to use a python script to create a batch file that includes all the simulations, one per line. And to then pass the batch file to the 'parallel' command in linux to run the batch file. I can provide additional information if you think this would be a useful approach for you, but in the meantime here is a basic outline.

'parallel' man page: https://docs.oracle.com/cd/E36784_01/...

example usage (to run 6 jobs simultaneously): parallel -j 6 --progress --no-notice < batch.sh

and the batch.sh file would contain something like this: energyplus --weather /path_to_wth_files/AUS_VIC.Melbourne.948680_RMY.epw --output-prefix result --output-suffix C file1.idf energyplus --weather /path_to_wth_files/AUS_VIC.Melbourne.948680_RMY.epw --output-prefix result --output-suffix C file2.idf energyplus --weather /path_to_wth_files/AUS_VIC.Melbourne.948680_RMY.epw --output-prefix result --output-suffix C file3.idf

You might need to play around with this idea a little bit because my batch file doesn't look quite like that. Each line of my batch file is a call to another python script that creates a temporary directory and runs energyplus in that directory. If you go down this route (i.e. with temp directories) then you will likely hit some of the same issues I did (such as needing an Energy+.ini file in the temp directory).

Sorry that this is only a partial answer but hopefully of some use.

And lastly, I'm running on a fairly old 8-core intel machine and for my system there isn't much benefit in running more than 5-way parallel.

more

Hi Jon, Thank you for taking the time to share your experience. It is all very useful information - starting with the way you organize your batch file, the "parallel" command and the fact that for you too on an intel processor it does not make sense to run more than 5 concurrent simulations. Except small details this all coincides with the way I have organised the parallel execution. The only thing that differs from my experience is that I did not need to copy the Energy+.ini. This leaves a doubt that I might not have done it correctly. May I kindly ask you to share your observations? Thankyo

( 2019-06-14 14:53:24 -0500 )edit

Hi SantoshPhilip, Liq2519,

Looking into eppy (https://github.com/santoshphilip/eppy...) it looks like that new processes are spawn much like in the simple shell script at the end of this post.

The machine I am running this script on is an Intel, 8 core, 32 GB Ram, running Ubuntu. I do not copy any libraries in the current directories contrary to the suggestion in (1) from my original post.

My results show that: - for a small model (6 zones) compute time for running 1,2,3, ... 8 processes in parallel is the same as the compute time for running 1 process, which means that the processes run concurrently without impeding each other's performance - for a bigger model however (150 zones), the time for a single process = time for 2 parallel processes, but for a higher number of concurrent processes, the compute time of each individual process increases to such an extent that running more than 5-6 concurrent processes does not bring any speedup

This could perhaps mean that there might be a bottleneck (when running energyplus) somewhere between RAM and cache for this particular Intel chip.

It looks like then that we can run energyplus as parallel and independent processes under Linux, without copying any libraries, but currently the degree of independence is machine dependent.

Any thoughts/suggestions are welcome.

Kind regards, Julian

P.S. On the other hand, I noticed also that readvars does not work well in this parallel processes set up.

startTime=$(date +%s) run1/run.sh > ./run1/run.log & pidRun1=$!
run2/run1.sh > ./run2/run.log &
pidRun=$! .................. run8/run.sh > ./run8/run.log & pidRun8=$!
wait
echo $pidRun1,$pidRun2, ... , $pidRun8 completed endTime=$(date +%s)
durationInSeconds=$(($endTime - $startTime )) echo "It took$durationInSeconds seconds"

enter code here
 Where, run.sh is similar to:  energyplus -d run1 -w weather.epw model.idf 
more

You can use Python module multiprocessing and modify the codes in Ref (2) to run on multiple cores.

more