Total calculation time since siumlation start

Submitted by uhelfenstein on Tue, 12/10/2013 - 13:11

I try to visualize the speed of a running solver. To do this I want to dump into a CSV file for example the elapsed time since the first run and the current time steps. This CSV file can be visualized and periodically updated (e.g. with gnuplot or LiveGraph) to estimate the required time to finalize the simulation and to see the change of the simulation speed.
I know that the elapsed time can be computed with the thermo style "cpu". The problem with this cpu time is, that it is only for one run. Because I use "run every" the cpu time is reset after the time steps defined by the every argument. Also the thermo style "cu" isn't very meaningful because it provides not realistic values after a new run (it may be bacause the elapsed time is reset and the thermo stile "cu" is calculated by time_step/elapsed_time).
Is there an other possibility to compute or calculate the elapsed time since the first run? For instance to access the real time clock at the beginning of the simulation and substract the current time from the start time? Or is there another possibility to visualize the solver performance?

Thank you in advance for your inputs.

richti83's picture

richti83 | Sun, 12/15/2013 - 00:48

you could add your own thermo keyword to thermo.cpp to calculate starttime-now.
Add a compute_simtime function and a keyword in parse_fields().

best,
Christian.

I'm not an associate of DCS GmbH and not a core developer of LIGGGHTS®
but I have 7 years user experience using LIGGGHTS®, ParaView and LINUX

uhelfenstein | Thu, 12/19/2013 - 16:27

Hi Christian,

Thank you for the hint. I add a new compute funtion to the thermo.cpp and modified this file as well as the thermo.h that it works. The function I wrote is called cputot which means total cpu time:

void Thermo::compute_cputot()
{
double new_cpu;
static double last_cpu;
static double sum_cpu = 0;

if (last_cpu == 0) last_cpu = MPI_Wtime();
new_cpu = MPI_Wtime();
double cpu_diff = new_cpu - last_cpu;
if (cpu_diff > 0.0) sum_cpu += cpu_diff;

dvalue = sum_cpu;

last_cpu = new_cpu;
}

I am very new with this programming and I do not know if it was the best way to discribe this function, but it works well.

To the LIGGGTS input script I add the following lines to dump into a CSV file:

variable simTime equal ${dt}*step
variable simProzent equal (v_simTime+0.0001)/${SimTime2}*100
variable atoms equal atoms
variable cputot equal cputot
fix dumpSimpProg all print 1000 "${cputot},${atoms},${simProcent}"
file dumpSimProg.csv screen no title "CpuTot[s],Atoms[-],Progress[%]"

To plot a graph with a continuous refreshing, a text file with the name plot.pl was created:

set datafile separator "," #CSV file

#XY diagram
plot 'dumpSimProg.csv' using 1:2 with lines title 'column2', \
'dumpSimProg.csv' using 1:3 with lines title 'column3'

pause 2 #update interval
reread

The plotting process can be started with the command:

gnuplot plot.pl

One question remains. I had now the modified thermo.cpp and thermo.h files. Is there a good way to hanle this when I update the source code with git? Do I have to copy the files every time by hand. If the files are updated I can create a desaster by doing this. Should I propose the developers to add this function? Or is there a thread about this topic?
Sorry for this questions, but I am new in the topic of developing open source.

Regards,

Urs

ckloss's picture

ckloss | Fri, 12/20/2013 - 17:46

Hi Urs,

there is a "hidden" thermo command line switch (LIGGGHTS3), i.e. if you start

liggghts -in infile -thermo

you will get a clean thermo file with all the data you may want to have. This is much easier to filter and post-process

Christoph