Automate and Visualize Results of Your Simulations Using Gnuplot on Rescale



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.


Figure 1: Bassel functions from order zero up to six plotted with the default Matlab R2014 line colors


Figure 2: Klein Bottle

world_color_3d (1)

Figure 3: Natural Earth II shaded relief and water plot of the world


Figure 4: Equirectangular projection of the world


Figure 5: Animation of Bessel Function

Analysis Description

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.

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.

Simulation Solution

The entire job setup can be cloned and run by using the following  URL: https://platform.rescale. com/jobs/HfvgT/clone/.  Examples of the plots generated an available while the simulation is running appear in Figures 6 through 9.


Figure 6: Solution residuals history


Figure 7: Coefficient of lift (CLift) history


Figure 8: Coefficient of drag (CDrag) history


Figure 9: Plot of the drag ratio (L/D) versus lift coefficient (CLift)


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!

This article was written by Rescale.