# Absolute Min or Max over time

User recently asked : What is the minimum temperature experienced at any point, throughout the whole time domain?  (absolute temporal minimum) Good question. This conceptually boils down to finding the minimum at each time, and then traversing the temporal domain looking for new minimum.

The Min() function works at a particular timestep, and will automatically update when the timestep is changed, but it is not easy to keep track of what the Min(Min()) is.

EnSight already has some very helpful temporal functions to return new variables that are sampled over time. One of them is “TempMinmaxField”, which returns the minimum or maximum over time in a particular element or node. This returns a new scalar or vector field which is minimum or maximum experienced over time in each element or node. This works great, but is limited to a geometry which does not change connectivity. His geometry is changing, so this feature does not work.

However, there are some Python provided hooks into the variable information which will immediately return items like the minimum or maximum. Now, this function is not tied to any particular part, but is rather the variable attribute rather than part related quantity.

Here is an example of using that Python call to return both the absolute minimum and maximum over time for a particular variable:

# SUBROUTINE to loop through all timesteps to figure out min and max over time
def find_minmax(step_min,step_max,varname):
nstep = step_max – step_min + 1
min_val = 9e99
max_val = -9e99
ensight.variables.activate(varname)
a = ensight.query(ensight.VARIABLE_OBJECTS)
var_list = a[2]
for i in range(len(var_list)):
name_now = var_list[i]
if name_now == varname:
var_id = i
#
for i in range(nstep):
ensight.solution_time.current_step(i)
ensight.solution_time.update_to_current()
b = ensight.query(ensight.VARIABLE_INFORMATION,var_id)
local_min_val = b[2][0]
local_max_val = b[2][1]
if local_min_val < min_val:
min_val = local_min_val
if local_max_val > max_val:
max_val = local_max_val
#
return(min_val,max_val)

# Right click data access

An annoying problem I saw quite often in doing support or training classes was to access the EnSight installation data sets. Usually the way to open one of the models is:

File -> Open -> Navigate to \$CEI_HOME\$/ensightxx/data -> select parts to load

Really exhausting if you have to do this 20 times in a single training class day. Using the ‘Open recent data file’ menu point was no really solution for me as EnSight will always ask you if you want to replace your current data. Too many clicks for me. I have written a routine which creates a background right click menu enhancement. Please find the linked routine. If you run that routine it will search for the hard drive location

\$HOMEDRIVE\$/\$HOMEPATH\$/.ensightXX/extensions/user_defined/examples.

The routine will create every directory level if the path could not be not found. However it won’t overwrite existing directories so you can run it if you already have defined some functions at that directory. As soon as the routine has created the new file called training_rightclick_background.py it will exit EnSight. Restart it to use the new right click enhancement.

The enhacement includes a quick tool access and hide function, which can be useful for quadric tools. Furthermore we can delete all currently loaded cases and we can find an option ‘Open Data’. Here the user can access all models which are automatically installed with EnSight. If the user selects oen model or clicks on ‘Delete data’, EnSight will immediately replce all current cases without asking. So this is a very quick way to open the file you need for demonstrating any EnSight functions.

download

# 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:

test_anim_out_sm

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

Download:

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

# Overset Grid enhancement : OVERINT grid.i.triq to EnSight format

For users of OVERSET grids and EnSight, we have written a little conversion routine to convert the “grid.i.triq” file from OVERINT into EnSight Format. This file contains the closed, water tight, triangulated surface representation of the geometry along with 13 variables stored at each of the node points. The python conversion routine reads the binary grid.i.triq file, and creates the appropriate EnSight Case Gold format .geo file, 13 variable files, along with the appropriate case file, and automatically loads the model into EnSight. This conversion routine only has to be run once per dataset, as all subsequent loads into EnSight can simply load in the converted EnSight Case Gold files.

More information on the OVERINT grid.i.triq file can be found here:

http://people.nas.nasa.gov/~wchan/cgt/doc/fomoco.html

You can download the following bundle and place into your UserDefinedTools area (for either EnSight 9 or EnSight 10). You can then restart EnSight, and you should find the icon for converting the grid.i.triq file. Should have any questions, or require further information, please do not hesitate to contact us.

Download grid.i.triq conversion tool