### Ansys Euler Angle Calculation

Tait-Brian Angles Z-X'-Y'' *

After a simulation is complete, it is sometimes useful to know how much the overall object is rotated and translated. This is true especially for rigid body objects. While simple in 2D, it gets more complicated for 3D rotations. Euler angles always makes my head spin.

A rotating reference frame?*

Ansys uses the Z-X'-Y'' sequence for defining the coordinate system but there is also the *GET command to extract the Euler Angles of a Local Coordinate System.

So let's say you have 3 nodes on a rigid beam that has been rotated and translated in 3D space. One could do it the hard way by starting with the general definition of R in the Rotation Matrices and go in reverse to get the angles with some fun scripting in your math package of choice.

Or... the easy way: define a local coordinate system using NWPLAN at the deformed nodes at each result time step and use the *GET command to extract angles.
*dim, MyAngles, ,3

*dim, MyDisp, ,3
nwplan, 10, n1, n2, n3 ! n1->n2 is X-axis
cswpla, 101, 0,        ! defines rotated coordinate system
! Extracts Angles and Location
*get, MyAngles(1), CDSY, 101, ang, xy
*get, MyAngles(2), CDSY, 101, ang, yz
*get, MyAngles(3), CDSY, 101, ang, zx
*get, MyDisp(1), CDSY, 101, loc, x
*get, MyDisp(2), CDSY, 101, loc, y
*get, MyDisp(3), CDSY, 101, loc, z

Below is the script that creates three local coordinate system to represent translation and rotation of an element with known answers. The resultant nodes are then used to define a 'test' local coordinate system for extraction of angles and displacements. The results are identical as expected.

What if the key interest is the relative 3D Euler angles between two bodies? One could potentially hack it with the TRANSFER command to rotate nodes of both bodies such that the first body align with the global coordinate system. The resultant extracted Euler Angles at the second body would thus be the relative angles.

Update: Future blog post to extract large rotation and translation of body [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