Tuesday 18 September 2012

ANSYS Command File Programming Features


The following ANSYS command listing, shows some of the commonly used programming features in the ANSYS command file language known as ADPL (ANSYS Parametric Design Language). It illustrates:
  • entering parameters (variables)
  • prompting the user for parameters
  • performing calculations with paramaters; note that the syntax and functions are similar to FORTRAN
  • control structures
    • if - then - else - endif
    • looping
This example file does not do anything really useful in itself besides generate keypoints along a line, but it does illustrate some of the "programming features" of the ANSYS command language.
!
/PREP7 ! preprocessor phase
!
x1 = 5 ! define some parameters
x2 = 10
*ask,ndivs,Enter number of divisions (default 5),5
!
! the above command prompts the user for input to be entered into the
! variable "ndivs"; if only is entered, a default of "5" is used
!
*IF,ndivs,GT,1,THEN ! if "ndivs" is greater than "1"
dx = (x2-x1)/ndivs
*DO,i,1,ndivs+1,1 ! do i = 1, ndivs + 1 (in steps of one)
x = x1 + dx*(i-1)
k,i,x,0,0
*ENDDO
*ELSE
k,1,x1,0,0
k,2,x2,0,0
*ENDIF
!
/pnum,kp,1 ! turn keypoint numbering on
kplot ! plot keypoints
klist,all,,,coord ! list all keypoints with coordinates

0 comments:

Post a Comment