Spatial Probability Density Function (PDF) in EnSight

In analyzing the variable distribution within a solution, it is quite helpful to look at some type of Probability Density Function for the variable. There are a few interpretations of this function depending upon whether you are looking at the probability across time, space, or different datasets. In essence, the spatial probability density function indicates to the engineer how much of the domain (% of total volume in this case) which contains particular variable range. “How much of the domain has Species 1 near 0.01, or How much of the domain has Temperature near 900 degrees K”.

This particular tool I wrote is to analyze the distribution of a function spatially, sometimes referred to a volumetric probability density function, or a volumetric histogram. In a very basic interpretation, it is similar to the histogram display in the Color Palette Editor, normalized based on element volume.

This routine takes the parent part(s) that you have selected along with the variable that you’d to interrogate, and a user specified number of bins (or bars) in the histogram. The routine automatically finds the minimum and maximum variable range for the part(s). Based on this range, it then divides the volume into N number of IsoVolumes (number of bins) based on this variable range. The routine then determines the fraction of the total volume which is contained within each of these variable constrained ranges. The result is placed into a query register and automatically plotted on the screen.

The Tool presents the user with the simple Window to select the variable, and number of bins (or bars) for the distribution function.


After executing, you will then get a graph of distribution of the variable within the parent part(s) selected.

The values on the graph should always sum to 1.0, as it is presented as a fraction of the domain which contains that variable.

Note: As users increase the number of bars( or bins) for the graph, the shape of the curve will increase in resolution, although values on the Y-axis of the graph will adjust (as more bins used will still sum to 1.0).

This Tool can be downloaded from the link below. Please unzip the file and place both the Python Script and Icon PNG file into your UserDefinedTools area and restart EnSight. You should see a “PDF Graph” icon available in your UDT area, and you can double click to execute. Note, in EnSight 10, you can now place these UDT

Update 16-April-2012:

Based on User Requests, I’ve updated the routine to create a Stair-Stepped Graph rather than the smooth graph to represent the “binning” concept further in the graph.

Updated 22-April-2012:

Based on User Requests, I’ve updated the routine to handle transient models now. It does this by exporting out each timestep as a 1D bar part that is then automatically read back into EnSight at the end. This results in the PDF function correctly sitting in the time domain, and allows the user to normally control the timestep & all other features of EnSight while the PDF Graph correctly dove-tailed into the heirarchy of EnSight. This also allows the user to further interrogate and  and operate with the data as though it were normal Elemental Data (filtering, elevated surfaces, coloring, etc.)

I also updated the routine to correctly work with 2D parent parts (using the EleSize() and StatMoment() together rather than Vol().)

In addition, I also updated the routine to select the original Parent Parts for ease of repeat usage (rather than leaving the IsoVolume part selected).

Here is a example movie made from the Transient PDF function:



Update 05-Nov-2013: Updated routine for bug regarding the variable used for the IsoVolume. Previously, the variable selected in the GUI might not have been the variable used in the IsoVolume. Fixed in version 2.3

Update 03-Nov-2015 : Updated the explicit setting for the IsoVolume to “Band”, rather than default (not explicitly set). This would cause problems if previous IsoVolumes were not of type == Band.

Full Change log within header of Python File


Click here to Download PDF Tool v2.3 (pdf_graph_v2.3) Dated 05-Nov-2013

Click here to Download PDF Tool v 2.6 (pdf_graph_v2.6) Dated 03-Nov-2015


RTZ Range Tool to generate Circumferential Average

Using roughly the same Python tool posted in the previous entry (RTZ Range Tool), I modified this tool to loop through the theta range and report back the distribution in the circumferential sense. This is useful when looking at some type of an average quantity as you traverse in theta, rather than using a line (which only reports back the local non-averaged value). The added benefit of using this small pie slice volume is that you can look at a more average quantity, rather than an unique quantity at a finite single point.

This routine shares about 85% with the above interactive routine, including all of the logic for the creation of the RTZ range selection. This routine has the added “loop” at the end of the routine, were the resulting RTZ range clip is then swept around through 360 degrees and a query of a variable is made.

The Batch version differs from the previous Interactive RTZ Clip tool in the following manner:

  1. It is made for batch operation (settings at the top of the file for input).
  2. It uses a single axial value, and this ends up as a thin clip.
  3. It uses a theta sector (say 5 degrees for example), and loops through the entire 360 deg range.
  4. It queries a variable on this clip part, and builds a Query and Plotter as a result.

The main goal for this tool is to be used in batch, and query a particular variable as a function of theta (over a sector plane).

An example screencast tutorial, dataset, and python routine for this batch python routine can be found at :

The same example manifold model is used for this case. A sample output from this routine yields the following type of graph:

The intention for this type of code is to allow the user to query a value on a segment in theta (rather than a single theta value), and report this back as a query and plot. This routine also works in batch mode, with a few user inputs listed at the top of the python routine.