Creating Custom Color Palette from Image

Suppose you have an image that was created in another package, and you would like to replicate the color palette used in the image within EnSight? Well, EnSight can easily accept custom Color Palettes (see UserManual). The only “tough” part is getting from original image file the RGB values used and into a form of the EnSight Color Palette (.cpal) file. Well, guess what, Python (and more specifically EnVe) can be used to grab out the color legend information, and create your own color palette file (.cpal) for EnSight.

So, how you go about doing this:

1. Start with an image created in another package, which has a color legend. Crop the image to just the color legend palette. You now have an image file which has (in this example) a vertical specification of the color palette.

2. Use the attached python routine below on this file image file. This python routine uses EnVe to query the image file for the RGB values of the pixels in the image, and grab those values off, and write out an EnSight Color Palette file (.cpal) with the appropriate information in it. (If your image has a horizontal legend, then you can switch the x,y values around to perform the same operation).

3. You can thus create a new EnSight Color Palette File (.cpal) from the original image created in another package. EnSight has a limit of 21 bands, but handles 16 colors per band for smooth palette range.

 

As always, please contact us here at CEI should you have any questions, comments, having trouble, or would like routines this customized to your needs. We are here to help.

Click here for Color Palette Create Tool

 

Create Triangle Mesh

If you are faced with the problem that you have a hole in a surface EnSight has no powerful tool to fill it. Think about the radiator grille of a car. If one has the request to create a clip plane within the grille geometry to calculate the flow for example, the plane tool wont help in most cases as it’s rectangular and radiator grills are often not rectangular.

This tool can create a triangle meshes within a closed spline. If you campare the result with the meshing of a point part it has two big advantages:

1. The mesh elements are connected

2. Point parts along splines are meshed with one row of triangles. Here we have multiple rows. This enables calculation and coloring on the new mesh.

The spline geometry should be circular or elliptic and as flat as possible. Convex or concave geometries might cause problems. If the geometry is elliptic the first spline point should be at a pointed area (Think about the two ends of an egg). The scipt can use an existing spline or you can create a new one. If you select the option new spline, the GUI becomes interactive. Just click along the surface with the left mouse button and check how the spline points get created. There’s a control field of the current number of splines in the script GUI. If you want to get rid of one or more spline points, just use the delete button within the GUI. The spline can be open. The code will create a final spline point to close it. This will be done on existing splines and on new splines. Furthermore you can map an existing fluid variable to the new surface.

When the create button was pressed EnSight will create a new case and geometry file in the current working directory. These files are loaded as an additional case

 

 

 

 

 

 

 

The attached script is a stand alone tool. You can run it via File > Command > Play. Just contact me if you want to add it to your user tools.

triangle_mesh_2013_04_07

Dynamic Range Plotter

Suppose that you have a transient domain, where you have some information at a high temporal frequency, but your time domain is relatively large. If you make a default plotter, the temporal range is too large to see the high frequency information. But, if you zoom in the time range, you are “fixed” to a particular time. Suppose you’d like to see both the higher frequency information, but also the whole time domain?

Python to the rescue again. Using Python, we can dynamically adjust the time range of the graph at each timestep… and thus create a plotter with a relatively small time “window”, but that window moves with the current timestep, so that you can see the whole time domain.

Here is a short example of what such a “dyanmic range plotter” would look like:

dynamic_range_plotter

Here is a short tutorial on using this python tool:

http://www.ceisoftware.com/wp-content/uploads/screencasts/dynamic_range_plotter/dynamic_range_plotter.html

And here is the tool itself:

dynamic range plotter python

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

 

Importing Converge .out files

The Converge Solver exports out additional quantitative information into various “*.out” files. The information contained within these .out files can be very useful in visualizing along with the fluid domain in EnSight, to quantify against other extracted values in EnSight, qualitative comparison, or just to easily visualize versus time in EnSight.

This very small/short routine was developed to work on the spray.out file which contains information regarding the spray computed by the solver (injection pressure, injected mass, spray penetration, etc). The routine reads the .out file, along with the user specified engine RPM (to calculate time in seconds), and places all of the values from the .out file into EnSight Queries.

The User Defined Tool should appear as :

