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)

temporal statistics

The EnSight calculator has the StatMoment function to calculate spatial  statistical quantities: mean, variance, skew, and kurtosis as shown in the image below from the User Manual.

But the EnSight calculator includes only the ability to calculate three temporal statistical quantities, min max and mean using two calculator functions.  An EnSight Python script is provided to calculate temporal mean, temporal variance, temporal skew and temporal kurtosis as well as temporal sum, temporal RMS, temporal min and temporal max scalars.  These are calculated over time rather than space, resulting in a spatial scalar with each element containing it’s temporal statistics.

These variables are named per the comments in the python script.

The user will have to edit this python script and change the variable name var_name to be their variable name, change the begin and end time values, and change the values of the variance_flag, skew_flag, and kurt_flag to True or False, in order to calculate these values.  Note that in order to calculate variance, skew or kurtosis, all other previous values must be True.

Note that an entire pass through all the timesteps is required for each of the temporal statistical values requested. That is, mean, variance, skew and kurtosis will require a total of 4 passes through all time.  Temporal sum, temporal RMS, temporal min, and temporal max will require an additional 4 passes.  For large datasets with a large number of times this can take quite a while.  First run this with the variance, skew and kurtosis flags set to false and set the min and max time close together to get an idea of how long it takes for one pass through.

Note that this will work for static geometry with temporal variables, or changing coordinate geometry with temporal variables.  It will not work for changing connectivity geometry, where the geometry connectivity changes at each timestep.  Do a query>dataset to determine if what kind of geometry is in your specific dataset.

The python script makes creative use of the temporal mean function included in EnSight to do temporal integrations using intermediate variables.  The Temporal Mean calculator function in EnSight uses, by default, the Trapezoidal rule for temporal integration.  The results using this integration are shown below.

 

Temporal Statistics Results for Flow2d Dataset

As of EnSight 9.2.2(e), a statistical integration option is allowed for Temporal Mean.  This methodology simply uses the data and the step size in a rectangular integration. This python script turns this form of integration on for the duration of the script then restores it back to the default of using Trapezoidal Rule.  Shown below are the results using this new statistical integration.  For this dataset there is not significant difference until the kurtosis.

and the temporal sum, min, max, and RMS are shown below.

Click on the link below to get the python script.

temporal_statistics7