Professional Documents
Culture Documents
ANSYS® Customization and Automation With APDL: Presented by Computer Aided Engineering Associates, Inc
ANSYS® Customization and Automation With APDL: Presented by Computer Aided Engineering Associates, Inc
Copyright © 2002 Computer Aided Engineering Associates, Inc. All rights reserved. Use, reproduction,
distribution, etc. without the express written consent of Computer Aided Engineering Associates, Inc. is
prohibited.
Presentation Topics
z Introduction
— What is APDL?
— What can you do with APDL?
— Features of APDL
— Advantages and Disadvantages of APDL
z APDL Basics
B i
z Parametric Modeling
z Importing/Exporting data in/out of ANSYS
z C t
Customized
i d menus andd toolbars
t lb
z Storing macros
z Encrypting macros
z M
Macro example
l
z Consulting examples:
— Pin insertion macro
— Stent automation macro
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 2
Associates, Inc.
Introduction: What is APDL?
z Automation
— Create ggeometry y with a new set of dimensions ((Parametric Modeling)
g)
— Calculate the volume of all selected elements
— Convert structural temperatures to heat transfer temperatures
— Write all of the max. and min. stress/strain components
p for the selected
element set to a file
— Calculate the maximum difference in stress over a range of load steps
— Move the selected nodes and elements by offset values
— Import shell elements, nodes, and thickness values from an external file
— Create component sets from node or element lists in an external file
z Customization
— Create simple input and output menus (*ASK, *MSG, Multipro)
— Create customized toolbar items to perform common tasks
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 4
Associates, Inc.
Introduction: Advantages of APDL
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 5
Associates, Inc.
Introduction: Disadvantages of APDL
z Limited Customization:
— Only simple input and message menus can be generated
generated.
z Speed:
— Can be slow for complex operations on large models. User subroutines are
generally much faster
faster.
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 6
Associates, Inc.
Introduction: APDL Basics
z Scalar Parameters
— Defining scalar parameters:
• parameter = value
— (example 1: A1 = 12.98)
— (example 2: B1 = ‘Turbine Blade Analysis’)
• OR *SET,parameter,value
— (example: *SET,A1,12.98)
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 7
Associates, Inc.
Introduction: APDL Basics
E
Example:
l Run
R multiple
lti l iinputt fil
files and
d solve
l th
them iin order
d
job=‘fname’
*DO,I,1,5
/input %job%%I% inp
/input,%job%%I%,inp ! input = ‘fname1
fname1.inp
inp’, ‘fname2
fname2.inp
inp’, …
/solu
solve
finish
*ENDDO
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 8
Associates, Inc.
Introduction: APDL Basics
z Array Parameters
— Defining array parameters:
• *DIM command
— (example 1: *DIM,A1,array,10,2,1)
— (example 2: *DIM,B1,character,6,2)
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 9
Associates, Inc.
Introduction: APDL Basics
z Scalar Functions
— Many standard programming functions are available:
• A = 4*2, B = 16/4, C = A – B, D = A+B, E = A**B
• SIN(x), COS(x), TAN(x), ASIN(x), ACOS(x), ATAN(x), ATAN2(y,x)
• SINH(x) COSH(x),
SINH(x), COSH(x) TANH(x)
• SQRT(x), ABS(x), SIGN(x,y)
• NINT(x), MOD(x,y)
• EXP(x), LOG(x), LOG10(x)
• RAND(x,y), GDIS(x,y)
• LWCASE(cparm), UPCASE(cparm), VALCHR(cparm)
• CHRVAL(parm) (where cparm is a character parameter)
Help on *SET
SET will list all of the functions
z Array Functions
— Many Array and Matrix operations are available:
Examples
• *VFUN – performs a function on one array parameter
• copy to another array, square root of each entry, etc.
• *VOPER – operates on two array parameters
• add, multiply, divide, etc. entries in two arrays
• *VSCFUN – determine the properties of an array parameter
• max., mean, standard deviation, etc. of all entries
• *MOPER – performs matrix operations on two arrays
• matrix multiplication, sorting, etc.
z *IF statements
— Same functionality as IF statements in FORTRAN
— *IF, *ENDIF,*ELSEIF, and *ELSE commands can be used to perform logical branching
operations
— Syntax: *IF, VAL1, Oper1, VAL2, AND / OR, VAL3, Oper2, VAL4, THEN
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 12
Associates, Inc.
Introduction: APDL Basics
z *DO loops
— Same functionalityy as *DO loops
p in FORTRAN
— *DO, parameter, ival, fval, inc
Sample Format:
*DO, i, 1, 7, 2
*DO, j, 1, 20
n, (i-1)*20 +j, 0.1*j, i-1
*ENDDO
ENDDO
*ENDDO
z *DOWHILE loops
— *DOWHILE, parameter
— Loops repeatedl
repeatedly thro
through
gh the ne
nextt *ENDDO command as long as parameter is
true (greater than zero)
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 13
Associates, Inc.
Introduction: APDL Basics
S
Sample
l off information
i f ti you can retrieve
t i with
ith the
th *GET command:
d
UX, UY, UZ structural displacement at node N
SX, SY, SZ stresses at node N
maximum node number in the selected set
coordinates of a keypoint
stress at a node
jobname and title
material
t i l property
t value
l att a specified
ifi d temperature
t t
time step size in solution
Help, *GET to get a full list of retrievable data
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 14
Associates, Inc.
Introduction: APDL Basics
Help, *VGET
VGET to get a full list of retrievable data
Note: *VGET
VGET is much faster than looping with *DO
DO
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 15
Associates, Inc.
Introduction: APDL Basics
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 16
Associates, Inc.
Parametric Modeling
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 18
Associates, Inc.
Customized Menus and Toolbars
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 19
Associates, Inc.
Customized Menus and Toolbars – cont…
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 20
Associates, Inc.
Customized Menus and Toolbars – cont…
PTCREATE.MAC: Macro to
create and mesh a
bracket
w1 = 3
w2 = 1
/prep7
rect 0 w1 0 1
rect,0,w1,0,1
rect,0,w2,0,5
aadd,all
…
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 21
Associates, Inc.
Storing macros
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 22
Associates, Inc.
Encrypting macros
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 23
Associates, Inc.
Sample Macro
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 24
Associates, Inc.
Sample Macro cont …
! Usage: sxyz,X,Y,Z,’comp’
pdef,S%arg4%,s,%arg4%,avg
! where: X= x coord. (undef. geom.)
!
! Y y coord.
Y= d
! Get the result from the first point on the path
! Z= z coord.
*get,ar21,path,,item,s%arg4%,pathpt,1
! comp= stress component
!
! (‘x’,’y’,’z’,’1’,etc. Use ‘eqv’ as default)
! Print the result
/nopr
*msg
msg,ui,arg4,arg1,arg2,arg3,ar21
ui arg4 arg1 arg2 arg3 ar21
*get,ar20,active,,rout
The averaged stress S%C at X= %g, Y= %g, Z= %g &
! If user is in /POST1 proceed
%/ is %g
*if,ar20,eq,31,then
!
! Turn off warning messages
! Turn warning messages back on
/uis,msgpop,3
/uis msgpop 2
/uis,msgpop,2
!
!
! Set up the path
*else
path,path1,2,,
!
! Define two path points
! Print warning message if user is not in /post1
ppath,1,,arg1,arg2,arg3
pp , ,, g , g , g
*msg ui
*msg,ui
ppath,2,,arg1+.0001,arg2+.0001,arg3
*** You need to be in /POST1 to run SXYZ ***
!
*endif
! Map the result onto the path
/gopr
*get,artype,parm,arg4,type
,a type,eq,0,t e
*if,artype,eq,0,then
arg4= ‘eqv’
*endif
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 25
Associates, Inc.
APDL Example 1: Pin insertion macro
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 26
Associates, Inc.
Input Parameters
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 27
Associates, Inc.
Geometric Variations
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 28
Associates, Inc.
Pin Model Generation
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 29
Associates, Inc.
Insertion Force Optimization
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 30
Associates, Inc.
APDL Example 2: Stent automation macro
Stent Automated
Analysis
y System
y
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 31
Associates, Inc.
What is a Stent ?
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 32
Associates, Inc.
Stent Finite Element Analysis
Example Parameters:
soptp(1,1) = 'outer bend radius'
soptp(1 3) = ‘width’
soptp(1,3) width
soptp(1,4) = 'axial c-to-c length'
soptp(1,5) = 'cir. c-to-c length'
!
rro = .00897
width = .00378
lst = .03577
03577
lcirc = .01479
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 33
Associates, Inc.
Stent Finite Element Analysis
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 34
Associates, Inc.
Automated Geometry Generation
Flat 3D Mesh
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 35
Associates, Inc.
3-D Stent Expansion
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 37
Associates, Inc.
Results for a Simple Stent Geometry
Deployed Device
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 38
Associates, Inc.
Copyright© 2002
Computer Aided Engineering Computer Aided Engineering Associates, Inc. 39
Associates, Inc.