CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [Other] A computing time estimate script I've written. (https://www.cfd-online.com/Forums/openfoam-community-contributions/220178-computing-time-estimate-script-ive-written.html)

AndrewM4000 August 28, 2019 03:50

A computing time estimate script I've written.
 
1 Attachment(s)
Hello, fellow foamers!

When I began using rhoPimpleFoam for transient simulations that were taking a long time to finish, I was always trying to estimate what time of day it would finish based on how quickly it was getting through the first couple of (virtual) milliseconds. So I decided to automate that step with a script which parses the output of rhoPimpleFoam and gives you a running estimate of time remaining and the date & time it will finish. It assumes that the solving rate will remain roughly same up until the simulation endTime, but this seems valid for rhoPimpleFoam in the models that I've been using.

This was only designed to work with rhoPimpleFoam and it has been well tested on that. Today I also tried it on interFoam in the damBreak tutorial and it works okay on that too. So you may find this works on several transient solvers besides rhoPimpleFoam.

There is not much point in using it on any steady-state solvers since they will end whenever the solution converges, which is often long before the endTime stated in the controlDict file. However I did try it on a simpleFoam case today and while the log text is compatible with this script, it is only going to estimate how long it would take to get to the maximum iteration limit (endTime) and it cannot tell when the simulation will really end.

I've found the estimation accuracy for rhoPimpleFoam is quite good. As an example, in one simulation which took 20 hours to run its first estimate was wrong by less than 25 minutes. But this accuracy is system load dependent, so when OpenFOAM does not have 100% capacity of your computer/cluster the initial estimate can be thrown off later by a change in system load.

I thought I should post it here in case others find this useful. Please find it attached to this message. You will need Python 2.7 (or later) installed to use it.

There is some parameters documentation built in to the source code, so you can read that or run foamTime.py --help

Using this tool may require changing your case's Allrun script to read the log file during the simulation.
On Linux you could use it in a bash script for a parallel run this way:

Code:

    # Get application name
    application=$(getApplication)
    rm "log.mpirun" 2>/dev/null
    endTime=3.3
    ( sleep 10 ; tail --follow=name log.mpirun | ~/Documents/foamTime.py ${endTime} -filter -singleServe ) &
    runApplication mpirun -np 6 $application -parallel
    mv log.mpirun "log.mpirun.backup"
    sleep 2  # Ensures that tail ends by noticing the disappearance of the log file name

Some sample output looks like this:
Code:

* Estimating time remaining until OpenFOAM timestep reaches 3.3.
 simTime=0.9948
simTime=0.995
* Estimated time remaining: 12.81 hours    * ETA approximately 2019-07-31, 11:05AM.
simTime=0.9952
* Estimated time remaining: 12.80 hours    * ETA approximately 2019-07-31, 11:05AM.
simTime=0.9954
* Estimated time remaining: 12.80 hours    * ETA approximately 2019-07-31, 11:05AM.
 simTime=0.9956

Any feedback on this software is appreciated.
Thanks,
- Andrew.


All times are GMT -4. The time now is 14:43.