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 APDL - Some Neat Commands

For those starting out, here's a few commands I find pretty neat. If you're not familiar with them, it's worth checking out.

NDNEXT & ELNEXT
When looping through a bunch of nodes or elements, this provide some convenience.
  /post1
  cmsel, s, NodesOfInterest
  *get, ncount, node, 0, count
  *dim, uxsave,, ncount, 2
  nnow = 0
  *do,ct,1,ncount
     nnow = ndnext(nnow)
     uxsave(ct, 1) = nnow
     *get, uxsave(ct, 2), node, nnow, u, x
     *enddo
  *stat, uxsave

Alternately, one could instead use fancier commands: *VGET with *VMASK
  cmsel, s, NodesOfInterest
  *get, nmx, node,, num, max
  *get, ncount, node,, count
  
  *dim, ndata,, nmx, 3
  *dim, nkeep,, ncount, 2
  
  *vget, ndata(1,1), node, 1, nsel
  *vfill,ndata(1,2),ramp,1,1
  *vmask, ndata(1,1)
  *vget, ndata(1,3), node, 1, u, x
  
  *vmask, ndata(1,1)
  *vfun, nkeep(1,1), comp, ndata(1,2)
  *vmask, ndata(1,1)
  *vfun, nkeep(1,2), comp, ndata(1,3)
  *stat, nkeep

q=UX(N)
This is equivalent to the above *get, q, node, N, u, x
Other succinct functions can be found here.

/PLOPTS, DATE, 0
This turns off the time and date display. It makes the screen more neat. 

*VWRITE
When needing to export data for nicer plots in another software, it took me a while to figure out I can't run the following in the GUI. It has to be in a separate ASCII file called via \INPUT or as a macro. There should also not be any spaces in front of the *vwrite and formatting commands.

*cfopen, rboltf1.txt
*vwrite, rbolt1(1,1), rbolt1(1,2), rbolt1(1,3)
(E,' ',E,' ',E)

*cfclos

%aVar%
The percentage symbol enclosing a variable will create a forced substitution. This is advantageous in loops, file names etc.

Comments