You are on page 1of 20

ANSYS Tutorial

Xiaoming He
Department of Mechanical Engineering
University of Minnesota, Twin Cities
xmhe@me.umn.edu

Class material for short course for ANSYS (7.0) in Mechanical Engineering Department
October 2003

Contents
1 General Introduction......................................................................................................................1
2 Starting ANSYS ............................................................................................................................1
3 The ANSYS Windows and File System........................................................................................1
3.1 ANSYS windows system ........................................................................................................1
3.2 ANSYS File System................................................................................................................2
4 Basic ANSYS Analysis .................................................................................................................3
4.1 Build the model .......................................................................................................................3
4.1.1 Modeling ...........................................................................................................................4
4.1.2 Meshing ............................................................................................................................5
4.2 Apply loads and obtain solution..............................................................................................7
4.2.1 Structural Analysis............................................................................................................7
4.2.2 Thermal Analysis ..............................................................................................................7
4.3 Review results .........................................................................................................................9
4.3.1 General Postprocessor.......................................................................................................9
4.3.2 Time-History Postprocessor............................................................................................11
5 ANSYS Batch Mode ...................................................................................................................12
5.1 ANSYS APDL language.......................................................................................................12
5.2 Batch files for the structural problem....................................................................................12
5.3 Batch files of the thermal problem........................................................................................13
5.4 Optimization..........................................................................................................................15
6 More on FEM Analysis using ANSYS .......................................................................................15
6.1 Mapped mesh ........................................................................................................................15
6.2 3D modeling and meshing ....................................................................................................17
6.3 Other random comments .......................................................................................................18
6.3.1 Run ANSYS in background............................................................................................18
6.3.2 Disk space and network traffic .......................................................................................19
6.3.3 Print and export image ....................................................................................................19
6.3.4 Import IGES files............................................................................................................19
7 Closures .......................................................................................................................................19
8 References ...................................................................................................................................19
ANSYS HE

