(844) 825-5971 Contact Us SimuTech Group’s YouTube Channel

Get Our Latest Tips & Tricks

Receive the latest updates to our popular Tips & Tricks articles and videos by subscribing to our Monthly Newsletter and Subscribe to the SimuTech Group YouTube channel channel.
For even more advanced ANSYS instruction, check out our consulting and training services. Or simply contact us to discuss any of your ANSYS needs.

Detecting UNITS with an APDL Commands Object in ANSYS® Mechanical (Workbench)

ANSYS Units 1

Figure 1: Units in Workbench Mechanical

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 in 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

Entity = ACTIVE, ENTNUM = 0 (or blank)
*GET, Par, ACTIVE, 0, Item1, IT1NUM, Item2, IT2NUM

Item1 IT1NUM Description
UNITS   Units specified by /UNITS command: 0 = USER, 1 = SI, 2 = CGS, 3 = BFT, 4 = BIN, 5 = MKS, 6 = MPA, 7 = uMKS.

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

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:

ANSYS Units 2a ANSYS Units 2b

Figure 2: Units as Set in Analysis Settings for Each Environment—Active System versus Manual 

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  ** %/&
   ************************************************************** %/&

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:

 ANSYS Units 3

Figure 3: Thermal Units and Energy Units in 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.

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.


 ANSYS Units 4

Figure 4: APDL Commands that Detect /UNITS Setting -- This Example Contains a Mismatch!

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.