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

### ANSYS User Defined Results

There is an abundant of options in ANSYS classic when one wishes to post process results. ANSYS workbench default pull down menu post processing options are more limited but they can still be accessed via the User Defined Results. One way not commonly used but can come in handy is as follows: Zeroth: Under Analysis Settings, there is "Output Controls" where you can toggle to "Yes" what you would like to save before the solution starts. This is like OUTRES in APDL. Output Controls First: After solving the model, click on Solution in the tree to highlight it. Solution Second: Click on Worksheet in the toolbar. Worksheet Third: In the worksheet, you will see list of results that are saved. Right click on it to create the User Defined Results. Create User Defined Results So here we have it. You could of look up the different expressions in the help document but I find this method of accessing the results convenient.  Example: Aspec

### Export Stiffness Matrix from Ansys

It is sometimes useful to extract the mass and stiffness matrix from Ansys.     *SMAT, MatK, D, IMPORT, FULL, file.full, STIFF       *PRINT, matk, matk, txt Exporting mass matrix would be similar:       *SMAT, MatM, D, import, full, file.full, MASS The above script uses APDL Math to get the job done. (Please see previous post for another example). The ordering of the matrix is unfortunately not concurrently exported. To verify the sequencing is as expected, we will work to replicate a truss example in the  Finite Element Trusses course notes by Bob Greenlee. Figure 1: Truss Problem Setup Model Creation Script to create model: /prep7 !! Creates Model to reflect course notes ! Properties et ,1,1  mp , ex, 1, 29.5e6 r , 1, 1 ! Geometry n ,1 $n ,2, 40$  n ,3, 40, 30 $n ,4, 0, 30 e ,1,2$  e ,2,3 $e ,1,3$  e ,3,4 ! Boundary Conditions d ,1,ux,0 $d ,1,uy,0 d ,2,uy,0 d ,4,ux,0$  d ,4,uy,0 f ,2,fx,20e3 f ,3,fy,-25e3 ! solves /solu eqslv , sparse