1. General Introduction
ANSYS is a commercially available software package for both computer aided design (CAD) and finite
element analysis (FEA) made by ANSYS Inc., Canonsburg, PA. ANSYS runs under a variety of
operation system including UNIX and Windows. ANSYS is available on all MEnet Sun, SGI and
Window machine. It is available on the Linux machines by remote-login only. Currently, MEnet has the
Research/Faculty version of both ANSYS 6.1 and ANSYS 7.0. ANSYS can be used to analyze transient
and nonlinear problems for a variety of physics including:
Heat transfer
Structural and solid mechanics
Fluid Dynamics (laminar and turbulent)
Electromagnetics (high and low frequency)
Multiphysics (thermal stress,
For this short class, we will focus our attention on the application of ANSYS in both thermal and
structural analysis. This document is meant to be at the entry level. The material covered here is by no
means comprehensive. In fact, we will only scratch the surface of ANSYSs capabilities. However, with
this entry level knowledge, you will be able to improve yourself to advanced level by making use of the
comprehensive ANSYS help system and of course the ANSYS website (www.ansys.com).
2. Starting ANSYS Interactively
As mentioned before, you can run ANSYS on both Windows and UNIX machines. To start ANSYS
interactively on Windows machines, following menu chains:
Starts > Program > ANSYS > Interactive
The ANSYS launcher will show up. Input the jobname and directory and then click on Run button to
start ANSYS. To start ANSYS interactively on UNIX machines, following:
unix% module load ansys
unix% ansys -g -p ANSYSRF
The first step is to load ANSYS into the memory of the machine, while the second step tell the operation
system to start ANSYS product for Research/Faculty (-p ANSYSRF) interactively (-g). You can start
ANSYS in the second step as follows:
unix% ansys
Then, the ANSYS launcher bar will show up. Click on the symbol ANSYS to expand the launcher.
Input the jobname and directory and then click on Run button to start ANSYS. You can just use the
default settings, run ANSYS and change the jobname in ANSYS under the File utility menu.
3. The ANSYS Windows and File System
3.1 ANSYS Windows system
Once you started successfully ANSYS. You should see the ANSYS interface windows as shown in Fig. 1.
From this windows and menu system, you can essentially do any finite element analysis that ANSYS can
do. Details of the function of the windows and menus are explained briefly below:
1. Utility Menu - Contains utility functions that are available throughout the ANSYS session, such as file
controls, selecting, graphics controls, and parameters. You also exit the ANSYS program through this
menu.
2. Standard Toolbar - Contains graphic buttons that execute frequently used ANSYS commands.
3. Input Window - Allows you to type in commands directly. All previously typed in commands appear in
a drop down list for easy reference and access.
4. ANSYS Toolbar - Customizable toolbar that contains push buttons that execute commonly used
ANSYS commands and functions. You may add your own push buttons by defining abbreviations.
5. Main Menu - Contains the primary ANSYS functions, organized by processors (preprocessor, solution,
general postprocessor, design optimizer, etc.).
6. Graphics Window - A window where graphics displays are drawn.

1
ANSYS HE

7. Status and Prompt Area - located at the bottom of the GUI, shows prompts and the status of your
analysis. Typically, you will see prompts for functions that involve graphical picking. Be sure to read
the prompt so you can pick the proper entities in the proper order. This area also contains status
information (PREP7, SOLU, etc.).
8. Output Window - Receives text output from the program. It is usually positioned behind the GUI, but
you can bring it to the front when necessary.

1
2 3
4

7
Fig. 1 ANSYS windows system
3.2 ANSYS Files System
The ANSYS program writes and reads many files for data storage and retrieval. File names follow this
pattern: Name.ExtName defaults to the jobname, which you can specify while or after entering the
ANSYS program. The default jobname is FILE (or file). Ext is a unique, two- to four-character ANSYS
identifier that identifies the contents of the file. Some systems (such as PCs) truncate the extension to
three characters. Also, the extension may be in lowercase, depending on the system. A summary of the
meanings of ANSYS file extension is given in Table 1.
The most important two files are the database file and results file. Your model is stored in the database
files while the results file keeps all your results from an analysis. The log file records in ANSYS
commands all your interactive operations via GUI windows and menu. The error notes down all the error
and warning message raised during this and all previous sessions. The output file has all the messages
appeared in the output window.

2
ANSYS HE

Table 1. ANSYS file types and formats


File Type File Name File Format
Log file Jobname.LOG ASCII
Error file Jobname.ERR ASCII
Output file Jobname.OUT ASCII
Database file Jobname.DB Binary
Results file:
structural or coupled Jobname.RST
thermal Jobname.RTH Binary
magnetic Jobname.RMG
FLOTRAN Jobname.RFL
Load step file Jobname.Sn ASCII
Graphics file Jobname.GRPH ASCII (special format)
Element matrices Jobname.EMAT Binary

4. Basic ANSYS Analysis


Regardless of the type of problem to be solved, a typical ANSYS analysis has three distinct steps:
1. Build the model:
2. Apply loads and obtain the solution
3. Review the results.
The easiest way to learn ANSYS is through simple but well covered tutorial examples. In this section, we
will learn how to do ANSYS FEM analysis through the above three general steps by solving 2D structural
and thermal problems as shown in Fig. 2A and B. The 2D structural and thermal problems have the same
geometry as shown below (i.e., a plate with a hole). Certainly, the governing equations, and boundary and
initial conditions will be totally different due to the two different physics.

0.004m 0.004m
q=100 W m-2
T=50oC
T=-196 oC
0.02m

0.02m

0.02m 0.02m

h=100W m-2 K-1


T=25oC
1000N
A B
Fig. 2 A, Structural Example Problem: Steady state 2D plane stress problem with homogeneous
force on the bottom and fixed on the top. All the other boundaries are free of constraint; B, Thermal
Example Problem: transient 2D thermal problem with convective boundary on the bottom, adiabatic
on the top and constant temperature on the right and left sides. The boundary at the inner circular
surface is constant heat flow.
4.1 Build a model
Building a finite element model requires more of your time than any other part of the analysis. You use
the preprocessor to define the model geometry (modeling) first and then mesh the geometry using
appropriate element types, element real constants, and material properties (meshing).

3
ANSYS HE

4.1.1 Solid Modeling


ANSYS has a very powerful solid modeler built into the processor, which allows the user to construct
surfaces and solids to model a variety of geometries. However, no matter how complex an ANSYS solid
model, it is a combination of four basic entities: Key points (KP), Lines (L), Areas (A) and Volumes
(V). There are generally five ways to construct a complex solid model using these four basic entities in
ANSYS:
1. Bottom up: construct the solid model from low to high order entities: KP L A V
2. Top down: construct the solid model sing ANSYS volume and area primitives
3. Dragging and rotating: Construct a high order entity by drag or rotate a low order entity.
4. Boolean operation: sculpt your solid model using intersections, subtractions, and other Boolean
operations. Models constructed this way usually are computationally expensive.
5. Moving and copying: move a component to appropriate position and generate repetitive
component by copying.
These methods should be use together to speed up the modeling process.
Note: if you still did not change the jobname, please change it now to solid from the Utility Menu as
follows:
File > Change Jobname > [/FILENAME] Enter New Jobname
Input solid in the text window and click OK to accept.

To make our drawing easier, we will use the ANSYS workplane, which is simply a 2D grid for drawing
using the mouse. From the Utility Menu,
WorkPlane > WP Settings > Grid and Triad
Snap Incr 0.0005
Spacing 0.001
Minimum 0.015
Maximum 0.015
Tolerance 0.00003
To display the workplane
WorkPlane > Display Working Plane
You will need to zoom in because it is too small (from the Utility Menu):
PlotCtrls > Pan, Zoom, Rotate ...
Now, lets start the solid modeling by entering the pre-processor from the main menu. Draw the
rectangular area using the following menu system:
Modeling > Create > Areas > Rectangular > By 2 Corners
Click and hold down on the left mouse button. The work plane coordinates will appear in the popup menu.
Position the mouse over X = -0.01 and Y = 0.01 and let go of the left mouse button. Now position the
mouse over (0.01,-0.01) and click again. You should have a rectangular area. Click on OK to complete.
Note that you can return to any of the popup menus spawned by the Main Menu at any time. Therefore,
we return to menu Areas and draw a circular area as follows:
Areas > Circle > Solid Circle
Notice that the middle line of the Input window instructs you to pick two workplane locations: a center
and a radius. Click on (0, 0) and let go of the left mouse button until the radius is shown to be 0.002, then
left click the mouse. You should have a circular area. Click on OK to complete.
Now, wed like to subtract the circular area from the square area,
Modeling > Operate > Booleans > Subtract > Areas
Click on the box. This will spawn an error message to let you know that there are two areas. If the square
is highlighted, click OK, otherwise, choose Next until the square is highlighted then OK. Click OK in the
Subtract popup menu. Select the center circle (again, this will raise a warning; make certain you have
selected the circle). Click on OK in the Subtract popup menu and you have a 2D plate with a hole.

4
ANSYS HE

This would be a good point to save your work. Use the Toolbar menu, SAVE DB. This will save all of the
pertinent information in an ANSYS database file called solid.db. Since we will use this solid model for
both thermal and structural analysis we should save two copies (one for thermal and one for structural
analysis) so that we can resume further analysis from this point. From the Utility Menu:
File > Save As > input the filename in the popup window.
Do this twice to save the files as 2dstr.db and 2dthm.db. Now, we save additional two copies of the
established solid model. The entire solid modeling work is done at this point.
4.1.2 Meshing
Since meshing requires given element types and ANSYS using different element types for thermal and
structural analysis, we need to do meshing for thermal and structural analysis separately.
4.1.2.1 Meshing for structural analysis
To use previously constructed solid model, we need to resume from there using the Utility menu:
File> Resume From
Choose 2dstr.db from the file list and click OK.
Change jobname to 2dstr as follows:
File> Change Jobname > [/FILENAME] Enter new jobname: 2dstr.
Then click OK.
Now, we begin to mesh the model. Click on Preprocessor in the main menu to open the submenu tree.
1. Select element type from the preprocessor:
Element Type > Add/Edit/Delete ... > Add ... > Structural Mass > Solid > Quad 8node 82
The Element Types windows should now show PLANE82 as element type 1. This element can be used
for plane stress, plane strain, and axisymmetric problems. From the Element Types Menu:
Options ... > Element behavior K3: Plane Stress
2. Assign material properties
Material Props > Material Models > Structural > Linear > Elastic > Isotropic >EX 2e11
PRXY 0.3
3. Define element size
There are a number of ways to define the element size. Here, we use two of them:
a. for the inner circle:
Meshing > Size Cntrls > ManualSize > Lines > Picked Lines >
Pick all the lines forming the inner circle, click OK, input the 10 to NDIV No. of element divisions in
the Element Size on Picked Lines window. This specifies the number of element divisions for each
line that forms the model.

Fig. 3 FE mesh for structural analysis

5
ANSYS HE

b. for the outer frame line of the rectangle:


Meshing > Size Cntrls > ManualSize > Lines > Picked Lines >
Pick all the four outer frame line of the rectangle, click OK, input the 0.001 to SIZE Element edge length
and -2 to the SPACE spacing ratio text windows in the Element Size on Picked Lines window. This
specifies the element edge length and -2 is the nominal ratio of center division(s) size to end divisions size
since we expect stress concentration on the edge.
4. Mesh the model using free mesh
Meshing > Mesh > Areas > Free
Select the plate area and click OK. ANSYS will mesh the model and plot the elements in the Graphics
window. Your mesh ought to look something like Fig. 3.
5. Now save the meshed model using SAVE_DB in the ANSYS Toolbar for future resuming from this
point.
4.1.2.2 Meshing for thermal analysis
To use previously constructed solid model, we need to resume from there using the Utility menu:
File> Resume From
Choose 2dthm.db from the file list and click OK.
Change jobname to 2dthm as follows:
File> Change Jobname > [/FILENAME] Enter new jobname: 2dthm.
Then click OK.
Now, we begin to mesh the model. Click on Preprocessor in the main menu to open the submenu tree.
1. Select element type from the preprocessor:
Element Type > Add/Edit/Delete ... > Add ... > Thermal Mass > Solid > Quad 8node 77
The Element Types windows should now show PLANE77 as element type 1. Use the default options and
click on OK.
2. Assign material properties
Material Props > Material Models > Thermal > Conductivity > Isotropic > KXX 0.5
>Specific Heat 2100
>Density 1000
For transient analysis, you also need to specify specific heat and density. For transient phase change
problem, you need to specify temperature dependent enthalpy or equivalent specific heat.

Fig. 4 FE mesh for transient thermal analysis


3. Define element size
There are a number of ways to define the element size. For now we will use a simple approach:
Meshing > Size Cntrls > SmartSize > Basic > LVL Size Level > 2

6
ANSYS HE

Be caution to use this tool. Since ANSYS does not know what you are solving for or what the boundary
conditions will be, it cannot know what the best mesh is.
4. Mesh the model using free mesh
Meshing > Mesh > Areas > Free
Select the plate area and click OK. ANSYS will mesh the model and plot the elements in the Graphics
window.
5. If we expect high temperature gradient surrounding the inner circle, we can refine the scheme there as
follows:
Meshing > Modify Mesh > Refine at > Lines
Pick all the lines forming the inner circle, click OK, and select LEVEL Level of refinement as 2 in the
Refine Mesh at Line window. Your mesh ought to look like the following Fig. 4.
5. Now save the meshed model using SAVE_DB in the ANSYS Toolbar for future resuming from this
point.
4.2 Apply loads and obtain solution
4.2.1 Structural analysis
First resume from previously meshed model
File> Resume From
Choose 2dstr.db from the file list and click OK.
Change jobname to 2dstr as follows:
File>Change Jobname > [/FILENAME] Enter new jobname: 2dstr.
Then click OK.
Now enter SOLUTION under main menu to apply loads and obtain solution.
1. Apply the load on the top edge:
Solution > Define Loads > Apply > Structural > Displacement > On Nodes
Select Box in the selection window and draw a box around the line defining the top of the plate. This
should select all of the nodes along that line. The Apply U, ROT on Nodes menu will pop up.
Lab2 DOFs to be constrained All DOF
2. Apply the load on the bottom edge:
Solution > Define Loads > Apply > Structural > Force/Moment > On Nodes
Again, select Box and select all of the nodes on the bottom line of the plate. The number of nodes you
selected ought to be listed in the Apply F/M on Nodes menu under Count. Click OK, spawning another
menu
[F] Apply Force/Moment on Nodes
Lab Direction of force/mom FY
VALUE Force/moment value -1000/41
Click OK. This will apply a total load of 1000N to the bottom edge of the plate (or 1000/41 per node for
41 nodes).
Use default option for all other setting. The model is now complete.
3. Solve the problem
Solution > Solve > Current LS
This will spawn two new windows. Click OK in the Solve Current Load Step window and simply close
the other window. This will begin the solution process. ANSYS will alert the user when the solution is
done.
4 Save the analysis by click on the save symbol on the standard toolbar for resuming from this point to
review results in the future
4.2.2 Thermal analysis
First resume from previously meshed model
File> Resume From
Choose 2dthm.db from the file list and click OK.
Change jobname to 2dthm as follows:
File> Change Jobname > [/FILENAME] Enter new jobname: 2dthm.

7
ANSYS HE

Then click OK.


Now enter SOLUTION under main menu to apply loads and obtain solution.
1. Specify initial conditions:
Solution > Define Loads > Apply > Initial Conditn > Define
Click on the Pick All Button, select TEMP and input 37 in the spawned window
2. Apply convective boundary condition on the bottom edge:
Solution > Define Loads > Apply > Thermal > Convection > On Lines
Pick the bottom line, click OK, and then input the values of Film coefficient (100) and bulk temperature
(25) in the Apply CONV on lines window.
3. Apply the constant heat flux load on left side of the rectangle
Solution > Define Loads > Apply > Thermal > Heat Flux > On Lines
Pick the left side, click OK, and then input the values of heat flux (100) in the Apply HFLUX on lines
window.
4. Apply the constant temperature loads
Solution > Define Loads > Apply > Thermal > Temperature > On Lines
Pick all the lines forming the inner circle, click OK, and then input the values of temperature (-196) in the
Apply TEMP on lines window. Repeat the procedure for the boundary on the right line (note: temperature
is 50)
5. Transfer the applied load from solid model to meshed model
Lines and areas are solid model entities. You must transfer boundary conditions imposed on these entities
to the nodes along those entities. First we select everything using the Utility menu:
Select > Everything
Then, we transfer the loads applied:
Solution > Define Loads > Operate > Transfer to FE > All Solid lds
Use default option for all other setting. The model is now complete.
6. Solve the problem
a. Set the analysis type to transient full analysis:
Solution > Analysis Type > New Analysis > Transient, click OK> Full
b. Set the solution controls as follows:
Solution > Analysis Type > Soln Controls
In the solution control window:
From tab: Basic> Time control> Time at the end of load step 600
Automatic time stepping: ON
(Check) Time increment: Time step size: 0.5
Minimum time step: 0.01
Maximum time step: 10
From tab: Transient > Full transient options > (check) Transient effects > (click) Stepped loading
You can change other options like the equation solver and nonlinear option from the other tabs. Here we
will use the default value.
c. Set the output control
Solution > Load Step Opts > Output Ctrls > DB/Results File
In the Controls for Database and Results File Writing Window, Click on At Time Points, then Click OK.
It will spawn another window, click on New array. Another window pops up:
Name the array: ResTime, number of element: 11. Another window pops up:
Input the following value: 1: 1, 2: 60, to 11: 600 with increase of 60s per array element. Thus, we
specified ANSYS to write results at 1s and 60s, 120s, 180s, , 600s, so that we can review results at this
time points.
d. Set the integration control
Solution > Load Step Opts > Time/Frequenc > Time Integration > Amplitude Decay
In the popup window, set THETA Transient Integ Param 1. We use fully implicit integration method.
e. Solve the problem
Solution > Solve > Current LS

8
ANSYS HE

This will spawn two new windows. Click OK in the Solve Current Load Step window and simply close
the other window. This will begin the solution process. ANSYS will alert the user when the solution is
done.
7. Save the analysis by click on the save symbol on the standard toolbar for resuming from this point to
review results in the future
4.3 Review results
The ANSYS post processor provides a powerful tool for viewing results. You can review your results as
contour plots, table format, and x-y plots in General Postproc. You can plot and list you results vs. time
for a transient problem in TimeHist Postproc.
4.3.1 General postprocessor
1. Review results of 2D structural analysis
Lets resume the 2D plane stress problem we solved before:
File> Resume From
Choose 2dstr.db from the file list and click OK.
Change jobname to 2dstr as follows:
File> Change Jobname > [/FILENAME] Enter new jobname: 2dstr.
Then click OK.

Fig. 5 Contour plot of the von Mises equivalent stress


Lets generate the contour plots of the von Mises equivalent stress:
General Postproc > Plot Results > Contour Plot > Nodal Solu > Stress > von Mises SEQV
Click OK, the following contour plot should show up as Fig. 5.
You can change the output style using the Utility menus as follows:
PlotCtrls > Windows Controls Windows Options
You can generate element tables of the von Mises equivalent stress:
General Postproc > Element Table > Define Table > Add > Stress > von Mises SEQV
Then you list and plot the element table of von Mises equivalent stress:
General Postproc > Element Table > Plot Elem Table
List Elem Table
You can also do some mathematical calculation using the element table and plot it using ANSYS under
submenus under the Element Table menu.
Sometimes, reviewing results along a certain path in the computational domain is very important. Let
show how the plot von Mises stress along a path. First, we need to define the path:
General Postprocessor > Path Operations > Define Path > By Nodes

9
ANSYS HE

Pick two nodes: one at the right most point of the circle and one at the middle of right side of the
rectangle, click OK, label it as path1, click OK.
Now, we need to map the von Mises stress on the this path:
Path Operations > Map onto Path > Stress > von Mises SEQV
Label it as vMP1, click OK. Now we can plot it:
Path Operations > Plot Path Item > On Graph > vMP1
The X-Y Plot should look as Fig. 6.

Fig. 6 von Mises equivalent stress along a specified path

Fig. 7 Contour plot of temperature distribution at 300 seconds


2. Review results of 2D transient thermal analysis
Similarly, for the thermal problem, we need to resume from the point we stopped:
File> Resume From
Choose 2dthm.db from the file list and click OK.
Change jobname to 2dthm as follows:

10
ANSYS HE

File> Change Jobname > [/FILENAME] Enter new jobname: 2dthm.


Then click OK.
Lets generate the contour plots of the temperature distribution. Since the thermal analysis is transient, we
nee to specify at what time point we want the contour plot:
General Postproc > Read Results > By Time/Freq
In the new window, fill 300 in the text window corresponding to TIME Value of time or freq, click OK.
Now, we can plot the contour at 300s:
General Postproc > Plot Results > Contour Plot > Nodal Solu > DOF solution >Temperature TEMP
Click OK, a contour plot like Fig. 7 should show up.
Similarly, you can change the output style using the Utility menus as follows:
PlotCtrls > Windows Controls > Windows Options
You can generate element tables of temperature:
General Postproc > Element Table > Define Table > Add >DOF solution > Temperature TEMP
Then you list and plot the element table of temperature. You can also do some mathematical calculation
using the element table and plot it using ANSYS using submenus under the Element Table menu. You
can also create a path and map temperature onto that path and plot the temperature along the path in x-y
plot. Please do this by yourself for practice.

One of the cool things ANSYS can do for you is to make a movie of your transients analysis:
Stay in general postprocessor and using the following Utility menus:
PlotCtrls > Animate > Over Time > Number of animation frames 10
(click on) Time Range
Range Minimum: 10, Maximum: 600
Leave all other options default, Click OK. You will see in the graphics windows the movie of the thermal
contour vs. time. Thermal contour Movie

Fig. 8 Thermal histories at two given nodes


4.3.2 Time-history postprocessor
This postprocessor is useful only for transient analysis.
Click on TimeHist Postpro in the main menu to enter this postprocessor. It will automatically open a
variable viewer. Click on the button with a plus, it will pop up and window called Add Time-history
Variable, click Nodal solution, click DOF solution, click on Temperature, click OK. ANSYS will ask you
to pick a node. Pick a node and click OK. Thermal history of this node will be defined as TEMP_2 and is

11
ANSYS HE

shown in the table. Here, I pick the node at the middle point of the bottom frame line. Repeat above
procedure and pick the node at the middle point of the left frame line. It is shown in the table as TEMP_3.
Now, we will plot the thermal histories of the selected two nodes. Select both variables by holding the
Ctrl or Shift keyboard and clicking the two variables in the table using your mouse. Then click the both
with a curve on a black background. The two thermal histories will be shown on the Graphical windows
as shown in Fig. 8.
5. ANSYS Batch Mode Analysis
There two primary ways to use ANSYS interactively: through the graphical user interface and through the
use of batch files of ANSYS programming language. Up to this point, we have used the GUI exclusively.
It is easiest to learn ANSYS interactively, especially when compared to the daunting task of learning all
of the relevant ANSYS commands. But do not be fooled! Easier does not mean better or faster. The
database file and results file from an analysis may be very big (10-1000 MB) even after compression. It is
very inconvenient to keep them. Batch files are about 10-100KB and can be run under background.
Therefore, it is especially useful for complex models and long jobs such as strong nonlinear analysis. In
short, batch mode saves your time and effort.
5.1 ANSYS APDL programming language
ANSYS has its owner programming language called APDL. APDL stands for ANSYS Parametric Design
Language, a scripting language that you can use to automate common tasks or even build your model in
terms of parameters (variables). APDL also encompasses a wide range of other features such as repeating
a command, macros, if-then-else branching, do-loops, and scalar, vector and matrix operations. It looks
very similar to a FORTRAN computer language although the exact format is a little different and APDL
has more commands for solid model generation.
Parameters are APDL variables (they are more similar to FORTRAN variables than to Fortran
parameters). You don't need to explicitly declare the parameter type. All numeric values (whether integer
or real) are stored as double-precision values. Parameters that are used but not defined are assigned a
near-zero, or "tiny," value of approximately 2-100. For example, if parameter A is defined as A=B, and B
is not defined, then A is assigned the tiny value. ANSYS uses two types of parameters: scalar and array
parameters. A scalar parameter is similar to a FORTRAN variable. Character strings (up to eight
characters long) can be assigned to parameters by simply enclosing the string in single quotes. APDL also
provides several types of array parameters: numeric, character, string and table (a special numeric type
that automatically interpolates values). You can use a parameter (instead of a literal number or character
string) as an argument to any ANSYS command; the parameter is evaluated and its current value is used
for that argument. Note that parameter names are limited to 8 characters. Names beginning with numbers
are not allowed, nor are special characters that could otherwise be construed as operators.
Interactively, parameters can be defined and modified through the Parameters submenu in the Utility
menu. Unlike Pro/E and other CAD packages, changes in parameters are not automatically reflected in
the geometry. Thus, using parameters from the GUI is not as useful as it could be. The real power of
parameters is seen when they are used to define the geometry within a batch file.
The following two subsections give the batch commands that allow solving the above structural and
thermal problem in batch mode.
5.2 Batch files for the static structural problem
This file shows how to a static analysis in batch mode.
!Jobname to use for all subsequent files EXX=2.0E11 ! Young's modulus
/FILNAME, b2dstr PR=0.3 ! Poisson's ratio
/TITLE, Static structural analysis WIDTH=0.02 ! Width of the plate
/UNITS, SI ! The SI system of units is used HEIGHT=0.02 ! Height of the plate
HALFW=WIDTH/2. ! Half width of the plate
/PREP7 !Enter Preprocessor HALFH=HEIGHT/2. ! Half height of the plate
! Define parameters for future use RADIUS=0.002 ! Radius of the inner hole
EPS=1.e-6

