Converting Plot3D variables to dimensional variables

PLOT3D variables in EnSight are non-dimensional.  They are non-dimensionalized in a somewhat arcane calculation.  The density is scaled by the freestream density, the momentum is scaled by the product of the  freestream density and the speed of sound, and the Energy is scaled by the product of the freestream density and the speed of sound squared.

For those who don’t want to go through this calculation of dimensioned variables manually and want access to the engineering variables in consistent, user-selected units at a user-selected altitude from a PLOT3D calculation, this script calculates the extended plot3d variables in either SI or English units. This script uses the non-dimensional Plot3D Energy, Density, and Momentum variables in its calculation. This script is assumes Earth atmospheric data. So, it is not valid for calculations on Mars, nor is it valid for calculations in water.

If ‘Energy’, ‘Density’ and ‘Momentum’ all exist then the script will prompt the user for unit type (SI or English) and the altitude and then use a lookup table to find the corresponding variables in consistent units.  The code will then calculate a Density_true, Momentum_true, and Energy_true variables (which have consistent units for the user input)  and use those to calculate the extended CFD variables.

Click below to download the zipped EnSight Python Script

extended_cfd_with_units4.py

Element Metrics and Histogram Tool

elemetric_histogramAs part of the core capability of EnSight to not only visualize, but analyze the domain and solution results, we have implemented the Element Metrics routines from Sandia Verdict Library (http://cubit.sandia.gov/public/documents/Verde_UG-2.5B.pdf). There are approximately 30 different element metrics that this routine will calculate for you, depending upon the grid types used. Again, we have implemented this function as a general purpose calculator function, as well wrap this fundamental capability with a Python-based macro to add further ease of use and end-user functionality. This macro is called “EleMetric_Histogram”, and performs the following on the selected parts in EnSight:

1. Determines the element types selected, and only calculates EleMetric quantities which apply.
2. Creates separate scalar variables for each Metric computed. Users can color by any of these variables, or further query where maximum or minimum values occur.
3. Determines a Histogram Distribution through the domain, and reports this to a text file (EleMetric_Histogram.txt) in the directory where your case is. This file is simple ascii, and can be inspected with any text editor.
4. An EnSight Query is generated for each Metric Histogram, so that you can visually graph the distribution of that Metric for the domain.

elemetrics_guiDouble clicking on this utility will launch the following short GUI for some basic user controls:
The first option allows the user to utilize the current selected parts only, or to calculate the variables for ALL parts in the model.
The histogram options provide the ability to control the number of bins for the histogram function, as well as where to write this information (text file and/or EnSight query registers).
The typical output to the text file should provide a nice overview of the variables computed, as well as quantification of the variable distribution in the domain.

The “EleMetric_Histogram.txt” file list all of the variables computed. If the minimum and maximum are the same, we simply report that. Else, the distribution is given as well:

txt_file_grab

In EnSight, the user now has access to the variable information computed, and can clip the domain (perhaps a crinkly clip would be best), and color the domain by the metric of interest:

image_quality1_lrg

 

The following link can be used to download the user defined tool for “EleMetric_Histogram”

Download here for elemetric_histogram

Current version is 4.0, dated 23-Oct-2014, updated by Marina Galvagni.

Kevin Colburn, CEI

 

In-Cylinder Tools

In-Cylinder Engine (ICE) simulations often contain specialized requirements for analysis. EnSight’s Python tool capability allows users to develop their own custom operations to fulfill the requirements of the analysis. I have written an initial set of tools here called “In-Cylinder Tools”, which can be installed as UserDefinedTools in EnSight 10

In this set of tools, we have the following:

1. Calculate Swirl. This routine takes the currently selected parent part(s) (typically the fluid domain of the cylinder), and calculates Swirl Velocity based about the Z axis. Using the parent part, it also calculates an Constant Variable which is the Spatial Mean of Swirl, so that you could easily create a plot vs. time for the average swirl.

 

 

 

2. Calculate Tumble. This routine takes the currently selected parent part(s) (typically the fluid domain of the cylinder), and calculates a tumble velocity, using the current average height of the parent part. The routine automatically works through time to determine this tumble velocity using the new center reference point at each timestep, and creates a graph of tumble vs time.

 

 

 

3. Crank Angle Conversion tool. This converts an EnSight .case file which has been setup with Analysis_Time specified as degrees crank angle, and converts this to Analysis_Time in seconds (user provides RPM). This allows EnSight to compute Pathlines correctly, as all of the constituent variables have consistent units.

4. Spray.out reader. For users of Converge, this tool will read in the Spray.out file information into a series of queries that you can then automatically plot. This reader will also read other Converge .out files which confirm to the save format.

 

 

 

 

 

5. Particle Distribution Function. This routine operates on the Measured Data within EnSight, to determine a mass-based distribution of any measured data variable (like radius or temperature) within the time domain. Please refer to this previous Python Exchange article for further information on the intended uses and application of this routine. Previous article.

 

 

 

Please download these tools from the link below. Unzip the file, and place the directory into your .ensight100/extensions/user_defined/Tools/ directory, and restart EnSight. You should then see a new tool folder in your UserDefinedTools area with the above tools.

Should you require any assistance with the tools or modification of them to suit your particular needs, please do not hesitate to contact CEI.

Click here to download In_Cylinder_Tools

 

Particle Distribution Analysis

As a follow on to the Probability Density/Distribution Function for the continuous phase domain (link here), I have created a close cousin of this routine which works on Discrete Particles to determine a Particle Distribution of the Discrete Phase.

This routine was written with the intended use for Spray Distribution in an In-Cylinder model, and built according to the typical variables and techniques used for this modeling scheme. It is common to determine and understand what the distribution of the particular spray is within the domain over time (mass distribution vs. radius).  This routine asks the user for a variable to base the Distribution on (in this case droplet radius). The routine breaks this value down into N number of “bins” (in this case 20). For each bin, the routine calculates the total mass of the spray in that bin, and reports back out a distribution. The routine then walks the transient domain to collect this information over time, and generate extracted information vs. time.

In order to base the total in each bin on Mass, the user must prescribe three items : a) the droplet radius, b) the droplet density, and c) the number of droplet per parcel. In this instance, the actual Discrete/Particle data in EnSight represents one parcel of spray (all with the same physical properties).  Therefore, the mass is represented as (number_drop_parcel)*(particle_density)*(4/3*pi*r^3).

