Follow

# Calculating Swirl and Tumble

Calculating swirl and tumble for either a plane or volume of your model can be done using the calculator operations within EnSight. In this particular example, I will use an In-Cylinder Model to illustrate this process, however this is not unique to In-Cylinder type applications, and thus can be used for other models.

First, let me layout the nomenclature for the Tumble and Swirl so that we are using.

1. Tumble is denoted as the amount of rotation about the horizontal axis, centered about the moving geometric horizontal center (denoted as Z0 in the image below).

2. Swirl is denoted as the amount of rotation about the vertical axis.

Tumble:

• Z0 is dynamically half distance between the piston and the top of the cylinder head. (Users can alternatively define other references, but for this illustration, we've choosen these two locations to constrain the Z0 definition).
• X0 is the center X of the Cylinder.
• Tumble is the Theta Velocity about X0 and Z0

Swirl:

• X0 and Y0 are the center of the cylinder
• Swirl is the Theta velocity about X0 and Y0

To achieve the theta component of velocity used in both the Tumble and Swirl calculation, we must simply transform the cartesian velocity vector in a cylindrical system. The image below helps illustrate how we transform the cartesian vector components into cylindrical components, given any particular location of the denoted center along with the location of the vector itself:

So, let's look at Swirl first, as this is a slightly easier form of the derivation, as its center location is fixed with respect to time (vertical axis does not change). With the Swirl, we need to convert the X and Y components of velocity into a Theta component of velocity (swirl).

varname = "Velocity"
# Step 1: Calculate X and Y locations, and alpha angle of the location.
ensight.variables.evaluate("CoordX = Coordinates[X]")
ensight.variables.evaluate("CoordY = Coordinates[Y]")
ensight.variables.evaluate("CoordZ = Coordinates[Z]")
ensight.variables.evaluate("alpha = atan2(CoordY,CoordX)")

# Step 2, Activate Velocity Variable and strip off components, calculate angle of velocity
ensight.variables.activate(varname)
eval_strx = "Vx = " + str(varname) + "[X]"
eval_stry = "Vy = " + str(varname) + "[Y]"
eval_strz = "Vz = " + str(varname) + "[Z]"
ensight.variables.evaluate(eval_strx)
ensight.variables.evaluate(eval_stry)
ensight.variables.evaluate(eval_strz)
ensight.variables.evaluate("UV = sqrt(Vx^2 + Vy^2)")
ensight.variables.evaluate("theta = atan2(Vy,Vx)")

# Step 3: Calculate the swirl velocity, and Volume Averaged Value
ensight.variables.evaluate("beta = theta - alpha")
ensight.variables.evaluate("Swirl_Velocity = UV * sin(beta)")
ensight.variables.evaluate("SpaMean_Swirl = SpaMean(plist,Swirl_Velocity)")

You can see the final step, which is to calculate the Spatial Mean (SpaMean) of this velocity value. The spatial mean returns the area, volume, or length weighted average value for the elements (parts) selected.

The calculation of Tumble is very similar to that of Swirl, with the added complication of the center reference point moves throughout the time domain (Z0). To determine the center reference in Z, the Minimum and Maximum Z value of the parent part(s) is first calculated, and a new "Z_rela" scalar field is created as the Z coordinate relative to this moving Z0 location. From there, the operations are similar to that of the swirl routine, albeit using different coordinate directions.

ensight.variables.evaluate("Max = Max(plist,CoordZ)")
ensight.variables.evaluate("Min = Min(plist,CoordZ)")
ensight.variables.evaluate("Z_rela = CoordZ - ((Max + Min)/2.0)")
ensight.variables.evaluate("alpha2 = atan2(Z_rela,CoordX)")

# Step 2: Caluculate angle of velocity
ensight.variables.evaluate("UW = sqrt(Vx^2 + Vz^2)")
ensight.variables.evaluate("theta2 = atan2(Vz,Vx)")

# Step 3: Calculate the tumble Velocity, and Volume Averaged Value
ensight.variables.evaluate("beta2 = theta2 - alpha2")
ensight.variables.evaluate("Tumble_Velocity = UW * sin(beta2)")
ensight.variables.evaluate("SpaMean_Tumble = SpaMean(plist,Tumble_Velocity)")

In the examples below, I've first used the Plane Tool and Clip operations to isolate just the cylinder volume (removing off the intake runners and ports) for the calculation. In the image below, we have the raw query of Tumble vs. time shown. The Green wireframe surface corresponds to the cylinder region which constituted the parent calculation for both the swirl and tumble.

Please download these tools from the link below. Unzip the file, and place the directory into your .ensightXXX/extensions/user_defined/Tools/ directory, and restart EnSight. You should then see a new tool folder (In-Cylinder Tools) 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.