12
ANSYS HE

ET,1,PLANE82 ! Eight-node quadrilateral element LESIZE,ALL,0.001,,,-2


MP,EX,1,EXX ! Young's modulus for material 1 LSEL,S,LINE,,5,8,1
MP,PRXY,1,PR ! Poisson's ratio for material 1 LESIZE,ALL,,,10

! Build the model (Bottom up) TYPE,1 ! Mesh using PLANE82 elements
!Create keypoints for the rectangular plate MSHAPE,,2D ! Use mixed quad and tri elements
K,1,-1*HALFW,-1*HALFH MSHKEY,0 !Use free mesh
K,2,HALFW,-1*HALFH SAVE ! Save database before meshing
K,3,HALFW,HALFH ASEL,ALL
K,4,-1*HALFW,HALFH AMESH,ALL
!Create key points for the central hole /TITLE,Meshed plate w/ hole
K,5,0,0 EPLOT
K,6,0,-1*RADIUS FINISH !Exit from preprocessor
K,7,RADIUS,0
K,8,0,RADIUS ! Enter solution: apply loads and obtain the solution
K,9,-1*RADIUS,0 /SOLU
ANTYPE, STATIC ! Static analysis (default)
!Create lines as sides of the rectangle /TITLE, Plane stress
L,1,2 !Line #1
L,2,3 !Line #2 ! Fix all nodes on the top side
L,3,4 !Line #3 ALLSEL
L,4,1 !Line #4 LSEL,ALL
LSEL,S,LOC,Y,HALFH-EPS,HALFH+EPS
!Create the inner circular arc NSLL,,1 ! Nodes on this line
LARC,6,7,5,RADIUS !Line #5 D,ALL,ALL ! Displacement constraints
LARC,7,8,5,RADIUS !Line #6
LARC,8,9,5,RADIUS !Line #7 ! Apply force on nodes on the bottom side
LARC,9,6,5,RADIUS !Line #8 LSEL,S,LOC,Y,-1*HALFH-EPS,-1*HALFH+EPS
NSLL,,1 ! Nodes on this line
!Create area from lines F,ALL,FY,-1000./41. ! Force boundary
AL,1,2,3,4 !Area1
AL,5,6,7,8 !Area2 SAVE ! Save database before solution

