Computing Mass Properties of Ansys Dynamic Models

Methods to compute mass properties about arbitrary coordinate systems using MAPDL commands

Steve Kiefer
Towards Data Science

--

Mass Matters! (credit: xibarodays on Pixaby)

Ansys is a commercial Finite Element Analysis (FEA) package. While Ansys has acquired and integrated many different analysis tools, its implicit structures package is robust and well-supported. One unique feature of Ansys for its implicit structural solver is the ability to script commands using simple comma-delimited MAPDL commands. whether using the Ansys classic interface or the modern Ansys Mechanical via the Workbench interface, MAPDL can be very useful for pre-processing models and/or post-processing results. This article covers some MAPDL commands to extract mass properties of the whole or parts of a model about user-defined coordinate systems.

When performing dynamic finite element analyses, verifying mass is an important step. It's half the equation after all! For 3D solid models, mass is pretty trivial. However, in dynamic models components are typically represented as shells, beams, and/or springs. In addition, dynamic models often contain non-structural mass such as SURF154 surface elements and point mass elements. Verifying mass can become non-trivial.

In the dark ages before switching to Ansys Mechanical, I would rely heavily on MAPDL text files to define all of the material property and element type data. I would try and group or otherwise control the numbering of these properties (usually in a spreadsheet) so that I could check the element type mass output listing from the solve.out file against what I was intending. If the dynamic representation did not match the component mass (usually obtained from CAD) I would apply ‘mass factors’ to densities then rinse and repeat until the individual element type masses and the total mass matched the intended values. While this worked it was a bit cumbersome and didn’t give me the fine control I sometimes wanted.

I now almost exclusively use the Ansys Mechanical application for pre-processing. In Mechanical one can click on individual bodies and get mass from the properties window (without a solve!) or use the selection tool to get mass of multiple selected bodies, the presence of non-structural mass posses a small challenge. With Ansys Mechanical we give up property numbering controls in exchange for an array of ease of use features. You can get some limited information using the selection tool but again, we miss the non structural mass and inertia mass properties.

Over the years i have picked up hints here and there from Sheldon Imaoka’s / Collaborative Solutions now down ansys.net as well as the xansys forum hosted by PADT (which appears inactive). So standing on the shoulders of giants I have created a boiler-plate MAPDL script that uses components to group portions of the model and write out a csv summary file I can then copy/paste into a spreadsheet for additional verification. The main advantages it provides are:

  • Grouping arbitrary portions of the model using components
  • Obtain partial model mass properties (including rotational inertia) about arbitrary coordinate system(s)
  • Formatted output file specifically for mass properties summary

Here is a github repository that includes a couple of versions of MAPDL script files and an example workbench project archive that incorporates them. Lets check out the important bits!

Mass properties of a model about a user defined coordinate system

While we could translate the model to the coordinate system of interest, run the analysis, and read the properties from the solve.out file, that isn’t always ideal. Note: we can not use CSYS or RSYS commands to force Ansys to analyze mass about a different coordinate system.

Here is a script that computes the mass properties of the entire model about a user defined coordinate system. Let's walk through it!

In the above section we make sure everything is selected with ALLSEL, then assign our coordinate system id to the cs_mass parameter. my_cs can be an integer if using manual numbering control (or Ansys Classic) or it can be an ‘APDL_name’ defined on the coordinate system property card. We *GET the location and Euler angles of the coordinate system. Note the use of variable replacement syntax (%var_name%) will fill that part of the string or command with the variable value when executed. It's not vital here but will be helpful later.

In this next section we enter the /sol module and run the magic commands (IRLF, & PSOLVE) that form the element matrices so we can get the mass properties but doesn’t run a full solution of the model. Again, this isn’t totally necessary for mass properties of the entire model but we will use it later.

Now we start some calculation! In the above section we are translating the inertia properties from the center of gravity (CG) to the location of the coordinate system. We then create an APDL 2D array and fill it as the inertia tensor.

Here we build the transformation matrix and assign it to an APDL 2D array.

