March 29, 2019
Prepared by:
Applied Programming Technology, Inc.
Bloomsburg, PA 17815
Prepared for:
U.S. Nuclear Regulatory Commission
Under Contract: 31310018C004
- Recommendations for Improving Plotting Tools For SNAP Visualization
AptPlot is a WYSIWYG plotting Java™ application derived from XMGR/ACGrace which supports parsing the plot files generated by a variety of analysis codes, including TRACE, FAST, PARCS, RELAP5, and MELCOR among others, as well as experimental data stored in the NRC Databank format.
AptPlot supports a variety of 2D plots such as: line plots, bar graphs, pie charts, and axial plots. These plots can be generated through the AptPlot user interface, its batch processing system, or as part of a SNAP Job Stream. Job Stream submission allows the plot generation to occur automatically after the analysis code completes.
This document contains the recommendations to implement additional plotting capabilities beyond those currently available in AptPlot and SNAP. The existing plotting capabilities in AptPlot and SNAP are discussed in Section 2. Section 3 describes the results of a general survey of the available plotting packages which could be used as a replacement to AptPlot.
The addition of 3D plotting capabilities was a primary focus during assessment of the various plotting packages. It should be noted that while the ability to generate 3D plots is available in all of the approaches, the plot file formats generated by the different analysis codes generally have very limited 3D mesh data available. Currently, this necessitates manual entry of the coordinate data along with a mapping of the individual data channels to each mesh location. Section 4 includes a discussion on 3D mesh generation utilities that are proposed for the TRACE, PARCS and FAST codes. Section 5 provides recommendations for improving AptPlot as well as interfacing additional plotting packages to SNAP.
Currently, plots can be generated from analysis code plot files and NRC databank files using AptPlot, MATLAB/Octave or the SNAP Animation Plug-in. In addition, PyPost provides the ability to read the various plot files and export the data to different applications through Python scripting.
AptPlot is a stand-alone application for generating plots. It is derived from XMGR/ACGrace and includes an extensive set of capabilities for 2D plot generation. Simple 3D surface plots have been recently added to AptPlot through the Jzy3D library as a proof of principle exercise. These surface plots show an isometric display of the 3D surface with a dynamic color range for the Z coordinate. The 3D data currently operates on the existing XYZ data set type, and can be selected from the Graph Type drop-down list. There are no 3D vector mathematical operations built into AptPlot at this time and the 3D plot does not support user customization.
AptPlot includes extensive batch processing capabilities. The batch format controls the generation, appearance, and layout of plots. This includes properties like titles, axis colors, line types, etc. A secondary batch processor supports manipulating data sets with automatic interpolation of the time scales. The AptPlot Analysis Code Support (ACS) plug-in provides the ability to retrieve data sets from plot files, perform mathematical operations to derive data, and set values into local AptPlot variables.
The AptPlot save format is ASCII text. An apf file includes the batch commands and all of the data sets required to recreate the graph. AptPlot is interfaced with SNAP in multiple locations. Most custom table editing dialogs in the Model Editor support plotting the data in AptPlot through the right-click menu. Jobs loaded into a local Calculation Server can be opened in AptPlot through the right-click menu or the main toolbar in Job Status. SNAP Job Streams include two job steps for using AptPlot to generate plot files: the AptPlot step that includes a GUI for defining plot data, and the AptBatch step which runs a user-supplied AptPlot batch script on the provided plot files.
The AptPlot ACS plug-in was updated in the last few years to provide an improved user interface for building axial plots for the TRACE and FRAPCON plot files. This user interface follows the general design and layout as the time-dependent plots, and is supported by existing training materials and a detailed users’ manual section.
The SNAP-MATLAB library provides the ability to access plot data from COBRA-IE, MELCOR, RELAP5, TRACE and NRC databank (via EXTDATA) files from MATLAB. Using the methods provided by the interface, a user can import data from a file into a MATLAB array. As an array, the data can be manipulated using all of the inherent functions of MATLAB. In addition, various other methods are provided for purposes such as retrieving information about plot variables, switching between British and S.I. units, managing open files, etc.. This library can also be used with the Octave, a free MATLAB clone.
The SNAP Model Editor can animate completed calculations through the Animation Plug-in. This plug-in includes a wide range of custom display beans for rendering the plot data to the user. One of the display beans is a 3D bar graph bean. This bean displays the values from a regular grid of user specified plot channels. The height of the 3D bars is the scaled value from the plot file at the current calculation time. This bean is limited in that it requires the user to build the regular rectangular grid of channel names.
PyPost consists of a Python library and stand-alone Java application designed to provide advanced post-processing capability for engineering analysis codes and experimental data results. Although the PyPost distribution includes Jython, a pure Java Python interpreter, it can also be used with the standard CPython interpreter. PyPost can be used to query and extract time-dependent plot data from several engineering analysis codes as well as read experimental data stored in NRC Databank format. In addition, PyPost can be used to:
-
Read and write data to and from Microsoft Excel and Open Office spreadsheets.
-
Read and write data to and from ASCII files.
-
Perform a wide range of mathematical operations on time-dependent vector data with automatic interpolation over the time scales.
-
Interact directly with AptPlot to generate plots in a wide range of formats.
PyPost and the MATLAB/Octave library are currently available through and maintained by the SNAP User's Group.
A survey of the following plotting packages was performed to determine possible replacements for AptPlot: ParaView, MATLAB, SciDav, Veusz, GnuPlot, Matplot, PLPlot, and SigmaPlot. Of these packages, the two packages that merited further investigation are ParaView and MATLAB/Octave. The other packages were determined to lack required functionality (GnuPlot, Matplot, SigmaPlot, PLPlot), or compare unfavorably to ParaView (Veusz, SciDav). Table 3 -1 below provides a brief overview of the software packages.
| Software | ParaView | MATLAB | Octave |
|---|---|---|---|
| Language | C++ | C++ | C++ |
| Platform Independent | No | No | No |
| License | BSD | Licensed | GPL3 |
| Developer | NTESS (Sandia) | MathWorks | GNU |
| Open Source | Yes | No | Yes |
| Scripting Language | Python | MATLAB Script | MATLAB Script |
| Last Release | V 5.6.0 Nov 6, 2018 | R2018B - Sept 12, 2018 | 4.1.1 - Aug 9, 2018 |
Table 3‑1: Software Overview
ParaView is a stand-alone scientific plotting and visualization software package. It was produced by NTESS (Sandia) under DOE funding. ParaView includes headless execution though Python script support, and also includes a substantial GUI with extensive capabilities.
-
Python Scripting language
-
BSD License
-
Actively Being Maintained
-
Online Documentation and Tutorials
-
Open Source
ParaView uses Python as its scripting language. This is advantageous as SNAP uses Python code for scripting capabilities in Numerics, Job Stream Sequences, and Job Step Pre/Post Execution Scripts. Using Python as the scripting language for plot generation reduces the training required to familiarize new users.
ParaView is provided under the business friendly BSD License. This license allows modifying and redistributing ParaView and preserves the license of derivative works.
The most recent stable version of ParaView was released in November of 2018. The project is actively being maintained which means that any issues encountered with ParaView can be reported to the maintaining body for resolution.
A large suite of documentation and tutorials are available to introduce users to the ParaView user interface and to support building a ParaView package to parse plot files generated by analysis codes.
ParaView is an open source application. Changes to the source code can be contributed back to the maintainer for inclusion in the main branch.
-
Platform Dependent Builds (Written in C++)
-
No Plot File Parsing
-
Limited Mathematical Operations
-
User-interface Limitations
-
No Job Stream Support
ParaView is a C++ application and all packages written for it must also be written in C++. This precludes the application from being platform independent.
The existing analysis code plot file parsing libraries are written in Java. The development of JNI (Java Native Interface) libraries would be required to allow ParaView to share the existing plot file parsing libraries currently used by AptPlot and SNAP. These JNI libraries are themselves platform dependent, and would need to be developed, tested, and maintained for the supported operating systems.
ParaView does not appear to support the full set of mathematical operations included with AptPlot and PyPost. 3rd party “Filter” plug-ins to ParaView may provide some capabilities, but the implementation is non-trivial.
The user interface for ParaView is not a significant improvement over AptPlot. It lends itself to plotting 3D mesh data with a limited number of channels as one might see in fluid dynamics type applications. It would be possible to use ParaView as a server to drive plot generation, but this would require the development of a custom user interface.
There currently is no job stream support for embedding a ParaView script in a job stream. A script-based job step could be implemented with minimal effort, however creating a GUI based job step with functionality similar to the existing AptPlot GUI job step could require a significant effort.
MATLAB is a very popular script-based mathematical engine. Currently SNAP supports interfacing with MATLAB through functions in the Model Editor. The existing SNAP-MATLAB library supports reading most of the same plot file formats as AptPlot with the notable exception of PARCS and NRC Databank files. A pending update will support reading NRC Databank data that has been converted to EXTDATA format. Currently there is no support for executing MATLAB as part of a job stream.
Octave is an open-source work-alike to MATLAB. It is freely available and is licensed to allow modifications to the code base, but otherwise can be considered equivalent to MATLAB. It is included in this section as it shares the listed pros and cons.
-
Existing Plot File Support (TRACE, RELAP, etc)
-
Advanced Mathematical Algorithms
-
Supports Headless Execution
SNAP includes a MATLAB library for parsing plot files. This support is through a MATLAB plug-in library that allows a MATLAB script to import channels from a plot file as data arrays. This allows MATLAB to produce 2D plots from the data. Additional functionality would be required to generate 3D mesh data from plot files.
MATLAB is an advanced mathematical calculation engine. This includes the capability to perform 3D vector manipulations without additional development.
Octave and MATLAB can be executed in headless mode. When running in this mode the MATLAB script must be entered in an ASCII text file that is provided with submission.
-
Limited GUI user-interface.
-
Platform Dependent Builds (Written in C++)
-
No existing job stream support
The user interface for interacting with MATLAB is primarily a script text editor. The current state of script execution is maintained, but there is a learning curve for building and interacting with the application. Once a plot is created, a separate plot GUI is available, but this is a secondary interface with limited capabilities.
MATLAB is a C++ application which precludes the application from being platform independent. SNAP users would be responsible for downloading and installing a current version of MATLAB or Octave independently from SNAP.
There currently is no job stream support for embedding a MATLAB script in a job stream. A script-based job step could be implemented, but replacing the existing AptPlot GUI job step would require a substantial effort.
The plot files generated by analysis codes are typically used to create time dependent plots of the various data points. While this time dependent data is easily handled by the existing file parsing routines, there is also a need to generate 2D and 3D plots at selected time values. Spatial data is required to create 2D axial and 3D surface plots. The plot file formats generated by the various analysis codes generally have very limited 2D and 3D mesh data available. Currently, this necessitates manual entry of the coordinate data along with a mapping of the individual data channels to each mesh location.
The TRACE XTV file includes component descriptors which provide some spatial data. The hydraulic components include axial length data, and heat structures include fine mesh and coarse mesh axial length. Vessel components include 3D spatial data for the lengths of each axis. However the XTV file does not include mapping data needed to identify relative 3D coordinates of components. PARCS, FAST and MELCOR do not include spatial geometry data in the plot files directly.
The TRACE XTV plot file includes data that will be used to generate 3D coordinate data for vessel components and individual heat structures. This component data is currently used to generate axial plots in AptPlot. Coupled TRACE/PARCS cases will support using the MAPTAB file and PARCS input file to build 3D meshes for the PARCS assembly data.
Vessel components are the 3D hydraulic component in the TRACE plug-in. A set of 3D vessel data can be built by generating clipping slices through the hydraulic volume, and selecting an existing plot file channel prefix and time value. The resulting 3D data set will include the volume labels along two axes, and the plot file data for the third axis.
Example 1: The user selects axial level 3 in vessel 20, the plot file variable TLN (Liquid Temperature), and the time 100.0. The generated 3D Mesh would include an entry for each volume in level 3 of the vessel. The X and Y coordinate values of an entry would be the position of the cell-center, relative to the origin of the vessel. The Z coordinate value of an entry would be the liquid temperature value of the cell at 100.0 seconds. If 100.0 seconds does not correspond to an existing plot record the Z values will be linearly interpolated from the adjacent time steps.
Example 2: The user wants to generate a 3D plot of the average void fraction inside a vessel at time 100.0. The user selects vessel 20, the plot file variable ALPN (Void Fraction), the time 100.0, and specifies that the average value is desired. The generated 3D mesh would then include an entry for each planar cell in the vessel. The X and Y coordinate values for each entry would be the cell-center position of the planar cell, relative to the origin of the vessel. The Z coordinate value for the entry would be the calculated average void fraction for that planar cell at time 100.0. If 100.0 seconds does not correspond to an existing plot record the Z values will be linearly interpolated from the adjacent time steps.
Heat structures in TRACE include a 2D array of temperature data, with the two axes being axial and radial. The 3D mesh generator will build a mesh for the temperature of a heat structure. The Y and X axes will contain the axial and radial lengths respectively, while the Z axis will contain the temperature value at a user specified time. It should be noted that this data is only available when using the full graphics level in the TRACE model.
Example: The user wants to generate a 3D plot of the fuel temperature for heat structure 100 at 200.0s. The user selects heat structure 100.0, selects RFTN (Temperature), and the time 200.0s. The generated mesh will include an entry for each axial and radial node in the heat structure. The X and Y values will contain the cell-centered position of the mesh. The Z coordinate value will be the temperature of the node at time 200.0s. If 100.0 seconds does not correspond to an existing plot record the Z values will be linearly interpolated from the adjacent time steps.
The TRACE analysis code also supports coupling with PARCS. Coupled cases include a MAPTAB file that defines how the PARCS assembly numbers map to the thermo-hydraulic components in a TRACE model. This data can be used, in combination with the PARCS input file, to build the X and Y coordinates of a 3D mesh. The Z value of the mesh can be calculated from the volumes that correspond to assembly locations in the MAPTAB file.
Example: The user wants to generate a 3D Plot of fuel temperature 2.0m from the bottom of the assemblies in a coupled TRACE/PARCS case at 200.0 seconds. The user selects the PARCS plot variable TFU (Fuel Temperature), the axial location 2.0m, and the time 200.0 seconds. The generated 3D mesh will include a value for each assembly in the PARCS input file. The X and Y coordinate values will be the center line position of the assembly relative to the upper left corner of the core. The z coordinate value is the inside surface temperature of the heat structures that correspond to the assembly at the axial node that corresponds to 2.0m from the inlet.
The PARCS analysis code does not include any 3D coordinate data in the binary plot file. The spatial information regarding assembly location is included in the PARCS input file. The 3D mesh generator for the PARCS analysis code will retrieve the data from the PARCS input file to define the X and Y coordinate values for assembly locations. The z coordinate values will be retrieved from the plot file for the target assembly.
Example: The user wants to build a 3D plot of the Doppler temperature for axial level 10 at time 200.0 seconds. The user selects the PARCS plot variable TDOPL, the axial level 10 and the time 200.0s. The mesh generator builds an XYZ data set where the X and Y values correspond to the cell-centered assembly location relative to the upper left corner of the core. The Z values will be the plot value for TDOPL at axial level 10 for the assembly at time 200.0s
The FAST analysis code mesh generation will build regular rectangular grids of data where the fuel pin geometry is used to build the X and Y coordinates and a user selected plot channel defines the Z value.
Example: The user selects plot channel FBURNUP and time 150 Days. The 3D Mesh generator builds an XYZ data set where the X and Y coordinates correspond to the radial node position, and axial node position respectively. The Z coordinate shows the FBURNUP corresponding to the X and Y coordinates.
There are several areas that the analysis code plotting tools can be expanded and improved. These include development of 2D and 3D mesh utilities, integration of new plotting packages such as ParaView with SNAP, creating job stream steps for ParaView and MATLAB/Octave, and a UI refactoring of AptPlot.
Support for 3D surface and contour plotting will require generation of 3D coordinate data. A stand-alone application can be developed that builds 3D mesh data, which can then be used by existing plotting packages to generate 3D plots. This application would use additional input obtained from the models where possible to construct the spatial coordinates of each data channel. This would be used with the existing plot file parsing libraries to extract the time-dependent data from plot files and output the 3D Mesh data for the selected time. To support this, each analysis code plug-in will require customized mesh generation utilities. In some cases it may be desirable to update the analysis codes to embed additional data in the plot files.
It is recommended that the initial phase of this effort includes development of this stand alone application with interfaces to AptPlot, MATLAB, and ParaView for 2D and 3D plot generation. Once completed portions of this application could be incorporated into the plotting applications as appropriate.
SNAP includes post-processing capabilities through Job Streams. Applications can be executed using the output of analysis codes automatically as part of the job execution. A job stream step can be developed which will run the mesh generator within a SNAP job stream. The step will include options for specifying the analysis code and mesh generation type desired. The output will be a file that contains the generated 3D mesh data.
Two additional steps will be developed to expand the existing post-processing utilities: the ParaView job step and the MATLAB job step. The Configuration Tool will allow the user to specify the location of the ParaView application and MATLAB application that will be used for the job stream.
A new job step will be written to execute ParaView. The user interface will allow the user to define required input files and expected output files, and to enter the ParaView script in Python. ParaView will be executed headlessly using the supplied Python script as input.
A new Job Stream step will be developed that will execute an Octave/MATLAB script as part of a job stream. This new step will be similar to the Python Script job step in that input files and output files will be defined on the job step through the user interface. Input and output keywords will be available inside the MATLAB script, through a new MATLAB job stream library.
This section describes the proposed updates to AptPlot. Please note that implementation of these recommendations would likely require additional funding sources.
The existing AptPlot user interface can be updated to utilize the JavaBeans™ architecture and generated GUI editors similar to the Model Editor. The data structures for the existing document will be displayed in a tree structure, allowing the users to navigate through the different elements that make up a Graph, and display their properties in a generated Property View style editor.
This will allow for custom editing dialogs when appropriate, and in-line editors for simple properties, while preserving the existing data structures and WYSIWYG plotting display. As part of this effort, a functional specification document will be written that describes the capabilities of the AptPlot user interface. This specification will be used to verify that no functionality is lost in the resulting AptPlot user interface.
The main window of AptPlot can be similarly be updated. The toolbar actions will be updated to include a more intuitive set of mouse controls. User interface capabilities that can only be accessed through keyboard commands will be converted into toolbar toggles.
The existing 3D plotting support in AptPlot can be updated to include additional options. The Surface Graph will be updated to include user customization options. Additionally, 3D bar graphs will be added to produce a similar graph to the 3D graph animation display bean.
The existing 3D surface graph type will be updated to include enhanced user interface operations, such as control of the camera location, field-of-view, and axis scaling parameters. Additional modifications will include support for wire-frame, point-cloud, and solid polygon rendering options.
3D Bar Graphs will be added to the list of graph types in AptPlot. The 3D Bar Graphs will use an XYZ data set. The X and Y coordinate will define a location in a 2D plane, and the Z coordinate will define the height of the bar. The color of the bar will either be fixed by the data set, or will be set using a color map.
Contour Graphs will all be added to AptPlot as a graph type. Color Mapping will also be added, allowing the color of a line or surface to vary based on the value at a given point.
Contour graphs show a color gradient that represents an independent value over a 2D surface. This graph type will require an XYZ data set. The X and Y coordinates of the data set will contain the 2D coordinates for the data point. The color for the graph will display an interpolated value based on the Z value of the nearby data points. The color gradient will require Color Maps, as described below.
Currently AptPlot only supports solid colors for values. Color maps will add the ability to specify a top and bottom color value and associated data values. When a color map is used by an AptPlot data set the color for points will correspond to the color linearly interpolated between the start and end values. Color Mappings will be supported by 2D, 3D, and Contour graphs.
The PyPost application interfaces with AptPlot, and allows for headless generation of plots through a Python script. This interface supports all of the data channel manipulation functions available in AptPlot directly and can execute unsupported elements by calling the AptPlot script commands directly. This interface could be updated to expand the AptPlot commands available through Python.