!Subtract circular area from the rectangular area ALLSEL


ASBA,1,2,,DELETE,DELETE SOLVE ! Solve the problem
FINISH
! Mesh the solid model /EOF
ALLSEL /EXIT, ALL
LSEL,S,LINE,,1,4,1

Note: All lines beginning with ! are comment lines; everything after the ! is ignored for that line. The /eof
command signals the end of input. If you would like to test just a portion of your batch file, you can do so
by placing an /eof anywhere in your batch file. To test a batch file from the GUI, simply type /input,file in
the Input window. Note that ANSYS is very picky about the filenames you choose: filenames must be
less than 9 letters.
One quick way to learn ANSYS batch commands is to check the *.log files. Whenever you start a session,
ANSYS logs all of the commands issued through the GUI or the Input window to that file. Consequently,
if you know how to do something through the GUI, after performing the operation you can check the
*.log file to find the command name and learn more about it in the Commands Manual. But beware of
cutting and pasting directly from the *.log file into your batch file! The ANSYS commands generated by
the GUI generally have special arguments to denote graphical picking with the mouse, arguments that are
not available during batch processing.
5.3 Batch files for the transient thermal problem
This file how to do a transient analysis in batch mode.

!Jobname to use for all subsequent files /UNITS,SI ! the SI system of units is used
/FILNAME, b2dthm
/TITLE,transient 2D thermal analysis ! Define parameters for future use

