Beruflich Dokumente
Kultur Dokumente
C t
Customization
i ti
and
d
Automation with
APDL
Presentation Topics
Introduction
z
z
z
z
z
z
z
z
What is APDL?
What can you do with APDL?
Features of APDL
Advantages and Disadvantages of APDL
APDL Basics
B i
Parametric Modeling
Importing/Exporting data in/out of ANSYS
C t
Customized
i d menus and
d toolbars
t lb
Storing macros
Encrypting macros
M
Macro
example
l
Consulting examples:
Copyright 2002
Computer Aided Engineering
Associates, Inc.
APDL is a scripting
p g language
g g used to automate and customize tasks in ANSYS
APDL combines ANSYS commands with FORTRAN-like functions
APDL is used to do many of the operations done by user-subroutines in other
FE codes
Create parametric models to quickly evaluate design changes
Create macros to automate complex or often-repeated tasks
Import and export data to external files
Perform scalar, vector, and matrix operations
Create simple customized menus and toolbar items
Features of APDL
Copyright 2002
Computer Aided Engineering
Associates, Inc.
Automation
Create g
geometry
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
Customization
Copyright 2002
Computer Aided Engineering
Associates, Inc.
G d Documentation:
Good
D
t ti
Other:
Specially
p
y compiled
p
version of ANSYS is not required
q
Copyright 2002
Computer Aided Engineering
Associates, Inc.
Limited Customization:
Speed:
Can be slow for complex operations on large models. User subroutines are
generally much faster
faster.
Copyright 2002
Computer Aided Engineering
Associates, Inc.
Scalar Parameters
OR *SET,parameter,value
(example: *SET,A1,12.98)
Copyright 2002
Computer Aided Engineering
Associates, Inc.
Forced p
parameter substitution:
Enclose the parameter name in % signs for substitution in
character expressions
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
Associates, Inc.
Array Parameters
Copyright 2002
Computer Aided Engineering
Associates, Inc.
Scalar Functions
SINH(x) COSH(x),
SINH(x),
COSH(x) TANH(x)
NINT(x), MOD(x,y)
RAND(x,y), GDIS(x,y)
Copyright 2002
Computer Aided Engineering
Associates, Inc.
10
Array Functions
Copyright 2002
Computer Aided Engineering
Associates, Inc.
11
*IF statements
*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
Associates, Inc.
12
*DO loops
*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
Associates, Inc.
13
*GET
GET commands and functions:
Can retrieve almost any scalar information needed from the database:
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
Associates, Inc.
14
*VGET
VGET functions:
Can read a large amount of database information into vectors:
Sample of information you can retrieve with the *VGET
VGET command:
X, Y, Z coordinates of all selected nodes
UX, UY, UZ displacements of all selected nodes
SX, SY, SZ stresses of all selected nodes
Keypoint numbers on all of the selected lines
Surface areas of all of the selected areas
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
Associates, Inc.
15
! ((block,,2,,3,,2))
sphere,arg4
! (sphere,1.4)
vsbv,1,2
finish
Copyright 2002
Computer Aided Engineering
Associates, Inc.
16
Parametric Modeling
Recommended procedure:
Create a first pass at a model using parameters for design variables
Copy the jobname
jobname.log
log file to another file name to be used as your parametric input
file.
Modify the design parameters in the input file
Read the input file into ANSYS to solve the new analysis with the design changes
Example: Parametric Plate Model
length = 20
width = 5
thick = 0.25
/prep7
rect,0,length,0,width
r,1,thick
Copyright 2002
Computer Aided Engineering
Associates, Inc.
17
Import
p data into ANSYS from an external file using
g *VREAD,, *TREAD
File: read2.txt
11 12
21 22
31 32
41 42
51 52
Copyright 2002
Computer Aided Engineering
Associates, Inc.
18
*ASK
ASK command: Pop up a simple input menu
Example: *ask, jtitle, job title
Copyright 2002
Computer Aided Engineering
Associates, Inc.
19
Copyright 2002
Computer Aided Engineering
Associates, Inc.
20
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
Associates, Inc.
21
Storing macros
Copyright 2002
Computer Aided Engineering
Associates, Inc.
22
Encrypting macros
Use the /ENCRYPT command to assign the password and the encrypted macro
name
Use the /DECRYPT command to enter the password and run the macro
esize,.25
amesh,all
/gopr
/ENCRYPT
Copyright 2002
Computer Aided Engineering
Associates, Inc.
0CT9FPdX1/?
0DYHLl@
/DECRYPT
23
Sample Macro
Copyright 2002
Computer Aided Engineering
Associates, Inc.
24
! Usage: sxyz,X,Y,Z,comp
! where: X= x coord. (undef. geom.)
!
Y y coord.
Y=
d
!
Z= z coord.
!
comp= stress component
! (x,y,z,1,etc. Use eqv as default)
/nopr
*get,ar20,active,,rout
! If user is in /POST1 proceed
*if,ar20,eq,31,then
! Turn off warning messages
/uis,msgpop,3
!
! Set up the path
path,path1,2,,
! Define two path points
ppath,1,,arg1,arg2,arg3
pp
, ,, g , g , g
ppath,2,,arg1+.0001,arg2+.0001,arg3
!
! Map the result onto the path
*get,artype,parm,arg4,type
,a type,eq,0,t e
*if,artype,eq,0,then
arg4= eqv
*endif
Copyright 2002
Computer Aided Engineering
Associates, Inc.
pdef,S%arg4%,s,%arg4%,avg
!
! Get the result from the first point on the path
*get,ar21,path,,item,s%arg4%,pathpt,1
!
! Print the result
*msg
msg,ui,arg4,arg1,arg2,arg3,ar21
ui arg4 arg1 arg2 arg3 ar21
The averaged stress S%C at X= %g, Y= %g, Z= %g &
%/ is %g
!
! Turn warning messages back on
/uis msgpop 2
/uis,msgpop,2
!
*else
!
! Print warning message if user is not in /post1
*msg ui
*msg,ui
*** You need to be in /POST1 to run SXYZ ***
*endif
/gopr
25
Copyright 2002
Computer Aided Engineering
Associates, Inc.
26
Input Parameters
Copyright 2002
Computer Aided Engineering
Associates, Inc.
27
Geometric Variations
Copyright 2002
Computer Aided Engineering
Associates, Inc.
28
Copyright 2002
Computer Aided Engineering
Associates, Inc.
29
Copyright 2002
Computer Aided Engineering
Associates, Inc.
30
Stent Automated
Analysis
y
System
y
Copyright 2002
Computer Aided Engineering
Associates, Inc.
31
What is a Stent ?
z
z
z
z
Copyright 2002
Computer Aided Engineering
Associates, Inc.
32
Copyright 2002
Computer Aided Engineering
Associates, Inc.
33
Copyright 2002
Computer Aided Engineering
Associates, Inc.
34
2D Geometry From
Parametric
a a et c Model
ode
Flat 3D Mesh
Copyright 2002
Computer Aided Engineering
Associates, Inc.
35
36
Automated Postprocessing
Copyright 2002
Computer Aided Engineering
Associates, Inc.
37
Deployed Device
Copyright 2002
Computer Aided Engineering
Associates, Inc.
38
Copyright 2002
Computer Aided Engineering
Associates, Inc.
39