Many engineers tasked with running HPC applications are usually intent on monitoring their simulations to ensure the computation is progressing as expected, determine when the solution error is below typical engineering error thresholds, or verify the integrity of the physical phenomena they are simulating. While most commercial applications offer some form of visualizing or plotting this type of data within their graphical driven interfaces, the options for plotting are usually limited, and the plots themselves are unattractive or otherwise unsuitable for presenting or documenting results for others.
Gnuplot is a portable command-line driven graphic utility that exists for several platforms that was originally created to assist scientists and students visualize mathematical functions and data interactively, but it has since grown to support many non-interactive uses. Gnuplot provides several advantages to help users automate plot creation and create terrific plots. Users can setup scripts, or templates, that can be re-used across different functions or datasets. These scripts can define how the plots should be formatted, how the data used should be parsed, and so on. Gnuplot’s versatility is highlighted in the examples shown in Figures 1 through 5.
To demonstrate using Gnuplot in a way that engineers and scientists may find beneficial for monitoring their own simulations on Rescale, in addition to generating plots of their results suitable for publication, a simple 3D Reynolds-Averaged Navier-Stokes (RANS) simulation is run using Stanford University’s Unstructured (SU2) open- source, finite-volume solver. Plots are generated periodically using Gnuplot for both solution residual and aerodynamic coefficient metrics that are being monitored throughout the CFD simulation. Users can view the plots being generated as they are refreshed on the Job Status page for their particular simulation while it runs.
The process is outlined by first defining a Gnuplot command or script file wherein the format for plot is defined, the plots themselves are generated, and so forth. Within this Gnuplot command file, a simple statement is added at the end of the file to have Gnuplot reread the command file periodically. As the RANS simulation runs and the monitor files are updated, Gnuplot will generate new plots using the updated simulation results until the solver exits.
For this example, the file SU2.gnu is used.
reset # postscript set terminal postscript eps enhanced color size 5.47,3.33 font ”Verdana, 12” linewidth 2 # color definitions set border linewidth 1.5 set style line 1 lc rgb ’4dbeee’ lt 1 lw 2 cyan set style line 2 lc rgb ’a2142f’ lt 1 lw 2 red set style line 3 lc rgb ’d95319’ lt 1 lw 2 orange set style line 4 lc rgb ’edb120’ lt 1 lw 2 yellow set style line 5 lc rgb ’77ac30’ lt 1 lw 2 green set style line 6 lc rgb ’0072bd’ lt 1 lw 2 blue set style line 7 lc rgb ’7e2f8e’ lt 1 lw 2 violet # key set key bottom right Left # axes set style line 11 lc rgb ’808080’ lt 1 set border 3 back ls 11 set tics nomirror out scale 0.75 # grid set style line 12 lc rgb ’808080’ lt 0 lw 1 set grid back ls 12 set xlabel ’Iteration’ set ylabel ’Residual’ set mxtics 2 set mytics 10 set datafile separator ”,” set format ’%g’ set format y ’10 %.0s}’ set output ’residuals.eps’ plot ’history.plt’ every::4 u 1:12 t ’rho’ w l ls 1, ’history.plt’ every::4 u 1:13 t ’x-mom’ w l ls 2, ’history.plt’ every::4 u 1:14 t ’y-mom’ w l ls 3, ’history.plt’ every::4 u 1:15 t ’z-mom’ w l ls 4, ’history.plt’ every::4 u 1:16 t ’energy’ w l ls 5, ’history.plt’ every::4 u 1:17 t ’nu’ w l ls 6 set ylabel ’Lift Coefficient, CLift’ set format y ’%g’ set output ’lift.eps’ plot ’history.plt’ every::4 u 1:2 t ’CLift’ w l ls 1 set ylabel ’Drag Coefficient, CDrag’ set output ’drag.eps’ plot ’history.plt’ every::4 u 1:3 t ’CDrag’ w l ls 2 set xlabel ’Lift Coefficient, CLift’ set ylabel ’Lift to Drag Ratio, L/D’ set output ’lift-drag.eps’ plot ’lift-drag.dat’ u 1:2 t ’L/D’ w l ls 1 pause 30 reread
The command file begins by defining a terminal setting in which the postscript terminal is used. Several terminals are available within Gnuplot, and those available for use can be listed by typing at a Gnuplot prompt, ”set terminal”. Typically the postscript terminal option is preferred when generating plots to be used within documentation; whereas, svg and pngcairo terminals are preferred when output is to be used for web publishing. Options also exist for integrating mathematical formulas or text within LATEXor TEXdocuments.
Next a few line styles with colors are defined to help distinguish a number of metrics being used in a single plot involving solution residuals. The key—or legend—is positioned at the bottom right and text is left justified. A color (gray) and line weight for the axes are specified, and formatting for the tics and their placement are supplied. Once all of the plot’s formatting options are configured, the actual data is plotted using SU2’s history.plt file wherein data associated with the simulation is output for each iteration while the simulation is running.
Gnuplot includes a seemingly limitless array of formatting options. While the number of options may be daunting at first, once you have configured the charts to appear as you prefer, there’s little need to make changes for subsequent charts. You can edit just the few lines needed to update the data or functions used in making the specific plots as needed. Thus, reusability of these command files can help save precious time in the long run.
The last two lines add a thirty second delay, and then prompt Gnuplot to reread or execute the command file once again. Any data that has been added to data source file(s) will be added to the plots the next time the command file is executed; thereby, updating what is plotted with the latest changes.
On Rescale, a simple wrapper script that initiates Gnuplot with a supplied command file, places that process in the background, and runs the solver is all that is needed. Alternatively, these separate commands can be added in the ”Command” field of the Software Settings page when setting up your job on Rescale. For this specific RANS simulation example with SU2, the run-su2 wrapper script was used and can serve as an example for creating your own custom scripts.
The entire job setup can be cloned and run by clicking here. Examples of the plots generated an available while the simulation is running appear in Figures 6 through 9.
Post-processing and reporting results from simulations that have been generated from HPC applications in order to verify the integrity of the physical phenomena being modeled can be a labor intensive process for any engineer or scientist. Gnuplot offers a non-interactive means to automate much of the work involved in generating attractive plots suitable for publishing. On Rescale, Gnuplot is accessible to any of your simulations and provides the additional benefit of allowing you to easily visualize and monitor the specific metrics that are important to you while your simulation runs.
Try out the example outlined here on Rescale’s cloud-based HPC platform today!