13
ANSYS HE

EPS=1.e-6 ASEL,ALL
KMAT=0.5 ! Thermal conductivity AMESH,ALL
CpMAT=2100. ! Specific Heat
RouMAT=1000. ! Density ALLSEL
WIDTH=0.02 ! Width of the plate LSEL,ALL
HEIGHT=0.02 ! Height of the plate CSYS,1
HALFW=WIDTH/2. ! Half width of the plate LSEL,S,LOC,X,RADIUS-EPS,RADIUS+EPS
HALFH=HEIGHT/2. ! Half height of the plate CSYS,0
RADIUS=.002 ! Radius of the inner hole !Refine the mesh around the inner circle
! Defines a array parameter LREFINE,ALL,,,2
*DIM,ResTime,ARRAY,11 /TITLE,Meshed plate w/ hole
ResTime(1)=1. EPLOT
*DO,i,2,11 FINISH !Exit from preprocessor
ResTime(i)=60.*(i-1)
*ENDDO ! Use do loop ! Enter solution: Apply loads and obtain the solution
/SOLU
/PREP7 ! Enter Preprocessor ! Set solution and output control
ET,1,Plane77 ! Eight-node quadrilateral element ANTYPE,TRANS,NEW
MP,KXX,1,KMAT ! Thermal conductivity TRNOPT,FULL
MP,C,1,CpMAT ! Specific Heat DELTIM,0.5,0.1,10
MP,DENS,1,RouMAT ! Density AUTOTS,ON
TIME,600
! Build the model (Bottom up) KBC,1
!Create keypoints for the rectangular plate OUTRES,ERASE
K,1,-1*HALFW,-1*HALFH OUTRES,NSOL,%ResTime%
K,2,HALFW,-1*HALFH TINTP,,,,1.0
K,3,HALFW,HALFH
K,4,-1*HALFW,HALFH ALLSEL
!Create keypoints for the central hole NSEL,ALL
K,5,0,0 IC,ALL,TEMP,37. !Specify IC
K,6,0,-1*RADIUS
K,7,RADIUS,0 !Adiabatic BC on the top side
K,8,0,RADIUS !Convective BC on the bottom side
K,9,-1*RADIUS,0 ALLSEL
NSEL,ALL
!Create lines as sides of the rectangle NSEL,S,LOC,Y,-1*HALFH-EPS,-1*HALFH+EPS
L,1,2 !Line #1 SF,ALL,CONV,100.,25.
L,2,3 !Line #2
L,3,4 !Line #3 !Constant heat flux on the left side
L,4,1 !Line #4 NSEL,S,LOC,X,-1*HALFW-EPS,-1*HALFW+EPS
SF,ALL,HFLUX,100.
!Create the inner circular line
LARC,6,7,5,RADIUS !Line #5 !Constant temperature on the right side
LARC,7,8,5,RADIUS !Line #6 NSEL,S,LOC,X,HALFW-EPS,HALFW+EPS
LARC,8,9,5,RADIUS !Line #7 D,ALL,TEMP,50.
LARC,9,6,5,RADIUS !Line #8
!Constant temperature on the circular side
!Create area from lines CSYS,1
AL,1,2,3,4 !Area1 NSEL,S,LOC,X,RADIUS-EPS,RADIUS+EPS
AL,5,6,7,8 !Area2 CSYS,0
D,ALL,TEMP,-196.
!Subtract circular area from the rectangular area SAVE ! Save database before solution
ASBA,1,2,,DELETE,DELETE
ALLSEL !Mesh control ALLSEL
SMRTSIZE,2 SOLVE ! Solve the problem
TYPE,1 ! Mesh using PLANE82 elements FINISH
MSHAPE,0,2D ! Use mixed quad and tri option /EOF
MSHKEY,0 ! Free mesh /EXIT,ALL
SAVE ! Save database before meshing