The GUI input for this routine is similar to the previous PDF macro for the continuous phase, with the addition of variable prescription needed for the mass calculation.

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 mass of the spray 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, along with the three items needed to calculate the mass of the spray (radius, density, parcel count)

 

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 the total mass of spray in the domain.

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.

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 Particle Graph” icon available in your UDT area, and you can double click to execute.

 

 Video Tutorial:

Please view this video tutorial for a detailed walk through of using this tool for Spray Analysis.

Screencast Tutorial

Download:
Please use the following link to download the UserDefinedTool:

Click here to download Particle Distribution Tool

 

Droplet Claculation Tool

In addition to the Droplet Histogram Tool I was asked for a routine that calculates the penetration depth and the injection cone angle of droplets. The attached tool does these two things. When launched a small GUI pops up which asks the user for the measured particle data, the time step for calculation and the percentage of droplets within the calculated cone angle. The default value here is 80%. With this value the routine tends to stop at a cone angle which comes close to the groplet injection geometry.

 

This routine is written as a user defined tool. If you have an existing directory for your own tools just put it together with the image into that directory. Otherwise it can be used as a standalone tool as well if line 360 is activated. Please contact me if you have any problems (david@ceisoftware.com).

 

download

 

Remove Vector Component

Last week a customer complained about the necessary steps to remove a component from any vector variable. In his case he wanted to project streamlines on the midplane in Y direction around a car surface. The standard way in EnSight is to get the X and Z components of the velocity vector and add those to the MaceVect Calculator function with zero as Y components. This new variable should be renamed and can be used for the desired streamlines. Too unhandy for the user.

 

This routine does all steps automatically. It launches a small GUI which offers a combo list with all vector variables in the loaded data. The user has to select the component that has to be removed and click OK. The routine will create a new variable on all parts which als called original_variable_name_component-0 (e.g. velocity_Y-0).

 

