3.2. Defining Parameters

Unless otherwise specified, the information in the next several sections applies to both scalar and array type parameters. Beginning with Array Parameters, the information is specific to array type parameters.

You can either assign values to parameters or retrieve values provided by Mechanical APDL and store these values in parameters. For retrieving values from Mechanical APDL, you can use either the *GET command or the various in-line get functions. The following sections cover these subjects in detail.

3.2.1. Assigning Parameter Values During Execution

You can use the *SET command to define parameters. The following examples illustrate a set of example parameters defined using *SET:

*SET,ABC,-24
*SET,QR,2.07E11
*SET,XORY,ABC
*SET,CPARM,'CASE1'

You can use an "=" as a shorthand way of calling the *SET command (this is the most convenient method). The format of the shortcut is Name = Value, where Name is the name assigned to the parameter and Value is the numeric or character value stored in that parameter. For character parameters, the assigned value must be enclosed in single quotes and cannot exceed eight alphanumeric characters. The following are examples of "=" in use:

ABC=-24
QR=2.07E11
XORY=ABC
CPARM='CASE1'

In the GUI, you can either type the "=" directly in the Mechanical APDL input window or in the "Selection" field of the Scalar Parameter dialog (Utility Menu> Parameters> Scalar Parameters).

3.2.2. Assigning Parameter Values at Startup

You can define parameters as arguments when launching Mechanical APDL from the operating system command line. Simply type parameter definitions after the Mechanical APDL execution command (which is system dependent) using the format -Name Value. For example, the following defines two parameters (parm1 and parm2) having the values 89.3 and -0.1:

ansys242 -parm1 89.3 -parm2 -0.1

It is a good practice to avoid assigning one or two character parameter names at startup to avoid conflicts with Mechanical APDL command line options.


Note:  Linux shells treat single quotes and many other non-alphanumeric characters as special characters. When defining character parameters, set Linux not to interpret the quotes by inserting a backslash (\) before the single quotes. For example, the following defines a character parameter having the value filename.


ansys242 -cparm1 \'filename\'

If you use the Mechanical APDL Launcher to start Mechanical APDL, you can define parameters through the Customization tab (using the -Name Value format described above).

If you are defining a large number of parameters at startup, you'll find it much more convenient to define these in the start.ans file or through a separate file that you can load through the /INPUT command instead of the command line.

3.2.3. Assigning Mechanical APDL-Provided Values to Parameters

Mechanical APDL provides two powerful methods for retrieving values:

  • The *GET command, which retrieves a value from a specified item and stores it in a specified parameter.

  • The in-line get functions, which can be used in operations. Each get function returns a specific value from a specific item.

3.2.3.1. Using the *GET Command

The *GET command retrieves a Mechanical APDL-provided value for an item (a node, an element, an area, etc.) and stores it as a user-named parameter. Various keyword, label, and number combinations identify the retrieved item. For example, *GET,A,ELEM,5,CENT,X returns the centroid x-location of element 5 and stores the result as parameter A.

The format for the *GET command is:

*GET,Par,Entity,ENTNUM,Item1,IT1NUM,Item2,IT2NUM

where

  • Par is the name of the parameter to store the retrieved item.

  • Entity is a keyword for the item to be stored. Valid keywords are NODE, ELEM, KP, LINE, AREA, VOLU, etc. For a complete list of valid keywords, see the *GET description in the Command Reference.

  • ENTNUM is the number of the entity (or zero for all entities).

  • Item1 is the name of an item for a particular entity. For example, if Entity is ELEM, Item1 is either NUM (the highest or lowest element number in the selected set) or COUNT (the number of elements in the set). (For a complete list of Item1 values for each entity type, see the *GET description in the Command Reference.)

You can think of the *GET command as a path down a tree structure, from general to specific information.

The following examples show the *GET command in use. The first command below gets the material attribute (the MAT reference number) of element 97 and assigns it to parameter BCD:

*GET,BCD,ELEM,97,ATTR,MAT     ! BCD = Material number of element 97
*GET,V37,ELEM,37,VOLU         ! V37 = volume of element 37
*GET,EL52,ELEM,52,HGEN        ! EL52 = value of heat generation in element 52
*GET,OPER,ELEM,102,HCOE,2     ! OPER = heat coefficient of element 102,face2
*GET,TMP,ELEM,16,TBULK,3      ! TMP = bulk temperature of element 16,face3
*GET,NMAX,NODE,,NUM,MAX       ! NMAX = maximum active node number
*GET,HNOD,NODE,12,HGEN        ! HNOD = value of heat generation at node 12
*GET,COORD,ACTIVE,,CSYS       ! COORD = active coordinate system number

3.2.3.2. Using In-line Get Functions

For some items, you can use in-line "get functions" in place of the*GET command. A get function returns a value for an item and uses it directly in the current operation. This process allows you to bypass the dual steps of storing the value with a parameter name and then entering the parameter name in an operation. For example, suppose that you want to calculate the average x-location of two nodes. You could do the following using the *GET function:

  1. Issue the following command to assign the x-location of Node 1 to parameter L1.

     *GET,L1,NODE,1,LOC,X
  2. Issue a second *GET command to assign the x-location of Node 2 to parameter L2.

  3. Compute the middle location from MID=(L1+L2)/2.

A shorter method is to use the node location "get function" NX(N), which returns the x-location of node N. You can use it to calculate the MID location without setting intermediate parameters L1 and L2, as is shown in the following example:

MID=(NX(1)+NX(2))/2

Get function arguments can themselves be parameters or other get functions. For instance, get function NELEM(ENUM,NPOS) returns the node number in position NPOS for element ENUM. Combining functions NX(NELEM(ENUM,NPOS)) returns the x-location of that node.

Get Function Summary summarizes the available get functions.

3.2.4. Listing Parameters

Once you have defined parameters, you can list them using the *STATUS command. If the *STATUS command is issued without arguments, it provides a list of all of the currently defined parameters. The following example shows the command and a typical listing.

*STATUS
PARAMETER STATUS-           (   5 PARAMETERS DEFINED)
NAME         VALUE         TYPE     DIMENSIONS
ABC      -24.0000000      SCALAR
HEIGHT    57.0000000      SCALAR
QR       2.070000000E+11  SCALAR
X_OR_Y   -24.0000000      SCALAR
CPARM      CASE1          CHARACTER

You can also access this information via Utility Menu> List> Other> Parameters or Utility Menu> List> Status> Parameters> All Parameters.


Note:  Any parameters beginning or ending in an underscore (_) are not shown by the *STATUS command.


You can check the status of individual parameters by providing these as arguments to the *STATUS command. The following example shows the status of the ABC parameter.

*STATUS,ABC
PARAMETER STATUS- abc       (   5 PARAMETERS DEFINED)
NAME         VALUE         TYPE     DIMENSIONS
ABC      -24.0000000      SCALAR

You can also check the status of specific parameters via Utility Menu> List> Other> Named Parameter or Utility Menu> List> Status> Parameters> Named Parameters.