14
ANSYS HE

5.4 Optimization
ANSYS has strong built-in optimization capabilities. However, to use the optimization function, you must
build your model parametrically using ANSYS APDL language. This is probably one of the most
important reasons why many ANSYS advanced users favor batch mode analysis.
As any optimization procedure, you need define optimization variables (design variable in ANSYS),
constraints (in the form of state variable in ANSYS, state variable is a function of design variables) and
objective function. You can define multiple design variable and state variable, but only one objective
function. Usually, you need to make use of the postprocessor to help you define the state variable and
objective function.
Lets look at an example to learn the basic optimization analysis. For example, we want to find the
optimal radius of the central hole in the above static structural problem to minimize the von Mises
equivalent stress at the hole edge. We will assume the radius varies between 1mm and 1mm. We start the
optimization from 6mm. The batch commands used to define the parameters, build the model and solve
the problem will be very similar to those given in section 5.2 with only one change. This change is that
the element size will be specified as 0.5mm on the circular side instead of 10 divisions on each line.
Below are the additional new batch commands for the optimization analysis:
/OPT !Enter optimization
! Define the element size on the hole edge as 0.5mm !Define design variable varying from 1mm to 9mm
LSEL,S,LINE,,5,8,1 OPVAR,RADIUS,DV,0.001,0.009
LESIZE,ALL,0.0005 !Define objective function to minimize
OPVAR,EQVMAX,OBJ
!Review the results OPTYPE,FIRST
/POST1 OPFRST,100,50,0.1
SET,1 ! Reads load step 1 results OPLOOP,PREP
ALLSEL OPPRNT,FULL
NSEL,ALL
CSYS,1 OPEXE !Execute optimization
NSEL,S,LOC,X,RDIUS-EPS,RADIUS+EPS FINISH
CSYS,0
NSORT,S,EQV /EOF
*GET,EQVMAX,SORT,,MAX ! Get maximum stress /EXIT,ALL
FINISH