This routine is written as a user defined tool. If you have an existing directory for your own tools just put it together with the image into that directory. Otherwise it can be used as a standalone tool as well if line 66 is activated. Please contact me if you have any problems (david@ceisoftware.com).

download

 

 

Moving Clip Plane

In EnSight we can move a clip plane depending on a selected part (e.g. a piston surface) over time. This can be done by this command:

test: special xyz clip

Recently a user asked me to automatize this feature. For this it’s necessary to create a new variable which has to be selected. No problem within the GUI but this was not possible in former EnSight versions by script. Thus this routine will only run on EnSight 10.0.2(f) or later. The result should look like this:

movie

This routine is written as a user defined tool. If you have an existing directory for your own tools just put it together with the image into that directory. Otherwise it can be used as a standalone tool as well if line 156 is activated. Please contact me if you have any problems (david@ceisoftware.com).

The tool will launch a GUI which asks for the fluid part which is clipped, the piston part surface and the moving direction. The tool is capable to create a new clip plane if toggled. Otherwise the name of an existing clip has to be typed in.

http://pythonexchange.com/?attachment_id=824

 

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


 

Multiple Variable Constraints (Venn Diagram)

EnSight’s capability to utilize multiple variables at once is very powerful. Coloring by multiple variables at once on the same part can be very powerful visual aspect to understanding the relationship of various variables at once. One variant of this is to allow the user to specify multiple variables as set of constraints so that the user can visualize a portion of the domain which has been restricted by multiple variables. For example, I would like see the portion of the domain which has Temperature between 290 and 310, and Density between 0.9 and 1.05, and a Velocity from 10 to 15…. and so forth. Basically, the user would like to build a Venn Diagram of the common constraints from multiple variables at once.

Well, enter in Python + EnSight again. Here, we utilize EnSight’s ability to create an IsoVolume (a region constrained by a range of a single variable), along with the ability in Python to loop through this constrain N times, as well as present the user with a new little GUI to specify the constraints. In this short example, I have coded up to 6 constraining variables at once. Each variable gets constrained as an IsoVolume, with the subsequent constraint using the previous IsoVolume as its parent. Voila.

Capitalizing on some of the benefits of EnSight’s dependancy tree structure, you can adjust any of the constraint variables or ranges after the fact, and the whole Venn Diagram Region is automatically updated. Each IsoVolume is now also labeled with the initial variable and range used to create it, so the user can go back through and understand the different constraints.

Here is what the tool in place looks like:

You can download the Python Tool and install it into your UserDefinedTool area:

Download Python Multiple Constraint Tool

Please provide comments back for issue you find, additional capability you’d like, or adjusts which would make this more useful for your implementation.

 

Direct Access to Variable information

Want a quick look at the variables in your model? Want to figure out minimums and maximums in a few steps? Through the use of Python in EnSight, you can get direct access to items such as what variable names are available (to check to see what the dataset has, or figure out if your potential new names conflict with any already there). You can also get quick access to items like min and max (for the model). This is particularly handy with regards to Vectors, where you can direct return of all components and magnitude.

# Obtain variable min and max info
varname = "Momentum"

print "========================="
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:
        print "Found ",varname
        var_id = i
        print "Var_Id = ",var_id
        type_flag = a[1][var_id + 1]
        print "Type_flag = ",type_flag
        ensight.variables.activate(varname)
        b = ensight.query(ensight.VARIABLE_INFORMATION,var_id)
        if type_flag == 0:
            min_val = b[2][0]
            max_val = b[2][1]
            print "Min_val = ",min_val
            print "Max_val = ",max_val
        if type_flag == 1:
            minx = b[2][0]
            maxx = b[2][1]
            miny = b[2][2]
            maxy = b[2][3]
            minz = b[2][4]
            maxz = b[2][5]
            minmag = b[2][6]
            maxmag = b[2][7]
            print "Minvals = ",minx,miny,minz
            print "Maxvals = ",maxx,maxy,maxz
            print "Mag     = ",minmag,maxmag