Recent News
SNAP Version 4.2.1 Released
February 16, 2024
AptPlot 8.0.4 Updated
February 16, 2024
PyPost 4.0.3 Released
August 18, 2022

What is PyPost?

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.

PyPost can be used to:

  • Query and extract time-dependent plot data from several nuclear engineering analysis codes including:
    • COBRA,
    • CONTAIN,
    • FRAPCON
    • FRAPTRAN
    • GOTHIC
    • MELCOR
    • PARCS
    • RELAP5
    • RELAP5-3D
    • TRAC-B
    • TRACE
  • Read experimental data stored in NRC Databank and EXTDATA format.
  • 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.
  • Interact directly with AptPlot to generate presentation quality plots in a wide range of formats.

The process to read data from a plot file includes opening a plot file, reading the data into Python variables, and closing the file. The following example illustrates this process with a RELAP5-3D plot file. An instance of each interface class is created when it’s bindings are loaded. The interface can hold any number of open plot files, organized using a file index integer. The file index can be specified explicitly when opening a file. If left unspecified, the file index will be initialized to the next available number. If the file index is specified explicitly and a file is currently opened at that index, the open file will be replaced with the new file. Some analysis codes can produce plot files in different formats. In addition, some plot files can be demutiplexed to improve performance. The interfaces typically provide different methods to open the different plot file formats. For example the following Python code opens two RELAP5-3D plot files, a legacy rstplt file and a demultiplexed plot file:

# Opens RELAP5 rstplt and RELAP5 demux files
RELAP.openPlotFile("./sample_data/relap/typpwr.rst")
RELAP.openDmxFile(3, "./sample_data/relap/relap.dmx")

The first file is given an implicit file ID of 0 while the second file’s ID is explicitly set to 3. In some cases, the file format can be determined by examining the file and a single open plot file method may support multiple formats.

Most plot files include engineering units for each of their data channels. The data written to these files may be in SI or British (Imperial) units. By default, all data read from the plot files are converted, if necessary, to SI units. The PyPost library includes two methods setUseBritishUnits() and setUseSIUnits() that can be used to alter this read behavior. Specifically, the following command will ensure all data is read into British units:

# Change default units to British
setUseBritishUnits()

Please note that these commands will not affect data that has already been read from the files. The getData method is used to read data from an open plot file into a Python variable. The method takes two arguments, the file ID, and a list of data channels. For example, the following code reads two data channels from the demultiplexed plot file opened above:

# Read in a couple temperatures
httemp1 = RELAP.getData(3, 'httemp-100100101')
httemp2 = RELAP.getData(3, 'httemp-100100201')

A shorthand notation for the getData() function is available for each interface. For RELAP5 files, RELAP.getData() can be replaced by simply R5() so the last commands can also be written:

# Read in a couple temperatures
httemp1 = R5(3,'httemp-100100101')
httemp2 = R5(3,'httemp-100100201')

As shown later, this notation makes it easier to use plot data directly in an equation:


# Read in a couple temperatures
deltaT = R5(3,'httemp-100100101')- R5(3,'httemp-100100201')

In the earlier case, two heat structure temperatures are read into two variables, httemp1 and httemp2. The getData method will also accept a list of data channel names in which case it will return a list of data channels as in the following example:

# Read a list of channels
plotvars = ['httemp-100100101', \
'httemp-100100201', \
'httemp-100100301', \
'httemp-100100401', \
'httemp-100100501', \
'httemp-100100601']
httemps = R5(3, plotvars)


Just like a front door, it is always good practice to close a file when you are done using it. To close a single file use the closeFile method:

# Close a plot file
RELAP.closeFile(3);

The closeAll() method can be used to close all open files:

# Read a list of channels
plotvars = ['httemp-100100101', \
'httemp-100100201', \
'httemp-100100301', \
'httemp-100100401', \
'httemp-100100501', \
'httemp-100100601']
httemps = R5(3, plotvars)

Just like a front door, it is always good practice to close a file when you are done using it. To close a single file use the closeFile method:

# Close a plot file
RELAP.closeFile(3);

The closeAll() method can be used to close all open files:

PyPost includes an Advanced Equation Interpreter that can be used to perform calculatationa with the data read from plot and experimental data files. Data extracted from analysis code plot files and experimental data files typically consists of time dependent vector data stored in ChannelVector objects.

These objects can be used directly in Python equations to calculate values. For example, difference in pressure between two hydraulic cells from a RELAP5 calculation can be determined from the following simple Python coding:

# Plot the pressure drop across Pipe 106.
RELAP.openDmxFile("./sample_data/relap/relap.dmx")
p106i = R5(0,'p-106010000')
p106o = R5(0,'p-106070000')
deltaP = p106o - p106i
aptIntf = AptPlotIntf()
aptIntf.plotChannels(deltaP)
aptIntf.runCmds(["view 0.35, 0.15, 1.15, 0.85",\
"title \"RELAP5 TYPPWR\"",\
"subtitle \"SG Tube dP\"" ])
aptIntf.printFile( "PDF", "./results/deltaP.pdf")

Note that the minus operator "-" is overloaded to handle ChannelVector variables directly. The results of the calculation are stored in a newly created ChannelVector, deltaP. This new variable will contain all of the independent data values (time in this case) and the difference between the two dependent data values, 'p-106070000' and 'p-106010000', respectively.

In this simple case, both variables came from the same RELAP5 run so each time dependent vector contains the same time values. The new time dependent vector simply contains the difference between the two pressure values at each time step. However, when a mathematical operation uses variables from different sources such as a RELAP5 run and an NRC Databank experimental data file, the time values in each vector will most likely not be identical. The post-processor handles this situation by interpolating the dependant data from the second vector using the time values from the first vector. The resulting vector contains all of the time values that fall within the bounds of the second vector, with dependent values calculated at these times using interpolated data from the second vector.

Several Python operators are overloaded to support mathematical and comarision operations. The overloaded addition, subtraction, multiplication and division operators can act on either two vectors, or a combination of a scalar and a vector variable. For example, the following equations are all valid and return vector variables:

p106i = R5(0,'p-106010000')
p106o = R5(0,'p-106070000')
ptot = p106o + p106i
p2 = 2.0 * p106o
p3 = p106i * 2.0
pave = (p106o + p106i)/2.0

If the operation involves two vector variables, the resulting vector will contain all of the x-values of the first vector that fall within the range of x-values of the second variable. Its y-values will be determined by performing the operation at each x-value using interpolated y-data from the second vector variable. If one of the operands is a scalar, the resulting vector will contain all of the x-values of the vector operand with its y-values determined by performing the operation using the scalar value and each y-value of the vector operand.

A comprehensive test suite has been developed to verify proper operation of the software. Tests are organized into four categories, channel vector function tests, plot & experimental data file I/O interface tests, external application interface tests, and miscellaneous tests. Each set of tests is located in a separate subdirectory under the testscripts directory included in the distribution.

Although PyPost was developed to be used primarily in a batch processing mode, the distribution does include a Graphical User Interface which provides the ability to created, modify and execute python scripts using the PyPost libraries. The user interface contains an editing panel, for modifying python scripts, and an output panel where the standard output is redirected as shown below:

pypostmainframe