In the output file, you can find the value of each of the optimization variables and the objective function
at the end of each iteration. Users can track the change of design variable, state variable and objective
function with respect to the iteration using appropriate commands or menu system (see ANSYS help for
more information). Finally, ANSYS will return the optimal values of the design variables which you can
see under the Parameters menu in the Utility menu. For the plate example,
RADIUS (DV) 0.13943E-02
EQVMAX (OBJ) 0.13799E+06
As with any optimization, the results are not guaranteed to be the global optimum. Furthermore, the
optimum found by the search may be different depending on the starting point (initial values of the
optimization variables) that you choose. Optimization is not an easy job.
6. More on ANSYS Analysis
6.1 Mapped mesh
In general, ANSYS has two methods of meshing: free meshing and mapped meshing. We have been
using free mesh exclusively for the above example problems. Free meshing is easy but for complex
geometries can lead to distorted elements that undermine accuracy. Free meshing is available for 2D
quadrilateral and triangular element shapes. However, free meshing can only produce 3D tetrahedral
elements for solid models. In mapped meshing, users specify the meshing pattern. Therefore, users have
more control on the final mesh. However, mapped meshing requires the 2D and 3D solid model following
several specified patterns:

15
ANSYS HE

2D The area must be bounded by either three or four lines (with or without concatenation). The area must
have equal numbers of element divisions specified on opposite sides, or have divisions matching one
of the transition mesh patterns (see ANSYS Help for more information). If the area is bounded by
three lines, the number of element divisions must be even and equal on all sides.
3D The volume must take the shape of a brick (bounded by six areas), wedge or prism (five areas), or
tetrahedron (four areas). The volume must have equal numbers of element divisions specified on
opposite sides, or have divisions matching one of the transition mesh patterns for hexahedral meshes
(see ANSYS help for examples of element divisions that will produce a mapped mesh for different
volume shapes). The number of element divisions on triangular areas must be even if the volume is a
prism or tetrahedron.
Therefore, for a complex solid model, users need to split areas or volumes in their solid model in certain
ways to make the mapped mesh applicable. Below is a batch file that draws the same plate with a hole.
The plate is split into two areas to make mapped meshing applicable for this model.
Fig. 9 shows the generated mapped mesh. You can see the mesh is well patterned for in entire domain.

Fig. 9 A mapped mesh of the plate with a central hole


/FILNAME, mapmesh K,11,-1*RADIUS,0
/UNITS,SI !Create lines as sides of the rectangle
WIDTH=0.02 ! Width of the plate L,1,2 !Line #1
HEIGHT=0.02 ! Height of the plate L,2,3 !Line #2
HALFW=WIDTH/2. ! Half width of the plate L,3,4 !Line #3
HALFH=HEIGHT/2. ! Half height of the plate L,4,5 !Line #4
RADIUS=.002 ! radius of the inner hole L,5,6 !Line #5
/PREP7 L,6,1 !Line #6
!Select element type and material properties !Create the inner circular line
ET,1,Plane82 ! Eight-node quadrilateral element LARC,8,9,7,RADIUS !Line #7
MP,EX,1,2.e11 LARC,9,10,7,RADIUS !Line #8
MP,PRXY,1,0.3 LARC,10,11,7,RADIUS !Line #9
!Create keypoints for the rectangular plate LARC,11,8,7,RADIUS !Line #10
K,1,-1*HALFW,-1*HALFH L,8,2 !Line #11
K,2,0.,-1*HALFH L,10,5 !Line #12
K,3,HALFW,-1*HALFH AL,2,3,4,12,8,7,11 ! Area #1
K,4,HALFW,HALFH AL,1,11,10,9,12,5,6 ! Area #2
K,5,0,HALFH
K,6,-1*HALFW,HALFH ! For the rhs half-box
!Create keypoints for the central hole ALLSEL
K,7,0,0 LSEL,ALL ! Select all lines
K,8,0,-1*RADIUS LSEL,S,,,1
K,9,RADIUS,0 LSEL,A,,,5,6
K,10,0,RADIUS LCCAT,ALL !Concatenate selected lines

16
ANSYS HE

! For the lhs box LSEL,ALL


ALLSEL LSEL,S,,,9,10
LSEL,ALL LCCAT,ALL
LSEL,S,,,2,4,1 ALLSEL
LCCAT,ALL ESIZE,0.001 !Define element size
! For the rhs hole TYPE,1 !Using PLANE82 elements
ALLSEL MSHAPE,0,2D ! Use quad option
LSEL,ALL MSHKEY,1 !Use mapped mesh
LSEL,S,,,7,8 SAVE ! Save database before meshing
LCCAT,ALL ASEL,ALL
! For the lhs hole AMESH,ALL
ALLSEL /EOF