The user simply needs to specify the Converge .out file, along with the Engine RPM, so that the routine can correctly tie the query with time.

Once executed, you should see a number of additional queries within EnSight. The name of the Query is taken from the .out file, along with the units. Each query is associated with “Time” in seconds, and should therefore play correctly and appropriately within EnSight, as well as synchronizing with the timesteps of the main dataset.

The resulting Queries can easily be plotted with the Right Mouse Button, or drag/drop onto current plotters. Query-on-query operations can also be performed to further inspect rate of change, comparisons (differences between queries).

You can download the current User Defined Tool here. Once downloaded, unzip the file, and place the contents into your .ensight100/extensions/user_defined/Tools/ directory, and restart EnSight.

Click here to download Converge .out file reader

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

 

Transient STL File Conversion

Do you have a series of STL files which represent moving geometry? If this geometric motion is simple (constant rotation, or translation), you can utilize the “Rigid Body Motion” capability already in EnSight. However, what if the motion is complex, or if the STL surfaces change from timestep to timestep? The native STL file reader in EnSight expects steady state STL file information (either a single STL file, or multiple STL files via .xct; but still only for a single timestep).

A short Python routine can be used here to actually help out. This python routine takes a series of STL files, and assumes that they are part of a transient sequence, with one STL file per timestep. The Python routine converts the STL information into EnSight Case Gold format files, with multiple .geo files, allowing you to view your STL information in a transient nature. This routine can be further modified and customized to suit your needs, file conventions, or time information (since no time information is explicitly available within the .stl file).

Please feel free to contact CEI, or the author of the routine (kevin@ceisoftware.com) for further customization or questions.

To download this example Python utility, please click on the link below, and place into your User Defined Tools area.

Click here to download Multiple Transient STL Conversion Tool

Current Version : 1.0 (11-January-2013)

Current Limitations/Assumptions:

a. A series of ASCII stl files all with ‘.stl’ extension
b. Will convert and assume ALL “*.stl” files in the directory are to be converted.
c. All STL files have the same number of parts (but can change triangles from timestep to timestep)
d. Since there is no Time information with STL, will force Time 0 = 0.0 seconds, Time 1 = 1.0 seconds, etc
If user needs other time information, just change the time values in the .case file
e. STL files are all triangles (no quads)

Help Documentation can be found here : https://sites.google.com/a/ensight.com/user_defined_tools/transient_stl_translation

LIGGGHTS and STL Transient Conversion Routine

liggghtsDo you have LIGGGHTS data that you’d like to visualize, analyze, or communicate? Do you have similar DEM (Discrete Element Model) type of data? EnSight can used easily to analyze, visualize, and communicate the results from a LIGGGHTS solution. In this particular situation, the user has both LIGGGHTS dataset for each timestep, along with STL data for each timestep which represents the moving geometry. This python routine converts both the LIGGGHTS data file as well as the STL data into EnSight format, allowing you to visualize both the moving geometry and particles at the same time, but also utilize the analysis capabilities within EnSight to quantify the discrete particle solution for such things as mass, center of gravity, particles & mass within a particular geometric region, amount of particles leaving the domain vs. time, etc.

Please visit this site for the up-to-date help and version information regarding this Conversion Routine:

https://sites.google.com/a/ensight.com/user_defined_tools/liggghts-translation

The current release of this tool (version 1.6; 04-Dec-2012) can be downloaded with the following link. Simply place both files into your User Defined Tools directory, re-launch EnSight and start to visualize, analyze, and communicate your LIGGGHTS data within EnSight.

Click here to Download new version 1.6 of LIGGGHTS Conversion Tool

CFx Particle Track Translator

Updated 23-Jan-2013

Users of CFx who utilize discrete particles in their domain were a bit stuck for options for visualizing and analyzing that data in EnSight. The current CFx Export to EnSight format does not include the particle track information, and the Native Reader of CFx files into EnSight did not handle the read of those particle very well (extremely slow for small amount of particle, and unusable for more.). Given some recent inquiries, and bit more investigation on our end, we here at CEI have come up with an alternative approach which seems to work fairly well. We have written a python routine which translates the Particle Traces exported from CFx (to a ascii text file) into EnSight Measured data, which can then be loaded up with your EnSight model. This allows you to now visualize and analyze your CFx particle data in EnSight.

