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

Ansys Matrix Sorting and Reordering

Sorting*

The *MOPER command has a sort which can be quite convenient. Here's an example of sorting the matrix of different columns consecutively.

/PREP7
! Creates Matrix
*dim, mymatrix, array, 5, 3
mymatrix(1, 1) = 4
mymatrix(2, 1) = 7
mymatrix(3, 1) = 4
mymatrix(4, 1) = 1
mymatrix(5, 1) = 4

mymatrix(1, 2) = 42
mymatrix(2, 2) = 78
mymatrix(3, 2) = 42
mymatrix(4, 2) = 16
mymatrix(5, 2) = 22

mymatrix(1, 3) = 3
mymatrix(2, 3) = 8
mymatrix(3, 3) = 2
mymatrix(4, 3) = 6
mymatrix(5, 3) = 5

! Writes Original Matrix
*cfopen, origmatrix, txt 
*vwrite, mymatrix(1,1), mymatrix(1,2), mymatrix(1,3)
(E20.5, ' ', E20.5, ' ', E20.5)
*cfclos

The original "mymatrix" is:
4 42 3
7 78 8
4 42 2
1 16 6
4 22 5

! Reorder Matrix by first column, then second, then third
*dim, ordering,,5 ! Ordering index array
*moper, ordering(1), mymatrix(1,1), sort, , 1,2,3 ! ordering column

! Writes Sorted Matrix
*cfopen, newmatrix, txt 
*vwrite, mymatrix(1,1), mymatrix(1,2), mymatrix(1,3)
(E20.5, ' ', E20.5, ' ', E20.5)
*cfclos

The new "mymatrix" that is sorted is now:
1 16 6
4 22 5
4 42 2
4 42 3
7 78 8

The ordering array contains the initial row position which could be useful if the matrix is to be put back together. "ordering":
4
5
3
1
2

Note that *VWRITE cannot be run within the GUI but must be called from a file using /INPUT or *USE. The Ansys script can be found here [Link].

Comments

  1. Hi Jason, your pages are nice inputs for someone involved in APDL. I have a small question, do you have any idea why the last column above, 3rd col, is not sorted whereas others are sorted. You mention in the comment that it sorts by first, then second and then third column but this does not happen. The result should be different if you sort according to col 3 at the end but indeed ANSYS gives the result you printed, I am a bit confused... Thx

    ReplyDelete
    Replies
    1. Hi Umut, The third column is sorted as well. This can be found in the third and fourth row, "2" comes before "3". Kind regards, Jason

      Delete

Post a Comment