6.2 3D modeling and meshing


All of the previous examples have focused on 2D solid models. ANSYS has a powerful built-in modeler
allowing us to create complex 3D model in several different ways. Here are two examples on generating
3D solid model and mesh using ANSYS model and meshing tools.
Lets first generate a 3D block with central cylindrical hole by extruding the 2D plate we have:
Now, resuming from previously meshed model
File> Resume From
Choose 2dstr.db from the file list and click OK.
Change jobname to 2dstr as follows:
File>Change Jobname > [/FILENAME] Enter new jobname: 3dstr. Then click OK.
Enter the preprocessor by clicking the Preprocessor menu in the main menu.
Now, generate 3D volume without mesh using area extrusion as follows:
Preprocessor>Modeling>Operate>Extrude>Areas>Along Normal
Pick the area, click OK, Fill 0.01 in the text window for DIST Length of extrusion, and click OK. Now,
hold on Ctrl keyboard, click and hold your right mouse button and move you mouse, you will see the
created 3D block with central cylindrical hole looks like Fig. 10A depending on the view angle.
Furthermore, you can generate a 3D mesh of the extruded volume by doing following:
Element Type > Add/Edit/Delete ... > Add ... > Structural Mass > Solid > Brick 20node 186
Modeling>Operate>Extrude>Elem Ext Opts > [TYPE] Element type number 2 Solid 186
VAL1 No. Elem divs 10
Modeling>Operate>Extrude>Areas>Along Normal
Pick the area, click OK, Fill 0.01 in the text window for DIST Length of extrusion, and click OK. Now,
you will see the meshed 3D block with central hole looks like Fig. 10B depending on the view angle.

A B
Fig. 10 Generating 3D volume with (A) or without finite element mesh from 2D area

17
ANSYS HE

Now, lets generate a 3D shaft structure using ANSYS APDL language. Before we create the shaft, we
need to do the following from the Utility menu:
File> Clear & Start New, click OK in the popup window
Input from the Input window the following commands:
/FILNAME,shaft L,6,1
/Prep7 LARC,5,6,7,0.001
ET,1,Plane82
ET,2,Solid186 AL,1,2,3,4,5,6
MP,EX,1,2.e11
MP,PRXY,1,0.3 ALLSEL
LSEL,ALL
K,1,-0.015,0.008 LESIZE,ALL,0.0005
K,2,-0.015,0 TYPE,1
K,3,0.015,0 MSHAPE,0,2D
K,4,0.015,0.005 MSHKEY,0
K,5,-0.005,0.005 ASEL,ALL
K,6,-0.006,0.006 AMESH,ALL
K,7,-0.005,0.006 TYPE,2
EXTOPT,ON
L,1,2 EXTOPT,ESIZE,10
L,2,3 VROTAT,1,,,,,,2,3,270
L,3,4 EPLOT
L,4,5 FINISH

This batch files tells ANSYS to generate a 2D first, mesh the 2D area, then generate the 3D shaft with
mesh by rotating the 2D meshed area along one of its sides. The created shaft with mesh should looks like
Fig. 11 depending on the view angle you choose. Please see ANSYS help system for more useful tools for
solid modeling and meshing.

Fig. 11 Creating meshed 3D shaft by rotating meshed 2D area


6.3 Other random comments
6.3.1 Running ANSYS in background
ANSYS is a resource hog. It uses large amounts of disk space, RAM, and CPU cycles. If you plan to run
all but the simplest analyses, it is best to do them using batch files. Most importantly, you can run
ANSYS without having to tie up a console (i.e., you can run your job in the background). Here is an
example,
unix% nice +6 nohup ansys70 b -p ANSYSRF < input file > & output file &
where:
nice +6: UNIX command that nices the job by adding to its priority. This means that your background
job will defer CPU cycles to the person logged in to the console. All background jobs must be
niced according MENET policies.
nohup: UNIX no hang-up command.
<: Pipes the batch input file to ANSYS.

18
ANSYS HE

>: Pipes ANSYS output to ASCII output file


&: Tells UNIX to execute this process in background
Submitting your ANSYS job with these UNIX commands, the ANSYS job will continue to run even if
you log out from the machine.
6.3.2 Disk space and network traffic
You are always advised to run ANSYS under a scratch space in all MENET machines as follows:
unix% cd /scratch
unix% mkdir foldername
Then, running ANSYS. Otherwise, ANSYS may run very slow and your disk space quota may be
overflowed since ANSYS need to run over MENET network and you only have 50MB space on MENET
server. Do not forget to compress your database and results file when you decide to keep them under you
home directory or other disks.
6.3.3 Print and export image
ANSYS can print a figure in the graphics window to a printer or file from the Utility menu:
PlotCtrls>Hard Copy > To Printer / To File
When you select To Printer option, a window with all available printers will show up. You can save it as
many different image files and PostScript file if you choose the To File option.
6.3.4 Import IGES files
As an alternative to creating a model directly in ANSYS, you can first create a solid model in your
favorite CAD system (e.g., Pro/E), save that model as an IGES (Initial Graphics Exchange Specification)
file, and then import that model into ANSYS. Once successfully imported, you can mesh the model just
as you would for any model created in ANSYS. The IGES specification is a vendor neutral standard
format used to exchange geometric models between various CAD and CAE systems. The filter can import
partial files, so you can generally import at least part of your file. You can also import multiple files into
the same model, but you must use the same import option for every file. See ANSYS Help for more
information
7. Closures
Be sure trying to reduce your model using symmetry and other conditions and ignore unnecessary details
in your model. It will make ANSYS solve your problems much easier and faster. You will save your time
and efforts to do other fun things rather than just enjoying doing ANSYS analysis.
8. References
1. ANSYS 7.0 online help, 2003
2. Langlais T. Material for ANSYS (V5.4) short course, 1999

19

You might also like