Arrays and Tables in APDL – A QuickReference

kaan-80x80Many times when I want to push the bounds of what I can do in Mechanical, I need to use APDL. Now I happen to think that APDL is straightforward to use for most of the things that I do, provided I have the documentation open to the right place. The one thing that tends to stop me in my tracks, however, is arrays and tables in APDL. The information is spread out in multiple places in the help and it is just not something I do often enough to memorize. Yet arrays allow you to deal with vectors and matrices of data and are extremely useful for postprocessing. Tables allow you to apply varying loads and properties in many places where you would normally apply a constant. It is too powerful of a feature to be a road block each time and I thought I’d provide this rundown of everything you need to define arrays, all in one place.

Arrays

array-cheatsheet_fig1

Arrays are a good way to hold vector or matrix data. As shown above, you can define arrays with the *DIM command. This defines the overall dimensions of the array (you can actually have up to 5 dimensions using special forms of the *DIM command, refer to the documentation for more). You can fill arrays yourself as below but I typically have ANSYS fill in arrays for me for postprocessing purposes, using commands like *VGET (to fill arrays prior to writing a file with *VWRITE) and VGET (sends time/frequency history curves from POST26 to arrays).

Below are examples of a vector and a matrix complete definition in APDL:

*dim,ntemp,array,3
ntemp(1) = -5.2, 25, 86.5
*dim,compstrs,array,4,2
compstrs(1,1) = 814, 1057, 1033, 786
compstrs(1,2) = -386, -704, -713, -348

Tables

Did you know you can apply a curve or contour instead of a constant in many places in ANSYS? These can vary based on position, time, temperature and more. Tables are how this is accomplished. Tables are like arrays but with labels on the rows and columns that are not just the row/column number.

array-cheatsheet_fig2

As you can see, you can get some nice interpolation functionality very quickly. Just like arrays you can do this in up to 5 dimensions! Many times you will use a *DO loop to define arrays in terms of an expression as well.

The row/col/plane_var fields are for labeling your axis. If you intend to send a varying load or property later, this is where you tell it what it varies by. Check the *DIM command documentation for a list of what you can vary it by. For load or property commands like D and RMODIF, the documentation will need to say that you can pass a table and you do so by passing the table name enclosed in %’s as below. If you are using spatially varying loads, you probably will want to specify a custom coordinate system using the coord_sys_id field.

*dim,tab1d,table,5,,,time
tab1d(1) = 0,3,3.5,3.75,3.875
tab1d(1,0) = 0,0.25,0.5,0.75,1

! Apply time varying x displacement
d,component1,ux,%tab1d%
*dim,tab2d,table,5,3,,y,x,,13
tab2d(1,1) = 0,0.125,0.25,0.375,0.5
tab2d(1,2) = 0.05,0.175,0.3,0.425,0.55
tab2d(1,3) = 0.1,0.225,0.35,0.475,0.6
*taxis,tab2d(1,1),1,0,0.25,0.5,0.75,1
*taxis,tab2d(1,1),2,0,0.5,1

!Apply spatially varying temperature
!Aligned with coordinate system 13
d,component2,temp,%tab2d%

If you are like me, you may be slightly perturbed by the lack of units in the above plots. This is intentional. These commands are unitless, just like APDL. It is highly recommended that you set Analysis Settings -> Analysis Data Management -> Solver Units from Active System to the correct unit system for your APDL. Doing this will make sure that your unit system is consistent and will prevent several types of errors.

The list of available variables for tables is below:

Primary VariableLabel for var1, var2, var3
TimeTIME
FrequencyFREQ
X-coordinate locationX
Y-coordinate locationY
Z-coordinate locationZ
TemperatureTEMP
VelocityVELOCITY
PressurePRESSURE
Geometric gap/penetrationGAP
Cyclic sector numberSECTOR
Amplitude of the rotational velocity vectorOMEGS
EccentricityECCENT
Phase shiftTHETA

If this was useful to you and you’d like to hear more, subscribe to our newsletter below:

Subscribe to Newsletter

  • This field is for validation purposes and should be left unchanged.