Detecting Units with an APDL Commands Object in Ansys Workbench

ANSYS Mechanical APDL Command Reference

Ansys Workbench Mechanical supports the presence of APDL commands in the Outline so that user-programmed commands will act on a model at the Body, Connection, Solver or Postprocessing stage of an Ansys job running from the ds.dat file generated by the Mechanical SOLVE command.


This article illustrates how to use APDL commands to detect the UNITS that are active when SOLVE is requested for an environment in Workbench Mechanical. The check could be included at the beginning of any APDL Commands Object in Workbench that assumes the UNITS employed in a SOLVE.

Units Commands in Ansys Workbench

Workbench Mechanical has several systems of units for a user to choose. Users are advised to check the Commands Manual for the /UNITS command. Note that /UNITS is merely a recording device.


Annotates the database with the system of units used.

The *GET command supports identification of the /UNITS setting employed:

Table 146: *GET General Items, Entity = ACTIVE


Note that the SI system is “newer” than the MKS system, with some differences in electronic units.

What are the default units used in Ansys APDL?

It is easy to have the wrong UNITS chosen when Workbench Mechanical SOLVE executes, for a Commands Object that assumes a particular system of units. Consider a material property in a Commands Object using the BIN system of units (lb-in-sec), but UNITS in Workbench Mechanical set to SI. If an APDL Commands Object assumes units during SOLVE for loads, material properties, contact settings, or makes other units-related assumptions during customized pre- or post-processing, it is critical to use the correct system of units.

A second control for Units during SOLVE is set in Details of each environment’s Analysis Settings. Default is the Active System Units from the Menu, but the Analysis Settings Details takes priority if set to Manual:

Detecting-Units-with-an-APDL-Commands-Object-in-Ansys-Workbench  APDL-Commands-Object-in-Ansys-Mechanical-Workbench

Ansys Workbench General Item and Component Labels

The following script example checks the Units setting in a Workbench Mechanical solution run, and works because the /UNITS command is executed by the Ansys input APDL job ds.dat file that Workbench Mechanical creates. The following code snippet can be added at the beginning of any existing Commands Object, or placed in its own Commands Object in the Project tree, typically at the Environment level. Its purpose is to stop the run if the desired Units are not employed in that Environment. It can be customized as desired:

! Check SOLVE units employed by the user in Workbench Mechanical
! Abort if not set to BIN in this example
*GET,myunits,ACTIVE,,UNITS ! returns 4 if set to BIN in test below
! Per the /UNITS command:
! 0 = USER, 1 = SI, 2 = CGS, 3 = BFT, 4 = BIN, 5 = MKS 6 = MPA, 7 = uMKS
*IF,myunits,NE,4,THEN ! If UNITS not set to BIN then quit!
************************************************************** %/&
************************************************************** %/&
** SOLVE Aborted — Set UNITS to LB-IN-SEC prior to SOLVE ** %/&
************************************************************** %/&

Detecting Units with an APDL Commands Object | Value Reflections

This check stops the ANSYS run if the Units setting is not satisfied. The *IF command can have the number and comment changed to reflect one of the values:

0 = USER, 1 = SI, 2 = CGS, 3 = BFT, 4 = BIN, 5 = MKS 6 = MPA, 7 = uMKS

Users may want to incorporate this type of code into all Workbench Mechanical models that contain assumptions about units in APDL Commands Objects, for quality control purposes.

It is important to realize that in the ds.dat file, Workbench Mechanical converts thermal energy units into work energy units, for example, BTU will be converted into inch-pounds of energy, yielding some non-intuitive material property settings. As an example of British units, consider this image regarding specific heat of air, from the UNITS toolbar of Workbench Mechanical:

Users need to be very careful with thermal property units in a Commands Object if they are not employing SI units throughout a model. Invalid results will be less likely if SI units are employed in such thermal models when they include units-dependent APDL Commands Objects.

Conclusions | Ansys Workbench APDL Commands Objects

Workbench Mechanical supports APDL Commands Objects that act on models at the Geometry, Connections, Environment, and Solution (postprocessing) level. Some of these objects assume that a particular system of units is employed during Solve. Since the ds.dat file that is produced for each environment includes a /UNITS command that records the system of units, certain APDL commands can detect the units choice as a final check that assumed units have been chosen.


The above check can be customized to check for the suitable system of units, and pasted into any APDL Commands Object for quality control purposes.

Note that each environment might have had its Analysis Settings Details set to employ a specific set of units during Solve. Although this assures that a certain system of units is employed, a mismatch with a particular APDL Commands Object could still occur, so as illustrated above, a final check on units with APDL commands in each APDL Commands Object may be desired.

Most Recent Tips & Tricks