Now for some interesting stuff. In order to use some of the linear algebra commands for matrix multiplication we need to move the APDL arrays to ‘APDL math’ space. We do that with the *DMAT command. Once in ‘APDL math’ we perform the matrix multiplication with appropriate transpose and finally copy the results from APDL math space back to APDL with the *EXPORT command. Next we assign the mass properties to variables that start with my_ which is the default prefix that Mechanical looks for to print the parameter values to the command snippet property card.

Mass properties are computed about a CS that is rotated from the global CS

Mass properties of multiple components about unique coordinate systems

While getting the mass properties of the entire model about an arbitrary coordinate system is nice, it is not particularly useful. Here we will extend the commands above by adding components to some arrays, defining a *DO loop, and using *VWRITE commands to write formatted output to a text file. Here is the full file for component based mass properties that i will walk through below.

First we begin by partitioning the model into components that we want to compute the mass properties of. If using the Ansys Mechanical application Named Selections are sent to the solver as components with the same name. One caveat is that Mechanical allows spaces in the name of the Named Selection but the solver does not. Its best to avoid spaces in names of Named Selections. Components can contain nodes or elements but not both. For mass properties we want to use element based components. Typically when selecting any portions of the model for mass properties we also want the non-structural mass on those bodies. Ansys adds distributed non-structural mass using SURF154 elements that share the same nodes as the underlying structural elements but do not add any stiffness. I think this is much more flexible than keeping non-structural mass tied to a property. The snippet below ensures any SURF154 element on the nodes of the elements in the Component are added to the Component. It can be repeated for each Named Selection.

cmsel,s,my_named_selection
nsle,s
esln,1
cm,my_named_selection,elem

In a similar fashion we can create a component of a Point Mass element attached to a Remote Point by using the Pilot Node APDL Name property on the Remote Point. Below we create a component that includes the single node point mass element by selecting all elements attached to the pilot node of the remote point which are completely defined by that one node.

nsel,s,node,,my_rp_name
esln,1
cm,my_pm_component,elem

Now that we have all of the components created and augmented as necessary to include non-structural mass elements we can move on to the next step. The commands below set the f_name parameter we will use for the filename and initializes two arrays. One array is for strings of component names and the other is for strings of variables assigned to coordinate system IDs. This way I can keep most of the script generic and change out this array for each use.

Next I initialize the output file. The %_wb_userfiles_dir(1)% gets replaced by the absolute path to the project user_files folder in the workbench project directory and %f_name% gets replaced for the string we assigned to the f_name parameter above. I then use *VWRITE to write the header to the file. I initialize a temporary output array outVars and tell Ansys to use a new filename to keep this output segregated from the structural analysis output.

Next we enter the component loop and as with the total model case we start by getting the properties (locations and angles) of the coordinate system for this component. The only difference is the use of the %css(1,j)% to get the parameter value assigned using the name of the variable with the coordinate system ID as the value. We then select only the elements in the component of interest and the associated nodes and issue the IRLF and PSOLVE commands. The beauty with these commands is that Ansys doesn’t have to perform a full solve to get the mass properties of each component.

The next set of commands is exactly the same as the total model case from translating the inertia tensor from the CG to the coordinate system through the *EXPORT command when we bring the rotated tensor back to an APDL 2D array. The only difference is we are inside the loop. I won't repeat them here.

Now instead of assigning the mass properties to variables that start with the my_ prefix we assign them to the outVars array. We then exit the loop and *vwrite our component names, coordinate system variable names, and mass properties for each component. Then close the file with a *cfclos, return to the default filename and post processor.

And here is an example from an output file:

I usually put a command snippet containing these commands in the Solution object of the Mechanical model tree as a post-processing step. Once a solve is completed you should find a my_mass.txt file in the user_files folder of the project directory.

That is it! Check out the github repository for the command snippets, an example output file, and a very simple workbench archive file (version 2020 R1) that contains 2 systems that use these command snippets. I hope this helps you with your dynamic modeling/mass verification adventures in Ansys!

Check out these other Ansys MAPDL related articles:

--

--