ANSYS® Customization and Automation With APDL

download ANSYS® Customization and Automation With APDL

of 39

  • date post

    18-Nov-2014
  • Category

    Documents

  • view

    2.925
  • download

    13

Embed Size (px)

Transcript of ANSYS® Customization and Automation With APDL

ANSYS Customization and Automation with APDLPresented 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

Introduction

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 Customized menus and toolbars C t i d d t lb Storing macros Encrypting macros Macro example M l Consulting examples:

Pin insertion macro Stent automation macro

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

2

Introduction: What is APDL?

APDL = ANSYS Parametric Design Language

APDL is a scripting language used to automate and customize tasks in ANSYS p g g g 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 Macros, if-then-else branching, do-loops, and scalar, vector, and matrix operations. Macros are APDL routines Virtually all ANSYS commands can be used in APDLComputer Aided Engineering Associates, Inc. 3

What can you do with APDL?

Features of APDL

Copyright 2002 Computer Aided Engineering Associates, Inc.

Introduction: APDL Examples

Automation

Create geometry with a new set of dimensions ( g y (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 for the selected p 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

Create simple input and output menus (*ASK, *MSG, Multipro) Create customized toolbar items to perform common tasksComputer Aided Engineering Associates, Inc. 4

Copyright 2002 Computer Aided Engineering Associates, Inc.

Introduction: Advantages of APDL

Price: No extra cost: Included with all ANSYS products Rapid Learning Curve:

Rapid learning curve, primarily devoted to learning ANSYS commands. Can use the jobname.log file to get the ANSYS command equivalent to your menu picks picks. Interpreted (not compiled) so effects of modifications are immediately realizable. APDL Programmers Guide ANSYS Commands Reference CAEA S i Seminar: ANSYS C Customization and P i i d Programming (APDL) i Specially compiled version of ANSYS is not required p y p q

Good D G d Documentation: t ti

Other:

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

5

Introduction: Disadvantages of APDL

Limited Customization:

Only simple input and message menus can be generated generated. Can be slow for complex operations on large models. User subroutines are generally much faster faster.

Speed:

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

6

Introduction: APDL Basics

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)

Listing scalar parameters: *STAT command d (example: *STAT,A1)

Deleting scalar parameters: parameter = OR *SET,parameter

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

7

Introduction: APDL Basics

Scalar Parameters cont

Forced parameter substitution: p Enclose the parameter name in % signs for substitution in character expressionsExample: R E l Run multiple i lti l input fil and solve th t files d l them i order in d job=fname *DO,I,1,5 /input,%job%%I%,inp /input %job%%I% inp /solu solve finish *ENDDO ! input = fname1 inp, fname2 inp, fname1.inp fname2.inp

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

8

Introduction: APDL Basics

Array Parameters

Defining array parameters: *DIM command (example 1: *DIM,A1,array,10,2,1) (example 2: *DIM,B1,character,6,2)

OR Parameters > Array Parameters > Define/Edit

Listing array parameters: *STAT command (example: *STAT,A1)

Deleting array parameters: parameter = OR *SET,parameter

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

9

Introduction: APDL Basics

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 will list all of the functions SET

These functions can be inserted into any numeric field of a command Example: Apply a sinusoidal force to node ipi = acos(-1) F, i, FY, fmax*SIN(2*pi*time/tmax)

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

10

Introduction: APDL Basics

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.

Array values can be inserted into any field of a command Example: Define keypoint #4 with an x coordinate equal to the value in position 2,5 of the array XVAL ii 25 f hK,4,XVAL(2,5),0.,0.

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

11

Introduction: APDL Basics

*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 Associates, Inc.

Computer Aided Engineering Associates, Inc.

12

Introduction: APDL Basics

*DO loops

Same functionality as *DO loops in FORTRAN y p *DO, parameter, ival, fval, incSample Format: *DO, i, 1, 7, 2 *DO, j, 1, 20 n, (i-1)*20 +j, 0.1*j, i-1 *ENDDO ENDDO *ENDDO

*DOWHILE loops

*DOWHILE, parameter Loops repeatedl thro gh the ne t *ENDDO command as long as parameter is repeatedly through next true (greater than zero)Computer Aided Engineering Associates, Inc. 13

Copyright 2002 Computer Aided Engineering Associates, Inc.

Introduction: APDL Basics

Getting information from the database

*GET commands and functions: GET Can retrieve almost any scalar information needed from the database:Sample of information you can retrieve with the *GET command: S l fi f ti t i ith th 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 property value at a specified temperature t i l t l t ifi d t t time step size in solution Help, *GET to get a full list of retrievable data

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

14

Introduction: APDL Basics

Getting information from the database

*VGET functions: VGET Can read a large amount of database information into vectors:Sample of information you can retrieve with the *VGET command: VGET 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 to get a full list of retrievable data VGET

Note: *VGET is much faster than looping with *DO VGET DOCopyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

15

Introduction: APDL Basics

Executing Macros and Input Files

File > Read input from (input file name) Command Line: /input,filename,ext Utility Menu > Macro > Execute Macro Use a macro command format: filename.mac

Up to 19 arguments can be passed to a macroExample: Macro to create a block with a hole: File: mkblk mac mkblk.mac Sample Call to the macro: mkblk, 2., 3., 2.,1.4 /prep7 g g g block,,arg1,,arg2,,arg3 sphere,arg4 vsbv,1,2 finish ! (block,,2,,3,,2) ( ) ! (sphere,1.4)

Copyright 2002 Computer Aided Engineering Associates, Inc.

Computer Aided Engineering Associates, Inc.

16

Par