A Quick Look at Some Vector Operations in Mechanical APDL
Rick Fischer Principal Engineer Argonne National Laboratory November 3, 2010
What are vector commands? A vector command operates on an entire array of values.
Nuclear Engineering Engineering Division - Engineering Operations Operations
One command completely fills an array.
Compare that to a scalar command, which operates on a single-valued parameter.
Nuclear Engineering Division - Engineering Operations
Why use vector operations? Because they are FAST!! •The cube below has 1,030,301 nodes. •Let’s get the x and y coordinate for every node. •The do loop makes a separate trip into the data base and comes out with one value, so it must enter the database 1,030,301 times. •The vector command enters the database once and comes out with 1,030,301 values. •The savings in IO time is huge!
Nuclear Engineering Division - Engineering Operations
2.052 min.
0.000 min.
Before I can use a vector command, I must create arrays. This is done with the *DIM command. The array will be initially filled with zeros.
Nuclear Engineering Division - Engineering Operations
Where can I use vector commands? 1. Mechanical (i.e. Workbench) in a command snippet. 2. Mechanical APDL (i.e. Ansys Classic) at the command line.
Nuclear Engineering Division - Engineering Operations
There are lots of vector commands. Some have many options, some are simple. Rather than going through the commands one at a time, which is time consuming and boring, lets look at a couple of typical problems and see how they can be solved with vector commands.
Nuclear Engineering Division - Engineering Operations
PROBLEM #1: Find the total change in heat energy in a model with multiple materials during a transient thermal analysis. APPROACH: Find the change in heat per element and sum across the model.
Q
qe
i
V e ci
multi-body part
applied temps Nuclear Engineering Division - Engineering Operations
T e
First, lets get some raw data. We need to get nodal geometry, elemental geometry, and material constants. We’ll use *VGET to speed things up. Just a simple do-loop for this. Only three materials, so a vector command is not needed.
Note that we used seven *VGET commands. On a million node model, that would take 14 minutes! Nuclear Engineering Division - Engineering Operations
At this point we have the material properties by material types, but we don’t have them associated with an element.
mat #
specific heat density
element # Nuclear Engineering Division - Engineering Operations
element centroid coordinates
element volume
We will use the *VOPER command to “gather” the material properties to the correct location.
Nuclear Engineering Division - Engineering Operations
This command is impossible to describe verbally. Use the diagrams below to decypher it.
Par1
ParR(j)=Par1(Par2(j))
data
order
ParR(Par2(j))=Par1(j)
Nuclear Engineering Division - Engineering Operations
Par2
ParR
Next, we need to get temperatures. Temps are available only as nodal temps, and we need an elemental temp. We could try and do some boring, repetitive math and average the nodal temps to get an elemental value, but here’s a slicker way.
Not a great description. It’s true, but the MAP option is not limited to mapping results. It can map any kind of data from one set of reference points to another set.
Nuclear Engineering Division - Engineering Operations
We can use the *MOPER,,,MAP command to interpolate data (nodal temps in TDAT) from a cloud of reference points (nodal coordinates in NDATA) to a new cloud of points(element centroids in EDATA).
An ecount x 1 vector of elemental temperatures.
data
An ncount x 1 vector of nodal temperatures.
3D
locations An ecount x 3 matrix of element centroid x, y and z coordinates. Nuclear Engineering Division - Engineering Operations
An ncount x 3 matrix of nodal x, y and z coordinates.
Nuclear Engineering Division - Engineering Operations
All that’s left is the math. We’ll use *VSCFUN (vector scalar function) to sum the individual elemental heat losses across the entire model.
Note that in the first *voper, Par2 = tinit, a scalar parameter. Either Par1 or Par2 or both can be a constant.
Note: four more vector operations = eight more minutes saved!
Nuclear Engineering Division - Engineering Operations
Back in Workbench Ansys Mechanical…
Create a command snippet under Solution and insert your APDL commands. Note that these commands will be executed after the POST1 command.
Nuclear Engineering Division - Engineering Operations
Next, run the solution.
Nuclear Engineering Division - Engineering Operations
Then, click on Solution Information, and scroll down to find your results.
Nuclear Engineering Division - Engineering Operations
CHECKING YOUR WORK: In Mechanical APDL, there are a couple ways to see what kind of damage you are doing.
To look at your Data array, click parameters, Array Parameters, Define/Edit, choose DATA, then click on EDIT. The window below, right will appear, displaying the DATA array
click here
Nuclear Engineering Division - Engineering Operations
Another method that allows dirrect access to a known locatiopn is to use the *STATUS command. If you want to look at the entries for element 567 in the DATA array, at the command line type: *status,data,567,567,1,10
Nuclear Engineering Division - Engineering Operations
PROBLEM #2: Calculate high cycle fatigue damage at every node in a model of a hydraulic pump and display it as a contour plot. APPROACH: 1. Assign fatigue parameters for each material to each node. 2. Obtain minimum and maximum stress at each node. Calculate mean and alternating stress. 3. Calculate the fatigue stress and damage at each node. 4. Plot the damage as a contour plot.
Nuclear Engineering Division - Engineering Operations
First, lets get the material data we’ll need for the fatigue calculations.
Estimate an S-N curve using the method given in Shigley, and fit it to a straight line in log-log space. Then input the material data needed for fatigue calculations. Next, select the component element HEAD, and select all the nodes associated with it. Now, use *VGET to create a “mask” based on nodal selection status.
Nuclear Engineering Division - Engineering Operations
What’ a mask? A mask is a column of 0s and 1s that can be used to control the execution of the first vector command that follows it.
Notice how the mask generated with the *vget command controls the action of the *vfill command.
-1 = defined, not selected
Last element with MAT=1 (not selected)
1 = defined, selected First element with MAT=2 (selected)
Column 1 only gets filled when column 6 = 1
Nuclear Engineering Division - Engineering Operations
Next, lets retrieve some stresses and crunch the math.
Modified Goodman line
adjust for a non-zero mean stress
find theoretical life
Nuclear Engineering Division - Engineering Operations
To create our plot, we’ll use *vput to put our calculated damage into the database for plotting. Pick a result that you are not using in your report. Lets use sx, st, and sz.
For this to work: •No Powergraphics (/graphics,full). •Can’t write over a derived result (e.g. s,eqv).
Nuclear Engineering Division - Engineering Operations
Here’s a very useful undocumented *VPUT option.
Change the selection status to coincide with the mask specified by ParR
Nuclear Engineering Division - Engineering Operations
At a glance, I can see every potential fatigue hot-spot everywhere on the entire assembly.
The head has a hot-spot in the fillet around the discharge port
Nuclear Engineering Division - Engineering Operations
The real high damage on the stainless steel housing is due the a BC, (bonded contact on the housing-head interface), so I can ignore it if I want.
We specified an endurance limit for the steel mounting flange, and it was above Sf everywhere on the part. The macro sets N to 108 cycles, so at 100,00 cycles, the damage is 0.001.
Nuclear Engineering Division - Engineering Operations