Skip to main content

Defining Ansys Superelement SUB File Manually

Photo by  James Owen  on  Unsplash A surprisingly popular blog-post written here is Exporting Stiffness Matrix from Ansys . A sensible follow up question is what can one do with the exported stiffness matrix? In a recent Xansys Forum post, a question was raised on how we can edit the stiffness matrix of a superelement and use it for our model.  An approach presented below is to first create a superelement that has the same number of DOF and nodal location that will serve as a template. An APDL script can then be written to edit the stiffness matrix entries as desired before exporting to a new superelement *.SUB file for use in future models. The self-contained script below demonstrates this.  /prep7 et ,1, 185 mp , ex, 1, 200e3 mp , prxy, 1, 0.33 w = 0.1 ! single element (note nodal locations) n , 1, w, -w, -w n , 2, w, w, -w n , 3, -w, w, -w n , 4, -w, -w, -w n , 5, w, -w, w n , 6, w, w, w n , 7, -w, w, w n , 8, -w, -w, w e , 1, 2, 3, 4, 5, 6, 7, 8 /solu antype , substr     ! analy

Extract Translation & Euler Angle Rotation

Figure 1: Z-X'-Y'' Rotation of the 'Grip'

PADT has a recent post on Extracting Relative Displacements in ANSYS Mechanical. The macro only works for small angles (in the order of 5 degrees). The accompanied PDF file shows:
\(u = dR \cdot (x-\overline{x}) + \overline{u}\)

Their nomenclature:
   \(dR\) : Small rotation matrix
   \(x\) : Nodal position vector
   \(\overline{x}\) : Center of Gravity (CG) position vector
   \(u\) : Nodal displacement vector
   \(\overline{u}\) : CG displacement vector

To extend their work to account for large deflection, I've added some terms:
\(x + u - \overline{x} \approx R \cdot (x - \overline{x}) + \overline{u} \)
   \(R\) : Rotation Matrix

The left side of the equation is the final deformed body. The right side of the equation is the rigid body rotation and translation. As the rotation is applied at the center of the body, \(\overline{x}\) is accounted for on both sides of the equation.

Note that 'equal' is just an approximation as the deformation due to strain has only been accounted for on the left side of the equation while the right side is purely rigid body. Now that the equation has been established, they can be vectorized and solve for the \(3\times3\) variables in \(R\) using least square curve fit. The Moore-Penrose inverse was used to achieve this. 

Euler Angles
Ansys uses the Z-X'-Y'' sequence to define the coordinate system (previous post). To avoid ill-conditioned matrix, the selected nodes or elements used for curve-fitting cannot all lie on a geometrical plane. The math has some difficulty here. 

Secondly, be aware of Gimbal Lock. As \(\alpha\) approaches \(90^o\), there is a loss of a degree of freedom. The solution around here is incorrect. If this is an issue for your case, look into quaternions.

Lastly, the rotation matrix is unique though the angles may not be. The script solves for the rotation matrix and the angles are derived from the matrix. For example, a \(0^o - 0^o - 0^o\) sequence is the same as \(180^o - 180^o - 180^o\). 

Workbench Example
As the rotations are on successive axis, a pseudo-robot arm seems to be appropriate. The model was set up such that there are 3 successive rotations of revolute joints with known angles and a pressure to slightly deform the body in question. 

Figure 2: Model Setup

By inserting the snippet and modifying the component name to match, the results are 'close' to the original input angles. They are not exact because of the slight deformation due to the pressure of 3Pa and inevitable errors from least-square curve fit. As shown below, the results are as expected. 

Figure 3: Results at the Details of the Command Snippet

A few housekeeping notes:
1. Large Deformation has to be turned ON. 
2. Save MAPDL db was set to YES before solution

Example Files Location
Archived Ansys Workbench v18.2 File with Results: Link
Command Snippet Macro/Script: Link