Smoke rendering for FDS

From the official site for FDS:

Fire Dynamics Simulator (FDS) is a large-eddy simulation (LES) code for low-speed flows, with an emphasis on smoke and heat transport from fires.

Smokeview (SMV) is a visualization program used to display the output of FDS and CFASTsimulations.

FDS+Evac is the evacuation simulation module for FDS.

These tools are open source and freely available.

FDS smoke 2

One use of FDS is simulation of visibility through smoke. The most realistic way to visualize smoke is volume rendering, which the default post processor Smokeview can do.

EnSight volume rendering color and transparency are customizable by the user, so they cannot be relied upon to accurately represent the visibility through smoke. The attached document and python script present a method which sets the volume rendering opacity in EnSight to accurately represent visibility. With minor modification the script also applies to any data that has a light extinction coefficient or optical density variable.

Analysis and python script.

A session file containing this dataset can be downloaded here.

Releasing Streamlines from Centroids of Elements

imgoutA request came in the other day to release streamlines from the centroids of all of the 2D elements of the selected parts. Now, EnSight, the default seed locations are from the nodes of the parts, not the centroids. However, this user would like to release from the centroids of the parts selected.

Python to rescue. We can utilize the Calculator Capability in EnSight to compute the X,Y,Z coordinates of the selected parts, and use the “NodeToElem” to convert those three scalar variable field values to be at the centroids of each element. With Elemental Values at the centroids of the parts, we use the FlatFile export with the “CELLID” parameter and ascii format to write out the elements of selected part(s) and their elemental variables to a text file. We can then just reformat this text file into a qualified “Particle Emitter File”. Voila. Within the standard streamline creation of EnSight, we can use a “Particle Emitter File” as the seed locations for the Streamlines, and therefore generate streamlines from the centroids of all elements in the selected part(s).

See below a short little Python Code to do this operation, as well as an image of what such a release would look like.

Python Utility to create Particle Emitter File from Centroids of Parts Selected

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

 

Exporting variable values on a grid

This was made for a specific customer request. It exports variable values that lay on a specified grid of points over an X-Y plane. It saves these values for all time steps. Download: probe_values_XY_export.zip

flow2d_probes

The default settings work with the flow2d data and save to a .csv file.

This was also my first venture with PyQt. These lines of code pop up a confirm file overwrite window if the target save file already exists:

q = PyQt4.QtGui.QMessageBox()
q.setWindowTitle(“File already exists”)
q.setText(“The file “+filename+” already exists.\nDo you want to overwrite the existing file?”)
q.setIcon(PyQt4.QtGui.QMessageBox.Warning)
q.addButton(“Cancel”,PyQt4.QtGui.QMessageBox.RejectRole)
q.addButton(“Overwrite”,PyQt4.QtGui.QMessageBox.YesRole)
ret = q.exec_()

I didn’t make my own class to do it, but QMessageBox is already a class so I don’t see why my own class would be better for a simple case like this. The setWindowTitle method doesn’t seem to work for me though (the window has no title). Making it a function would have been cleaner but this was just a quick script.

Prepare cube tool for a skybox

Here is a very short script that prepares the cube tool to make a skybox. Just change the numbers in the first 2 lines and go. Then create the skybox manually.

skbox_size=1000
skbox_center=[0,0,0]
ensight.tools.box(“ON”)
ensight.view_transf.function(“box”)
ensight.view_transf.box_length(skbox_size,skbox_size,skbox_size)
ensight.view_transf.box_origin(-skbox_size/2+skbox_center[0],-skbox_size/2+skbox_center[1],-skbox_size/2+skbox_center[2])
ensight.view.highlight_parts(“OFF”)
ensight.tools.box(“OFF”)

Moving car animation

This script assists in creating an animation with frame mode. It makes the car appear to move and wheel spin at a rate that matches the car’s speed. It can do constant speed as well as constant acceleration and deceleration.

First create 3 frames (ground and background, front wheels, rear wheels) and assign them to the parts. Then adjust the settings at the beginning of the script. The car will stay stationary while the ground moves in the opposite direction to give the appearance of motion.

Download: drive_car.py

Transient animation update palette range

Problem statement: EnSight has an option for setting the variable palette range to what is visible in a given viewport or to selected parts. However there is no option to update to these ranges automatically when time changes.

Value proposition: These are two scripts for updating the palette range automatically. One script adds a time callback, but this is only called when changing solution time in the GUI. It is not called for transient flipbooks, keyframes, or when saving a solution time animation. So the other script uses EnVe to save a solution time animation. Neither script works with flipbook or keyframe.

Script 1: Time callback update palette range

This works by remembering the selected parts when the script is run and using their min/max range. If the variable used to color the first part (of the selected parts) is changed then the new variable will update instead of the old one. You can add multiple independent callbacks by running the script again (each run creates a new instance of the class). The user should not need to edit the script, just select parts and run. There is some output in the python tab.

Download: time_callback_update_palette_range.zip

Script 2: Transient update palette

A very basic script that creates a single transient movie. All the settings are near the beginning of the script. Only a few lines of code update the palette range, and these could easily be changed to perform different actions every time step. So this is also a template for saving any transient animation with changes each time step.

Download: transient_update_palette.zip

Calculate percent volume/area/length

For users who want to calculate the % or fraction of a part which has variable values within a certain range. This is fairly easy to do manually in EnSight but requires some knowledge and can give false answers if parent parts have mixed dimensions. This routine automates the steps:

  1. create an isovolume
  2. calculate the volume, area, or length of the isovolume and parent part(s)
  3. divide the isovolume by parent to get fraction (x100 for %)

In addition to automating, the script also checks for the existence of mixed element dimensions in the selected parts. If there is more than one dimensionality (1D, 2D, 3D) of elements then the script aborts. If only one type exists then the script chooses the correct calculator function for that dimension and names the constant variables accordingly.

The options are set by 3 variables at the beginning of the script. Just variable, isovolume by high/low/band, and the iso values. Multiple values can be specified to create multiple isos.

This is really just the bare beginnings and there is certainly a lot more that can be done. GUI, error reporting, creating annotations, more options, command language, extension class.

After you have run this script you will have a Vol_percent_1 variable which represents the isovolume fraction % of total.  Now select the isovolume part and double click on the Tools icon at the top, and go into the Analyze folder and run the Part Constant Query tool. Choose the Vol_percent_1 constant variable.  Now you have a nice plot from sweeping the max isovolume from min to max.

Vol_vs_var

 

Download script: percent_area.zip

Logo annotation helper

Problem statement: Most EnSight graphics and annotations will resize automatically with the graphics window or output image size, however, the logo annotation does not. Also, the location of the logo is fixed by the bottom-left corner, which means it won’t stay fixed in the upper-right corner when the resolution changes.

Value proposition: This tools makes it easy to set the logo size, aspect ratio, and location in ways useful for image and animation output.

The current state of this python is a script with a simple GUI. It is unfinished but in a usable state and lacking documentation. The GUI options are a bit long and confusing at first.

Download the script: logo_helper.zip