Transient Model Users:
Please note that in order for this routine to work with transient models, the information written to the PT1.trk file for “Traveling Time” must actually be uniquely equal to the Absolute Time (Analysis_Time). According to the CFx usage and documentation, the time written to the PT1.trk file is just the Particle_Traveling time, and therefore is not specifically the unique Analysis_Time (ie the Particle Traveling Time is relative to when that particle started, not a single fixed absolute time (aka Analysis_Time). If your transient model does conform to Traveling_Time == Analysis_Time, then this routine should work. If not, this routine will certainly not work.

The current documentation is kept on our User Defined Tools Help page here:

https://sites.google.com/a/ensight.com/user_defined_tools/cfx-particle-conversion

The translation routine takes existing EnSight Case File exported from CFx, along with a CFx exported Particle Track file (ascii format) (.trk), and translate this into measured data. The routine creates a new .case file with the appropriate additions for the Measured data. The user therefore only has to run this translation routine once, and can directly load the new .case file on his 2nd and subsequent load of the data into EnSight. With the Particle Track information read into EnSight as Measured data, the user can visualize, scale, animate, calculate, and analyze the characteristics of the Particle information.

Please view the Help page link mentioned above before launching the User Defined Tool, as there are a few options to control how the Particle Track information gets translated. Once viewed, please download the python routine below and place it (along with the .png file) into your User Defined Tools area.

Please Click here to download the current Version of this Tool (version 3.0)

Any updates to the routine will be re-posted back here, with appropriate notes/changes. Please feel free to provide feedback and comments back to us so that we can ensure that we provide the most appropriate and useful tool for your visualization needs.

Updated 16-Oct-2012:

Version 2.0 of the routine, with the following changes:

Updated routine to handle different ASCII format (provided by CEI GmbH) (differing number of values per line in file)
Updated routine to handle explicit min and max times provided in the Track files
Updated routine to handle gaps in the ParticleIDs
Updated routine to stop routine if supplied .case file already has Measured Data in it (Information provided in Terminal window)
Updated routine to handle .case file which is already transient (time set += 1)

Updated 23-January-2013:
Version 3.0:
    Updated to handle particles not starting all at the same time (for Transients only)
    Updated to handle Stick & non-existent particles at initial time
    Modified linear interpolation during re-sampling.
    Modified sort algorithm to utilize ‘sorted’ with a lambda.
Please see note at top regarding Transient Model integration.

kevin@ceisoftware.com

 

LAMMPS DEM Particles into EnSight

Recently, a user inquired about the ability to read in Discrete Element Model (DEM) data from the LAMMPS program. EnSight has many features used to visualize and analyze DEM particles from other solvers. With a quick look at their format, along with the ability to utilize Python to write a small translation routine, there is a new translation script available here to work with LAMMPS datasets.

This Python routine takes a particular LAMMPS output file containing DEM particles, denoted with a “.dat” extension, and converts this dataset into EnSight Format. The single part in EnSight contains only points (and point elements) representing the DEM particles. The routine will also convert the variable information provided within the .dat file into nodal variables. This routine does not have a lot of testing, but seems to work fairly straight forward.
Assumptions:
(1) The provided .dat file is ASCII
(2) Variable names used within the .dat file are provided at the top of the file
(3) Columns 1,2,3 contain the X,Y,Z positions of the particles.
(4) Timestep information is provided in the “Zone” field.

After using the tool to convert the dataset, the user will have an “ensight_files” directory containing the converted information. The user can subsequently just load the “lammps.case” file within the “ensight_files” directory directly to read the data in (there is no need to convert the data each time). The Tool writes command language back into the Journal File, so that recovery and utilization of the Journal File for scripting is still valid.

Help for this tool is provided from the “Help” button straight in the tool’s GUI, or via the Tool Help in the User Defined Tool Window. Help can b found here : https://sites.google.com/a/ensight.com/user_defined_tools/lammps-translation

The current version of the Tool is version 2.0 from September 18, 2012

Any issues or problems should be reported back here, to CEI, or the author (Kevin Colburn:  kevin@ceisoftware.com).

Download LAMMPS Conversion Tool here